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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/debug/debug-interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 688e96136e91517a1fe9844af3980ff38313ca20..45cc7f91e206b9c240b1dde76288d59e232d28bd 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -9101,6 +9101,42 @@ MaybeLocal<DebugInterface::Script> DebugInterface::Script::Wrap(
handle_scope.CloseAndEscape(script_obj));
}
+DebugInterface::WasmScript* DebugInterface::WasmScript::Cast(
+ DebugInterface::Script* script) {
+ CHECK(script->IsWasm());
+ return static_cast<WasmScript*>(script);
+}
+
+int DebugInterface::WasmScript::NumFunction() const {
titzer 2016/12/02 09:52:36 NumFunctions?
Clemens Hammacher 2016/12/02 10:38:09 Doh! Thanks.
+ i::DisallowHeapAllocation no_gc;
+ i::Handle<i::Script> script = Utils::OpenHandle(this);
+ DCHECK_EQ(i::Script::TYPE_WASM, script->type());
+ i::WasmCompiledModule* compiled_module =
+ i::WasmCompiledModule::cast(script->wasm_compiled_module());
+ DCHECK_GE(i::kMaxInt, compiled_module->module()->functions.size());
+ return static_cast<int>(compiled_module->module()->functions.size());
+}
+
+int DebugInterface::WasmScript::NumImportedFunction() const {
+ i::DisallowHeapAllocation no_gc;
+ i::Handle<i::Script> script = Utils::OpenHandle(this);
+ DCHECK_EQ(i::Script::TYPE_WASM, script->type());
+ i::WasmCompiledModule* compiled_module =
+ i::WasmCompiledModule::cast(script->wasm_compiled_module());
+ DCHECK_GE(i::kMaxInt, compiled_module->module()->num_imported_functions);
+ return static_cast<int>(compiled_module->module()->num_imported_functions);
+}
+
+std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>>
+DebugInterface::WasmScript::DisassembleFunction(int function_index) {
+ i::DisallowHeapAllocation no_gc;
+ i::Handle<i::Script> script = Utils::OpenHandle(this);
+ DCHECK_EQ(i::Script::TYPE_WASM, script->type());
+ i::WasmCompiledModule* compiled_module =
+ i::WasmCompiledModule::cast(script->wasm_compiled_module());
+ return compiled_module->DisassembleFunction(function_index);
+}
+
DebugInterface::Location::Location(int lineNumber, int columnNumber)
: lineNumber_(lineNumber), columnNumber_(columnNumber) {
CHECK(lineNumber >= 0);
@@ -9146,24 +9182,6 @@ void DebugInterface::GetLoadedScripts(
}
}
-std::pair<std::string, std::vector<std::tuple<uint32_t, int, int>>>
-DebugInterface::DisassembleWasmFunction(Isolate* v8_isolate,
- Local<Object> v8_script,
- int function_index) {
- i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
- if (v8_script.IsEmpty()) return {};
- i::Handle<i::Object> script_wrapper = Utils::OpenHandle(*v8_script);
- if (!script_wrapper->IsJSValue()) return {};
- i::Handle<i::Object> script_obj(
- i::Handle<i::JSValue>::cast(script_wrapper)->value(), isolate);
- if (!script_obj->IsScript()) return {};
- i::Handle<i::Script> script = i::Handle<i::Script>::cast(script_obj);
- if (script->type() != i::Script::TYPE_WASM) return {};
- i::Handle<i::WasmCompiledModule> compiled_module(
- i::WasmCompiledModule::cast(script->wasm_compiled_module()), isolate);
- return compiled_module->DisassembleFunction(function_index);
-}
-
MaybeLocal<UnboundScript> DebugInterface::CompileInspectorScript(
Isolate* v8_isolate, Local<String> source) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
« 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