OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include "api.h" | 30 #include "api.h" |
31 #include "arguments.h" | 31 #include "arguments.h" |
32 #include "bootstrapper.h" | 32 #include "bootstrapper.h" |
33 #include "compiler.h" | 33 #include "compiler.h" |
34 #include "debug.h" | 34 #include "debug.h" |
35 #include "execution.h" | 35 #include "execution.h" |
36 #include "global-handles.h" | 36 #include "global-handles.h" |
37 #include "messages.h" | 37 #include "messages.h" |
38 #include "platform.h" | 38 #include "platform.h" |
| 39 #include "profile-generator-inl.h" |
39 #include "serialize.h" | 40 #include "serialize.h" |
40 #include "snapshot.h" | 41 #include "snapshot.h" |
41 #include "top.h" | 42 #include "top.h" |
42 #include "utils.h" | 43 #include "utils.h" |
43 #include "v8threads.h" | 44 #include "v8threads.h" |
44 #include "version.h" | 45 #include "version.h" |
45 | 46 |
| 47 #include "../include/v8-profiler.h" |
46 | 48 |
47 #define LOG_API(expr) LOG(ApiEntryCall(expr)) | 49 #define LOG_API(expr) LOG(ApiEntryCall(expr)) |
48 | 50 |
49 #ifdef ENABLE_HEAP_PROTECTION | 51 #ifdef ENABLE_HEAP_PROTECTION |
50 #define ENTER_V8 i::VMState __state__(i::OTHER) | 52 #define ENTER_V8 i::VMState __state__(i::OTHER) |
51 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL) | 53 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL) |
52 #else | 54 #else |
53 #define ENTER_V8 ((void) 0) | 55 #define ENTER_V8 ((void) 0) |
54 #define LEAVE_V8 ((void) 0) | 56 #define LEAVE_V8 ((void) 0) |
55 #endif | 57 #endif |
(...skipping 3934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3990 i::Execution::ProcessDebugMesssages(true); | 3992 i::Execution::ProcessDebugMesssages(true); |
3991 } | 3993 } |
3992 | 3994 |
3993 Local<Context> Debug::GetDebugContext() { | 3995 Local<Context> Debug::GetDebugContext() { |
3994 i::EnterDebugger debugger; | 3996 i::EnterDebugger debugger; |
3995 return Utils::ToLocal(i::Debug::debug_context()); | 3997 return Utils::ToLocal(i::Debug::debug_context()); |
3996 } | 3998 } |
3997 | 3999 |
3998 #endif // ENABLE_DEBUGGER_SUPPORT | 4000 #endif // ENABLE_DEBUGGER_SUPPORT |
3999 | 4001 |
| 4002 |
| 4003 #ifdef ENABLE_CPP_PROFILES_PROCESSOR |
| 4004 |
| 4005 Handle<String> CpuProfileNode::GetFunctionName() const { |
| 4006 IsDeadCheck("v8::CpuProfileNode::GetFunctionName"); |
| 4007 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 4008 const i::CodeEntry* entry = node->entry(); |
| 4009 if (!entry->has_name_prefix()) { |
| 4010 return Handle<String>(ToApi<String>( |
| 4011 i::Factory::LookupAsciiSymbol(entry->name()))); |
| 4012 } else { |
| 4013 return Handle<String>(ToApi<String>(i::Factory::NewConsString( |
| 4014 i::Factory::LookupAsciiSymbol(entry->name_prefix()), |
| 4015 i::Factory::LookupAsciiSymbol(entry->name())))); |
| 4016 } |
| 4017 } |
| 4018 |
| 4019 |
| 4020 Handle<String> CpuProfileNode::GetScriptResourceName() const { |
| 4021 IsDeadCheck("v8::CpuProfileNode::GetScriptResourceName"); |
| 4022 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 4023 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( |
| 4024 node->entry()->resource_name()))); |
| 4025 } |
| 4026 |
| 4027 |
| 4028 int CpuProfileNode::GetLineNumber() const { |
| 4029 IsDeadCheck("v8::CpuProfileNode::GetLineNumber"); |
| 4030 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); |
| 4031 } |
| 4032 |
| 4033 |
| 4034 double CpuProfileNode::GetTotalSamplesCount() const { |
| 4035 IsDeadCheck("v8::CpuProfileNode::GetTotalSamplesCount"); |
| 4036 return reinterpret_cast<const i::ProfileNode*>(this)->total_ticks(); |
| 4037 } |
| 4038 |
| 4039 |
| 4040 double CpuProfileNode::GetSelfSamplesCount() const { |
| 4041 IsDeadCheck("v8::CpuProfileNode::GetSelfSamplesCount"); |
| 4042 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); |
| 4043 } |
| 4044 |
| 4045 |
| 4046 unsigned long CpuProfileNode::GetCallUid() const { |
| 4047 IsDeadCheck("v8::CpuProfileNode::GetCallUid"); |
| 4048 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->call_uid(); |
| 4049 } |
| 4050 |
| 4051 |
| 4052 int CpuProfileNode::GetChildrenCount() const { |
| 4053 IsDeadCheck("v8::CpuProfileNode::GetChildrenCount"); |
| 4054 return reinterpret_cast<const i::ProfileNode*>(this)->children()->length(); |
| 4055 } |
| 4056 |
| 4057 |
| 4058 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { |
| 4059 IsDeadCheck("v8::CpuProfileNode::GetChild"); |
| 4060 const i::ProfileNode* child = |
| 4061 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); |
| 4062 return reinterpret_cast<const CpuProfileNode*>(child); |
| 4063 } |
| 4064 |
| 4065 |
| 4066 unsigned CpuProfile::GetUid() const { |
| 4067 IsDeadCheck("v8::CpuProfile::GetUid"); |
| 4068 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); |
| 4069 } |
| 4070 |
| 4071 |
| 4072 Handle<String> CpuProfile::GetTitle() const { |
| 4073 IsDeadCheck("v8::CpuProfile::GetTitle"); |
| 4074 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| 4075 return Handle<String>(ToApi<String>(i::Factory::LookupAsciiSymbol( |
| 4076 profile->title()))); |
| 4077 } |
| 4078 |
| 4079 |
| 4080 const CpuProfileNode* CpuProfile::GetBottomUpRoot() const { |
| 4081 IsDeadCheck("v8::CpuProfile::GetBottomUpRoot"); |
| 4082 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| 4083 return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root()); |
| 4084 } |
| 4085 |
| 4086 |
| 4087 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { |
| 4088 IsDeadCheck("v8::CpuProfile::GetTopDownRoot"); |
| 4089 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| 4090 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); |
| 4091 } |
| 4092 |
| 4093 |
| 4094 int CpuProfiler::GetProfilesCount() { |
| 4095 IsDeadCheck("v8::CpuProfiler::GetProfilesCount"); |
| 4096 return i::CpuProfiler::GetProfilesCount(); |
| 4097 } |
| 4098 |
| 4099 |
| 4100 const CpuProfile* CpuProfiler::GetProfile(int index) { |
| 4101 IsDeadCheck("v8::CpuProfiler::GetProfile"); |
| 4102 return reinterpret_cast<const CpuProfile*>(i::CpuProfiler::GetProfile(index)); |
| 4103 } |
| 4104 |
| 4105 |
| 4106 const CpuProfile* CpuProfiler::FindProfile(unsigned uid) { |
| 4107 IsDeadCheck("v8::CpuProfiler::FindProfile"); |
| 4108 return reinterpret_cast<const CpuProfile*>(i::CpuProfiler::FindProfile(uid)); |
| 4109 } |
| 4110 |
| 4111 |
| 4112 void CpuProfiler::StartProfiling(Handle<String> title) { |
| 4113 IsDeadCheck("v8::CpuProfiler::StartProfiling"); |
| 4114 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); |
| 4115 } |
| 4116 |
| 4117 |
| 4118 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title) { |
| 4119 IsDeadCheck("v8::CpuProfiler::StopProfiling"); |
| 4120 return reinterpret_cast<const CpuProfile*>( |
| 4121 i::CpuProfiler::StopProfiling(*Utils::OpenHandle(*title))); |
| 4122 } |
| 4123 |
| 4124 #endif // ENABLE_CPP_PROFILES_PROCESSOR |
| 4125 |
| 4126 |
4000 namespace internal { | 4127 namespace internal { |
4001 | 4128 |
4002 | 4129 |
4003 HandleScopeImplementer* HandleScopeImplementer::instance() { | 4130 HandleScopeImplementer* HandleScopeImplementer::instance() { |
4004 return &thread_local; | 4131 return &thread_local; |
4005 } | 4132 } |
4006 | 4133 |
4007 | 4134 |
4008 void HandleScopeImplementer::FreeThreadResources() { | 4135 void HandleScopeImplementer::FreeThreadResources() { |
4009 thread_local.Free(); | 4136 thread_local.Free(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4073 | 4200 |
4074 | 4201 |
4075 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 4202 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
4076 HandleScopeImplementer* thread_local = | 4203 HandleScopeImplementer* thread_local = |
4077 reinterpret_cast<HandleScopeImplementer*>(storage); | 4204 reinterpret_cast<HandleScopeImplementer*>(storage); |
4078 thread_local->IterateThis(v); | 4205 thread_local->IterateThis(v); |
4079 return storage + ArchiveSpacePerThread(); | 4206 return storage + ArchiveSpacePerThread(); |
4080 } | 4207 } |
4081 | 4208 |
4082 } } // namespace v8::internal | 4209 } } // namespace v8::internal |
OLD | NEW |