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

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

Issue 23440034: Make sure we throw the right NSM error when indexing out of range of a variable that can be null. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | sdk/lib/_internal/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (revision 27429)
+++ sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (working copy)
@@ -1976,23 +1976,35 @@
js.Statement thenBody = new js.Block.empty();
js.Block oldContainer = currentContainer;
currentContainer = thenBody;
- generateThrowWithHelper('ioore', node.index);
+ generateThrowWithHelper('ioore', [node.array, node.index]);
currentContainer = oldContainer;
thenBody = unwrapStatement(thenBody);
pushStatement(new js.If.noElse(underOver, thenBody), node);
} else {
- generateThrowWithHelper('ioore', node.index);
+ generateThrowWithHelper('ioore', [node.array, node.index]);
}
}
- void generateThrowWithHelper(String helperName, HInstruction argument) {
+ void generateThrowWithHelper(String helperName, argument) {
Element helper = compiler.findHelper(new SourceString(helperName));
world.registerStaticUse(helper);
js.VariableUse jsHelper =
new js.VariableUse(backend.namer.isolateAccess(helper));
- use(argument);
- js.Call value = new js.Call(jsHelper, [pop()]);
- attachLocation(value, argument);
+ List arguments = [];
+ var location;
+ if (argument is List) {
+ location = argument[0];
+ argument.forEach((instruction) {
+ use(instruction);
+ arguments.add(pop());
+ });
+ } else {
+ location = argument;
+ use(argument);
+ arguments.add(pop());
+ }
+ js.Call value = new js.Call(jsHelper, arguments);
+ attachLocation(value, location);
// BUG(4906): Using throw here adds to the size of the generated code
// but it has the advantage of explicitly telling the JS engine that
// this code path will terminate abruptly. Needs more work.
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/ssa/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698