| Index: test/cctest/test-api.cc
|
| diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
|
| index 1c17e8c9b3ca913923b98ba914f747ff2284e6aa..c9685f8f4c07fa07914b68b4f15196543f29e815 100644
|
| --- a/test/cctest/test-api.cc
|
| +++ b/test/cctest/test-api.cc
|
| @@ -4688,9 +4688,9 @@ THREADED_TEST(NamedInterceptorDictionaryIC) {
|
|
|
|
|
| THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) {
|
| - v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| -
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope scope(isolate);
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
|
|
| context1->Enter();
|
| Local<ObjectTemplate> templ = ObjectTemplate::New();
|
| @@ -4725,8 +4725,6 @@ THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) {
|
| context1->Enter();
|
| CompileRun("var obj = { x : 0 }; delete obj.x;");
|
| context1->Exit();
|
| -
|
| - context1.Dispose(context1->GetIsolate());
|
| }
|
|
|
|
|
| @@ -5501,14 +5499,14 @@ static v8::Handle<Value> HandleLogDelegator(const v8::Arguments& args) {
|
|
|
|
|
| THREADED_TEST(GlobalObjectTemplate) {
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
| Local<ObjectTemplate> global_template = ObjectTemplate::New();
|
| global_template->Set(v8_str("JSNI_Log"),
|
| v8::FunctionTemplate::New(HandleLogDelegator));
|
| - v8::Persistent<Context> context = Context::New(0, global_template);
|
| - Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
|
| + v8::Local<Context> context = Context::New(isolate, 0, global_template);
|
| + Context::Scope context_scope(context);
|
| Script::Compile(v8_str("JSNI_Log('LOG')"))->Run();
|
| - context.Dispose(context->GetIsolate());
|
| }
|
|
|
|
|
| @@ -7676,7 +7674,8 @@ static void UnreachableSetter(Local<String>, Local<Value>,
|
|
|
|
|
| TEST(AccessControl) {
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
| v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
|
|
|
| global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
|
| @@ -7696,7 +7695,7 @@ TEST(AccessControl) {
|
| v8::DEFAULT);
|
|
|
| // Create an environment
|
| - v8::Persistent<Context> context0 = Context::New(NULL, global_template);
|
| + v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
|
| context0->Enter();
|
|
|
| v8::Handle<v8::Object> global0 = context0->Global();
|
| @@ -7722,9 +7721,9 @@ TEST(AccessControl) {
|
| Local<Value> el_getter = global0->Get(v8_str("el_getter"));
|
| Local<Value> el_setter = global0->Get(v8_str("el_setter"));
|
|
|
| - v8::HandleScope scope1(v8::Isolate::GetCurrent());
|
| + v8::HandleScope scope1(isolate);
|
|
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
| context1->Enter();
|
|
|
| v8::Handle<v8::Object> global1 = context1->Global();
|
| @@ -7914,13 +7913,12 @@ TEST(AccessControl) {
|
|
|
| context1->Exit();
|
| context0->Exit();
|
| - context1.Dispose(context1->GetIsolate());
|
| - context0.Dispose(context0->GetIsolate());
|
| }
|
|
|
|
|
| TEST(AccessControlES5) {
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
| v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
|
|
|
| global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
|
| @@ -7941,12 +7939,12 @@ TEST(AccessControlES5) {
|
| v8::DEFAULT);
|
|
|
| // Create an environment
|
| - v8::Persistent<Context> context0 = Context::New(NULL, global_template);
|
| + v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
|
| context0->Enter();
|
|
|
| v8::Handle<v8::Object> global0 = context0->Global();
|
|
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
| context1->Enter();
|
| v8::Handle<v8::Object> global1 = context1->Global();
|
| global1->Set(v8_str("other"), global0);
|
| @@ -8006,7 +8004,8 @@ static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global,
|
|
|
|
|
| THREADED_TEST(AccessControlGetOwnPropertyNames) {
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
| v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New();
|
|
|
| obj_template->Set(v8_str("x"), v8::Integer::New(42));
|
| @@ -8014,14 +8013,14 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
|
| GetOwnPropertyNamesIndexedBlocker);
|
|
|
| // Create an environment
|
| - v8::Persistent<Context> context0 = Context::New(NULL, obj_template);
|
| + v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template);
|
| context0->Enter();
|
|
|
| v8::Handle<v8::Object> global0 = context0->Global();
|
|
|
| v8::HandleScope scope1(v8::Isolate::GetCurrent());
|
|
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
| context1->Enter();
|
|
|
| v8::Handle<v8::Object> global1 = context1->Global();
|
| @@ -8043,8 +8042,6 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
|
|
|
| context1->Exit();
|
| context0->Exit();
|
| - context1.Dispose(context1->GetIsolate());
|
| - context0.Dispose(context0->GetIsolate());
|
| }
|
|
|
|
|
| @@ -8100,7 +8097,8 @@ static v8::Handle<Value> ConstTenGetter(Local<String> name,
|
|
|
|
|
| THREADED_TEST(CrossDomainAccessors) {
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
|
|
| v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
|
|
|
| @@ -8122,7 +8120,7 @@ THREADED_TEST(CrossDomainAccessors) {
|
| v8::Handle<Value>(),
|
| v8::DEFAULT);
|
|
|
| - v8::Persistent<Context> context0 = Context::New(NULL, global_template);
|
| + v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
|
| context0->Enter();
|
|
|
| Local<v8::Object> global = context0->Global();
|
| @@ -8131,7 +8129,7 @@ THREADED_TEST(CrossDomainAccessors) {
|
|
|
| // Enter a new context.
|
| v8::HandleScope scope1(v8::Isolate::GetCurrent());
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
| context1->Enter();
|
|
|
| v8::Handle<v8::Object> global1 = context1->Global();
|
| @@ -8147,8 +8145,6 @@ THREADED_TEST(CrossDomainAccessors) {
|
|
|
| context1->Exit();
|
| context0->Exit();
|
| - context1.Dispose(context1->GetIsolate());
|
| - context0.Dispose(context0->GetIsolate());
|
| }
|
|
|
|
|
| @@ -8178,10 +8174,11 @@ TEST(AccessControlIC) {
|
| named_access_count = 0;
|
| indexed_access_count = 0;
|
|
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
|
|
| // Create an environment.
|
| - v8::Persistent<Context> context0 = Context::New();
|
| + v8::Local<Context> context0 = Context::New(isolate);
|
| context0->Enter();
|
|
|
| // Create an object that requires access-check functions to be
|
| @@ -8191,10 +8188,10 @@ TEST(AccessControlIC) {
|
| IndexedAccessCounter);
|
| Local<v8::Object> object = object_template->NewInstance();
|
|
|
| - v8::HandleScope scope1(v8::Isolate::GetCurrent());
|
| + v8::HandleScope scope1(isolate);
|
|
|
| // Create another environment.
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
| context1->Enter();
|
|
|
| // Make easy access to the object from the other environment.
|
| @@ -8282,8 +8279,6 @@ TEST(AccessControlIC) {
|
|
|
| context1->Exit();
|
| context0->Exit();
|
| - context1.Dispose(context1->GetIsolate());
|
| - context0.Dispose(context0->GetIsolate());
|
| }
|
|
|
|
|
| @@ -8327,10 +8322,11 @@ THREADED_TEST(AccessControlFlatten) {
|
| named_access_count = 0;
|
| indexed_access_count = 0;
|
|
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
|
|
| // Create an environment.
|
| - v8::Persistent<Context> context0 = Context::New();
|
| + v8::Local<Context> context0 = Context::New(isolate);
|
| context0->Enter();
|
|
|
| // Create an object that requires access-check functions to be
|
| @@ -8340,10 +8336,10 @@ THREADED_TEST(AccessControlFlatten) {
|
| IndexedAccessFlatten);
|
| Local<v8::Object> object = object_template->NewInstance();
|
|
|
| - v8::HandleScope scope1(v8::Isolate::GetCurrent());
|
| + v8::HandleScope scope1(isolate);
|
|
|
| // Create another environment.
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
| context1->Enter();
|
|
|
| // Make easy access to the object from the other environment.
|
| @@ -8357,8 +8353,6 @@ THREADED_TEST(AccessControlFlatten) {
|
|
|
| context1->Exit();
|
| context0->Exit();
|
| - context1.Dispose(context1->GetIsolate());
|
| - context0.Dispose(context0->GetIsolate());
|
| }
|
|
|
|
|
| @@ -8391,10 +8385,11 @@ THREADED_TEST(AccessControlInterceptorIC) {
|
| named_access_count = 0;
|
| indexed_access_count = 0;
|
|
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
|
|
| // Create an environment.
|
| - v8::Persistent<Context> context0 = Context::New();
|
| + v8::Local<Context> context0 = Context::New(isolate);
|
| context0->Enter();
|
|
|
| // Create an object that requires access-check functions to be
|
| @@ -8409,10 +8404,10 @@ THREADED_TEST(AccessControlInterceptorIC) {
|
| AccessControlIndexedSetter);
|
| Local<v8::Object> object = object_template->NewInstance();
|
|
|
| - v8::HandleScope scope1(v8::Isolate::GetCurrent());
|
| + v8::HandleScope scope1(isolate);
|
|
|
| // Create another environment.
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
| context1->Enter();
|
|
|
| // Make easy access to the object from the other environment.
|
| @@ -8449,8 +8444,6 @@ THREADED_TEST(AccessControlInterceptorIC) {
|
|
|
| context1->Exit();
|
| context0->Exit();
|
| - context1.Dispose(context1->GetIsolate());
|
| - context0.Dispose(context0->GetIsolate());
|
| }
|
|
|
|
|
| @@ -9311,10 +9304,11 @@ THREADED_TEST(CrossEval) {
|
| // its global throws an exception. This behavior is consistent with
|
| // other JavaScript implementations.
|
| THREADED_TEST(EvalInDetachedGlobal) {
|
| - v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope scope(isolate);
|
|
|
| - v8::Persistent<Context> context0 = Context::New();
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Local<Context> context0 = Context::New(isolate);
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
|
|
| // Set up function in context0 that uses eval from context0.
|
| context0->Enter();
|
| @@ -9339,9 +9333,6 @@ THREADED_TEST(EvalInDetachedGlobal) {
|
| CHECK(x_value.IsEmpty());
|
| CHECK(catcher.HasCaught());
|
| context1->Exit();
|
| -
|
| - context1.Dispose(context1->GetIsolate());
|
| - context0.Dispose(context0->GetIsolate());
|
| }
|
|
|
|
|
| @@ -11974,7 +11965,7 @@ THREADED_TEST(CheckForCrossContextObjectLiterals) {
|
| }
|
|
|
|
|
| -static v8::Handle<Value> NestedScope(v8::Persistent<Context> env) {
|
| +static v8::Handle<Value> NestedScope(v8::Local<Context> env) {
|
| v8::HandleScope inner(env->GetIsolate());
|
| env->Enter();
|
| v8::Handle<Value> three = v8_num(3);
|
| @@ -11985,14 +11976,14 @@ static v8::Handle<Value> NestedScope(v8::Persistent<Context> env) {
|
|
|
|
|
| THREADED_TEST(NestedHandleScopeAndContexts) {
|
| - v8::HandleScope outer(v8::Isolate::GetCurrent());
|
| - v8::Persistent<Context> env = Context::New();
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope outer(isolate);
|
| + v8::Local<Context> env = Context::New(isolate);
|
| env->Enter();
|
| v8::Handle<Value> value = NestedScope(env);
|
| v8::Handle<String> str(value->ToString());
|
| CHECK(!str.IsEmpty());
|
| env->Exit();
|
| - env.Dispose(env->GetIsolate());
|
| }
|
|
|
|
|
| @@ -12024,8 +12015,9 @@ static void RunLoopInNewEnv() {
|
| bar_ptr = NULL;
|
| foo_ptr = NULL;
|
|
|
| - v8::HandleScope outer(v8::Isolate::GetCurrent());
|
| - v8::Persistent<Context> env = Context::New();
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope outer(isolate);
|
| + v8::Local<Context> env = Context::New(isolate);
|
| env->Enter();
|
|
|
| const char* script =
|
| @@ -12351,11 +12343,11 @@ static int64_t cast(intptr_t x) { return static_cast<int64_t>(x); }
|
|
|
|
|
| THREADED_TEST(ExternalAllocatedMemory) {
|
| - v8::HandleScope outer(v8::Isolate::GetCurrent());
|
| - v8::Persistent<Context> env(Context::New());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope outer(isolate);
|
| + v8::Local<Context> env(Context::New(isolate));
|
| CHECK(!env.IsEmpty());
|
| const intptr_t kSize = 1024*1024;
|
| - v8::Isolate* isolate = env->GetIsolate();
|
| int64_t baseline = cast(isolate->AdjustAmountOfExternalAllocatedMemory(0));
|
| CHECK_EQ(baseline + cast(kSize),
|
| cast(isolate->AdjustAmountOfExternalAllocatedMemory(kSize)));
|
| @@ -12366,8 +12358,14 @@ THREADED_TEST(ExternalAllocatedMemory) {
|
|
|
| THREADED_TEST(DisposeEnteredContext) {
|
| LocalContext outer;
|
| - v8::HandleScope scope(outer->GetIsolate());
|
| - { v8::Persistent<v8::Context> inner = v8::Context::New();
|
| + v8::Isolate* isolate = outer->GetIsolate();
|
| + v8::Persistent<v8::Context> inner;
|
| + {
|
| + v8::HandleScope scope(isolate);
|
| + inner.Reset(isolate, v8::Context::New(isolate));
|
| + }
|
| + v8::HandleScope scope(isolate);
|
| + {
|
| inner->Enter();
|
| inner.Dispose(inner->GetIsolate());
|
| inner.Clear();
|
| @@ -12687,7 +12685,8 @@ THREADED_TEST(AccessChecksReenabledCorrectly) {
|
| // This tests that access check information remains on the global
|
| // object template when creating contexts.
|
| THREADED_TEST(AccessControlRepeatedContextCreation) {
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
| v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
|
| global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker,
|
| IndexedSetAccessBlocker);
|
| @@ -12697,14 +12696,15 @@ THREADED_TEST(AccessControlRepeatedContextCreation) {
|
| i::Handle<i::FunctionTemplateInfo> constructor(
|
| i::FunctionTemplateInfo::cast(internal_template->constructor()));
|
| CHECK(!constructor->access_check_info()->IsUndefined());
|
| - v8::Persistent<Context> context0(Context::New(NULL, global_template));
|
| + v8::Local<Context> context0(Context::New(isolate, NULL, global_template));
|
| CHECK(!context0.IsEmpty());
|
| CHECK(!constructor->access_check_info()->IsUndefined());
|
| }
|
|
|
|
|
| THREADED_TEST(TurnOnAccessCheck) {
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
|
|
| // Create an environment with access check to the global object disabled by
|
| // default.
|
| @@ -12713,8 +12713,8 @@ THREADED_TEST(TurnOnAccessCheck) {
|
| IndexedGetAccessBlocker,
|
| v8::Handle<v8::Value>(),
|
| false);
|
| - v8::Persistent<Context> context = Context::New(NULL, global_template);
|
| - Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
|
| + v8::Local<Context> context = Context::New(isolate, NULL, global_template);
|
| + Context::Scope context_scope(context);
|
|
|
| // Set up a property and a number of functions.
|
| context->Global()->Set(v8_str("a"), v8_num(1));
|
| @@ -12784,7 +12784,8 @@ static bool NamedGetAccessBlockAandH(Local<v8::Object> obj,
|
|
|
|
|
| THREADED_TEST(TurnOnAccessCheckAndRecompile) {
|
| - v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope handle_scope(isolate);
|
|
|
| // Create an environment with access check to the global object disabled by
|
| // default. When the registered access checker will block access to properties
|
| @@ -12794,8 +12795,8 @@ THREADED_TEST(TurnOnAccessCheckAndRecompile) {
|
| IndexedGetAccessBlocker,
|
| v8::Handle<v8::Value>(),
|
| false);
|
| - v8::Persistent<Context> context = Context::New(NULL, global_template);
|
| - Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
|
| + v8::Local<Context> context = Context::New(isolate, NULL, global_template);
|
| + Context::Scope context_scope(context);
|
|
|
| // Set up a property and a number of functions.
|
| context->Global()->Set(v8_str("a"), v8_num(1));
|
| @@ -13053,9 +13054,10 @@ THREADED_TEST(DictionaryICLoadedFunction) {
|
| // Test that cross-context new calls use the context of the callee to
|
| // create the new JavaScript object.
|
| THREADED_TEST(CrossContextNew) {
|
| - v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| - v8::Persistent<Context> context0 = Context::New();
|
| - v8::Persistent<Context> context1 = Context::New();
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope scope(isolate);
|
| + v8::Local<Context> context0 = Context::New(isolate);
|
| + v8::Local<Context> context1 = Context::New(isolate);
|
|
|
| // Allow cross-domain access.
|
| Local<String> token = v8_str("<security token>");
|
| @@ -13076,10 +13078,6 @@ THREADED_TEST(CrossContextNew) {
|
| CHECK(value->IsInt32());
|
| CHECK_EQ(42, value->Int32Value());
|
| context1->Exit();
|
| -
|
| - // Dispose the contexts to allow them to be garbage collected.
|
| - context0.Dispose(context0->GetIsolate());
|
| - context1.Dispose(context1->GetIsolate());
|
| }
|
|
|
|
|
| @@ -13860,9 +13858,10 @@ THREADED_TEST(ForceDeleteIC) {
|
|
|
| TEST(InlinedFunctionAcrossContexts) {
|
| i::FLAG_allow_natives_syntax = true;
|
| - v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
|
| - v8::Persistent<v8::Context> ctx1 = v8::Context::New();
|
| - v8::Persistent<v8::Context> ctx2 = v8::Context::New();
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope outer_scope(isolate);
|
| + v8::Local<v8::Context> ctx1 = v8::Context::New(isolate);
|
| + v8::Local<v8::Context> ctx2 = v8::Context::New(isolate);
|
| ctx1->Enter();
|
|
|
| {
|
| @@ -13892,15 +13891,13 @@ TEST(InlinedFunctionAcrossContexts) {
|
| "ReferenceError: G is not defined");
|
| ctx2->Exit();
|
| ctx1->Exit();
|
| - ctx1.Dispose(ctx1->GetIsolate());
|
| }
|
| - ctx2.Dispose(ctx2->GetIsolate());
|
| }
|
|
|
|
|
| -v8::Persistent<Context> calling_context0;
|
| -v8::Persistent<Context> calling_context1;
|
| -v8::Persistent<Context> calling_context2;
|
| +static v8::Local<Context> calling_context0;
|
| +static v8::Local<Context> calling_context1;
|
| +static v8::Local<Context> calling_context2;
|
|
|
|
|
| // Check that the call to the callback is initiated in
|
| @@ -13917,11 +13914,15 @@ static v8::Handle<Value> GetCallingContextCallback(const v8::Arguments& args) {
|
|
|
|
|
| THREADED_TEST(GetCallingContext) {
|
| - v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope scope(isolate);
|
|
|
| - calling_context0 = Context::New();
|
| - calling_context1 = Context::New();
|
| - calling_context2 = Context::New();
|
| + Local<Context> calling_context0(Context::New(isolate));
|
| + Local<Context> calling_context1(Context::New(isolate));
|
| + Local<Context> calling_context2(Context::New(isolate));
|
| + ::calling_context0 = calling_context0;
|
| + ::calling_context1 = calling_context1;
|
| + ::calling_context2 = calling_context2;
|
|
|
| // Allow cross-domain access.
|
| Local<String> token = v8_str("<security token>");
|
| @@ -13952,14 +13953,9 @@ THREADED_TEST(GetCallingContext) {
|
| calling_context1->Global());
|
| CompileRun("context1.f()");
|
| calling_context2->Exit();
|
| -
|
| - // Dispose the contexts to allow them to be garbage collected.
|
| - calling_context0.Dispose(calling_context0->GetIsolate());
|
| - calling_context1.Dispose(calling_context1->GetIsolate());
|
| - calling_context2.Dispose(calling_context2->GetIsolate());
|
| - calling_context0.Clear();
|
| - calling_context1.Clear();
|
| - calling_context2.Clear();
|
| + ::calling_context0.Clear();
|
| + ::calling_context1.Clear();
|
| + ::calling_context2.Clear();
|
| }
|
|
|
|
|
| @@ -15804,17 +15800,20 @@ TEST(Regress2107) {
|
| const int kShortIdlePauseInMs = 100;
|
| const int kLongIdlePauseInMs = 1000;
|
| LocalContext env;
|
| + v8::Isolate* isolate = env->GetIsolate();
|
| v8::HandleScope scope(env->GetIsolate());
|
| intptr_t initial_size = HEAP->SizeOfObjects();
|
| // Send idle notification to start a round of incremental GCs.
|
| v8::V8::IdleNotification(kShortIdlePauseInMs);
|
| // Emulate 7 page reloads.
|
| for (int i = 0; i < 7; i++) {
|
| - v8::Persistent<v8::Context> ctx = v8::Context::New();
|
| - ctx->Enter();
|
| - CreateGarbageInOldSpace();
|
| - ctx->Exit();
|
| - ctx.Dispose(ctx->GetIsolate());
|
| + {
|
| + v8::HandleScope inner_scope(env->GetIsolate());
|
| + v8::Local<v8::Context> ctx = v8::Context::New(isolate);
|
| + ctx->Enter();
|
| + CreateGarbageInOldSpace();
|
| + ctx->Exit();
|
| + }
|
| v8::V8::ContextDisposedNotification();
|
| v8::V8::IdleNotification(kLongIdlePauseInMs);
|
| }
|
| @@ -16143,22 +16142,21 @@ THREADED_TEST(SpaghettiStackReThrow) {
|
|
|
| TEST(Regress528) {
|
| v8::V8::Initialize();
|
| -
|
| - v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| - v8::Persistent<Context> context;
|
| - v8::Persistent<Context> other_context;
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::HandleScope scope(isolate);
|
| + v8::Local<Context> other_context;
|
| int gc_count;
|
|
|
| // Create a context used to keep the code from aging in the compilation
|
| // cache.
|
| - other_context = Context::New();
|
| + other_context = Context::New(isolate);
|
|
|
| // Context-dependent context data creates reference from the compilation
|
| // cache to the global object.
|
| const char* source_simple = "1";
|
| - context = Context::New();
|
| {
|
| - v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| + v8::HandleScope scope(isolate);
|
| + v8::Local<Context> context = Context::New(isolate);
|
|
|
| context->Enter();
|
| Local<v8::String> obj = v8::String::New("");
|
| @@ -16166,7 +16164,6 @@ TEST(Regress528) {
|
| CompileRun(source_simple);
|
| context->Exit();
|
| }
|
| - context.Dispose(context->GetIsolate());
|
| v8::V8::ContextDisposedNotification();
|
| for (gc_count = 1; gc_count < 10; gc_count++) {
|
| other_context->Enter();
|
| @@ -16181,15 +16178,14 @@ TEST(Regress528) {
|
| // Eval in a function creates reference from the compilation cache to the
|
| // global object.
|
| const char* source_eval = "function f(){eval('1')}; f()";
|
| - context = Context::New();
|
| {
|
| - v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| + v8::HandleScope scope(isolate);
|
| + v8::Local<Context> context = Context::New(isolate);
|
|
|
| context->Enter();
|
| CompileRun(source_eval);
|
| context->Exit();
|
| }
|
| - context.Dispose(context->GetIsolate());
|
| v8::V8::ContextDisposedNotification();
|
| for (gc_count = 1; gc_count < 10; gc_count++) {
|
| other_context->Enter();
|
| @@ -16204,9 +16200,9 @@ TEST(Regress528) {
|
| // Looking up the line number for an exception creates reference from the
|
| // compilation cache to the global object.
|
| const char* source_exception = "function f(){throw 1;} f()";
|
| - context = Context::New();
|
| {
|
| - v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| + v8::HandleScope scope(isolate);
|
| + v8::Local<Context> context = Context::New(isolate);
|
|
|
| context->Enter();
|
| v8::TryCatch try_catch;
|
| @@ -16217,7 +16213,6 @@ TEST(Regress528) {
|
| CHECK_EQ(1, message->GetLineNumber());
|
| context->Exit();
|
| }
|
| - context.Dispose(context->GetIsolate());
|
| v8::V8::ContextDisposedNotification();
|
| for (gc_count = 1; gc_count < 10; gc_count++) {
|
| other_context->Enter();
|
| @@ -16229,7 +16224,6 @@ TEST(Regress528) {
|
| CHECK_GE(2, gc_count);
|
| CHECK_EQ(1, GetGlobalObjectsCount());
|
|
|
| - other_context.Dispose(other_context->GetIsolate());
|
| v8::V8::ContextDisposedNotification();
|
| }
|
|
|
| @@ -16946,7 +16940,11 @@ TEST(RunTwoIsolatesOnSingleThread) {
|
| // Run isolate 1.
|
| v8::Isolate* isolate1 = v8::Isolate::New();
|
| isolate1->Enter();
|
| - v8::Persistent<v8::Context> context1 = v8::Context::New();
|
| + v8::Persistent<v8::Context> context1;
|
| + {
|
| + v8::HandleScope scope(isolate1);
|
| + context1.Reset(isolate1, Context::New(isolate1));
|
| + }
|
|
|
| {
|
| v8::HandleScope scope(isolate1);
|
| @@ -16962,8 +16960,8 @@ TEST(RunTwoIsolatesOnSingleThread) {
|
|
|
| {
|
| v8::Isolate::Scope iscope(isolate2);
|
| - context2 = v8::Context::New();
|
| v8::HandleScope scope(isolate2);
|
| + context2.Reset(isolate2, Context::New(isolate2));
|
| v8::Context::Scope cscope(isolate2, context2);
|
|
|
| // Run something in new isolate.
|
| @@ -16981,7 +16979,13 @@ TEST(RunTwoIsolatesOnSingleThread) {
|
| isolate1->Exit();
|
|
|
| // Run some stuff in default isolate.
|
| - v8::Persistent<v8::Context> context_default = v8::Context::New();
|
| + v8::Persistent<v8::Context> context_default;
|
| + {
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + v8::Isolate::Scope iscope(isolate);
|
| + v8::HandleScope scope(isolate);
|
| + context_default.Reset(isolate, Context::New(isolate));
|
| + }
|
|
|
| {
|
| v8::HandleScope scope(v8::Isolate::GetCurrent());
|
| @@ -17107,12 +17111,12 @@ TEST(MultipleIsolatesOnIndividualThreads) {
|
|
|
| TEST(IsolateDifferentContexts) {
|
| v8::Isolate* isolate = v8::Isolate::New();
|
| - Persistent<v8::Context> context;
|
| + Local<v8::Context> context;
|
| {
|
| v8::Isolate::Scope isolate_scope(isolate);
|
| v8::HandleScope handle_scope(isolate);
|
| - context = v8::Context::New();
|
| - v8::Context::Scope context_scope(isolate, context);
|
| + context = v8::Context::New(isolate);
|
| + v8::Context::Scope context_scope(context);
|
| Local<Value> v = CompileRun("2");
|
| CHECK(v->IsNumber());
|
| CHECK_EQ(2, static_cast<int>(v->NumberValue()));
|
| @@ -17120,13 +17124,12 @@ TEST(IsolateDifferentContexts) {
|
| {
|
| v8::Isolate::Scope isolate_scope(isolate);
|
| v8::HandleScope handle_scope(isolate);
|
| - context = v8::Context::New();
|
| - v8::Context::Scope context_scope(isolate, context);
|
| + context = v8::Context::New(isolate);
|
| + v8::Context::Scope context_scope(context);
|
| Local<Value> v = CompileRun("22");
|
| CHECK(v->IsNumber());
|
| CHECK_EQ(22, static_cast<int>(v->NumberValue()));
|
| }
|
| - isolate->Dispose();
|
| }
|
|
|
| class InitDefaultIsolateThread : public v8::internal::Thread {
|
| @@ -18015,7 +18018,8 @@ static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global,
|
|
|
|
|
| THREADED_TEST(Regress93759) {
|
| - HandleScope scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + HandleScope scope(isolate);
|
|
|
| // Template for object with security check.
|
| Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New();
|
| @@ -18036,7 +18040,7 @@ THREADED_TEST(Regress93759) {
|
| protected_hidden_proto_template->SetHiddenPrototype(true);
|
|
|
| // Context for "foreign" objects used in test.
|
| - Persistent<Context> context = v8::Context::New();
|
| + Local<Context> context = v8::Context::New(isolate);
|
| context->Enter();
|
|
|
| // Plain object, no security check.
|
| @@ -18100,8 +18104,6 @@ THREADED_TEST(Regress93759) {
|
|
|
| Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)");
|
| CHECK(result6->Equals(Undefined()));
|
| -
|
| - context.Dispose(context->GetIsolate());
|
| }
|
|
|
|
|
| @@ -18140,14 +18142,15 @@ static void TestReceiver(Local<Value> expected_result,
|
|
|
|
|
| THREADED_TEST(ForeignFunctionReceiver) {
|
| - HandleScope scope(v8::Isolate::GetCurrent());
|
| + v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| + HandleScope scope(isolate);
|
|
|
| // Create two contexts with different "id" properties ('i' and 'o').
|
| // Call a function both from its own context and from a the foreign
|
| // context, and see what "this" is bound to (returning both "this"
|
| // and "this.id" for comparison).
|
|
|
| - Persistent<Context> foreign_context = v8::Context::New();
|
| + Local<Context> foreign_context = v8::Context::New(isolate);
|
| foreign_context->Enter();
|
| Local<Value> foreign_function =
|
| CompileRun("function func() { return { 0: this.id, "
|
| @@ -18228,8 +18231,6 @@ THREADED_TEST(ForeignFunctionReceiver) {
|
| TestReceiver(o, context->Global(), "func()");
|
| // Calling with no base.
|
| TestReceiver(o, context->Global(), "(1,func)()");
|
| -
|
| - foreign_context.Dispose(foreign_context->GetIsolate());
|
| }
|
|
|
|
|
|
|