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

Unified Diff: tools/dom/scripts/systemnative.py

Issue 1832713002: Optimize dartium dart:html bindings so real world application performance is acceptable. Improves d… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: tools/dom/scripts/systemnative.py
diff --git a/tools/dom/scripts/systemnative.py b/tools/dom/scripts/systemnative.py
index 1fd37f4bcf1fbd05ee1f7432f10790f5284144f4..b9e8e3ba67230a74510a3583cbaa0ea3fcac957f 100644
--- a/tools/dom/scripts/systemnative.py
+++ b/tools/dom/scripts/systemnative.py
@@ -250,7 +250,7 @@ class DartiumBackend(HtmlDartGenerator):
self._members_emitter.Emit(
'\n @DocsEditable()\n'
' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) => '
- 'wrap_jso($TOPLEVEL_NAME($OUTPARAMETERS));\n',
+ '$TOPLEVEL_NAME($OUTPARAMETERS);\n',
INTERFACE_NAME=self._interface_type_info.interface_name(),
FACTORY_METHOD_NAME=factory_method_name,
PARAMETERS=typed_formals,
@@ -272,7 +272,7 @@ class DartiumBackend(HtmlDartGenerator):
self._interface, self._interface.id, ' ')
self._members_emitter.Emit(
- '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => wrap_jso(_create($FACTORY_PARAMS));\n',
+ '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => _create($FACTORY_PARAMS);\n',
ANNOTATIONS=annotations,
CTOR=constructor_info._ConstructorFullName(self._DartType),
PARAMS=constructor_info.ParametersAsDeclaration(self._DartType),
@@ -536,7 +536,7 @@ class DartiumBackend(HtmlDartGenerator):
# JsObject maybe stored in the Dart class.
return_wrap_jso = wrap_return_type_blink(return_type, attr.type.id, self._type_registry)
wrap_unwrap_list.append(return_wrap_jso) # wrap_jso the returned object
- wrap_unwrap_list.append(self._dart_use_blink) # this must be unwrap_jso
+ wrap_unwrap_list.append(self._dart_use_blink)
# This seems to have been replaced with Custom=Getter (see above), but
# check to be sure we don't see the old syntax
@@ -583,9 +583,7 @@ class DartiumBackend(HtmlDartGenerator):
# Is the setter value a DartClass (that has a JsObject) or the type is
# None (it's a dynamic/any type) then unwrap_jso before passing to blink.
- parameters = ['unwrap_jso(value)' if (isinstance(type_info, InterfaceIDLTypeInfo) or
- not(attr.type.id) or ptype == 'Object')
- else 'value']
+ parameters = ['value']
dart_declaration = 'set %s(%s value)' % (html_name, ptype)
is_custom = _IsCustom(attr) and (_IsCustomValue(attr, None) or
@@ -663,36 +661,17 @@ class DartiumBackend(HtmlDartGenerator):
dart_native_name)
type_info = self._TypeInfo(element_type)
- # Does nativeIndexGetter return a DartClass (JsObject) if so wrap_jso.
- wrap_jso_start = ''
- wrap_jso_end = ''
- if (isinstance(type_info, InterfaceIDLTypeInfo) or
- wrap_type_blink(type_info.narrow_dart_type(), self._type_registry)):
- wrap_jso_start = 'wrap_jso('
- wrap_jso_end = ')'
blinkNativeIndexed = """
$TYPE operator[](int index) {
if (index < 0 || index >= length)
throw new RangeError.index(index, this);
- return %s$(DART_NATIVE_NAME)(unwrap_jso(this), index)%s;
+ return $(DART_NATIVE_NAME)(this, index);
}
- $TYPE _nativeIndexedGetter(int index) => %s$(DART_NATIVE_NAME)(unwrap_jso(this), index)%s;
-""" % (wrap_jso_start, wrap_jso_end, wrap_jso_start, wrap_jso_end)
- # Wrap the type to store the JsObject if Type is:
- #
- # - known IDL type
- # - type_id is None then it's probably a union type or overloaded
- # it's a dynamic/any type
- # - type is Object
- #
- # JsObject maybe stored in the Dart class.
- if isinstance(type_info, InterfaceIDLTypeInfo) or not(type_info) or dart_element_type == 'Object':
- blinkNativeIndexedGetter = \
- ' {0}$(DART_NATIVE_NAME)(unwrap_jso(this), index){1};\n'.format('wrap_jso(', ')')
- else:
- blinkNativeIndexedGetter = \
- ' $(DART_NATIVE_NAME)(unwrap_jso(this), index);\n'
+ $TYPE _nativeIndexedGetter(int index) => $(DART_NATIVE_NAME)(this, index);
+"""
+ blinkNativeIndexedGetter = \
+ ' $(DART_NATIVE_NAME)(this, index);\n'
self._members_emitter.Emit(blinkNativeIndexed,
DART_NATIVE_NAME=dart_qualified_name,
TYPE=self.SecureOutputType(element_type),
@@ -821,20 +800,14 @@ class DartiumBackend(HtmlDartGenerator):
if self._dart_use_blink:
# Wrap the type to store the JsObject if Type is:
#
- # - known IDL type
- # - type_id is None then it's probably a union type or overloaded
# it's a dynamic/any type
# - type is Object
#
# JsObject maybe stored in the Dart class.
return_wrap_jso = wrap_return_type_blink(return_type, info.type_name, self._type_registry)
return_type_info = self._type_registry.TypeInfo(info.type_name)
- if (isinstance(return_type_info, SequenceIDLTypeInfo) and
- not isinstance(return_type_info._item_info, PrimitiveIDLTypeInfo)):
- return_wrap_jso = True
# wrap_jso the returned object
wrap_unwrap_list.append(return_wrap_jso)
- # The 'this' parameter must be unwrap_jso
wrap_unwrap_list.append(self._dart_use_blink)
if info.callback_args:
@@ -880,7 +853,7 @@ class DartiumBackend(HtmlDartGenerator):
base_name = '_%s_%s' % (operation.id, version)
static = True
if not operation.is_static:
- actuals = ['unwrap_jso(this)' if self._dart_use_blink else 'this'] + actuals
+ actuals = ['this'] + actuals
formals = ['mthis'] + formals
actuals_s = ", ".join(actuals)
formals_s = ", ".join(formals)
@@ -892,10 +865,7 @@ class DartiumBackend(HtmlDartGenerator):
overload_name = \
self.DeriveQualifiedBlinkName(self._interface.id,
overload_base_name)
- if return_wrap_jso:
- call_emitter.Emit('wrap_jso($NAME($ARGS))', NAME=overload_name, ARGS=actuals_s)
- else:
- call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=actuals_s)
+ call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=actuals_s)
auto_scope_setup = \
self._GenerateAutoSetupScope(base_name, native_suffix)
cpp_callback_name = self._GenerateNativeBinding(
@@ -946,10 +916,7 @@ class DartiumBackend(HtmlDartGenerator):
if not static:
formals = ", ".join(['mthis'] + parameters)
- if wrap_unwrap_list and wrap_unwrap_list[1]:
- actuals = ", ".join(['unwrap_jso(this)'] + parameters)
- else:
- actuals = ", ".join(['this'] + parameters)
+ actuals = ", ".join(['this'] + parameters)
else:
formals = ", ".join(parameters)
actuals = ", ".join(parameters)
@@ -973,7 +940,7 @@ class DartiumBackend(HtmlDartGenerator):
if return_type == 'Rectangle':
jso_util_method = 'make_dart_rectangle'
elif wrap_unwrap_list[0]:
- jso_util_method = 'wrap_jso'
+ jso_util_method = ''
if dictionary_return:
emit_jso_template = '''

Powered by Google App Engine
This is Rietveld 408576698