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

Unified Diff: src/interpreter/source-position-table.cc

Issue 1668863002: [interpreter] source positions should not be emitted for dead code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 10 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/source-position-table.h ('k') | test/mjsunit/ignition/dead-code-source-position.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/source-position-table.cc
diff --git a/src/interpreter/source-position-table.cc b/src/interpreter/source-position-table.cc
index f408f159db3bef2df859043eab3b41cd7c0da6b6..b82f608ac4001bd2ba72b4a8cb2d594024893321 100644
--- a/src/interpreter/source-position-table.cc
+++ b/src/interpreter/source-position-table.cc
@@ -15,20 +15,32 @@ namespace interpreter {
class IsStatementField : public BitField<bool, 0, 1> {};
class SourcePositionField : public BitField<int, 1, 30> {};
-void SourcePositionTableBuilder::AddStatementPosition(int bytecode_offset,
+void SourcePositionTableBuilder::AddStatementPosition(size_t bytecode_offset,
int source_position) {
- AssertMonotonic(bytecode_offset);
+ int offset = static_cast<int>(bytecode_offset);
+ AssertMonotonic(offset);
uint32_t encoded = IsStatementField::encode(true) |
SourcePositionField::encode(source_position);
- entries_.push_back({bytecode_offset, encoded});
+ entries_.push_back({offset, encoded});
}
-void SourcePositionTableBuilder::AddExpressionPosition(int bytecode_offset,
+void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset,
int source_position) {
- AssertMonotonic(bytecode_offset);
+ int offset = static_cast<int>(bytecode_offset);
+ AssertMonotonic(offset);
uint32_t encoded = IsStatementField::encode(false) |
SourcePositionField::encode(source_position);
- entries_.push_back({bytecode_offset, encoded});
+ entries_.push_back({offset, encoded});
+}
+
+void SourcePositionTableBuilder::RevertPosition(size_t bytecode_offset) {
+ int offset = static_cast<int>(bytecode_offset);
+ // If we already added a source position table entry, but the bytecode array
+ // builder ended up not outputting a bytecode for the corresponding bytecode
+ // offset, we have to remove that entry.
+ if (entries_.size() > 0 && entries_.back().bytecode_offset == offset) {
+ entries_.pop_back();
+ }
}
Handle<FixedArray> SourcePositionTableBuilder::ToFixedArray() {
« no previous file with comments | « src/interpreter/source-position-table.h ('k') | test/mjsunit/ignition/dead-code-source-position.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698