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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 45143003: Implement JS_INTERCEPTOR_CONSTANT (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index d025633cea73351b7ae16e336e238b1efe9fdd9d..5a26177def4e3b11efe350769586c4d9fdf290af 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -3201,6 +3201,33 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
argument, string.dartString.slowToString())));
}
+ void handleJsInterceptorConstant(Send node) {
+ void bad(Node node) {
+ compiler.reportError(node,
+ MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
+ stack.add(graph.addConstantNull(compiler));
+ }
+ if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) {
+ return bad(node.arguments);
+ }
+ Node argument = node.arguments.head;
+ // argument must be a TypeConstant.
+ visit(argument);
+ HInstruction argumentInstruction = pop();
+ if (argumentInstruction is! HConstant) {
+ return bad(argument);
+ }
+ Constant argumentConstant = argumentInstruction.constant;
+ if (argumentConstant is! TypeConstant) {
+ return bad(argument);
+ }
+
+ Constant constant =
+ new InterceptorConstant(argumentConstant.representedType);
+ HInstruction instruction = graph.addConstant(constant, compiler);
+ stack.add(instruction);
+ }
+
void handleForeignJsCallInIsolate(Send node) {
Link<Node> link = node.arguments;
if (!compiler.hasIsolateSupport()) {
@@ -3370,6 +3397,8 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
handleForeignJsGetName(node);
} else if (name == 'JS_EFFECT') {
stack.add(graph.addConstantNull(compiler));
+ } else if (name == 'JS_INTERCEPTOR_CONSTANT') {
+ handleJsInterceptorConstant(node);
} else {
throw "Unknown foreign: ${selector}";
}

Powered by Google App Engine
This is Rietveld 408576698