| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| old mode 100644
|
| new mode 100755
|
| index a06e0dbbbc640d07aabdd3938a9410741f2a2f74..3145719b3b60c636b2a425ddcdcb1a01efb75ad5
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -296,8 +296,13 @@ static inline bool EmptyCheck(const char* location, const v8::Data* obj) {
|
| // --- S t a t i c s ---
|
|
|
|
|
| -static bool InitializeHelper() {
|
| - if (i::Snapshot::Initialize()) return true;
|
| +static bool InitializeHelper(i::Isolate* isolate) {
|
| + // If the isolate has a function entry hook, it needs to re-build all its
|
| + // code stubs with entry hooks embedded, so let's deserialize a snapshot.
|
| + if (isolate == NULL || isolate->function_entry_hook() == NULL) {
|
| + if (i::Snapshot::Initialize())
|
| + return true;
|
| + }
|
| return i::V8::Initialize(NULL);
|
| }
|
|
|
| @@ -309,7 +314,7 @@ static inline bool EnsureInitializedForIsolate(i::Isolate* isolate,
|
| if (isolate->IsInitialized()) return true;
|
| }
|
| ASSERT(isolate == i::Isolate::Current());
|
| - return ApiCheck(InitializeHelper(), location, "Error initializing V8");
|
| + return ApiCheck(InitializeHelper(isolate), location, "Error initializing V8");
|
| }
|
|
|
| // Some initializing API functions are called early and may be
|
| @@ -5132,7 +5137,7 @@ bool v8::V8::Initialize() {
|
| if (isolate != NULL && isolate->IsInitialized()) {
|
| return true;
|
| }
|
| - return InitializeHelper();
|
| + return InitializeHelper(isolate);
|
| }
|
|
|
|
|
| @@ -5148,7 +5153,30 @@ void v8::V8::SetReturnAddressLocationResolver(
|
|
|
|
|
| bool v8::V8::SetFunctionEntryHook(FunctionEntryHook entry_hook) {
|
| - return i::ProfileEntryHookStub::SetFunctionEntryHook(entry_hook);
|
| + return SetFunctionEntryHook(Isolate::GetCurrent(), entry_hook);
|
| +}
|
| +
|
| +
|
| +bool v8::V8::SetFunctionEntryHook(Isolate* ext_isolate,
|
| + FunctionEntryHook entry_hook) {
|
| + ASSERT(ext_isolate != NULL);
|
| + ASSERT(entry_hook != NULL);
|
| +
|
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(ext_isolate);
|
| +
|
| + // The entry hook can only be set before the Isolate is initialized, as
|
| + // otherwise the Isolate's code stubs generated at initialization won't
|
| + // contain entry hooks.
|
| + if (isolate->IsInitialized())
|
| + return false;
|
| +
|
| + // Setting an entry hook is a one-way operation, once set, it cannot be
|
| + // changed or unset.
|
| + if (isolate->function_entry_hook() != NULL)
|
| + return false;
|
| +
|
| + isolate->set_function_entry_hook(entry_hook);
|
| + return true;
|
| }
|
|
|
|
|
|
|