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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 954253002: dart2js: add compiler builtins to the core-runtime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix bad return type. (Also removes duplicate getInterceptor call). Created 5 years, 8 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 | « pkg/compiler/lib/src/resolution/registry.dart ('k') | pkg/compiler/lib/src/universe/side_effects.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 3ca33f1f59ae59d2f661483e410623227aaa58ff..4773a9c9a2834f8b48b6a4d1c3ea316143ea5346 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -3772,7 +3772,7 @@ class SsaBuilder extends NewResolvedVisitor {
default:
for (int i = 1; i < arguments.length; i++) {
compiler.reportError(
- arguments[i], MessageKind.GENERIC,
+ arguments[i], MessageKind.GENERIC,
{'text': 'Error: Extra argument to JS_GET_NAME.'});
}
return;
@@ -3793,6 +3793,47 @@ class SsaBuilder extends NewResolvedVisitor {
argument, JsGetName.values[index])));
}
+ void handleForeignJsBuiltin(ast.Send node) {
+ List<ast.Node> arguments = node.arguments.toList();
+ ast.Node argument;
+ if (arguments.length < 2) {
+ compiler.reportError(
+ node, MessageKind.GENERIC,
+ {'text': 'Error: Expected at least two arguments to JS_BUILTIN.'});
+ }
+
+ Element builtinElement = elements[arguments[1]];
+ if (builtinElement == null ||
+ (builtinElement is! FieldElement) ||
+ builtinElement.enclosingClass != backend.jsBuiltinEnum) {
+ compiler.reportError(
+ argument, MessageKind.GENERIC,
+ {'text': 'Error: Expected a JsBuiltin enum value.'});
+ }
+ EnumClassElement enumClass = builtinElement.enclosingClass;
+ int index = enumClass.enumValues.indexOf(builtinElement);
+
+ js.Template template =
+ backend.emitter.builtinTemplateFor(JsBuiltin.values[index]);
+
+ List<HInstruction> compiledArguments = <HInstruction>[];
+ for (int i = 2; i < arguments.length; i++) {
+ visit(arguments[i]);
+ compiledArguments.add(pop());
+ }
+
+ native.NativeBehavior nativeBehavior =
+ compiler.enqueuer.resolution.nativeEnqueuer.getNativeBehaviorOf(node);
+
+ TypeMask ssaType =
+ TypeMaskFactory.fromNativeBehavior(nativeBehavior, compiler);
+
+ push(new HForeignCode(template,
+ ssaType,
+ compiledArguments,
+ nativeBehavior: nativeBehavior));
+ }
+
void handleForeignJsEmbeddedGlobal(ast.Send node) {
List<ast.Node> arguments = node.arguments.toList();
ast.Node globalNameNode;
@@ -3816,7 +3857,7 @@ class SsaBuilder extends NewResolvedVisitor {
}
return;
}
- visit(arguments[1]);
+ visit(globalNameNode);
HInstruction globalNameHNode = pop();
if (!globalNameHNode.isConstantString()) {
compiler.reportError(
@@ -3940,17 +3981,6 @@ class SsaBuilder extends NewResolvedVisitor {
effects: sideEffects));
}
- void handleForeignDartObjectJsConstructorFunction(ast.Send node) {
- if (!node.arguments.isEmpty) {
- compiler.internalError(node.argumentsNode, 'Too many arguments.');
- }
- push(new HForeignCode(
- js.js.expressionTemplateYielding(
- backend.emitter.typeAccess(compiler.objectClass)),
- backend.dynamicType,
- <HInstruction>[]));
- }
-
void handleForeignJsCurrentIsolate(ast.Send node) {
if (!node.arguments.isEmpty) {
compiler.internalError(node.argumentsNode, 'Too many arguments.');
@@ -3986,10 +4016,6 @@ class SsaBuilder extends NewResolvedVisitor {
// TODO(floitsch): this should be a JS_NAME.
String name = backend.namer.runtimeTypeName(compiler.nullClass);
stack.add(addConstantString(name));
- } else if (name == 'JS_FUNCTION_CLASS_NAME') {
- // TODO(floitsch): this should be a JS_NAME.
- String name = backend.namer.runtimeTypeName(compiler.functionClass);
- stack.add(addConstantString(name));
} else if (name == 'JS_OPERATOR_AS_PREFIX') {
// TODO(floitsch): this should be a JS_NAME.
stack.add(addConstantString(backend.namer.operatorAsPrefix));
@@ -3999,9 +4025,6 @@ class SsaBuilder extends NewResolvedVisitor {
} else if (name == 'JS_TYPEDEF_TAG') {
// TODO(floitsch): this should be a JS_NAME.
stack.add(addConstantString(backend.namer.typedefTag));
- } else if (name == 'JS_FUNCTION_TYPE_TAG') {
- // TODO(floitsch): this should be a JS_NAME.
- stack.add(addConstantString(backend.namer.functionTypeTag));
} else if (name == 'JS_FUNCTION_TYPE_VOID_RETURN_TAG') {
// TODO(floitsch): this should be a JS_NAME.
stack.add(addConstantString(backend.namer.functionTypeVoidReturnTag));
@@ -4023,8 +4046,6 @@ class SsaBuilder extends NewResolvedVisitor {
// TODO(floitsch): this should be a JS_NAME.
stack.add(addConstantString(
backend.namer.functionTypeNamedParametersTag));
- } else if (name == 'JS_DART_OBJECT_CONSTRUCTOR') {
- handleForeignDartObjectJsConstructorFunction(node);
} else if (name == 'JS_IS_INDEXABLE_FIELD_NAME') {
// TODO(floitsch): this should be a JS_NAME.
Element element = backend.findHelper('JavaScriptIndexingBehavior');
@@ -4035,6 +4056,8 @@ class SsaBuilder extends NewResolvedVisitor {
handleForeignJsGetName(node);
} else if (name == 'JS_EMBEDDED_GLOBAL') {
handleForeignJsEmbeddedGlobal(node);
+ } else if (name == 'JS_BUILTIN') {
+ handleForeignJsBuiltin(node);
} else if (name == 'JS_GET_FLAG') {
handleForeingJsGetFlag(node);
} else if (name == 'JS_EFFECT') {
« no previous file with comments | « pkg/compiler/lib/src/resolution/registry.dart ('k') | pkg/compiler/lib/src/universe/side_effects.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698