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

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

Issue 160523002: Don't share same name for js proxies cache. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean up. 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 | sdk/lib/js/dart2js/js_dart2js.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 6b79cb780c543fec2e95fdec7f0ad98d89755fad..5e5ff6495b4c15b9f53c4050cadc37be85c2fed1 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
@@ -975,14 +975,6 @@ class CodeEmitterTask extends CompilerTask {
jsAst.Expression generateDispatchPropertyInitialization() {
return js('!#', js.fun([], [
- // 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.
@@ -992,7 +984,7 @@ class CodeEmitterTask extends CompilerTask {
js('var rootProperty = "${generateDispatchPropertyName()}"'),
js.for_('var i = 0', null, 'i++', [
- js('property = intern(rootProperty + "_" + i + "_")'),
+ js('property = convertToJSSymbol(rootProperty + "_" + i + "_")'),
js.if_('!(property in usedProperties)', [
js('usedProperties[property] = 1'),
js.return_(
@@ -1164,7 +1156,8 @@ class CodeEmitterTask extends CompilerTask {
void emitConvertToFastObjectFunction() {
// Create an instance that uses 'properties' as prototype. This should make
// 'properties' a fast object.
- mainBuffer.add(r'''function convertToFastObject(properties) {
+ mainBuffer.add(r'''
+function convertToFastObject(properties) {
function MyClass() {};
MyClass.prototype = properties;
new MyClass();
@@ -1185,10 +1178,19 @@ if (typeof $printHelperName === "function") {
}
''');
}
-mainBuffer.add(r'''
+ mainBuffer.add(r'''
return properties;
}
''');
+ // On V8, the 'intern' function converts a string to a symbol, which
+ // makes property access much faster.
+ mainBuffer.add(r'''
+function convertToJSSymbol(s) {
+ var o = {};
+ o[s] = 1;
+ return Object.keys(convertToFastObject(o))[0];
+}
+''');
}
void writeLibraryDescriptors(LibraryElement library) {
« no previous file with comments | « no previous file | sdk/lib/js/dart2js/js_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698