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

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

Issue 1458313002: Fix for the js-interop crash Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 0945568cfec8ca52f74c4eecf1ca669123a40266..223b688f4a6188de72069acef609c458f8fb22f3 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -5864,7 +5864,7 @@ class SsaBuilder extends ast.Visitor
&& params.optionalParametersAreNamed;
}
- HForeignCode invokeJsInteropFunction(Element element,
+ HForeignCode invokeJsInteropFunction(FunctionElement element,
List<HInstruction> arguments,
SourceInformation sourceInformation) {
assert(backend.isJsInterop(element));
@@ -5918,13 +5918,13 @@ class SsaBuilder extends ast.Visitor
var inputs = <HInstruction>[target]..addAll(arguments);
js.Template codeTemplate;
+ DartType type = element.type.returnType;
if (element.isGetter) {
codeTemplate = js.js.parseForeignJS("#");
} else if (element.isSetter) {
codeTemplate = js.js.parseForeignJS("# = #");
} else {
- FunctionElement function = element;
- FunctionSignature params = function.functionSignature;
+ FunctionSignature params = element.functionSignature;
var argsStub = <String>[];
for (int i = 0; i < arguments.length; i++) {
@@ -5933,17 +5933,22 @@ class SsaBuilder extends ast.Visitor
if (element.isConstructor) {
codeTemplate = js.js.parseForeignJS("new #(${argsStub.join(",")})");
+ type = element.enclosingClass.thisType;
} else {
codeTemplate = js.js.parseForeignJS("#(${argsStub.join(",")})");
}
}
+ // Note: here we are trusting the declared type by default to keep the
+ // codegen behavior consistent with the resolution behavior. Currently the
+ // NativeResolutionEnqueuer will trust the types by default (since this is
+ // what we always did for native APIs in dart:html). We could change both to
+ // be more conservative, but that could bring in a lot more code than what
+ // we want.
Jacob 2015/11/20 00:50:34 I thought in resolution we were treating each of t
Siggi Cherem (dart-lang) 2015/11/20 01:06:17 Good question - we have been debating about this t
Siggi Cherem (dart-lang) 2015/11/20 01:56:15 I made a CL with the alternative approach, I'm sti
var nativeBehavior = new native.NativeBehavior()
..codeTemplate = codeTemplate
- ..typesReturned.add(
- helpers.jsJavaScriptObjectClass.thisType)
- ..typesInstantiated.add(
- helpers.jsJavaScriptObjectClass.thisType)
+ ..typesReturned.add(type)
+ ..typesInstantiated.add(type)
..sideEffects.setAllSideEffects();
return new HForeignCode(
codeTemplate,
« no previous file with comments | « pkg/compiler/lib/src/js_backend/js_interop_analysis.dart ('k') | tests/compiler/dart2js/compiler_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698