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

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

Issue 836753002: dart2js: First part of native support in the new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. 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
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 19e4458cd50b860c0ef81b27f8bc2c106e1d8724..36719ae03b6eee52cc2117c11f09db4c30f41a01 100644
--- a/pkg/compiler/lib/src/js_emitter/native_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/native_generator.dart
@@ -5,14 +5,20 @@
part of dart2js.js_emitter;
class NativeGenerator {
+
+ static bool needsBoilerplate(JavaScriptBackend backend) {
sra1 2015/01/05 20:14:23 Like previous CL, I think this needs a better name
floitsch 2015/01/06 12:54:57 Done.
+ return backend.needToInitializeIsolateAffinityTag;
+ }
+
/// Generates the boilerplate code necessary for native functions.
- static jsAst.Statement generateBoilerPlate(
+ ///
+ /// The [convertToFastObject] argument must point to a JavaScript function
+ /// which must convert a given argument to a fast object.
+ static jsAst.Statement generateBoilerplate(
+ JavaScriptBackend backend,
jsAst.Expression generateEmbeddedGlobalAccess(String global),
- {bool initializeIsolateAffinityTag,
- bool initializeDispatchProperty}) {
- assert(initializeIsolateAffinityTag != null);
- assert(initializeDispatchProperty != null);
- assert(!initializeDispatchProperty || initializeIsolateAffinityTag);
+ jsAst.Expression convertToFastObject) {
+ assert(backend.needToInitializeIsolateAffinityTag);
jsAst.Expression getIsolateTagAccess =
generateEmbeddedGlobalAccess(embeddedNames.GET_ISOLATE_TAG);
@@ -22,14 +28,13 @@ class NativeGenerator {
generateEmbeddedGlobalAccess(embeddedNames.DISPATCH_PROPERTY_NAME);
return js.statement('''
- if (#initializeIsolateAffinityTag)
!function() {
// On V8, the 'intern' function converts a string to a symbol, which
// makes property access much faster.
function intern(s) {
var o = {};
o[s] = 1;
- return Object.keys(convertToFastObject(o))[0];
+ return Object.keys(#convertToFastObject(o))[0];
}
#getIsolateTag = function(name) {
@@ -57,8 +62,8 @@ class NativeGenerator {
}
}();
''',
- {'initializeIsolateAffinityTag': initializeIsolateAffinityTag,
- 'initializeDispatchProperty': initializeDispatchProperty,
+ {'initializeDispatchProperty': backend.needToInitializeDispatchProperty,
+ 'convertToFastObject': convertToFastObject,
'getIsolateTag': getIsolateTagAccess,
'isolateTag': isolateTagAccess,
'dispatchPropertyName': dispatchPropertyNameAccess});

Powered by Google App Engine
This is Rietveld 408576698