Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: Source/bindings/templates/interface.cpp

Issue 657523002: Skip expensive hasInstance() type-checks in overloads (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% block indexed_property_getter %} 5 {% block indexed_property_getter %}
6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
7 {% set getter = indexed_property_getter %} 7 {% set getter = indexed_property_getter %}
8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
9 { 9 {
10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 {% if constructor_overloads %} 463 {% if constructor_overloads %}
464 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 464 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
465 { 465 {
466 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), info.GetIsolate()); 466 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), info.GetIsolate());
467 {# 2. Initialize argcount to be min(maxarg, n). #} 467 {# 2. Initialize argcount to be min(maxarg, n). #}
468 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) { 468 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) {
469 {# 3. Remove from S all entries whose type list is not of length argcount. # } 469 {# 3. Remove from S all entries whose type list is not of length argcount. # }
470 {% for length, tests_constructors in constructor_overloads.length_tests_meth ods %} 470 {% for length, tests_constructors in constructor_overloads.length_tests_meth ods %}
471 case {{length}}: 471 case {{length}}:
472 {# Then resolve by testing argument #} 472 {# Then resolve by testing argument #}
473 {% for test, constructor in tests_constructors %} 473 {% for test, constructor, type_checked_argument_index in tests_construct ors %}
474 {# 10. If i = d, then: #} 474 {# 10. If i = d, then: #}
475 if ({{test}}) { 475 if ({{test}}) {
476 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(i nfo); 476 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(i nfo, {{type_checked_argument_index}});
477 return; 477 return;
478 } 478 }
479 {% endfor %} 479 {% endfor %}
480 break; 480 break;
481 {% endfor %} 481 {% endfor %}
482 default: 482 default:
483 {# Invalid arity, throw error #} 483 {# Invalid arity, throw error #}
484 {# Report full list of valid arities if gaps and above minimum #} 484 {# Report full list of valid arities if gaps and above minimum #}
485 {% if constructor_overloads.valid_arities %} 485 {% if constructor_overloads.valid_arities %}
486 if (info.Length() >= {{constructor_overloads.minarg}}) { 486 if (info.Length() >= {{constructor_overloads.minarg}}) {
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 {% endif %} 895 {% endif %}
896 } 896 }
897 897
898 template<> 898 template<>
899 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 899 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
900 { 900 {
901 return toV8(impl, creationContext, isolate); 901 return toV8(impl, creationContext, isolate);
902 } 902 }
903 903
904 {% endblock %} 904 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698