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

Unified Diff: src/interpreter/bytecode-peephole-optimizer.cc

Issue 2042633002: [interpreter] Ensure optimizations preserve source positions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 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 | « src/interpreter/bytecode-peephole-optimizer.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-peephole-optimizer.cc
diff --git a/src/interpreter/bytecode-peephole-optimizer.cc b/src/interpreter/bytecode-peephole-optimizer.cc
index 790b270abddf3cccb90ba3a6b834c1a87795891f..7d4f852103311d00ec7862c955f00a4a0c51ae60 100644
--- a/src/interpreter/bytecode-peephole-optimizer.cc
+++ b/src/interpreter/bytecode-peephole-optimizer.cc
@@ -173,6 +173,7 @@ namespace {
void TransformLdaStarToLdrLdar(Bytecode new_bytecode, BytecodeNode* const last,
BytecodeNode* const current) {
DCHECK_EQ(current->bytecode(), Bytecode::kStar);
+
//
// An example transformation here would be:
//
@@ -186,20 +187,17 @@ void TransformLdaStarToLdrLdar(Bytecode new_bytecode, BytecodeNode* const last,
last->Transform(new_bytecode, current->operand(0), current->operand_scale());
current->set_bytecode(Bytecode::kLdar, current->operand(0),
current->operand_scale());
-
- // If there was a source position on |current| transfer it to the
- // updated |last| to maintain the debugger's causal view. ie. if an
- // expression position LdrGlobal is the bytecode that could throw
- // and if a statement position it needs to be placed before the
- // store to R occurs.
- last->source_info().Update(current->source_info());
- current->source_info().set_invalid();
}
} // namespace
-bool BytecodePeepholeOptimizer::ChangeLdaToLdr(BytecodeNode* const current) {
- if (current->bytecode() == Bytecode::kStar) {
+bool BytecodePeepholeOptimizer::TransformLastAndCurrentBytecodes(
+ BytecodeNode* const current) {
+ if (current->bytecode() == Bytecode::kStar &&
+ !current->source_info().is_statement()) {
+ // Note: If the Star is tagged with a statement position, we can't
+ // perform this transform as the store to the register will
+ // have the wrong ordering for stepping in the debugger.
switch (last_.bytecode()) {
case Bytecode::kLdaNamedProperty:
TransformLdaStarToLdrLdar(Bytecode::kLdrNamedProperty, &last_, current);
@@ -252,10 +250,10 @@ bool BytecodePeepholeOptimizer::RemoveToBooleanFromLogicalNot(
return can_remove;
}
-bool BytecodePeepholeOptimizer::TransformLastAndCurrentBytecodes(
+bool BytecodePeepholeOptimizer::TransformCurrentBytecode(
BytecodeNode* const current) {
return RemoveToBooleanFromJump(current) ||
- RemoveToBooleanFromLogicalNot(current) || ChangeLdaToLdr(current);
+ RemoveToBooleanFromLogicalNot(current);
}
bool BytecodePeepholeOptimizer::CanElideLast(
@@ -283,7 +281,8 @@ bool BytecodePeepholeOptimizer::CanElideLast(
BytecodeNode* BytecodePeepholeOptimizer::Optimize(BytecodeNode* current) {
TryToRemoveLastExpressionPosition(current);
- if (TransformLastAndCurrentBytecodes(current)) {
+ if (TransformCurrentBytecode(current) ||
+ TransformLastAndCurrentBytecodes(current)) {
return current;
}
« no previous file with comments | « src/interpreter/bytecode-peephole-optimizer.h ('k') | src/interpreter/bytecodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698