From d0e604bf261470b1404e2ddf6da29206dad72026 Mon Sep 17 00:00:00 2001 From: jkummerow Date: Tue, 14 Mar 2017 05:31:03 -0700 Subject: [PATCH] FunctionEntryHook: require no-snapshot build When a FunctionEntryHook parameter was passed to isolate creation, we ignored any existing snapshots anyway. Since the ability to bootstrap from scratch will be removed from snapshot builds, the FunctionEntryHook feature must depend on a no-snapshot build. BUG=v8:6055 Review-Url: https://codereview.chromium.org/2733203002 Cr-Commit-Position: refs/heads/master@{#43779} --- BUILD.gn | 3 +++ include/v8.h | 5 +++-- src/api.cc | 6 ++++++ test/cctest/cctest.status | 4 ++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 94c09a1670..7524ba8421 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -258,6 +258,9 @@ config("features") { if (v8_enable_handle_zapping) { defines += [ "ENABLE_HANDLE_ZAPPING" ] } + if (v8_use_snapshot) { + defines += [ "V8_USE_SNAPSHOT" ] + } if (v8_use_external_startup_data) { defines += [ "V8_USE_EXTERNAL_STARTUP_DATA" ] } diff --git a/include/v8.h b/include/v8.h index 2e67bc333d..d7b7205ef0 100644 --- a/include/v8.h +++ b/include/v8.h @@ -6342,8 +6342,9 @@ class V8_EXPORT Isolate { * The optional entry_hook allows the host application to provide the * address of a function that's invoked on entry to every V8-generated * function. Note that entry_hook is invoked at the very start of each - * generated function. Furthermore, if an entry_hook is given, V8 will - * not use a snapshot, including custom snapshots. + * generated function. + * An entry_hook can only be provided in no-snapshot builds; in snapshot + * builds it must be nullptr. */ FunctionEntryHook entry_hook; diff --git a/src/api.cc b/src/api.cc index 156afe349d..031ad5a023 100644 --- a/src/api.cc +++ b/src/api.cc @@ -8143,6 +8143,12 @@ Isolate* Isolate::New(const Isolate::CreateParams& params) { isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob()); } if (params.entry_hook) { +#ifdef V8_USE_SNAPSHOT + // Setting a FunctionEntryHook is only supported in no-snapshot builds. + Utils::ApiCheck( + false, "v8::Isolate::New", + "Setting a FunctionEntryHook is only supported in no-snapshot builds."); +#endif isolate->set_function_entry_hook(params.entry_hook); } auto code_event_handler = params.code_event_handler; diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status index c75b53d6f5..49150a15bc 100644 --- a/test/cctest/cctest.status +++ b/test/cctest/cctest.status @@ -185,6 +185,10 @@ 'test-api/FastReturnValues*': [PASS, SLOW], 'test-decls/CrossScriptReferences_Simple2': [PASS, SLOW], }], # 'no_snap == True' +['no_snap == False', { + # FunctionEntryHooks require bootstrapping from scratch. + 'test-api/SetFunctionEntryHook': [SKIP], +}], # 'no_snap == False' ############################################################################## # TODO(machenbach): Fix application of '*'. Nosnap windows needs a separate