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 30 matching lines...) Expand all Loading... |
41 #include "snapshot.h" | 41 #include "snapshot.h" |
42 #include "top.h" | 42 #include "top.h" |
43 #include "utils.h" | 43 #include "utils.h" |
44 #include "v8threads.h" | 44 #include "v8threads.h" |
45 #include "version.h" | 45 #include "version.h" |
46 | 46 |
47 #include "../include/v8-profiler.h" | 47 #include "../include/v8-profiler.h" |
48 | 48 |
49 #define LOG_API(expr) LOG(ApiEntryCall(expr)) | 49 #define LOG_API(expr) LOG(ApiEntryCall(expr)) |
50 | 50 |
51 #ifdef ENABLE_HEAP_PROTECTION | 51 #ifdef ENABLE_VMSTATE_TRACKING |
52 #define ENTER_V8 i::VMState __state__(i::OTHER) | 52 #define ENTER_V8 i::VMState __state__(i::OTHER) |
53 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL) | 53 #define LEAVE_V8 i::VMState __state__(i::EXTERNAL) |
54 #else | 54 #else |
55 #define ENTER_V8 ((void) 0) | 55 #define ENTER_V8 ((void) 0) |
56 #define LEAVE_V8 ((void) 0) | 56 #define LEAVE_V8 ((void) 0) |
57 #endif | 57 #endif |
58 | 58 |
59 namespace v8 { | 59 namespace v8 { |
60 | 60 |
61 | 61 |
(...skipping 3923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3985 error = *result; | 3985 error = *result; |
3986 } | 3986 } |
3987 i::Handle<i::Object> result(error); | 3987 i::Handle<i::Object> result(error); |
3988 return Utils::ToLocal(result); | 3988 return Utils::ToLocal(result); |
3989 } | 3989 } |
3990 | 3990 |
3991 | 3991 |
3992 // --- D e b u g S u p p o r t --- | 3992 // --- D e b u g S u p p o r t --- |
3993 | 3993 |
3994 #ifdef ENABLE_DEBUGGER_SUPPORT | 3994 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 3995 |
| 3996 static v8::Debug::EventCallback event_callback = NULL; |
| 3997 |
| 3998 static void EventCallbackWrapper(const v8::Debug::EventDetails& event_details) { |
| 3999 if (event_callback) { |
| 4000 event_callback(event_details.GetEvent(), |
| 4001 event_details.GetExecutionState(), |
| 4002 event_details.GetEventData(), |
| 4003 event_details.GetCallbackData()); |
| 4004 } |
| 4005 } |
| 4006 |
| 4007 |
3995 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) { | 4008 bool Debug::SetDebugEventListener(EventCallback that, Handle<Value> data) { |
3996 EnsureInitialized("v8::Debug::SetDebugEventListener()"); | 4009 EnsureInitialized("v8::Debug::SetDebugEventListener()"); |
3997 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); | 4010 ON_BAILOUT("v8::Debug::SetDebugEventListener()", return false); |
3998 ENTER_V8; | 4011 ENTER_V8; |
| 4012 |
| 4013 event_callback = that; |
| 4014 |
| 4015 HandleScope scope; |
| 4016 i::Handle<i::Object> proxy = i::Factory::undefined_value(); |
| 4017 if (that != NULL) { |
| 4018 proxy = i::Factory::NewProxy(FUNCTION_ADDR(EventCallbackWrapper)); |
| 4019 } |
| 4020 i::Debugger::SetEventListener(proxy, Utils::OpenHandle(*data)); |
| 4021 return true; |
| 4022 } |
| 4023 |
| 4024 |
| 4025 bool Debug::SetDebugEventListener2(EventCallback2 that, Handle<Value> data) { |
| 4026 EnsureInitialized("v8::Debug::SetDebugEventListener2()"); |
| 4027 ON_BAILOUT("v8::Debug::SetDebugEventListener2()", return false); |
| 4028 ENTER_V8; |
3999 HandleScope scope; | 4029 HandleScope scope; |
4000 i::Handle<i::Object> proxy = i::Factory::undefined_value(); | 4030 i::Handle<i::Object> proxy = i::Factory::undefined_value(); |
4001 if (that != NULL) { | 4031 if (that != NULL) { |
4002 proxy = i::Factory::NewProxy(FUNCTION_ADDR(that)); | 4032 proxy = i::Factory::NewProxy(FUNCTION_ADDR(that)); |
4003 } | 4033 } |
4004 i::Debugger::SetEventListener(proxy, Utils::OpenHandle(*data)); | 4034 i::Debugger::SetEventListener(proxy, Utils::OpenHandle(*data)); |
4005 return true; | 4035 return true; |
4006 } | 4036 } |
4007 | 4037 |
4008 | 4038 |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4243 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); | 4273 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); |
4244 } | 4274 } |
4245 | 4275 |
4246 | 4276 |
4247 int CpuProfiler::GetProfilesCount() { | 4277 int CpuProfiler::GetProfilesCount() { |
4248 IsDeadCheck("v8::CpuProfiler::GetProfilesCount"); | 4278 IsDeadCheck("v8::CpuProfiler::GetProfilesCount"); |
4249 return i::CpuProfiler::GetProfilesCount(); | 4279 return i::CpuProfiler::GetProfilesCount(); |
4250 } | 4280 } |
4251 | 4281 |
4252 | 4282 |
4253 const CpuProfile* CpuProfiler::GetProfile(int index) { | 4283 const CpuProfile* CpuProfiler::GetProfile(int index, |
| 4284 Handle<Value> security_token) { |
4254 IsDeadCheck("v8::CpuProfiler::GetProfile"); | 4285 IsDeadCheck("v8::CpuProfiler::GetProfile"); |
4255 return reinterpret_cast<const CpuProfile*>(i::CpuProfiler::GetProfile(index)); | 4286 return reinterpret_cast<const CpuProfile*>( |
| 4287 i::CpuProfiler::GetProfile( |
| 4288 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), |
| 4289 index)); |
4256 } | 4290 } |
4257 | 4291 |
4258 | 4292 |
4259 const CpuProfile* CpuProfiler::FindProfile(unsigned uid) { | 4293 const CpuProfile* CpuProfiler::FindProfile(unsigned uid, |
| 4294 Handle<Value> security_token) { |
4260 IsDeadCheck("v8::CpuProfiler::FindProfile"); | 4295 IsDeadCheck("v8::CpuProfiler::FindProfile"); |
4261 return reinterpret_cast<const CpuProfile*>(i::CpuProfiler::FindProfile(uid)); | 4296 return reinterpret_cast<const CpuProfile*>( |
| 4297 i::CpuProfiler::FindProfile( |
| 4298 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), |
| 4299 uid)); |
4262 } | 4300 } |
4263 | 4301 |
4264 | 4302 |
4265 void CpuProfiler::StartProfiling(Handle<String> title) { | 4303 void CpuProfiler::StartProfiling(Handle<String> title) { |
4266 IsDeadCheck("v8::CpuProfiler::StartProfiling"); | 4304 IsDeadCheck("v8::CpuProfiler::StartProfiling"); |
4267 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); | 4305 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); |
4268 } | 4306 } |
4269 | 4307 |
4270 | 4308 |
4271 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title) { | 4309 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, |
| 4310 Handle<Value> security_token) { |
4272 IsDeadCheck("v8::CpuProfiler::StopProfiling"); | 4311 IsDeadCheck("v8::CpuProfiler::StopProfiling"); |
4273 return reinterpret_cast<const CpuProfile*>( | 4312 return reinterpret_cast<const CpuProfile*>( |
4274 i::CpuProfiler::StopProfiling(*Utils::OpenHandle(*title))); | 4313 i::CpuProfiler::StopProfiling( |
| 4314 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), |
| 4315 *Utils::OpenHandle(*title))); |
4275 } | 4316 } |
4276 | 4317 |
4277 #endif // ENABLE_LOGGING_AND_PROFILING | 4318 #endif // ENABLE_LOGGING_AND_PROFILING |
4278 | 4319 |
4279 | 4320 |
4280 namespace internal { | 4321 namespace internal { |
4281 | 4322 |
4282 | 4323 |
4283 HandleScopeImplementer* HandleScopeImplementer::instance() { | 4324 HandleScopeImplementer* HandleScopeImplementer::instance() { |
4284 return &thread_local; | 4325 return &thread_local; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4353 | 4394 |
4354 | 4395 |
4355 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 4396 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
4356 HandleScopeImplementer* thread_local = | 4397 HandleScopeImplementer* thread_local = |
4357 reinterpret_cast<HandleScopeImplementer*>(storage); | 4398 reinterpret_cast<HandleScopeImplementer*>(storage); |
4358 thread_local->IterateThis(v); | 4399 thread_local->IterateThis(v); |
4359 return storage + ArchiveSpacePerThread(); | 4400 return storage + ArchiveSpacePerThread(); |
4360 } | 4401 } |
4361 | 4402 |
4362 } } // namespace v8::internal | 4403 } } // namespace v8::internal |
OLD | NEW |