Commit 3137c367 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

v8binding: Micro-optimizes callback's arguments.

Removes unused code in processing arguments of callback
functions and callback interfaces.

Change-Id: I5a98a011ef5c42c69b9f9016579a19942cbad01f
Reviewed-on: https://chromium-review.googlesource.com/1067569Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561437}
parent 208d4dce
......@@ -12,7 +12,7 @@
namespace blink {
v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Invoke({{argument_declarations | join(', ')}}) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......@@ -91,13 +91,13 @@ v8::Maybe<{{return_cpp_type}}> {{cpp_class}}::Invoke({{argument_declarations | j
// arguments list. If this throws an exception, set completion to the
// completion value representing the thrown exception and jump to the step
// labeled return.
{% if arguments %}
v8::Local<v8::Object> argument_creation_context =
CallbackRelevantScriptState()->GetContext()->Global();
ALLOW_UNUSED_LOCAL(argument_creation_context);
{% for argument in arguments %}
v8::Local<v8::Value> {{argument.v8_name}} = {{argument.cpp_value_to_v8_value}};
{% endfor %}
{% if arguments %}
v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'v8_name')}} };
{% else %}
{# Zero-length arrays are ill-formed in C++. #}
......
......@@ -169,13 +169,13 @@ v8::Maybe<{{method.cpp_type}}> {{v8_class}}::{{method.name}}({{method.argument_d
// arguments list. If this throws an exception, set completion to the
// completion value representing the thrown exception and jump to the step
// labeled return.
{% if method.arguments %}
v8::Local<v8::Object> argument_creation_context =
CallbackRelevantScriptState()->GetContext()->Global();
ALLOW_UNUSED_LOCAL(argument_creation_context);
{% for argument in method.arguments %}
v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value}};
{% endfor %}
{% if method.arguments %}
v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} };
{% else %}
{# Zero-length arrays are ill-formed in C++. #}
......
......@@ -217,7 +217,7 @@ void TestDictionary::Trace(blink::Visitor* visitor) {
visitor->Trace(test_interface_or_null_member_);
visitor->Trace(test_interface_sequence_member_);
visitor->Trace(test_object_sequence_member_);
visitor->Trace(uint8_array_member_);
visitor->Trace(uint_8_array_member_);
visitor->Trace(union_in_record_member_);
visitor->Trace(union_member_with_sequence_default_);
visitor->Trace(union_or_null_record_member_);
......
......@@ -388,9 +388,9 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase {
}
void setTreatNullAsStringSequenceMember(const Vector<String>&);
bool hasUint8ArrayMember() const { return uint8_array_member_; }
bool hasUint8ArrayMember() const { return uint_8_array_member_; }
NotShared<DOMUint8Array> uint8ArrayMember() const {
return uint8_array_member_;
return uint_8_array_member_;
}
inline void setUint8ArrayMember(NotShared<DOMUint8Array>);
......@@ -529,7 +529,7 @@ class CORE_EXPORT TestDictionary : public IDLDictionaryBase {
HeapVector<Member<TestInterfaceImplementation>> test_interface_sequence_member_;
HeapVector<Member<TestObject>> test_object_sequence_member_;
Vector<String> treat_null_as_string_sequence_member_;
Member<DOMUint8Array> uint8_array_member_;
Member<DOMUint8Array> uint_8_array_member_;
HeapVector<std::pair<String, LongOrBoolean>> union_in_record_member_;
DoubleOrDoubleSequence union_member_with_sequence_default_;
HeapVector<std::pair<String, DoubleOrString>> union_or_null_record_member_;
......@@ -663,7 +663,7 @@ void TestDictionary::setTestInterfaceOrNullMemberToNull() {
}
void TestDictionary::setUint8ArrayMember(NotShared<DOMUint8Array> value) {
uint8_array_member_ = value.View();
uint_8_array_member_ = value.View();
}
void TestDictionary::setUnrestrictedDoubleMember(double value) {
......
......@@ -22,7 +22,7 @@
namespace blink {
v8::Maybe<ScriptValue> V8AnyCallbackFunctionOptionalAnyArg::Invoke(ScriptWrappable* callback_this_value, ScriptValue optionalAnyArg) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......
......@@ -22,7 +22,7 @@
namespace blink {
v8::Maybe<int32_t> V8LongCallbackFunction::Invoke(ScriptWrappable* callback_this_value, int32_t num1, int32_t num2) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......
......@@ -22,7 +22,7 @@
namespace blink {
v8::Maybe<Vector<String>> V8StringSequenceCallbackFunctionLongSequenceArg::Invoke(ScriptWrappable* callback_this_value, const Vector<int32_t>& arg) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......
......@@ -103,9 +103,6 @@ v8::Maybe<void> V8TestCallbackInterface::voidMethod(ScriptWrappable* callback_th
// arguments list. If this throws an exception, set completion to the
// completion value representing the thrown exception and jump to the step
// labeled return.
v8::Local<v8::Object> argument_creation_context =
CallbackRelevantScriptState()->GetContext()->Global();
ALLOW_UNUSED_LOCAL(argument_creation_context);
v8::Local<v8::Value> *argv = nullptr;
// step 13. Let callResult be Call(X, thisArg, esArgs).
......@@ -210,9 +207,6 @@ v8::Maybe<bool> V8TestCallbackInterface::booleanMethod(ScriptWrappable* callback
// arguments list. If this throws an exception, set completion to the
// completion value representing the thrown exception and jump to the step
// labeled return.
v8::Local<v8::Object> argument_creation_context =
CallbackRelevantScriptState()->GetContext()->Global();
ALLOW_UNUSED_LOCAL(argument_creation_context);
v8::Local<v8::Value> *argv = nullptr;
// step 13. Let callResult be Call(X, thisArg, esArgs).
......
......@@ -21,7 +21,7 @@
namespace blink {
v8::Maybe<void> V8VoidCallbackFunction::Invoke(ScriptWrappable* callback_this_value) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......@@ -75,9 +75,6 @@ v8::Maybe<void> V8VoidCallbackFunction::Invoke(ScriptWrappable* callback_this_va
// arguments list. If this throws an exception, set completion to the
// completion value representing the thrown exception and jump to the step
// labeled return.
v8::Local<v8::Object> argument_creation_context =
CallbackRelevantScriptState()->GetContext()->Global();
ALLOW_UNUSED_LOCAL(argument_creation_context);
v8::Local<v8::Value> *argv = nullptr;
// step 11. Let callResult be Call(X, thisArg, esArgs).
......
......@@ -22,7 +22,7 @@
namespace blink {
v8::Maybe<void> V8VoidCallbackFunctionDictionaryArg::Invoke(ScriptWrappable* callback_this_value, const TestDictionary& arg) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......
......@@ -22,7 +22,7 @@
namespace blink {
v8::Maybe<void> V8VoidCallbackFunctionEnumArg::Invoke(ScriptWrappable* callback_this_value, const String& arg) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......
......@@ -22,7 +22,7 @@
namespace blink {
v8::Maybe<void> V8VoidCallbackFunctionInterfaceArg::Invoke(ScriptWrappable* callback_this_value, HTMLDivElement* divElement) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......
......@@ -23,7 +23,7 @@
namespace blink {
v8::Maybe<void> V8VoidCallbackFunctionTestInterfaceSequenceArg::Invoke(ScriptWrappable* callback_this_value, const HeapVector<Member<TestInterfaceImplementation>>& arg) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......
......@@ -22,7 +22,7 @@
namespace blink {
v8::Maybe<void> V8VoidCallbackFunctionTypedef::Invoke(ScriptWrappable* callback_this_value, const String& arg) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......
......@@ -21,7 +21,7 @@
namespace blink {
v8::Maybe<void> V8VoidCallbackFunctionModules::Invoke(ScriptWrappable* callback_this_value) {
// This function implements "invoke" steps in
// This function implements "invoke" algorithm defined in
// "3.10. Invoking callback functions".
// https://heycam.github.io/webidl/#es-invoking-callback-functions
......@@ -75,9 +75,6 @@ v8::Maybe<void> V8VoidCallbackFunctionModules::Invoke(ScriptWrappable* callback_
// arguments list. If this throws an exception, set completion to the
// completion value representing the thrown exception and jump to the step
// labeled return.
v8::Local<v8::Object> argument_creation_context =
CallbackRelevantScriptState()->GetContext()->Global();
ALLOW_UNUSED_LOCAL(argument_creation_context);
v8::Local<v8::Value> *argv = nullptr;
// step 11. Let callResult be Call(X, thisArg, esArgs).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment