Chromium Code Reviews| 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 7494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7505 } | 7505 } |
| 7506 | 7506 |
| 7507 | 7507 |
| 7508 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { | 7508 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { |
| 7509 const i::ProfileNode* child = | 7509 const i::ProfileNode* child = |
| 7510 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); | 7510 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); |
| 7511 return reinterpret_cast<const CpuProfileNode*>(child); | 7511 return reinterpret_cast<const CpuProfileNode*>(child); |
| 7512 } | 7512 } |
| 7513 | 7513 |
| 7514 | 7514 |
| 7515 unsigned CpuProfileNode::GetDeoptCount() const { | |
| 7516 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | |
| 7517 return static_cast<unsigned>(node->deopt_infos().size()); | |
| 7518 } | |
| 7519 | |
| 7520 | |
| 7521 const CpuProfileDeoptInfo* CpuProfileNode::GetDeoptInfo(unsigned index) const { | |
| 7522 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | |
| 7523 DCHECK_LT(index, node->deopt_infos().size()); | |
|
yurys
2015/03/30 13:20:18
Drop this as List already performs such checks.
| |
| 7524 if (index >= node->deopt_infos().size()) return NULL; | |
| 7525 const i::DeoptInfo& deopt_info = node->deopt_infos().at(index); | |
| 7526 return reinterpret_cast<const CpuProfileDeoptInfo*>(&deopt_info); | |
| 7527 } | |
| 7528 | |
| 7529 | |
| 7530 const char* CpuProfileDeoptInfo::GetDeoptReason() const { | |
| 7531 const i::DeoptInfo* deopt_info = reinterpret_cast<const i::DeoptInfo*>(this); | |
| 7532 return deopt_info->deopt_reason; | |
| 7533 } | |
| 7534 | |
| 7535 | |
| 7536 unsigned CpuProfileDeoptInfo::GetFramesCount() const { | |
| 7537 const i::DeoptInfo* deopt_info = reinterpret_cast<const i::DeoptInfo*>(this); | |
| 7538 return static_cast<unsigned>(deopt_info->stack.size()); | |
| 7539 } | |
| 7540 | |
| 7541 | |
| 7542 bool CpuProfileDeoptInfo::GetCallFrames(Frame* frames, | |
|
yurys
2015/03/30 13:20:18
Return number of written frames?
| |
| 7543 unsigned int length) const { | |
| 7544 if (frames == NULL || length == 0) return false; | |
| 7545 const i::DeoptInfo* deopt_info = reinterpret_cast<const i::DeoptInfo*>(this); | |
| 7546 for (size_t i = 0; i < deopt_info->stack.size() && i < length; ++i) { | |
| 7547 frames[i] = deopt_info->stack[i]; | |
| 7548 } | |
| 7549 return true; | |
| 7550 } | |
| 7551 | |
| 7552 | |
| 7515 void CpuProfile::Delete() { | 7553 void CpuProfile::Delete() { |
| 7516 i::Isolate* isolate = i::Isolate::Current(); | 7554 i::Isolate* isolate = i::Isolate::Current(); |
| 7517 i::CpuProfiler* profiler = isolate->cpu_profiler(); | 7555 i::CpuProfiler* profiler = isolate->cpu_profiler(); |
| 7518 DCHECK(profiler != NULL); | 7556 DCHECK(profiler != NULL); |
| 7519 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); | 7557 profiler->DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); |
| 7520 } | 7558 } |
| 7521 | 7559 |
| 7522 | 7560 |
| 7523 Handle<String> CpuProfile::GetTitle() const { | 7561 Handle<String> CpuProfile::GetTitle() const { |
| 7524 i::Isolate* isolate = i::Isolate::Current(); | 7562 i::Isolate* isolate = i::Isolate::Current(); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8054 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8092 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8055 Address callback_address = | 8093 Address callback_address = |
| 8056 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8094 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8057 VMState<EXTERNAL> state(isolate); | 8095 VMState<EXTERNAL> state(isolate); |
| 8058 ExternalCallbackScope call_scope(isolate, callback_address); | 8096 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8059 callback(info); | 8097 callback(info); |
| 8060 } | 8098 } |
| 8061 | 8099 |
| 8062 | 8100 |
| 8063 } } // namespace v8::internal | 8101 } } // namespace v8::internal |
| OLD | NEW |