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

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: Move more foreigns to builtins. 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
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 58904818d0e55005fe7d326daa411b915fa5e338..5f71bfd69b96e300743ffc5f728b60008be0b3fd 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -3773,7 +3773,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;
@@ -3794,6 +3794,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;
@@ -3817,7 +3858,7 @@ class SsaBuilder extends NewResolvedVisitor {
}
return;
}
- visit(arguments[1]);
+ visit(globalNameNode);
HInstruction globalNameHNode = pop();
if (!globalNameHNode.isConstantString()) {
compiler.reportError(
@@ -3941,17 +3982,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.');
@@ -3987,10 +4017,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));
@@ -4000,9 +4026,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));
@@ -4024,8 +4047,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');
@@ -4036,6 +4057,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') {

Powered by Google App Engine
This is Rietveld 408576698