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

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

Issue 10915122: Fix source locations for inlined and patched functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
Index: lib/compiler/implementation/ssa/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index ac81eb7ea4e948c1e6ce2ab5e0d42d56852cb1e1..d78c5b2ed25ee24bfed04948f482f1563876abc5 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -845,6 +845,8 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// block is closed.
HBasicBlock lastOpenedBlock;
+ List<Element> sourceElementStack;
+
LibraryElement get currentLibrary => work.element.getLibrary();
Element get currentElement => work.element;
Compiler get compiler => builder.compiler;
@@ -860,6 +862,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
activationVariables = new Map<Element, HLocalValue>(),
jumpTargets = new Map<TargetElement, JumpHandler>(),
parameters = new Map<Element, HParameterValue>(),
+ sourceElementStack = <Element>[work.element],
inliningStack = <InliningState>[],
super(work.resolutionTree) {
localsHandler = new LocalsHandler(this);
@@ -958,6 +961,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
InliningState state =
new InliningState(function, returnElement, elements, stack);
inliningStack.add(state);
+ sourceElementStack.add(function);
stack = <HInstruction>[];
returnElement = new Element(const SourceString("result"),
ElementKind.VARIABLE,
@@ -978,6 +982,8 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
void leaveInlinedMethod(InliningState state) {
InliningState poppedState = inliningStack.removeLast();
assert(state == poppedState);
+ FunctionElement poppedElement = sourceElementStack.removeLast();
+ assert(poppedElement == poppedState.function);
elements = state.oldElements;
stack.add(localsHandler.readLocal(returnElement));
returnElement = state.oldReturnElement;
@@ -1105,7 +1111,9 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
SendSet init = link.head;
Link<Node> arguments = init.arguments;
assert(!arguments.isEmpty() && arguments.tail.isEmpty());
+ sourceElementStack.add(constructor);
visit(arguments.head);
+ sourceElementStack.removeLast();
fieldValues[elements[init]] = pop();
}
}
@@ -1461,10 +1469,19 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
}
HInstruction attachPosition(HInstruction target, Node node) {
- target.sourcePosition = node.getBeginToken();
+ target.sourcePosition = sourceFileLocationForToken(node.getBeginToken());
return target;
}
+ SourceFileLocation sourceFileLocationForToken(Token token) {
+ Element element = sourceElementStack.last();
+ if (element is FunctionElement && element.dynamic.patch != null) {
floitsch 2012/09/06 16:44:55 don't use 'dynamic'. Either use "as", or create a
ahe 2012/09/08 08:55:50 Yes. Please don't use "as".
podivilov 2012/09/10 11:13:23 Done.
+ element = element.dynamic.patch;
ahe 2012/09/08 08:55:50 This is a hack and you should add a TODO for Johnn
podivilov 2012/09/10 11:13:23 Done.
+ }
+ SourceFile sourceFile = element.getCompilationUnit().script.file;
+ return new SourceFileLocation(sourceFile, token);
+ }
+
void visit(Node node) {
if (node !== null) node.accept(this);
}
@@ -1663,7 +1680,8 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
wrapExpressionGraph(updateGraph),
conditionBlock.loopInformation.target,
conditionBlock.loopInformation.labels,
- loop);
+ sourceFileLocationForToken(loop.getBeginToken()),
+ sourceFileLocationForToken(loop.getEndToken()));
startBlock.setBlockFlow(info, current);
loopInfo.loopBlockInformation = info;
@@ -1791,7 +1809,8 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
null,
loopEntryBlock.loopInformation.target,
loopEntryBlock.loopInformation.labels,
- node);
+ sourceFileLocationForToken(node.getBeginToken()),
+ sourceFileLocationForToken(node.getEndToken()));
loopEntryBlock.setBlockFlow(loopBlockInfo, current);
loopInfo.loopBlockInformation = loopBlockInfo;
}

Powered by Google App Engine
This is Rietveld 408576698