| OLD | NEW |
| 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 9077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9088 return MaybeLocal<Script>(); | 9088 return MaybeLocal<Script>(); |
| 9089 } | 9089 } |
| 9090 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); | 9090 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); |
| 9091 if (script_obj->type() != i::Script::TYPE_NORMAL && | 9091 if (script_obj->type() != i::Script::TYPE_NORMAL && |
| 9092 script_obj->type() != i::Script::TYPE_WASM) { | 9092 script_obj->type() != i::Script::TYPE_WASM) { |
| 9093 return MaybeLocal<Script>(); | 9093 return MaybeLocal<Script>(); |
| 9094 } | 9094 } |
| 9095 return ToApiHandle<debug::Script>(handle_scope.CloseAndEscape(script_obj)); | 9095 return ToApiHandle<debug::Script>(handle_scope.CloseAndEscape(script_obj)); |
| 9096 } | 9096 } |
| 9097 | 9097 |
| 9098 debug::WasmScript* debug::WasmScript::Cast(debug::Script* script) { |
| 9099 CHECK(script->IsWasm()); |
| 9100 return static_cast<WasmScript*>(script); |
| 9101 } |
| 9102 |
| 9103 int debug::WasmScript::NumFunctions() const { |
| 9104 i::DisallowHeapAllocation no_gc; |
| 9105 i::Handle<i::Script> script = Utils::OpenHandle(this); |
| 9106 DCHECK_EQ(i::Script::TYPE_WASM, script->type()); |
| 9107 i::WasmCompiledModule* compiled_module = |
| 9108 i::WasmCompiledModule::cast(script->wasm_compiled_module()); |
| 9109 DCHECK_GE(i::kMaxInt, compiled_module->module()->functions.size()); |
| 9110 return static_cast<int>(compiled_module->module()->functions.size()); |
| 9111 } |
| 9112 |
| 9113 int debug::WasmScript::NumImportedFunctions() const { |
| 9114 i::DisallowHeapAllocation no_gc; |
| 9115 i::Handle<i::Script> script = Utils::OpenHandle(this); |
| 9116 DCHECK_EQ(i::Script::TYPE_WASM, script->type()); |
| 9117 i::WasmCompiledModule* compiled_module = |
| 9118 i::WasmCompiledModule::cast(script->wasm_compiled_module()); |
| 9119 DCHECK_GE(i::kMaxInt, compiled_module->module()->num_imported_functions); |
| 9120 return static_cast<int>(compiled_module->module()->num_imported_functions); |
| 9121 } |
| 9122 |
| 9123 debug::WasmDisassembly debug::WasmScript::DisassembleFunction( |
| 9124 int function_index) const { |
| 9125 i::Handle<i::Script> script = Utils::OpenHandle(this); |
| 9126 DCHECK_EQ(i::Script::TYPE_WASM, script->type()); |
| 9127 i::WasmCompiledModule* compiled_module = |
| 9128 i::WasmCompiledModule::cast(script->wasm_compiled_module()); |
| 9129 return compiled_module->DisassembleFunction(function_index); |
| 9130 } |
| 9131 |
| 9098 debug::Location::Location(int line_number, int column_number) | 9132 debug::Location::Location(int line_number, int column_number) |
| 9099 : line_number_(line_number), column_number_(column_number) { | 9133 : line_number_(line_number), column_number_(column_number) { |
| 9100 CHECK(line_number >= 0); | 9134 CHECK(line_number >= 0); |
| 9101 CHECK(column_number >= 0); | 9135 CHECK(column_number >= 0); |
| 9102 } | 9136 } |
| 9103 | 9137 |
| 9104 debug::Location::Location() : line_number_(-1), column_number_(-1) {} | 9138 debug::Location::Location() : line_number_(-1), column_number_(-1) {} |
| 9105 | 9139 |
| 9106 int debug::Location::GetLineNumber() const { | 9140 int debug::Location::GetLineNumber() const { |
| 9107 CHECK(line_number_ >= 0); | 9141 CHECK(line_number_ >= 0); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 9132 if (script->type() != i::Script::TYPE_NORMAL) continue; | 9166 if (script->type() != i::Script::TYPE_NORMAL) continue; |
| 9133 if (script->HasValidSource()) { | 9167 if (script->HasValidSource()) { |
| 9134 i::HandleScope handle_scope(isolate); | 9168 i::HandleScope handle_scope(isolate); |
| 9135 i::Handle<i::Script> script_handle(script, isolate); | 9169 i::Handle<i::Script> script_handle(script, isolate); |
| 9136 scripts.Append(ToApiHandle<Script>(script_handle)); | 9170 scripts.Append(ToApiHandle<Script>(script_handle)); |
| 9137 } | 9171 } |
| 9138 } | 9172 } |
| 9139 } | 9173 } |
| 9140 } | 9174 } |
| 9141 | 9175 |
| 9142 debug::WasmDisassembly debug::DisassembleWasmFunction(Isolate* v8_isolate, | |
| 9143 Local<Object> v8_script, | |
| 9144 int function_index) { | |
| 9145 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | |
| 9146 if (v8_script.IsEmpty()) return {}; | |
| 9147 i::Handle<i::Object> script_wrapper = Utils::OpenHandle(*v8_script); | |
| 9148 if (!script_wrapper->IsJSValue()) return {}; | |
| 9149 i::Handle<i::Object> script_obj( | |
| 9150 i::Handle<i::JSValue>::cast(script_wrapper)->value(), isolate); | |
| 9151 if (!script_obj->IsScript()) return {}; | |
| 9152 i::Handle<i::Script> script = i::Handle<i::Script>::cast(script_obj); | |
| 9153 if (script->type() != i::Script::TYPE_WASM) return {}; | |
| 9154 i::Handle<i::WasmCompiledModule> compiled_module( | |
| 9155 i::WasmCompiledModule::cast(script->wasm_compiled_module()), isolate); | |
| 9156 return compiled_module->DisassembleFunction(function_index); | |
| 9157 } | |
| 9158 | |
| 9159 MaybeLocal<UnboundScript> debug::CompileInspectorScript(Isolate* v8_isolate, | 9176 MaybeLocal<UnboundScript> debug::CompileInspectorScript(Isolate* v8_isolate, |
| 9160 Local<String> source) { | 9177 Local<String> source) { |
| 9161 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9178 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 9162 PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(isolate, UnboundScript); | 9179 PREPARE_FOR_DEBUG_INTERFACE_EXECUTION_WITH_ISOLATE(isolate, UnboundScript); |
| 9163 i::ScriptData* script_data = NULL; | 9180 i::ScriptData* script_data = NULL; |
| 9164 i::Handle<i::String> str = Utils::OpenHandle(*source); | 9181 i::Handle<i::String> str = Utils::OpenHandle(*source); |
| 9165 i::Handle<i::SharedFunctionInfo> result; | 9182 i::Handle<i::SharedFunctionInfo> result; |
| 9166 { | 9183 { |
| 9167 ScriptOriginOptions origin_options; | 9184 ScriptOriginOptions origin_options; |
| 9168 result = i::Compiler::GetSharedFunctionInfoForScript( | 9185 result = i::Compiler::GetSharedFunctionInfoForScript( |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9856 Address callback_address = | 9873 Address callback_address = |
| 9857 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9874 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 9858 VMState<EXTERNAL> state(isolate); | 9875 VMState<EXTERNAL> state(isolate); |
| 9859 ExternalCallbackScope call_scope(isolate, callback_address); | 9876 ExternalCallbackScope call_scope(isolate, callback_address); |
| 9860 callback(info); | 9877 callback(info); |
| 9861 } | 9878 } |
| 9862 | 9879 |
| 9863 | 9880 |
| 9864 } // namespace internal | 9881 } // namespace internal |
| 9865 } // namespace v8 | 9882 } // namespace v8 |
| OLD | NEW |