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

Unified Diff: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart

Issue 12045019: Fix braino with return types, and make sure the compiler knows we might call noSuchMethod with a JS… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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
« no previous file with comments | « no previous file | tests/language/no_such_method2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (revision 17377)
+++ sdk/lib/_internal/compiler/implementation/js_backend/backend.dart (working copy)
@@ -14,7 +14,7 @@
: compiledFunctions = new List<Element>();
ReturnInfo.unknownType()
- : this.returnType = null,
+ : this.returnType = HType.UNKNOWN,
compiledFunctions = new List<Element>();
void update(HType type, Recompile recompile, Compiler compiler) {
@@ -128,6 +128,7 @@
bool get hasNamedArguments => namedArguments != null;
int get length => types.length;
HType operator[](int index) => types[index];
+ void operator[]=(int index, HType type) { types[index] = type; }
HTypeList union(HTypeList other, Compiler compiler) {
if (allUnknown) return this;
@@ -482,9 +483,7 @@
staticTypeMap[element] = HTypeList.ALL_UNKNOWN;
}
- void registerDynamicInvocation(HInvokeDynamic node,
- Selector selector,
- HTypeMap types) {
+ void registerDynamicInvocation(HTypeList providedTypes, Selector selector) {
if (selector.isClosureCall()) {
// We cannot use the current framework to do optimizations based
// on the 'call' selector because we are also generating closure
@@ -492,8 +491,6 @@
// track parameter types, nor invalidates optimized methods.
return;
}
- HTypeList providedTypes =
- new HTypeList.fromDynamicInvocation(node, selector, types);
if (!selectorTypeMap.containsKey(selector)) {
selectorTypeMap[selector] = providedTypes;
} else {
@@ -643,7 +640,7 @@
Element jsStringConcat;
Element getInterceptorMethod;
Element fixedLengthListConstructor;
- bool _interceptorsAreInitialized = false;
+ bool oneClassSeen = false;
kasperl 2013/01/22 13:16:01 firstClassSeen?
ngeoffray 2013/01/22 13:19:42 Senamed to seenAnyClass.
final Namer namer;
@@ -843,12 +840,25 @@
}
}
+ void initializeNoSuchMethod() {
+ // In case the emitter generates noSuchMethod calls, we need to
+ // make sure all [noSuchMethod] methods know they might take a
+ // [JsInvocationMirror] as parameter.
+ HTypeList types = new HTypeList(1);
+ types[0] = new HType.fromBoundedType(
+ compiler.jsInvocationMirrorClass.computeType(compiler),
+ compiler,
+ false);
+ argumentTypes.registerDynamicInvocation(types, new Selector.noSuchMethod());
+ }
+
void registerInstantiatedClass(ClassElement cls, Enqueuer enqueuer) {
- ClassElement result = null;
- if (!_interceptorsAreInitialized) {
+ if (!oneClassSeen) {
initializeInterceptorElements();
- _interceptorsAreInitialized = true;
+ initializeNoSuchMethod();
+ oneClassSeen = true;
}
+ ClassElement result = null;
if (cls == compiler.stringClass) {
addInterceptors(jsStringClass, enqueuer);
} else if (cls == compiler.listClass) {
@@ -964,7 +974,9 @@
void registerDynamicInvocation(HInvokeDynamic node,
Selector selector,
HTypeMap types) {
- argumentTypes.registerDynamicInvocation(node, selector, types);
+ HTypeList providedTypes =
+ new HTypeList.fromDynamicInvocation(node, selector, types);
+ argumentTypes.registerDynamicInvocation(providedTypes, selector);
}
/**
« no previous file with comments | « no previous file | tests/language/no_such_method2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698