aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/runtime/runtime-debug.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-02-14 11:27:26 +0100
committerMichaël Zasso <targos@protonmail.com>2017-02-22 15:55:42 +0100
commit7a77daf24344db7942e34c962b0f1ee729ab7af5 (patch)
treee7cbe7bf4e2f4b802a8f5bc18336c546cd6a0d7f /deps/v8/src/runtime/runtime-debug.cc
parent5f08871ee93ea739148cc49e0f7679e33c70295a (diff)
downloadandroid-node-v8-7a77daf24344db7942e34c962b0f1ee729ab7af5.tar.gz
android-node-v8-7a77daf24344db7942e34c962b0f1ee729ab7af5.tar.bz2
android-node-v8-7a77daf24344db7942e34c962b0f1ee729ab7af5.zip
deps: update V8 to 5.6.326.55
PR-URL: https://github.com/nodejs/node/pull/10992 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/src/runtime/runtime-debug.cc')
-rw-r--r--deps/v8/src/runtime/runtime-debug.cc199
1 files changed, 118 insertions, 81 deletions
diff --git a/deps/v8/src/runtime/runtime-debug.cc b/deps/v8/src/runtime/runtime-debug.cc
index 2d217b83f7..824ea92a0f 100644
--- a/deps/v8/src/runtime/runtime-debug.cc
+++ b/deps/v8/src/runtime/runtime-debug.cc
@@ -16,8 +16,8 @@
#include "src/interpreter/interpreter.h"
#include "src/isolate-inl.h"
#include "src/runtime/runtime.h"
-#include "src/wasm/wasm-debug.h"
#include "src/wasm/wasm-module.h"
+#include "src/wasm/wasm-objects.h"
namespace v8 {
namespace internal {
@@ -47,7 +47,7 @@ RUNTIME_FUNCTION(Runtime_DebugBreakOnBytecode) {
isolate->debug()->Break(it.frame());
// If live-edit has dropped frames, we are not going back to dispatch.
- if (LiveEdit::SetAfterBreakTarget(isolate->debug())) return Smi::FromInt(0);
+ if (LiveEdit::SetAfterBreakTarget(isolate->debug())) return Smi::kZero;
// Return the handler from the original bytecode array.
DCHECK(it.frame()->is_interpreted());
@@ -256,14 +256,14 @@ MaybeHandle<JSArray> Runtime::GetInternalProperties(Isolate* isolate,
const char* status = "rejected";
int status_val = Handle<Smi>::cast(status_obj)->value();
switch (status_val) {
- case +1:
+ case kPromiseFulfilled:
status = "resolved";
break;
- case 0:
+ case kPromisePending:
status = "pending";
break;
default:
- DCHECK_EQ(-1, status_val);
+ DCHECK_EQ(kPromiseRejected, status_val);
}
Handle<FixedArray> result = factory->NewFixedArray(2 * 2);
@@ -457,7 +457,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameCount) {
StackFrame::Id id = isolate->debug()->break_frame_id();
if (id == StackFrame::NO_ID) {
// If there is no JavaScript stack frame count is 0.
- return Smi::FromInt(0);
+ return Smi::kZero;
}
for (StackTraceFrameIterator it(isolate, id); !it.done(); it.Advance()) {
@@ -551,10 +551,10 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
details->set(kFrameDetailsFrameIdIndex, *frame_id);
// Add the function name.
- Handle<Object> wasm_obj(it.wasm_frame()->wasm_obj(), isolate);
+ Handle<Object> wasm_instance(it.wasm_frame()->wasm_instance(), isolate);
int func_index = it.wasm_frame()->function_index();
Handle<String> func_name =
- wasm::GetWasmFunctionName(isolate, wasm_obj, func_index);
+ wasm::GetWasmFunctionName(isolate, wasm_instance, func_index);
details->set(kFrameDetailsFunctionIndex, *func_name);
// Add the script wrapper
@@ -563,14 +563,26 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) {
details->set(kFrameDetailsScriptIndex, *script_wrapper);
// Add the arguments count.
- details->set(kFrameDetailsArgumentCountIndex, Smi::FromInt(0));
+ details->set(kFrameDetailsArgumentCountIndex, Smi::kZero);
// Add the locals count
- details->set(kFrameDetailsLocalCountIndex, Smi::FromInt(0));
+ details->set(kFrameDetailsLocalCountIndex, Smi::kZero);
// Add the source position.
+ // For wasm, it is function-local, so translate it to a module-relative
+ // position, such that together with the script it uniquely identifies the
+ // position.
+ Handle<Object> positionValue;
if (position != kNoSourcePosition) {
- details->set(kFrameDetailsSourcePositionIndex, Smi::FromInt(position));
+ int translated_position = position;
+ if (!wasm::WasmIsAsmJs(*wasm_instance, isolate)) {
+ Handle<WasmCompiledModule> compiled_module(
+ wasm::GetCompiledModule(JSObject::cast(*wasm_instance)), isolate);
+ translated_position +=
+ wasm::GetFunctionCodeOffset(compiled_module, func_index);
+ }
+ details->set(kFrameDetailsSourcePositionIndex,
+ Smi::FromInt(translated_position));
}
// Add the constructor information.
@@ -929,7 +941,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeCount) {
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
- if (!args[0]->IsJSGeneratorObject()) return Smi::FromInt(0);
+ if (!args[0]->IsJSGeneratorObject()) return Smi::kZero;
// Check arguments.
CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, gen, 0);
@@ -948,7 +960,7 @@ RUNTIME_FUNCTION(Runtime_GetGeneratorScopeDetails) {
DCHECK(args.length() == 2);
if (!args[0]->IsJSGeneratorObject()) {
- return *isolate->factory()->undefined_value();
+ return isolate->heap()->undefined_value();
}
// Check arguments.
@@ -1429,6 +1441,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 +1582,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 +1597,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);
@@ -1601,7 +1616,7 @@ RUNTIME_FUNCTION(Runtime_ScriptLineStartPosition) {
if (line < 0 || line > line_count) {
return Smi::FromInt(-1);
} else if (line == 0) {
- return Smi::FromInt(0);
+ return Smi::kZero;
} else {
DCHECK(0 < line && line <= line_count);
const int pos = Smi::cast(line_ends_array->get(line - 1))->value() + 1;
@@ -1609,6 +1624,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);
@@ -1634,7 +1650,7 @@ static Handle<Object> GetJSPositionInfo(Handle<Script> script, int position,
Script::OffsetFlag offset_flag,
Isolate* isolate) {
Script::PositionInfo info;
- if (!script->GetPositionInfo(position, &info, offset_flag)) {
+ if (!Script::GetPositionInfo(script, position, &info, offset_flag)) {
return isolate->factory()->null_value();
}
@@ -1661,62 +1677,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(script, 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 +1730,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 +1806,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);
@@ -1822,12 +1881,19 @@ RUNTIME_FUNCTION(Runtime_DebugPopPromise) {
return isolate->heap()->undefined_value();
}
+RUNTIME_FUNCTION(Runtime_DebugNextMicrotaskId) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 0);
+ return Smi::FromInt(isolate->GetNextDebugMicrotaskId());
+}
RUNTIME_FUNCTION(Runtime_DebugAsyncTaskEvent) {
- DCHECK(args.length() == 1);
+ DCHECK(args.length() == 3);
HandleScope scope(isolate);
- CONVERT_ARG_HANDLE_CHECKED(JSObject, data, 0);
- isolate->debug()->OnAsyncTaskEvent(data);
+ CONVERT_ARG_HANDLE_CHECKED(String, type, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, id, 1);
+ CONVERT_ARG_HANDLE_CHECKED(String, name, 2);
+ isolate->debug()->OnAsyncTaskEvent(type, id, name);
return isolate->heap()->undefined_value();
}
@@ -1843,34 +1909,5 @@ RUNTIME_FUNCTION(Runtime_DebugBreakInOptimizedCode) {
return NULL;
}
-RUNTIME_FUNCTION(Runtime_GetWasmFunctionOffsetTable) {
- DCHECK(args.length() == 1);
- HandleScope scope(isolate);
- CONVERT_ARG_CHECKED(JSValue, script_val, 0);
-
- CHECK(script_val->value()->IsScript());
- Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
-
- Handle<wasm::WasmDebugInfo> debug_info =
- wasm::GetDebugInfo(handle(script->wasm_object(), isolate));
- Handle<FixedArray> elements = wasm::WasmDebugInfo::GetFunctionOffsetTable(
- debug_info, script->wasm_function_index());
- return *isolate->factory()->NewJSArrayWithElements(elements);
-}
-
-RUNTIME_FUNCTION(Runtime_DisassembleWasmFunction) {
- DCHECK(args.length() == 1);
- HandleScope scope(isolate);
- CONVERT_ARG_CHECKED(JSValue, script_val, 0);
-
- CHECK(script_val->value()->IsScript());
- Handle<Script> script = Handle<Script>(Script::cast(script_val->value()));
-
- Handle<wasm::WasmDebugInfo> debug_info =
- wasm::GetDebugInfo(handle(script->wasm_object(), isolate));
- return *wasm::WasmDebugInfo::DisassembleFunction(
- debug_info, script->wasm_function_index());
-}
-
} // namespace internal
} // namespace v8