Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Unified Diff: src/api.cc

Issue 16578008: Improved function entry hook coverage (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@post_fix
Patch Set: Fix Windows X64 compile warnings." Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/arm/builtins-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 014d82ee4f0aab86c5f16ca339c22b335c42753b..edffca18f42c7e792da0857f512172b27238a315 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -300,8 +300,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);
}
@@ -313,7 +318,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
@@ -5211,7 +5216,7 @@ bool v8::V8::Initialize() {
if (isolate != NULL && isolate->IsInitialized()) {
return true;
}
- return InitializeHelper();
+ return InitializeHelper(isolate);
}
@@ -5227,7 +5232,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;
}
« no previous file with comments | « include/v8.h ('k') | src/arm/builtins-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698