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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart

Issue 155983004: Fix DOM Isolate affinity for interceptors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/multiscript_part1_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart
diff --git a/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart b/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart
index 2f81f2d981126de5a93d3f680db7a081043b5261..11136c0cf31f8625753550df2f10f5eb98ffc932 100644
--- a/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart
+++ b/sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart
@@ -974,13 +974,29 @@ class CodeEmitterTask extends CompilerTask {
jsAst.Expression generateDispatchPropertyInitialization() {
return js('!#', js.fun([], [
- js('var objectProto = Object.prototype'),
+
+ // On V8, the 'intern' function converts a string to a symbol, which
+ // makes property access much faster.
+ new jsAst.FunctionDeclaration(new jsAst.VariableDeclaration('intern'),
+ js.fun(['s'], [
+ js('var o = {}'),
+ js('o[s] = 1'),
+ js.return_(js('Object.keys(convertToFastObject(o))[0]'))])),
+
+ // To ensure that different programs loaded into the same context (page)
+ // use distinct dispatch properies, we place an object on `Object` to
+ // contain the names already in use.
+ js('var tableProperty = "___dart_dispatch_property_names_"'),
+ js('var usedProperties = Object[tableProperty] ||'
+ '(Object[tableProperty] = Object.create(null))'),
floitsch 2014/02/12 15:33:39 We could also just store the counter of the last u
sra1 2014/02/12 22:01:20 Not if every program has an MD5-like root property
+
+ js('var rootProperty = "${generateDispatchPropertyName(0)}"'),
js.for_('var i = 0', null, 'i++', [
- js('var property = "${generateDispatchPropertyName(0)}"'),
- js.if_('i > 0', js('property = rootProperty + "_" + i')),
- js.if_('!(property in objectProto)',
- js.return_(
- js('init.dispatchPropertyName = property')))])])());
+ js('property = intern(rootProperty + "_" + i + "_")'),
floitsch 2014/02/12 10:38:25 Isn't generateDispatchPropertyName supposed to do
sra1 2014/02/12 22:01:20 The seed was for when I was generating a list of n
+ js.if_('!(property in usedProperties)', [
+ js('usedProperties[property] = 1'),
floitsch 2014/02/12 10:38:25 That line seems to be important :)
+ js.return_(
+ js('init.dispatchPropertyName = property'))])])])());
}
String generateDispatchPropertyName(int seed) {
« no previous file with comments | « no previous file | tests/compiler/dart2js_native/multiscript_part1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698