Index: src/v8.cc |
diff --git a/src/v8.cc b/src/v8.cc |
index 2910a0700d92223521dddf8a072fc65fb6fa9615..96ffcd581edc69dde6a0611457dc6f81845a33c1 100644 |
--- a/src/v8.cc |
+++ b/src/v8.cc |
@@ -60,6 +60,8 @@ static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; |
static EntropySource entropy_source; |
+static FunctionEntryHook profiler_entry_hook = NULL; |
+ |
bool V8::Initialize(Deserializer* des) { |
FlagList::EnforceFlagImplications(); |
@@ -164,6 +166,37 @@ void V8::SetReturnAddressLocationResolver( |
} |
+bool V8::SetFunctionEntryHook(FunctionEntryHook entry_hook) { |
+ // We don't allow setting a new entry hook over one that's |
+ // already active, as the hooks won't stack. |
+ if (entry_hook != 0 && profiler_entry_hook != 0) |
+ return false; |
+ |
+ profiler_entry_hook = entry_hook; |
+ |
+ return true; |
+} |
+ |
+ |
+static void EntryHookDispatcher(intptr_t function, |
+ intptr_t stack_pointer, |
+ uint64_t entry_time) { |
+ if (profiler_entry_hook != NULL) |
+ profiler_entry_hook(function, stack_pointer, entry_time); |
danno
2012/07/10 09:37:13
80 col?
Sigurður Ásgeirsson
2012/07/11 14:50:34
Done.
|
+} |
+ |
+ |
+ |
+const FunctionEntryHook* V8::GetFunctionEntryHookLocation() { |
+ return &profiler_entry_hook; |
+} |
+ |
+ |
+FunctionEntryHook V8::GetFunctionEntryHookDispatcher() { |
+ return EntryHookDispatcher; |
+} |
+ |
+ |
// Used by JavaScript APIs |
uint32_t V8::Random(Context* context) { |
ASSERT(context->IsGlobalContext()); |