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 9541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9552 return ToApiHandle<String>(name); | 9552 return ToApiHandle<String>(name); |
9553 } else { | 9553 } else { |
9554 // We do not expect this to fail. Change this if it does. | 9554 // We do not expect this to fail. Change this if it does. |
9555 i::Handle<i::String> cons = isolate->factory()->NewConsString( | 9555 i::Handle<i::String> cons = isolate->factory()->NewConsString( |
9556 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), | 9556 isolate->factory()->InternalizeUtf8String(entry->name_prefix()), |
9557 name).ToHandleChecked(); | 9557 name).ToHandleChecked(); |
9558 return ToApiHandle<String>(cons); | 9558 return ToApiHandle<String>(cons); |
9559 } | 9559 } |
9560 } | 9560 } |
9561 | 9561 |
9562 debug::Coverage::Range::Range(i::CoverageRange* range, | 9562 debug::Coverage::FunctionData::FunctionData(i::CoverageFunction* function, |
9563 Local<debug::Script> script) | 9563 Local<debug::Script> script) |
9564 : range_(range), script_(script) { | 9564 : function_(function) { |
9565 i::Handle<i::Script> i_script = v8::Utils::OpenHandle(*script); | 9565 i::Handle<i::Script> i_script = v8::Utils::OpenHandle(*script); |
9566 i::Script::PositionInfo start; | 9566 i::Script::PositionInfo start; |
9567 i::Script::PositionInfo end; | 9567 i::Script::PositionInfo end; |
9568 i::Script::GetPositionInfo(i_script, range->start, &start, | 9568 i::Script::GetPositionInfo(i_script, function->start, &start, |
9569 i::Script::WITH_OFFSET); | 9569 i::Script::WITH_OFFSET); |
9570 i::Script::GetPositionInfo(i_script, range->end, &end, | 9570 i::Script::GetPositionInfo(i_script, function->end, &end, |
9571 i::Script::WITH_OFFSET); | 9571 i::Script::WITH_OFFSET); |
9572 start_ = Location(start.line, start.column); | 9572 start_ = Location(start.line, start.column); |
9573 end_ = Location(end.line, end.column); | 9573 end_ = Location(end.line, end.column); |
9574 } | 9574 } |
9575 | 9575 |
9576 uint32_t debug::Coverage::Range::Count() { return range_->count; } | 9576 uint32_t debug::Coverage::FunctionData::Count() { return function_->count; } |
9577 | 9577 |
9578 size_t debug::Coverage::Range::NestedCount() { return range_->inner.size(); } | 9578 MaybeLocal<String> debug::Coverage::FunctionData::Name() { |
9579 | 9579 return ToApiHandle<String>(function_->name); |
9580 debug::Coverage::Range debug::Coverage::Range::GetNested(size_t i) { | |
9581 return Range(&range_->inner[i], script_); | |
9582 } | 9580 } |
9583 | 9581 |
9584 MaybeLocal<String> debug::Coverage::Range::Name() { | 9582 Local<debug::Script> debug::Coverage::ScriptData::GetScript() { |
9585 return ToApiHandle<String>(range_->name); | 9583 return ToApiHandle<debug::Script>(script_->script); |
| 9584 } |
| 9585 |
| 9586 size_t debug::Coverage::ScriptData::FunctionCount() { |
| 9587 return script_->functions.size(); |
| 9588 } |
| 9589 |
| 9590 debug::Coverage::FunctionData debug::Coverage::ScriptData::GetFunctionData( |
| 9591 size_t i) { |
| 9592 return FunctionData(&script_->functions.at(i), GetScript()); |
9586 } | 9593 } |
9587 | 9594 |
9588 debug::Coverage::~Coverage() { delete coverage_; } | 9595 debug::Coverage::~Coverage() { delete coverage_; } |
9589 | 9596 |
9590 size_t debug::Coverage::ScriptCount() { return coverage_->size(); } | 9597 size_t debug::Coverage::ScriptCount() { return coverage_->size(); } |
9591 | 9598 |
9592 Local<debug::Script> debug::Coverage::GetScript(size_t i) { | 9599 debug::Coverage::ScriptData debug::Coverage::GetScriptData(size_t i) { |
9593 return ToApiHandle<debug::Script>(coverage_->at(i).script); | 9600 return ScriptData(&coverage_->at(i)); |
9594 } | |
9595 | |
9596 debug::Coverage::Range debug::Coverage::GetRange(size_t i) { | |
9597 return Range(&coverage_->at(i).toplevel, GetScript(i)); | |
9598 } | 9601 } |
9599 | 9602 |
9600 debug::Coverage debug::Coverage::Collect(Isolate* isolate) { | 9603 debug::Coverage debug::Coverage::Collect(Isolate* isolate) { |
9601 return Coverage(i::Coverage::Collect(reinterpret_cast<i::Isolate*>(isolate))); | 9604 return Coverage(i::Coverage::Collect(reinterpret_cast<i::Isolate*>(isolate))); |
9602 } | 9605 } |
9603 | 9606 |
9604 void debug::Coverage::TogglePrecise(Isolate* isolate, bool enable) { | 9607 void debug::Coverage::TogglePrecise(Isolate* isolate, bool enable) { |
9605 i::Coverage::TogglePrecise(reinterpret_cast<i::Isolate*>(isolate), enable); | 9608 i::Coverage::TogglePrecise(reinterpret_cast<i::Isolate*>(isolate), enable); |
9606 } | 9609 } |
9607 | 9610 |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10273 Address callback_address = | 10276 Address callback_address = |
10274 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10277 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10275 VMState<EXTERNAL> state(isolate); | 10278 VMState<EXTERNAL> state(isolate); |
10276 ExternalCallbackScope call_scope(isolate, callback_address); | 10279 ExternalCallbackScope call_scope(isolate, callback_address); |
10277 callback(info); | 10280 callback(info); |
10278 } | 10281 } |
10279 | 10282 |
10280 | 10283 |
10281 } // namespace internal | 10284 } // namespace internal |
10282 } // namespace v8 | 10285 } // namespace v8 |
OLD | NEW |