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

Side by Side Diff: src/api.cc

Issue 2531163010: [inspector] Introduce debug::WasmScript (Closed)
Patch Set: Address comments Created 4 years 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') | no next file with comments »
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 9083 matching lines...) Expand 10 before | Expand all | Expand 10 after
9094 } 9094 }
9095 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); 9095 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value);
9096 if (script_obj->type() != i::Script::TYPE_NORMAL && 9096 if (script_obj->type() != i::Script::TYPE_NORMAL &&
9097 script_obj->type() != i::Script::TYPE_WASM) { 9097 script_obj->type() != i::Script::TYPE_WASM) {
9098 return MaybeLocal<Script>(); 9098 return MaybeLocal<Script>();
9099 } 9099 }
9100 return ToApiHandle<DebugInterface::Script>( 9100 return ToApiHandle<DebugInterface::Script>(
9101 handle_scope.CloseAndEscape(script_obj)); 9101 handle_scope.CloseAndEscape(script_obj));
9102 } 9102 }
9103 9103
9104 DebugInterface::WasmScript* DebugInterface::WasmScript::Cast(
9105 DebugInterface::Script* script) {
9106 CHECK(script->IsWasm());
9107 return static_cast<WasmScript*>(script);
9108 }
9109
9110 int DebugInterface::WasmScript::NumFunction() const {
titzer 2016/12/02 09:52:36 NumFunctions?
Clemens Hammacher 2016/12/02 10:38:09 Doh! Thanks.
9111 i::DisallowHeapAllocation no_gc;
9112 i::Handle<i::Script> script = Utils::OpenHandle(this);
9113 DCHECK_EQ(i::Script::TYPE_WASM, script->type());
9114 i::WasmCompiledModule* compiled_module =
9115 i::WasmCompiledModule::cast(script->wasm_compiled_module());
9116 DCHECK_GE(i::kMaxInt, compiled_module->module()->functions.size());
9117 return static_cast<int>(compiled_module->module()->functions.size());
9118 }
9119
9120 int DebugInterface::WasmScript::NumImportedFunction() const {
9121 i::DisallowHeapAllocation no_gc;
9122 i::Handle<i::Script> script = Utils::OpenHandle(this);
9123 DCHECK_EQ(i::Script::TYPE_WASM, script->type());
9124 i::WasmCompiledModule* compiled_module =
9125 i::WasmCompiledModule::cast(script->wasm_compiled_module());
9126 DCHECK_GE(i::kMaxInt, compiled_module->module()->num_imported_functions);
9127 return static_cast<int>(compiled_module->module()->num_imported_functions);
9128 }
9129
9130 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>>
9131 DebugInterface::WasmScript::DisassembleFunction(int function_index) {
9132 i::DisallowHeapAllocation no_gc;
9133 i::Handle<i::Script> script = Utils::OpenHandle(this);
9134 DCHECK_EQ(i::Script::TYPE_WASM, script->type());
9135 i::WasmCompiledModule* compiled_module =
9136 i::WasmCompiledModule::cast(script->wasm_compiled_module());
9137 return compiled_module->DisassembleFunction(function_index);
9138 }
9139
9104 DebugInterface::Location::Location(int lineNumber, int columnNumber) 9140 DebugInterface::Location::Location(int lineNumber, int columnNumber)
9105 : lineNumber_(lineNumber), columnNumber_(columnNumber) { 9141 : lineNumber_(lineNumber), columnNumber_(columnNumber) {
9106 CHECK(lineNumber >= 0); 9142 CHECK(lineNumber >= 0);
9107 CHECK(columnNumber >= 0); 9143 CHECK(columnNumber >= 0);
9108 } 9144 }
9109 9145
9110 DebugInterface::Location::Location() : lineNumber_(-1), columnNumber_(-1) {} 9146 DebugInterface::Location::Location() : lineNumber_(-1), columnNumber_(-1) {}
9111 9147
9112 int DebugInterface::Location::GetLineNumber() const { 9148 int DebugInterface::Location::GetLineNumber() const {
9113 CHECK(lineNumber_ >= 0); 9149 CHECK(lineNumber_ >= 0);
(...skipping 25 matching lines...) Expand all
9139 if (script->type() != i::Script::TYPE_NORMAL) continue; 9175 if (script->type() != i::Script::TYPE_NORMAL) continue;
9140 if (script->HasValidSource()) { 9176 if (script->HasValidSource()) {
9141 i::HandleScope handle_scope(isolate); 9177 i::HandleScope handle_scope(isolate);
9142 i::Handle<i::Script> script_handle(script, isolate); 9178 i::Handle<i::Script> script_handle(script, isolate);
9143 scripts.Append(ToApiHandle<Script>(script_handle)); 9179 scripts.Append(ToApiHandle<Script>(script_handle));
9144 } 9180 }
9145 } 9181 }
9146 } 9182 }
9147 } 9183 }
9148 9184
9149 std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>>
9150 DebugInterface::DisassembleWasmFunction(Isolate* v8_isolate,
9151 Local<Object> v8_script,
9152 int function_index) {
9153 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9154 if (v8_script.IsEmpty()) return {};
9155 i::Handle<i::Object> script_wrapper = Utils::OpenHandle(*v8_script);
9156 if (!script_wrapper->IsJSValue()) return {};
9157 i::Handle<i::Object> script_obj(
9158 i::Handle<i::JSValue>::cast(script_wrapper)->value(), isolate);
9159 if (!script_obj->IsScript()) return {};
9160 i::Handle<i::Script> script = i::Handle<i::Script>::cast(script_obj);
9161 if (script->type() != i::Script::TYPE_WASM) return {};
9162 i::Handle<i::WasmCompiledModule> compiled_module(
9163 i::WasmCompiledModule::cast(script->wasm_compiled_module()), isolate);
9164 return compiled_module->DisassembleFunction(function_index);
9165 }
9166
9167 MaybeLocal<UnboundScript> DebugInterface::CompileInspectorScript( 9185 MaybeLocal<UnboundScript> DebugInterface::CompileInspectorScript(
9168 Isolate* v8_isolate, Local<String> source) { 9186 Isolate* v8_isolate, Local<String> source) {
9169 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); 9187 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
9170 PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(isolate, UnboundScript); 9188 PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(isolate, UnboundScript);
9171 i::ScriptData* script_data = NULL; 9189 i::ScriptData* script_data = NULL;
9172 i::Handle<i::String> str = Utils::OpenHandle(*source); 9190 i::Handle<i::String> str = Utils::OpenHandle(*source);
9173 i::Handle<i::SharedFunctionInfo> result; 9191 i::Handle<i::SharedFunctionInfo> result;
9174 { 9192 {
9175 ScriptOriginOptions origin_options; 9193 ScriptOriginOptions origin_options;
9176 result = i::Compiler::GetSharedFunctionInfoForScript( 9194 result = i::Compiler::GetSharedFunctionInfoForScript(
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
9864 Address callback_address = 9882 Address callback_address =
9865 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9883 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9866 VMState<EXTERNAL> state(isolate); 9884 VMState<EXTERNAL> state(isolate);
9867 ExternalCallbackScope call_scope(isolate, callback_address); 9885 ExternalCallbackScope call_scope(isolate, callback_address);
9868 callback(info); 9886 callback(info);
9869 } 9887 }
9870 9888
9871 9889
9872 } // namespace internal 9890 } // namespace internal
9873 } // namespace v8 9891 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/debug/debug-interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698