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

Unified Diff: pkg/compiler/lib/src/js_emitter/native_generator.dart

Issue 830923003: dart2js: make "boilerplate" function in Native generator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 5 years, 11 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 | pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/native_generator.dart
diff --git a/pkg/compiler/lib/src/js_emitter/native_generator.dart b/pkg/compiler/lib/src/js_emitter/native_generator.dart
index 4ade4eac1380dfad03bdaf5208882778fa30415b..6aba6f1d2aeef34347f2aae0e2d53f3c1ee61efc 100644
--- a/pkg/compiler/lib/src/js_emitter/native_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/native_generator.dart
@@ -5,20 +5,28 @@
part of dart2js.js_emitter;
class NativeGenerator {
- final Function generateEmbeddedGlobalAccess;
- NativeGenerator(this.generateEmbeddedGlobalAccess);
+ /// Generates the code for isolate affinity tags.
+ ///
+ /// Independently Dart programs on the same page must not interfer and
+ /// this code sets up the variables needed to guarantee that behavior.
+ static jsAst.Statement generateIsolateAffinityTagInitialization(
+ jsAst.Expression generateEmbeddedGlobalAccess(String global),
+ {bool initializeIsolateAffinityTag,
+ bool initializeDispatchProperty}) {
+ assert(initializeIsolateAffinityTag != null);
+ assert(initializeDispatchProperty != null);
+ assert(!initializeDispatchProperty || initializeIsolateAffinityTag);
- /**
- * Emits code that sets the `isolateTag embedded global to a unique string.
- */
- jsAst.Expression generateIsolateAffinityTagInitialization() {
jsAst.Expression getIsolateTagAccess =
generateEmbeddedGlobalAccess(embeddedNames.GET_ISOLATE_TAG);
jsAst.Expression isolateTagAccess =
generateEmbeddedGlobalAccess(embeddedNames.ISOLATE_TAG);
+ jsAst.Expression dispatchPropertyNameAccess =
+ generateEmbeddedGlobalAccess(embeddedNames.DISPATCH_PROPERTY_NAME);
- return js('''
+ return js.statement('''
+ if (#initializeIsolateAffinityTag)
!function() {
// On V8, the 'intern' function converts a string to a symbol, which
// makes property access much faster.
@@ -48,22 +56,19 @@ class NativeGenerator {
break;
}
}
- }()
+ if (#initializeDispatchProperty) {
+ #dispatchPropertyName = #getIsolateTag("dispatch_record");
+ }
+ }();
''',
- {'getIsolateTag': getIsolateTagAccess, 'isolateTag': isolateTagAccess});
- }
-
- jsAst.Expression generateDispatchPropertyNameInitialization() {
- jsAst.Expression dispatchPropertyNameAccess =
- generateEmbeddedGlobalAccess(embeddedNames.DISPATCH_PROPERTY_NAME);
- jsAst.Expression getIsolateTagAccess =
- generateEmbeddedGlobalAccess(embeddedNames.GET_ISOLATE_TAG);
- return js('# = #("dispatch_record")',
- [dispatchPropertyNameAccess,
- getIsolateTagAccess]);
+ {'initializeIsolateAffinityTag': initializeIsolateAffinityTag,
+ 'initializeDispatchProperty': initializeDispatchProperty,
+ 'getIsolateTag': getIsolateTagAccess,
+ 'isolateTag': isolateTagAccess,
+ 'dispatchPropertyName': dispatchPropertyNameAccess});
}
- String generateIsolateTagRoot() {
+ static String generateIsolateTagRoot() {
// TODO(sra): MD5 of contributing source code or URIs?
return 'ZxYxX';
}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_emitter/old_emitter/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698