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 9173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9184 i::handle(script->line_ends(), script->GetIsolate())); | 9184 i::handle(script->line_ends(), script->GetIsolate())); |
9185 CHECK(line_ends->length()); | 9185 CHECK(line_ends->length()); |
9186 if (line >= line_ends->length()) | 9186 if (line >= line_ends->length()) |
9187 return GetSmiValue(line_ends, line_ends->length() - 1); | 9187 return GetSmiValue(line_ends, line_ends->length() - 1); |
9188 int line_offset = GetSmiValue(line_ends, line); | 9188 int line_offset = GetSmiValue(line_ends, line); |
9189 if (line == 0) return std::min(column, line_offset); | 9189 if (line == 0) return std::min(column, line_offset); |
9190 int prev_line_offset = GetSmiValue(line_ends, line - 1); | 9190 int prev_line_offset = GetSmiValue(line_ends, line - 1); |
9191 return std::min(prev_line_offset + column + 1, line_offset); | 9191 return std::min(prev_line_offset + column + 1, line_offset); |
9192 } | 9192 } |
9193 | 9193 |
9194 MaybeLocal<debug::Script> debug::Script::Wrap(v8::Isolate* v8_isolate, | |
9195 v8::Local<v8::Object> script) { | |
9196 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | |
9197 ENTER_V8(isolate); | |
9198 i::HandleScope handle_scope(isolate); | |
9199 i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script)); | |
9200 if (!script_receiver->IsJSValue()) return MaybeLocal<Script>(); | |
9201 i::Handle<i::Object> script_value( | |
9202 i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate); | |
9203 if (!script_value->IsScript()) { | |
9204 return MaybeLocal<Script>(); | |
9205 } | |
9206 i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); | |
9207 if (script_obj->type() != i::Script::TYPE_NORMAL && | |
9208 script_obj->type() != i::Script::TYPE_WASM) { | |
9209 return MaybeLocal<Script>(); | |
9210 } | |
9211 return ToApiHandle<debug::Script>(handle_scope.CloseAndEscape(script_obj)); | |
9212 } | |
9213 | |
9214 debug::WasmScript* debug::WasmScript::Cast(debug::Script* script) { | 9194 debug::WasmScript* debug::WasmScript::Cast(debug::Script* script) { |
9215 CHECK(script->IsWasm()); | 9195 CHECK(script->IsWasm()); |
9216 return static_cast<WasmScript*>(script); | 9196 return static_cast<WasmScript*>(script); |
9217 } | 9197 } |
9218 | 9198 |
9219 int debug::WasmScript::NumFunctions() const { | 9199 int debug::WasmScript::NumFunctions() const { |
9220 i::DisallowHeapAllocation no_gc; | 9200 i::DisallowHeapAllocation no_gc; |
9221 i::Handle<i::Script> script = Utils::OpenHandle(this); | 9201 i::Handle<i::Script> script = Utils::OpenHandle(this); |
9222 DCHECK_EQ(i::Script::TYPE_WASM, script->type()); | 9202 DCHECK_EQ(i::Script::TYPE_WASM, script->type()); |
9223 i::WasmCompiledModule* compiled_module = | 9203 i::WasmCompiledModule* compiled_module = |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9309 } | 9289 } |
9310 | 9290 |
9311 void debug::SetAsyncTaskListener(Isolate* v8_isolate, | 9291 void debug::SetAsyncTaskListener(Isolate* v8_isolate, |
9312 debug::AsyncTaskListener listener, | 9292 debug::AsyncTaskListener listener, |
9313 void* data) { | 9293 void* data) { |
9314 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9294 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
9315 ENTER_V8(isolate); | 9295 ENTER_V8(isolate); |
9316 isolate->debug()->SetAsyncTaskListener(listener, data); | 9296 isolate->debug()->SetAsyncTaskListener(listener, data); |
9317 } | 9297 } |
9318 | 9298 |
| 9299 void debug::SetCompileEventListener(Isolate* v8_isolate, |
| 9300 debug::CompileEventListener listener, |
| 9301 void* data) { |
| 9302 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 9303 ENTER_V8(isolate); |
| 9304 isolate->debug()->SetCompileEventListener(listener, data); |
| 9305 } |
| 9306 |
9319 Local<String> CpuProfileNode::GetFunctionName() const { | 9307 Local<String> CpuProfileNode::GetFunctionName() const { |
9320 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 9308 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
9321 i::Isolate* isolate = node->isolate(); | 9309 i::Isolate* isolate = node->isolate(); |
9322 const i::CodeEntry* entry = node->entry(); | 9310 const i::CodeEntry* entry = node->entry(); |
9323 i::Handle<i::String> name = | 9311 i::Handle<i::String> name = |
9324 isolate->factory()->InternalizeUtf8String(entry->name()); | 9312 isolate->factory()->InternalizeUtf8String(entry->name()); |
9325 if (!entry->has_name_prefix()) { | 9313 if (!entry->has_name_prefix()) { |
9326 return ToApiHandle<String>(name); | 9314 return ToApiHandle<String>(name); |
9327 } else { | 9315 } else { |
9328 // We do not expect this to fail. Change this if it does. | 9316 // We do not expect this to fail. Change this if it does. |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9996 Address callback_address = | 9984 Address callback_address = |
9997 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9985 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9998 VMState<EXTERNAL> state(isolate); | 9986 VMState<EXTERNAL> state(isolate); |
9999 ExternalCallbackScope call_scope(isolate, callback_address); | 9987 ExternalCallbackScope call_scope(isolate, callback_address); |
10000 callback(info); | 9988 callback(info); |
10001 } | 9989 } |
10002 | 9990 |
10003 | 9991 |
10004 } // namespace internal | 9992 } // namespace internal |
10005 } // namespace v8 | 9993 } // namespace v8 |
OLD | NEW |