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

Unified Diff: src/objects.cc

Issue 1682853003: [debugger] introduce abstract interface for break location. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: revert stray edit 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/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index c1f072145094776375392053f929bc7f798c5713..801ecdc83cec971a80b477773f18ee0442832b3e 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -14498,8 +14498,13 @@ void Code::ClearInlineCaches(Code::Kind* kind) {
}
int AbstractCode::SourcePosition(int offset) {
- if (IsBytecodeArray()) return GetBytecodeArray()->SourcePosition(offset);
- return GetCode()->SourcePosition(offset);
+ return IsBytecodeArray() ? GetBytecodeArray()->SourcePosition(offset)
+ : GetCode()->SourcePosition(offset);
+}
+
+int AbstractCode::SourceStatementPosition(int offset) {
+ return IsBytecodeArray() ? GetBytecodeArray()->SourceStatementPosition(offset)
+ : GetCode()->SourceStatementPosition(offset);
}
void SharedFunctionInfo::ClearTypeFeedbackInfo() {
@@ -15194,8 +15199,32 @@ void Code::Disassemble(const char* name, std::ostream& os) { // NOLINT
#endif // ENABLE_DISASSEMBLER
int BytecodeArray::SourcePosition(int offset) {
- return interpreter::SourcePositionTableIterator::PositionFromBytecodeOffset(
- this, offset);
+ int last_position = 0;
+ for (interpreter::SourcePositionTableIterator iterator(this);
+ !iterator.done() && iterator.bytecode_offset() <= offset;
+ iterator.Advance()) {
+ last_position = iterator.source_position();
+ }
+ return last_position;
+}
+
+int BytecodeArray::SourceStatementPosition(int offset) {
+ // First find the position as close as possible using all position
+ // information.
+ int position = SourcePosition(offset);
+ // Now find the closest statement position before the position.
+ int statement_position = 0;
+ interpreter::SourcePositionTableIterator iterator(this);
+ while (!iterator.done()) {
+ if (iterator.is_statement()) {
+ int p = iterator.source_position();
+ if (statement_position < p && p <= position) {
+ statement_position = p;
+ }
+ }
+ iterator.Advance();
+ }
+ return statement_position;
}
void BytecodeArray::Disassemble(std::ostream& os) {
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698