| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.js_emitter.native_generator; | 5 library dart2js.js_emitter.native_generator; |
| 6 | 6 |
| 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 7 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
| 8 | 8 |
| 9 import '../js/js.dart' as jsAst; | 9 import '../js/js.dart' as jsAst; |
| 10 import '../js/js.dart' show js; | 10 import '../js/js.dart' show js; |
| 11 import '../js_backend/js_backend.dart' show JavaScriptBackend; | 11 import '../js_backend/js_backend.dart' show JavaScriptBackend; |
| 12 | 12 |
| 13 import 'model.dart'; | 13 import 'model.dart'; |
| 14 | 14 |
| 15 class NativeGenerator { | 15 class NativeGenerator { |
| 16 static bool needsIsolateAffinityTagInitialization(JavaScriptBackend backend) { | 16 static bool needsIsolateAffinityTagInitialization(JavaScriptBackend backend) { |
| 17 return backend.needToInitializeIsolateAffinityTag; | 17 return backend.backendUsage.needToInitializeIsolateAffinityTag; |
| 18 } | 18 } |
| 19 | 19 |
| 20 /// Generates the code for isolate affinity tags. | 20 /// Generates the code for isolate affinity tags. |
| 21 /// | 21 /// |
| 22 /// Independently Dart programs on the same page must not interfer and | 22 /// Independently Dart programs on the same page must not interfer and |
| 23 /// this code sets up the variables needed to guarantee that behavior. | 23 /// this code sets up the variables needed to guarantee that behavior. |
| 24 static jsAst.Statement generateIsolateAffinityTagInitialization( | 24 static jsAst.Statement generateIsolateAffinityTagInitialization( |
| 25 JavaScriptBackend backend, | 25 JavaScriptBackend backend, |
| 26 jsAst.Expression generateEmbeddedGlobalAccess(String global), | 26 jsAst.Expression generateEmbeddedGlobalAccess(String global), |
| 27 jsAst.Expression internStringFunction) { | 27 jsAst.Expression internStringFunction) { |
| 28 assert(backend.needToInitializeIsolateAffinityTag); | 28 assert(backend.backendUsage.needToInitializeIsolateAffinityTag); |
| 29 | 29 |
| 30 jsAst.Expression getIsolateTagAccess = | 30 jsAst.Expression getIsolateTagAccess = |
| 31 generateEmbeddedGlobalAccess(embeddedNames.GET_ISOLATE_TAG); | 31 generateEmbeddedGlobalAccess(embeddedNames.GET_ISOLATE_TAG); |
| 32 jsAst.Expression isolateTagAccess = | 32 jsAst.Expression isolateTagAccess = |
| 33 generateEmbeddedGlobalAccess(embeddedNames.ISOLATE_TAG); | 33 generateEmbeddedGlobalAccess(embeddedNames.ISOLATE_TAG); |
| 34 jsAst.Expression dispatchPropertyNameAccess = | 34 jsAst.Expression dispatchPropertyNameAccess = |
| 35 generateEmbeddedGlobalAccess(embeddedNames.DISPATCH_PROPERTY_NAME); | 35 generateEmbeddedGlobalAccess(embeddedNames.DISPATCH_PROPERTY_NAME); |
| 36 | 36 |
| 37 return js.statement( | 37 return js.statement( |
| 38 ''' | 38 ''' |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 break; | 59 break; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 if (#initializeDispatchProperty) { | 62 if (#initializeDispatchProperty) { |
| 63 #dispatchPropertyName = #getIsolateTag("dispatch_record"); | 63 #dispatchPropertyName = #getIsolateTag("dispatch_record"); |
| 64 } | 64 } |
| 65 }(); | 65 }(); |
| 66 ''', | 66 ''', |
| 67 { | 67 { |
| 68 'initializeDispatchProperty': | 68 'initializeDispatchProperty': |
| 69 backend.needToInitializeDispatchProperty, | 69 backend.backendUsage.needToInitializeDispatchProperty, |
| 70 'internStringFunction': internStringFunction, | 70 'internStringFunction': internStringFunction, |
| 71 'getIsolateTag': getIsolateTagAccess, | 71 'getIsolateTag': getIsolateTagAccess, |
| 72 'isolateTag': isolateTagAccess, | 72 'isolateTag': isolateTagAccess, |
| 73 'dispatchPropertyName': dispatchPropertyNameAccess | 73 'dispatchPropertyName': dispatchPropertyNameAccess |
| 74 }); | 74 }); |
| 75 } | 75 } |
| 76 | 76 |
| 77 static String generateIsolateTagRoot() { | 77 static String generateIsolateTagRoot() { |
| 78 // TODO(sra): MD5 of contributing source code or URIs? | 78 // TODO(sra): MD5 of contributing source code or URIs? |
| 79 return 'ZxYxX'; | 79 return 'ZxYxX'; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 'info': infoAccess, | 209 'info': infoAccess, |
| 210 'constructor': constructorAccess, | 210 'constructor': constructorAccess, |
| 211 'subclassRead': subclassRead, | 211 'subclassRead': subclassRead, |
| 212 'interceptorsByTagAccess': interceptorsByTagAccess, | 212 'interceptorsByTagAccess': interceptorsByTagAccess, |
| 213 'leafTagsAccess': leafTagsAccess, | 213 'leafTagsAccess': leafTagsAccess, |
| 214 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, | 214 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, |
| 215 'allowNativesSubclassing': true | 215 'allowNativesSubclassing': true |
| 216 }); | 216 }); |
| 217 } | 217 } |
| 218 } | 218 } |
| OLD | NEW |