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 9272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9283 i::WasmCompiledModule::cast(script->wasm_compiled_module()); | 9283 i::WasmCompiledModule::cast(script->wasm_compiled_module()); |
9284 return compiled_module->DisassembleFunction(function_index); | 9284 return compiled_module->DisassembleFunction(function_index); |
9285 } | 9285 } |
9286 | 9286 |
9287 debug::Location::Location(int line_number, int column_number) | 9287 debug::Location::Location(int line_number, int column_number) |
9288 : line_number_(line_number), column_number_(column_number) { | 9288 : line_number_(line_number), column_number_(column_number) { |
9289 CHECK(line_number >= 0); | 9289 CHECK(line_number >= 0); |
9290 CHECK(column_number >= 0); | 9290 CHECK(column_number >= 0); |
9291 } | 9291 } |
9292 | 9292 |
9293 debug::Location::Location() : line_number_(-1), column_number_(-1) {} | 9293 debug::Location::Location() |
9294 : line_number_(v8::Function::kLineOffsetNotFound), | |
9295 column_number_(v8::Function::kLineOffsetNotFound) {} | |
9294 | 9296 |
9295 int debug::Location::GetLineNumber() const { | 9297 int debug::Location::GetLineNumber() const { |
9296 CHECK(line_number_ >= 0); | 9298 CHECK(line_number_ >= 0); |
9297 return line_number_; | 9299 return line_number_; |
9298 } | 9300 } |
9299 | 9301 |
9300 int debug::Location::GetColumnNumber() const { | 9302 int debug::Location::GetColumnNumber() const { |
9301 CHECK(column_number_ >= 0); | 9303 CHECK(column_number_ >= 0); |
9302 return column_number_; | 9304 return column_number_; |
9303 } | 9305 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9407 if (object->IsJSSetIterator()) { | 9409 if (object->IsJSSetIterator()) { |
9408 i::Handle<i::JSSetIterator> it = i::Handle<i::JSSetIterator>::cast(object); | 9410 i::Handle<i::JSSetIterator> it = i::Handle<i::JSSetIterator>::cast(object); |
9409 *is_key_value = false; | 9411 *is_key_value = false; |
9410 if (!it->HasMore()) return v8::Array::New(v8_isolate); | 9412 if (!it->HasMore()) return v8::Array::New(v8_isolate); |
9411 return Utils::ToLocal( | 9413 return Utils::ToLocal( |
9412 SetAsArray(isolate, it->table(), i::Smi::cast(it->index())->value())); | 9414 SetAsArray(isolate, it->table(), i::Smi::cast(it->index())->value())); |
9413 } | 9415 } |
9414 return v8::MaybeLocal<v8::Array>(); | 9416 return v8::MaybeLocal<v8::Array>(); |
9415 } | 9417 } |
9416 | 9418 |
9419 MaybeLocal<debug::Script> debug::GeneratorObject::Script() { | |
9420 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this); | |
9421 if (!obj->function()->shared()->script()->IsScript()) | |
jgruber
2017/02/07 08:32:28
Nit: I think this'd be more readable if we store o
kozy
2017/02/07 17:09:45
Done.
| |
9422 return MaybeLocal<debug::Script>(); | |
9423 i::Handle<i::Script> script( | |
9424 i::Script::cast(obj->function()->shared()->script()), obj->GetIsolate()); | |
9425 return ToApiHandle<debug::Script>(script); | |
9426 } | |
9427 | |
9428 Local<Function> debug::GeneratorObject::Function() { | |
9429 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this); | |
9430 return Utils::ToLocal(handle(obj->function())); | |
9431 } | |
9432 | |
9433 debug::Location debug::GeneratorObject::SuspendedLocation() { | |
9434 i::Handle<i::JSGeneratorObject> obj = Utils::OpenHandle(this); | |
9435 CHECK(obj->is_suspended()); | |
9436 if (!obj->function()->shared()->script()->IsScript()) | |
9437 return debug::Location(); | |
9438 i::Handle<i::Script> script( | |
9439 i::Script::cast(obj->function()->shared()->script()), obj->GetIsolate()); | |
9440 i::Script::PositionInfo info; | |
9441 i::Script::GetPositionInfo(script, obj->source_position(), &info, | |
9442 i::Script::WITH_OFFSET); | |
9443 return debug::Location(info.line, info.column); | |
9444 } | |
9445 | |
9446 bool debug::GeneratorObject::IsSuspended() { | |
9447 return Utils::OpenHandle(this)->is_suspended(); | |
9448 } | |
9449 | |
9450 v8::Local<debug::GeneratorObject> debug::GeneratorObject::Cast( | |
9451 v8::Local<v8::Value> value) { | |
9452 CHECK(value->IsGeneratorObject()); | |
9453 return ToApiHandle<debug::GeneratorObject>(Utils::OpenHandle(*value)); | |
9454 } | |
9455 | |
9417 Local<String> CpuProfileNode::GetFunctionName() const { | 9456 Local<String> CpuProfileNode::GetFunctionName() const { |
9418 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 9457 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
9419 i::Isolate* isolate = node->isolate(); | 9458 i::Isolate* isolate = node->isolate(); |
9420 const i::CodeEntry* entry = node->entry(); | 9459 const i::CodeEntry* entry = node->entry(); |
9421 i::Handle<i::String> name = | 9460 i::Handle<i::String> name = |
9422 isolate->factory()->InternalizeUtf8String(entry->name()); | 9461 isolate->factory()->InternalizeUtf8String(entry->name()); |
9423 if (!entry->has_name_prefix()) { | 9462 if (!entry->has_name_prefix()) { |
9424 return ToApiHandle<String>(name); | 9463 return ToApiHandle<String>(name); |
9425 } else { | 9464 } else { |
9426 // We do not expect this to fail. Change this if it does. | 9465 // We do not expect this to fail. Change this if it does. |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10099 Address callback_address = | 10138 Address callback_address = |
10100 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10139 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10101 VMState<EXTERNAL> state(isolate); | 10140 VMState<EXTERNAL> state(isolate); |
10102 ExternalCallbackScope call_scope(isolate, callback_address); | 10141 ExternalCallbackScope call_scope(isolate, callback_address); |
10103 callback(info); | 10142 callback(info); |
10104 } | 10143 } |
10105 | 10144 |
10106 | 10145 |
10107 } // namespace internal | 10146 } // namespace internal |
10108 } // namespace v8 | 10147 } // namespace v8 |
OLD | NEW |