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

Side by Side Diff: src/api.cc

Issue 2493773003: [inspector] Introduce translation of wasm frames (Closed)
Patch Set: Address Dmitry's comments Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/debug/debug-interface.h » ('j') | src/inspector/v8-debugger.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 8891 matching lines...) Expand 10 before | Expand all | Expand 10 after
8902 8902
8903 int DebugInterface::Script::LineOffset() const { 8903 int DebugInterface::Script::LineOffset() const {
8904 return Utils::OpenHandle(this)->line_offset(); 8904 return Utils::OpenHandle(this)->line_offset();
8905 } 8905 }
8906 8906
8907 int DebugInterface::Script::ColumnOffset() const { 8907 int DebugInterface::Script::ColumnOffset() const {
8908 return Utils::OpenHandle(this)->column_offset(); 8908 return Utils::OpenHandle(this)->column_offset();
8909 } 8909 }
8910 8910
8911 std::vector<int> DebugInterface::Script::LineEnds() const { 8911 std::vector<int> DebugInterface::Script::LineEnds() const {
8912 if (IsWasm()) return {};
8912 i::Handle<i::Script> script = Utils::OpenHandle(this); 8913 i::Handle<i::Script> script = Utils::OpenHandle(this);
8913 i::Isolate* isolate = script->GetIsolate(); 8914 i::Isolate* isolate = script->GetIsolate();
8914 i::HandleScope scope(isolate); 8915 i::HandleScope scope(isolate);
8915 i::Script::InitLineEnds(script); 8916 i::Script::InitLineEnds(script);
8916 CHECK(script->line_ends()->IsFixedArray()); 8917 CHECK(script->line_ends()->IsFixedArray());
8917 i::Handle<i::FixedArray> line_ends(i::FixedArray::cast(script->line_ends())); 8918 i::Handle<i::FixedArray> line_ends(i::FixedArray::cast(script->line_ends()));
8918 std::vector<int> result(line_ends->length()); 8919 std::vector<int> result(line_ends->length());
8919 for (int i = 0; i < line_ends->length(); ++i) { 8920 for (int i = 0; i < line_ends->length(); ++i) {
8920 i::Smi* line_end = i::Smi::cast(line_ends->get(i)); 8921 i::Smi* line_end = i::Smi::cast(line_ends->get(i));
8921 result[i] = line_end->value(); 8922 result[i] = line_end->value();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
8966 MaybeLocal<String> DebugInterface::Script::Source() const { 8967 MaybeLocal<String> DebugInterface::Script::Source() const {
8967 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 8968 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
8968 i::HandleScope handle_scope(isolate); 8969 i::HandleScope handle_scope(isolate);
8969 i::Handle<i::Script> script = Utils::OpenHandle(this); 8970 i::Handle<i::Script> script = Utils::OpenHandle(this);
8970 i::Handle<i::Object> value(script->source(), isolate); 8971 i::Handle<i::Object> value(script->source(), isolate);
8971 if (!value->IsString()) return MaybeLocal<String>(); 8972 if (!value->IsString()) return MaybeLocal<String>();
8972 return Utils::ToLocal( 8973 return Utils::ToLocal(
8973 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); 8974 handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value)));
8974 } 8975 }
8975 8976
8977 bool DebugInterface::Script::IsWasm() const {
8978 return Utils::OpenHandle(this)->type() == i::Script::TYPE_WASM;
8979 }
8980
8976 namespace { 8981 namespace {
8977 int GetSmiValue(i::Handle<i::FixedArray> array, int index) { 8982 int GetSmiValue(i::Handle<i::FixedArray> array, int index) {
8978 return i::Smi::cast(array->get(index))->value(); 8983 return i::Smi::cast(array->get(index))->value();
8979 } 8984 }
8980 } // namespace 8985 } // namespace
8981 8986
8982 bool DebugInterface::Script::GetPossibleBreakpoints( 8987 bool DebugInterface::Script::GetPossibleBreakpoints(
8983 const Location& start, const Location& end, 8988 const Location& start, const Location& end,
8984 std::vector<Location>* locations) const { 8989 std::vector<Location>* locations) const {
8985 CHECK(!start.IsEmpty()); 8990 CHECK(!start.IsEmpty());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
9055 ENTER_V8(isolate); 9060 ENTER_V8(isolate);
9056 i::HandleScope handle_scope(isolate); 9061 i::HandleScope handle_scope(isolate);
9057 i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script)); 9062 i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script));
9058 if (!script_receiver->IsJSValue()) return MaybeLocal<Script>(); 9063 if (!script_receiver->IsJSValue()) return MaybeLocal<Script>();
9059 i::Handle<i::Object> script_value( 9064 i::Handle<i::Object> script_value(
9060 i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate); 9065 i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate);
9061 if (!script_value->IsScript()) { 9066 if (!script_value->IsScript()) {
9062 return MaybeLocal<Script>(); 9067 return MaybeLocal<Script>();
9063 } 9068 }
9064 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); 9069 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value);
9065 if (script_obj->type() != i::Script::TYPE_NORMAL) return MaybeLocal<Script>(); 9070 if (script_obj->type() != i::Script::TYPE_NORMAL &&
9071 script_obj->type() != i::Script::TYPE_WASM) {
9072 return MaybeLocal<Script>();
9073 }
9066 return ToApiHandle<DebugInterface::Script>( 9074 return ToApiHandle<DebugInterface::Script>(
9067 handle_scope.CloseAndEscape(script_obj)); 9075 handle_scope.CloseAndEscape(script_obj));
9068 } 9076 }
9069 9077
9070 DebugInterface::Location::Location(int lineNumber, int columnNumber) 9078 DebugInterface::Location::Location(int lineNumber, int columnNumber)
9071 : lineNumber_(lineNumber), columnNumber_(columnNumber) { 9079 : lineNumber_(lineNumber), columnNumber_(columnNumber) {
9072 CHECK(lineNumber >= 0); 9080 CHECK(lineNumber >= 0);
9073 CHECK(columnNumber >= 0); 9081 CHECK(columnNumber >= 0);
9074 } 9082 }
9075 9083
(...skipping 29 matching lines...) Expand all
9105 if (script->type() != i::Script::TYPE_NORMAL) continue; 9113 if (script->type() != i::Script::TYPE_NORMAL) continue;
9106 if (script->HasValidSource()) { 9114 if (script->HasValidSource()) {
9107 i::HandleScope handle_scope(isolate); 9115 i::HandleScope handle_scope(isolate);
9108 i::Handle<i::Script> script_handle(script, isolate); 9116 i::Handle<i::Script> script_handle(script, isolate);
9109 scripts.Append(ToApiHandle<Script>(script_handle)); 9117 scripts.Append(ToApiHandle<Script>(script_handle));
9110 } 9118 }
9111 } 9119 }
9112 } 9120 }
9113 } 9121 }
9114 9122
9123 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>>
9124 DebugInterface::DisassembleWasmFunction(Isolate* v8_isolate,
9125 Local<Object> v8_script,
9126 int function_index) {
9127 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9128 if (v8_script.IsEmpty()) return {};
9129 i::Handle<i::Object> script_wrapper = Utils::OpenHandle(*v8_script);
9130 if (!script_wrapper->IsJSValue()) return {};
9131 i::Handle<i::Object> script_obj(
9132 i::Handle<i::JSValue>::cast(script_wrapper)->value(), isolate);
9133 if (!script_obj->IsScript()) return {};
9134 i::Handle<i::Script> script = i::Handle<i::Script>::cast(script_obj);
9135 if (script->type() != i::Script::TYPE_WASM) return {};
9136 i::Handle<i::WasmCompiledModule> compiled_module(
9137 i::WasmCompiledModule::cast(script->wasm_compiled_module()), isolate);
9138 return i::wasm::DisassembleFunction(compiled_module, function_index);
9139 }
9140
9115 Local<String> CpuProfileNode::GetFunctionName() const { 9141 Local<String> CpuProfileNode::GetFunctionName() const {
9116 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 9142 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
9117 i::Isolate* isolate = node->isolate(); 9143 i::Isolate* isolate = node->isolate();
9118 const i::CodeEntry* entry = node->entry(); 9144 const i::CodeEntry* entry = node->entry();
9119 i::Handle<i::String> name = 9145 i::Handle<i::String> name =
9120 isolate->factory()->InternalizeUtf8String(entry->name()); 9146 isolate->factory()->InternalizeUtf8String(entry->name());
9121 if (!entry->has_name_prefix()) { 9147 if (!entry->has_name_prefix()) {
9122 return ToApiHandle<String>(name); 9148 return ToApiHandle<String>(name);
9123 } else { 9149 } else {
9124 // We do not expect this to fail. Change this if it does. 9150 // We do not expect this to fail. Change this if it does.
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
9793 Address callback_address = 9819 Address callback_address =
9794 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9820 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9795 VMState<EXTERNAL> state(isolate); 9821 VMState<EXTERNAL> state(isolate);
9796 ExternalCallbackScope call_scope(isolate, callback_address); 9822 ExternalCallbackScope call_scope(isolate, callback_address);
9797 callback(info); 9823 callback(info);
9798 } 9824 }
9799 9825
9800 9826
9801 } // namespace internal 9827 } // namespace internal
9802 } // namespace v8 9828 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/debug/debug-interface.h » ('j') | src/inspector/v8-debugger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698