 Chromium Code Reviews
 Chromium Code Reviews Issue 608853008:
  Canvas2D Performance: fix the bottleneck of hasInstance in JS binding -- TypeChecking Interface  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 608853008:
  Canvas2D Performance: fix the bottleneck of hasInstance in JS binding -- TypeChecking Interface  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| Index: Source/bindings/scripts/v8_types.py | 
| diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py | 
| index a63a39326c34290d437e66f575a8979d8e177ec1..c5386332ab68783947cef766934f2463ce8048f6 100644 | 
| --- a/Source/bindings/scripts/v8_types.py | 
| +++ b/Source/bindings/scripts/v8_types.py | 
| @@ -501,7 +501,7 @@ def v8_conversion_is_trivial(idl_type): | 
| IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial) | 
| -def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolate): | 
| +def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, type_checked, index, isolate): | 
| if idl_type.name == 'void': | 
| return '' | 
| @@ -532,6 +532,9 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat | 
| 'V8{idl_type}::toImpl(v8::Handle<v8::{idl_type}>::Cast({v8_value})) : 0') | 
| elif idl_type.is_dictionary: | 
| cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, exceptionState)' | 
| + elif type_checked: | 
| + cpp_expression_format = ( | 
| + 'V8{idl_type}::toImpl(v8::Handle<v8::Object>::Cast({v8_value}))') | 
| 
Jens Widell
2014/10/02 12:18:14
This isn't safe if the argument is nullable or if
 
yunchao
2014/10/08 07:04:58
Hi Jens, thanks for your review. However, nullable
 
Jens Widell
2014/10/08 08:11:13
Did you try my testcase? With your patch applied t
 
yunchao
2014/10/08 11:23:23
You are correct, Jens. So I want to narrow down to
 
Jens Widell
2014/10/08 11:51:26
This still generates code that crashes in the [Def
 | 
| else: | 
| cpp_expression_format = ( | 
| 'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})') | 
| @@ -560,7 +563,7 @@ def v8_value_to_cpp_value_array_or_sequence(native_array_element_type, v8_value, | 
| return expression | 
| -def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variable_name, index=None, declare_variable=True, isolate='info.GetIsolate()', used_in_private_script=False, return_promise=False): | 
| +def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variable_name, type_checked=False, index=None, declare_variable=True, isolate='info.GetIsolate()', used_in_private_script=False, return_promise=False): | 
| 
haraken
2014/10/02 11:52:57
type_checked => needs_type_check (and flip the tru
 | 
| """Returns an expression that converts a V8 value to a C++ value and stores it as a local value.""" | 
| # FIXME: Support union type. | 
| @@ -573,7 +576,7 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl | 
| if idl_type.base_type in ('void', 'object', 'EventHandler', 'EventListener'): | 
| return '/* no V8 -> C++ conversion for IDL type: %s */' % idl_type.name | 
| - cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolate) | 
| + cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, type_checked, index, isolate) | 
| if idl_type.is_string_type or idl_type.v8_conversion_needs_exception_state: | 
| # Types that need error handling and use one of a group of (C++) macros | 
| # to take care of this. |