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 9624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9635 v8::Local<debug::Script> script) { | 9635 v8::Local<debug::Script> script) { |
9636 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9636 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
9637 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); | 9637 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); |
9638 i::DisallowHeapAllocation no_gc; | 9638 i::DisallowHeapAllocation no_gc; |
9639 i::SharedFunctionInfo::ScriptIterator iter(Utils::OpenHandle(*script)); | 9639 i::SharedFunctionInfo::ScriptIterator iter(Utils::OpenHandle(*script)); |
9640 while (i::SharedFunctionInfo* info = iter.Next()) { | 9640 while (i::SharedFunctionInfo* info = iter.Next()) { |
9641 info->set_computed_debug_is_blackboxed(false); | 9641 info->set_computed_debug_is_blackboxed(false); |
9642 } | 9642 } |
9643 } | 9643 } |
9644 | 9644 |
| 9645 void debug::SetIdle(Isolate* v8_isolate, bool is_idle) { |
| 9646 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 9647 v8::StateTag state = isolate->current_vm_state(); |
| 9648 DCHECK(state == v8::EXTERNAL || state == v8::IDLE); |
| 9649 if (isolate->js_entry_sp() != NULL) return; |
| 9650 if (is_idle) { |
| 9651 isolate->set_current_vm_state(v8::IDLE); |
| 9652 } else if (state == v8::IDLE) { |
| 9653 isolate->set_current_vm_state(v8::EXTERNAL); |
| 9654 } |
| 9655 } |
| 9656 |
9645 int debug::EstimatedValueSize(Isolate* v8_isolate, v8::Local<v8::Value> value) { | 9657 int debug::EstimatedValueSize(Isolate* v8_isolate, v8::Local<v8::Value> value) { |
9646 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 9658 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
9647 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); | 9659 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); |
9648 i::Handle<i::Object> object = Utils::OpenHandle(*value); | 9660 i::Handle<i::Object> object = Utils::OpenHandle(*value); |
9649 if (object->IsSmi()) return i::kPointerSize; | 9661 if (object->IsSmi()) return i::kPointerSize; |
9650 CHECK(object->IsHeapObject()); | 9662 CHECK(object->IsHeapObject()); |
9651 return i::Handle<i::HeapObject>::cast(object)->Size(); | 9663 return i::Handle<i::HeapObject>::cast(object)->Size(); |
9652 } | 9664 } |
9653 | 9665 |
9654 v8::MaybeLocal<v8::Array> debug::EntriesPreview(Isolate* v8_isolate, | 9666 v8::MaybeLocal<v8::Array> debug::EntriesPreview(Isolate* v8_isolate, |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10004 return reinterpret_cast<CpuProfile*>( | 10016 return reinterpret_cast<CpuProfile*>( |
10005 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling( | 10017 reinterpret_cast<i::CpuProfiler*>(this)->StopProfiling( |
10006 *Utils::OpenHandle(*title))); | 10018 *Utils::OpenHandle(*title))); |
10007 } | 10019 } |
10008 | 10020 |
10009 | 10021 |
10010 void CpuProfiler::SetIdle(bool is_idle) { | 10022 void CpuProfiler::SetIdle(bool is_idle) { |
10011 i::CpuProfiler* profiler = reinterpret_cast<i::CpuProfiler*>(this); | 10023 i::CpuProfiler* profiler = reinterpret_cast<i::CpuProfiler*>(this); |
10012 i::Isolate* isolate = profiler->isolate(); | 10024 i::Isolate* isolate = profiler->isolate(); |
10013 if (!isolate->is_profiling()) return; | 10025 if (!isolate->is_profiling()) return; |
10014 v8::StateTag state = isolate->current_vm_state(); | 10026 debug::SetIdle(reinterpret_cast<v8::Isolate*>(isolate), is_idle); |
10015 DCHECK(state == v8::EXTERNAL || state == v8::IDLE); | |
10016 if (isolate->js_entry_sp() != NULL) return; | |
10017 if (is_idle) { | |
10018 isolate->set_current_vm_state(v8::IDLE); | |
10019 } else if (state == v8::IDLE) { | |
10020 isolate->set_current_vm_state(v8::EXTERNAL); | |
10021 } | |
10022 } | 10027 } |
10023 | 10028 |
10024 | 10029 |
10025 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { | 10030 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { |
10026 return const_cast<i::HeapGraphEdge*>( | 10031 return const_cast<i::HeapGraphEdge*>( |
10027 reinterpret_cast<const i::HeapGraphEdge*>(edge)); | 10032 reinterpret_cast<const i::HeapGraphEdge*>(edge)); |
10028 } | 10033 } |
10029 | 10034 |
10030 | 10035 |
10031 HeapGraphEdge::Type HeapGraphEdge::GetType() const { | 10036 HeapGraphEdge::Type HeapGraphEdge::GetType() const { |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10501 Address callback_address = | 10506 Address callback_address = |
10502 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10507 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10503 VMState<EXTERNAL> state(isolate); | 10508 VMState<EXTERNAL> state(isolate); |
10504 ExternalCallbackScope call_scope(isolate, callback_address); | 10509 ExternalCallbackScope call_scope(isolate, callback_address); |
10505 callback(info); | 10510 callback(info); |
10506 } | 10511 } |
10507 | 10512 |
10508 | 10513 |
10509 } // namespace internal | 10514 } // namespace internal |
10510 } // namespace v8 | 10515 } // namespace v8 |
OLD | NEW |