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

Unified Diff: src/runtime/runtime-debug.cc

Issue 2447073007: [debugger] Various break-related functionality in test wrapper (Closed)
Patch Set: Move DebugEvent to DebugWrapper to preserve old API Created 4 years, 2 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/runtime/runtime.h ('k') | src/runtime/runtime-function.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-debug.cc
diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc
index 8e1abf249580e12171b84f1e4158734b693177af..4810b1ac0a7d30f1dc144e43638fe13f256bc605 100644
--- a/src/runtime/runtime-debug.cc
+++ b/src/runtime/runtime-debug.cc
@@ -1429,6 +1429,7 @@ RUNTIME_FUNCTION(Runtime_DebugGetPrototype) {
// Patches script source (should be called upon BeforeCompile event).
+// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
@@ -1569,6 +1570,7 @@ RUNTIME_FUNCTION(Runtime_GetScript) {
return *Script::GetWrapper(found);
}
+// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_ScriptLineCount) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
@@ -1583,6 +1585,7 @@ RUNTIME_FUNCTION(Runtime_ScriptLineCount) {
return Smi::FromInt(line_ends_array->length());
}
+// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_ScriptLineStartPosition) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
@@ -1609,6 +1612,7 @@ RUNTIME_FUNCTION(Runtime_ScriptLineStartPosition) {
}
}
+// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_ScriptLineEndPosition) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
@@ -1661,62 +1665,49 @@ static Handle<Object> GetJSPositionInfo(Handle<Script> script, int position,
return jsinfo;
}
-// Get information on a specific source line and column possibly offset by a
-// fixed source position. This function is used to find a source position from
-// a line and column position. The fixed source position offset is typically
-// used to find a source position in a function based on a line and column in
-// the source for the function alone. The offset passed will then be the
-// start position of the source for the function within the full script source.
-// Note that incoming line and column parameters may be undefined, and are
-// assumed to be passed *with* offsets.
-RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 4);
- CONVERT_ARG_CHECKED(JSValue, script, 0);
-
- CHECK(script->value()->IsScript());
- Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
+namespace {
+Handle<Object> ScriptLocationFromLine(Isolate* isolate, Handle<Script> script,
+ Handle<Object> opt_line,
+ Handle<Object> opt_column,
+ int32_t offset) {
// Line and column are possibly undefined and we need to handle these cases,
// additionally subtracting corresponding offsets.
int32_t line;
- if (args[1]->IsNull(isolate) || args[1]->IsUndefined(isolate)) {
+ if (opt_line->IsNull(isolate) || opt_line->IsUndefined(isolate)) {
line = 0;
} else {
- CHECK(args[1]->IsNumber());
- line = NumberToInt32(args[1]) - script_handle->line_offset();
+ CHECK(opt_line->IsNumber());
+ line = NumberToInt32(*opt_line) - script->line_offset();
}
int32_t column;
- if (args[2]->IsNull(isolate) || args[2]->IsUndefined(isolate)) {
+ if (opt_column->IsNull(isolate) || opt_column->IsUndefined(isolate)) {
column = 0;
} else {
- CHECK(args[2]->IsNumber());
- column = NumberToInt32(args[2]);
- if (line == 0) column -= script_handle->column_offset();
+ CHECK(opt_column->IsNumber());
+ column = NumberToInt32(*opt_column);
+ if (line == 0) column -= script->column_offset();
}
- CONVERT_NUMBER_CHECKED(int32_t, offset_position, Int32, args[3]);
-
- if (line < 0 || column < 0 || offset_position < 0) {
- return isolate->heap()->null_value();
+ if (line < 0 || column < 0 || offset < 0) {
+ return isolate->factory()->null_value();
}
- Script::InitLineEnds(script_handle);
+ Script::InitLineEnds(script);
- FixedArray* line_ends_array = FixedArray::cast(script_handle->line_ends());
+ FixedArray* line_ends_array = FixedArray::cast(script->line_ends());
const int line_count = line_ends_array->length();
int position;
if (line == 0) {
- position = offset_position + column;
+ position = offset + column;
} else {
Script::PositionInfo info;
- if (!script_handle->GetPositionInfo(offset_position, &info,
- Script::NO_OFFSET) ||
+ if (!script->GetPositionInfo(offset, &info, Script::NO_OFFSET) ||
info.line + line >= line_count) {
- return isolate->heap()->null_value();
+ return isolate->factory()->null_value();
}
const int offset_line = info.line + line;
@@ -1727,10 +1718,65 @@ RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) {
position = offset_line_position + column;
}
- return *GetJSPositionInfo(script_handle, position, Script::NO_OFFSET,
- isolate);
+ return GetJSPositionInfo(script, position, Script::NO_OFFSET, isolate);
+}
+
+// Slow traversal over all scripts on the heap.
+bool GetScriptById(Isolate* isolate, int needle, Handle<Script>* result) {
+ Script::Iterator iterator(isolate);
+ Script* script = NULL;
+ while ((script = iterator.Next()) != NULL) {
+ if (script->id() == needle) {
+ *result = handle(script);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+} // namespace
+
+// Get information on a specific source line and column possibly offset by a
+// fixed source position. This function is used to find a source position from
+// a line and column position. The fixed source position offset is typically
+// used to find a source position in a function based on a line and column in
+// the source for the function alone. The offset passed will then be the
+// start position of the source for the function within the full script source.
+// Note that incoming line and column parameters may be undefined, and are
+// assumed to be passed *with* offsets.
+// TODO(5530): Remove once uses in debug.js are gone.
+RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 4);
+ CONVERT_ARG_HANDLE_CHECKED(JSValue, script, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, opt_line, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, opt_column, 2);
+ CONVERT_NUMBER_CHECKED(int32_t, offset, Int32, args[3]);
+
+ CHECK(script->value()->IsScript());
+ Handle<Script> script_handle = Handle<Script>(Script::cast(script->value()));
+
+ return *ScriptLocationFromLine(isolate, script_handle, opt_line, opt_column,
+ offset);
+}
+
+// TODO(5530): Rename once conflicting function has been deleted.
+RUNTIME_FUNCTION(Runtime_ScriptLocationFromLine2) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 4);
+ CONVERT_NUMBER_CHECKED(int32_t, scriptid, Int32, args[0]);
+ CONVERT_ARG_HANDLE_CHECKED(Object, opt_line, 1);
+ CONVERT_ARG_HANDLE_CHECKED(Object, opt_column, 2);
+ CONVERT_NUMBER_CHECKED(int32_t, offset, Int32, args[3]);
+
+ Handle<Script> script;
+ CHECK(GetScriptById(isolate, scriptid, &script));
+
+ return *ScriptLocationFromLine(isolate, script, opt_line, opt_column, offset);
}
+// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_ScriptPositionInfo) {
HandleScope scope(isolate);
DCHECK(args.length() == 3);
@@ -1748,6 +1794,7 @@ RUNTIME_FUNCTION(Runtime_ScriptPositionInfo) {
// Returns the given line as a string, or null if line is out of bounds.
// The parameter line is expected to include the script's line offset.
+// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_ScriptSourceLine) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
@@ -1850,6 +1897,7 @@ RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
return NULL;
}
+// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) {
DCHECK(args.length() == 1);
HandleScope scope(isolate);
@@ -1865,6 +1913,7 @@ RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) {
return *isolate->factory()->NewJSArrayWithElements(elements);
}
+// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) {
DCHECK(args.length() == 1);
HandleScope scope(isolate);
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698