| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 5d3a79d6bb3c6a974ecb234aea7f36a11dd2678a..efc4b206b8621b22821c6f3dac1c1bbcea9a9681 100755
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -12288,27 +12288,27 @@ static void entry_hook(uintptr_t function,
|
| if (bar_ptr != NULL && code == (*bar_ptr)->code())
|
| ++bar_entry_count;
|
|
|
| - if (foo_ptr != NULL && code == (*foo_ptr)->code())
|
| + if (foo_ptr != NULL && code == (*foo_ptr)->code()) {
|
| ++foo_entry_count;
|
|
|
| - // Let's check whether bar is the caller.
|
| - if (bar_ptr != NULL) {
|
| - const v8::internal::byte* caller =
|
| - *reinterpret_cast<v8::internal::byte**>(return_addr_location);
|
| + // Count the bar->foo calls.
|
| + if (bar_ptr != NULL) {
|
| + const v8::internal::byte* caller =
|
| + *reinterpret_cast<v8::internal::byte**>(return_addr_location);
|
|
|
| - if ((*bar_ptr)->code()->instruction_start() <= caller &&
|
| - (*bar_ptr)->code()->instruction_end() > caller) {
|
| - ++bar_caller_count;
|
| + if ((*bar_ptr)->code()->instruction_start() <= caller &&
|
| + (*bar_ptr)->code()->instruction_end() > caller) {
|
| + ++bar_caller_count;
|
| + }
|
| }
|
| }
|
| }
|
|
|
|
|
| -static void RunLoopInNewEnv() {
|
| +static void RunLoopInNewEnv(v8::Isolate* isolate) {
|
| bar_ptr = NULL;
|
| foo_ptr = NULL;
|
|
|
| - v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| v8::HandleScope outer(isolate);
|
| v8::Local<Context> env = Context::New(isolate);
|
| env->Enter();
|
| @@ -12360,7 +12360,7 @@ TEST(SetFunctionEntryHook) {
|
| i::FLAG_allow_natives_syntax = true;
|
| i::FLAG_use_inlining = false;
|
|
|
| - // Test setting and resetting the entry hook.
|
| + // Test setting and resetting the entry hook on the current isolate.
|
| // Nulling it should always succeed.
|
| CHECK(v8::V8::SetFunctionEntryHook(NULL));
|
|
|
| @@ -12370,32 +12370,38 @@ TEST(SetFunctionEntryHook) {
|
|
|
| CHECK(v8::V8::SetFunctionEntryHook(NULL));
|
|
|
| - // Reset the entry count to zero and set the entry hook.
|
| - bar_entry_count = 0;
|
| - bar_caller_count = 0;
|
| - foo_entry_count = 0;
|
| - CHECK(v8::V8::SetFunctionEntryHook(entry_hook));
|
| - RunLoopInNewEnv();
|
| -
|
| - CHECK_EQ(2, bar_entry_count);
|
| - CHECK_EQ(200, bar_caller_count);
|
| - CHECK_EQ(200, foo_entry_count);
|
| -
|
| - // Clear the entry hook and count.
|
| - bar_entry_count = 0;
|
| - bar_caller_count = 0;
|
| - foo_entry_count = 0;
|
| - v8::V8::SetFunctionEntryHook(NULL);
|
| -
|
| - // Clear the compilation cache to make sure we don't reuse the
|
| - // functions from the previous invocation.
|
| - v8::internal::Isolate::Current()->compilation_cache()->Clear();
|
| -
|
| - // Verify that entry hooking is now disabled.
|
| - RunLoopInNewEnv();
|
| - CHECK_EQ(0u, bar_entry_count);
|
| - CHECK_EQ(0u, bar_caller_count);
|
| - CHECK_EQ(0u, foo_entry_count);
|
| + v8::Isolate* isolate = v8::Isolate::New();
|
| + {
|
| + v8::Isolate::Scope scope(isolate);
|
| +
|
| + // Reset the entry count to zero and set the entry hook.
|
| + bar_entry_count = 0;
|
| + bar_caller_count = 0;
|
| + foo_entry_count = 0;
|
| + CHECK(v8::V8::SetFunctionEntryHook(entry_hook));
|
| + RunLoopInNewEnv(isolate);
|
| +
|
| + CHECK_EQ(2, bar_entry_count);
|
| + CHECK_EQ(200, bar_caller_count);
|
| + CHECK_EQ(200, foo_entry_count);
|
| +
|
| + // Clear the entry hook and count.
|
| + bar_entry_count = 0;
|
| + bar_caller_count = 0;
|
| + foo_entry_count = 0;
|
| + v8::V8::SetFunctionEntryHook(NULL);
|
| +
|
| + // Clear the compilation cache to make sure we don't reuse the
|
| + // functions from the previous invocation.
|
| + v8::internal::Isolate::Current()->compilation_cache()->Clear();
|
| +
|
| + // Verify that entry hooking is now disabled.
|
| + RunLoopInNewEnv(isolate);
|
| + CHECK_EQ(0u, bar_entry_count);
|
| + CHECK_EQ(0u, bar_caller_count);
|
| + CHECK_EQ(0u, foo_entry_count);
|
| + }
|
| + isolate->Dispose();
|
| }
|
|
|
|
|
|
|