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

Unified Diff: test/cctest/test-api.cc

Issue 15038002: Revert "deprecate Context::New which returns Persistent" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 | « test/cctest/cctest.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index c9685f8f4c07fa07914b68b4f15196543f29e815..1c17e8c9b3ca913923b98ba914f747ff2284e6aa 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -4688,9 +4688,9 @@ THREADED_TEST(NamedInterceptorDictionaryIC) {
THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope scope(isolate);
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+
+ v8::Persistent<Context> context1 = Context::New();
context1->Enter();
Local<ObjectTemplate> templ = ObjectTemplate::New();
@@ -4725,6 +4725,8 @@ THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) {
context1->Enter();
CompileRun("var obj = { x : 0 }; delete obj.x;");
context1->Exit();
+
+ context1.Dispose(context1->GetIsolate());
}
@@ -5499,14 +5501,14 @@ static v8::Handle<Value> HandleLogDelegator(const v8::Arguments& args) {
THREADED_TEST(GlobalObjectTemplate) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
Local<ObjectTemplate> global_template = ObjectTemplate::New();
global_template->Set(v8_str("JSNI_Log"),
v8::FunctionTemplate::New(HandleLogDelegator));
- v8::Local<Context> context = Context::New(isolate, 0, global_template);
- Context::Scope context_scope(context);
+ v8::Persistent<Context> context = Context::New(0, global_template);
+ Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
Script::Compile(v8_str("JSNI_Log('LOG')"))->Run();
+ context.Dispose(context->GetIsolate());
}
@@ -7674,8 +7676,7 @@ static void UnreachableSetter(Local<String>, Local<Value>,
TEST(AccessControl) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
@@ -7695,7 +7696,7 @@ TEST(AccessControl) {
v8::DEFAULT);
// Create an environment
- v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
+ v8::Persistent<Context> context0 = Context::New(NULL, global_template);
context0->Enter();
v8::Handle<v8::Object> global0 = context0->Global();
@@ -7721,9 +7722,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(isolate);
+ v8::HandleScope scope1(v8::Isolate::GetCurrent());
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::Persistent<Context> context1 = Context::New();
context1->Enter();
v8::Handle<v8::Object> global1 = context1->Global();
@@ -7913,12 +7914,13 @@ TEST(AccessControl) {
context1->Exit();
context0->Exit();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
TEST(AccessControlES5) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
@@ -7939,12 +7941,12 @@ TEST(AccessControlES5) {
v8::DEFAULT);
// Create an environment
- v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
+ v8::Persistent<Context> context0 = Context::New(NULL, global_template);
context0->Enter();
v8::Handle<v8::Object> global0 = context0->Global();
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::Persistent<Context> context1 = Context::New();
context1->Enter();
v8::Handle<v8::Object> global1 = context1->Global();
global1->Set(v8_str("other"), global0);
@@ -8004,8 +8006,7 @@ static bool GetOwnPropertyNamesIndexedBlocker(Local<v8::Object> global,
THREADED_TEST(AccessControlGetOwnPropertyNames) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
v8::Handle<v8::ObjectTemplate> obj_template = v8::ObjectTemplate::New();
obj_template->Set(v8_str("x"), v8::Integer::New(42));
@@ -8013,14 +8014,14 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
GetOwnPropertyNamesIndexedBlocker);
// Create an environment
- v8::Local<Context> context0 = Context::New(isolate, NULL, obj_template);
+ v8::Persistent<Context> context0 = Context::New(NULL, obj_template);
context0->Enter();
v8::Handle<v8::Object> global0 = context0->Global();
v8::HandleScope scope1(v8::Isolate::GetCurrent());
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::Persistent<Context> context1 = Context::New();
context1->Enter();
v8::Handle<v8::Object> global1 = context1->Global();
@@ -8042,6 +8043,8 @@ THREADED_TEST(AccessControlGetOwnPropertyNames) {
context1->Exit();
context0->Exit();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -8097,8 +8100,7 @@ static v8::Handle<Value> ConstTenGetter(Local<String> name,
THREADED_TEST(CrossDomainAccessors) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
v8::Handle<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
@@ -8120,7 +8122,7 @@ THREADED_TEST(CrossDomainAccessors) {
v8::Handle<Value>(),
v8::DEFAULT);
- v8::Local<Context> context0 = Context::New(isolate, NULL, global_template);
+ v8::Persistent<Context> context0 = Context::New(NULL, global_template);
context0->Enter();
Local<v8::Object> global = context0->Global();
@@ -8129,7 +8131,7 @@ THREADED_TEST(CrossDomainAccessors) {
// Enter a new context.
v8::HandleScope scope1(v8::Isolate::GetCurrent());
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::Persistent<Context> context1 = Context::New();
context1->Enter();
v8::Handle<v8::Object> global1 = context1->Global();
@@ -8145,6 +8147,8 @@ THREADED_TEST(CrossDomainAccessors) {
context1->Exit();
context0->Exit();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -8174,11 +8178,10 @@ TEST(AccessControlIC) {
named_access_count = 0;
indexed_access_count = 0;
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
// Create an environment.
- v8::Local<Context> context0 = Context::New(isolate);
+ v8::Persistent<Context> context0 = Context::New();
context0->Enter();
// Create an object that requires access-check functions to be
@@ -8188,10 +8191,10 @@ TEST(AccessControlIC) {
IndexedAccessCounter);
Local<v8::Object> object = object_template->NewInstance();
- v8::HandleScope scope1(isolate);
+ v8::HandleScope scope1(v8::Isolate::GetCurrent());
// Create another environment.
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::Persistent<Context> context1 = Context::New();
context1->Enter();
// Make easy access to the object from the other environment.
@@ -8279,6 +8282,8 @@ TEST(AccessControlIC) {
context1->Exit();
context0->Exit();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -8322,11 +8327,10 @@ THREADED_TEST(AccessControlFlatten) {
named_access_count = 0;
indexed_access_count = 0;
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
// Create an environment.
- v8::Local<Context> context0 = Context::New(isolate);
+ v8::Persistent<Context> context0 = Context::New();
context0->Enter();
// Create an object that requires access-check functions to be
@@ -8336,10 +8340,10 @@ THREADED_TEST(AccessControlFlatten) {
IndexedAccessFlatten);
Local<v8::Object> object = object_template->NewInstance();
- v8::HandleScope scope1(isolate);
+ v8::HandleScope scope1(v8::Isolate::GetCurrent());
// Create another environment.
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::Persistent<Context> context1 = Context::New();
context1->Enter();
// Make easy access to the object from the other environment.
@@ -8353,6 +8357,8 @@ THREADED_TEST(AccessControlFlatten) {
context1->Exit();
context0->Exit();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -8385,11 +8391,10 @@ THREADED_TEST(AccessControlInterceptorIC) {
named_access_count = 0;
indexed_access_count = 0;
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
// Create an environment.
- v8::Local<Context> context0 = Context::New(isolate);
+ v8::Persistent<Context> context0 = Context::New();
context0->Enter();
// Create an object that requires access-check functions to be
@@ -8404,10 +8409,10 @@ THREADED_TEST(AccessControlInterceptorIC) {
AccessControlIndexedSetter);
Local<v8::Object> object = object_template->NewInstance();
- v8::HandleScope scope1(isolate);
+ v8::HandleScope scope1(v8::Isolate::GetCurrent());
// Create another environment.
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::Persistent<Context> context1 = Context::New();
context1->Enter();
// Make easy access to the object from the other environment.
@@ -8444,6 +8449,8 @@ THREADED_TEST(AccessControlInterceptorIC) {
context1->Exit();
context0->Exit();
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -9304,11 +9311,10 @@ THREADED_TEST(CrossEval) {
// its global throws an exception. This behavior is consistent with
// other JavaScript implementations.
THREADED_TEST(EvalInDetachedGlobal) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope scope(isolate);
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
- v8::Local<Context> context0 = Context::New(isolate);
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::Persistent<Context> context0 = Context::New();
+ v8::Persistent<Context> context1 = Context::New();
// Set up function in context0 that uses eval from context0.
context0->Enter();
@@ -9333,6 +9339,9 @@ THREADED_TEST(EvalInDetachedGlobal) {
CHECK(x_value.IsEmpty());
CHECK(catcher.HasCaught());
context1->Exit();
+
+ context1.Dispose(context1->GetIsolate());
+ context0.Dispose(context0->GetIsolate());
}
@@ -11965,7 +11974,7 @@ THREADED_TEST(CheckForCrossContextObjectLiterals) {
}
-static v8::Handle<Value> NestedScope(v8::Local<Context> env) {
+static v8::Handle<Value> NestedScope(v8::Persistent<Context> env) {
v8::HandleScope inner(env->GetIsolate());
env->Enter();
v8::Handle<Value> three = v8_num(3);
@@ -11976,14 +11985,14 @@ static v8::Handle<Value> NestedScope(v8::Local<Context> env) {
THREADED_TEST(NestedHandleScopeAndContexts) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope outer(isolate);
- v8::Local<Context> env = Context::New(isolate);
+ v8::HandleScope outer(v8::Isolate::GetCurrent());
+ v8::Persistent<Context> env = Context::New();
env->Enter();
v8::Handle<Value> value = NestedScope(env);
v8::Handle<String> str(value->ToString());
CHECK(!str.IsEmpty());
env->Exit();
+ env.Dispose(env->GetIsolate());
}
@@ -12015,9 +12024,8 @@ static void RunLoopInNewEnv() {
bar_ptr = NULL;
foo_ptr = NULL;
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope outer(isolate);
- v8::Local<Context> env = Context::New(isolate);
+ v8::HandleScope outer(v8::Isolate::GetCurrent());
+ v8::Persistent<Context> env = Context::New();
env->Enter();
const char* script =
@@ -12343,11 +12351,11 @@ static int64_t cast(intptr_t x) { return static_cast<int64_t>(x); }
THREADED_TEST(ExternalAllocatedMemory) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope outer(isolate);
- v8::Local<Context> env(Context::New(isolate));
+ v8::HandleScope outer(v8::Isolate::GetCurrent());
+ v8::Persistent<Context> env(Context::New());
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)));
@@ -12358,14 +12366,8 @@ THREADED_TEST(ExternalAllocatedMemory) {
THREADED_TEST(DisposeEnteredContext) {
LocalContext outer;
- 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);
- {
+ v8::HandleScope scope(outer->GetIsolate());
+ { v8::Persistent<v8::Context> inner = v8::Context::New();
inner->Enter();
inner.Dispose(inner->GetIsolate());
inner.Clear();
@@ -12685,8 +12687,7 @@ THREADED_TEST(AccessChecksReenabledCorrectly) {
// This tests that access check information remains on the global
// object template when creating contexts.
THREADED_TEST(AccessControlRepeatedContextCreation) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
global_template->SetAccessCheckCallbacks(NamedSetAccessBlocker,
IndexedSetAccessBlocker);
@@ -12696,15 +12697,14 @@ THREADED_TEST(AccessControlRepeatedContextCreation) {
i::Handle<i::FunctionTemplateInfo> constructor(
i::FunctionTemplateInfo::cast(internal_template->constructor()));
CHECK(!constructor->access_check_info()->IsUndefined());
- v8::Local<Context> context0(Context::New(isolate, NULL, global_template));
+ v8::Persistent<Context> context0(Context::New(NULL, global_template));
CHECK(!context0.IsEmpty());
CHECK(!constructor->access_check_info()->IsUndefined());
}
THREADED_TEST(TurnOnAccessCheck) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
// 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::Local<Context> context = Context::New(isolate, NULL, global_template);
- Context::Scope context_scope(context);
+ v8::Persistent<Context> context = Context::New(NULL, global_template);
+ Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
// Set up a property and a number of functions.
context->Global()->Set(v8_str("a"), v8_num(1));
@@ -12784,8 +12784,7 @@ static bool NamedGetAccessBlockAandH(Local<v8::Object> obj,
THREADED_TEST(TurnOnAccessCheckAndRecompile) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope handle_scope(isolate);
+ v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
// Create an environment with access check to the global object disabled by
// default. When the registered access checker will block access to properties
@@ -12795,8 +12794,8 @@ THREADED_TEST(TurnOnAccessCheckAndRecompile) {
IndexedGetAccessBlocker,
v8::Handle<v8::Value>(),
false);
- v8::Local<Context> context = Context::New(isolate, NULL, global_template);
- Context::Scope context_scope(context);
+ v8::Persistent<Context> context = Context::New(NULL, global_template);
+ Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
// Set up a property and a number of functions.
context->Global()->Set(v8_str("a"), v8_num(1));
@@ -13054,10 +13053,9 @@ 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::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope scope(isolate);
- v8::Local<Context> context0 = Context::New(isolate);
- v8::Local<Context> context1 = Context::New(isolate);
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Persistent<Context> context0 = Context::New();
+ v8::Persistent<Context> context1 = Context::New();
// Allow cross-domain access.
Local<String> token = v8_str("<security token>");
@@ -13078,6 +13076,10 @@ 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());
}
@@ -13858,10 +13860,9 @@ THREADED_TEST(ForceDeleteIC) {
TEST(InlinedFunctionAcrossContexts) {
i::FLAG_allow_natives_syntax = true;
- 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);
+ v8::HandleScope outer_scope(v8::Isolate::GetCurrent());
+ v8::Persistent<v8::Context> ctx1 = v8::Context::New();
+ v8::Persistent<v8::Context> ctx2 = v8::Context::New();
ctx1->Enter();
{
@@ -13891,13 +13892,15 @@ TEST(InlinedFunctionAcrossContexts) {
"ReferenceError: G is not defined");
ctx2->Exit();
ctx1->Exit();
+ ctx1.Dispose(ctx1->GetIsolate());
}
+ ctx2.Dispose(ctx2->GetIsolate());
}
-static v8::Local<Context> calling_context0;
-static v8::Local<Context> calling_context1;
-static v8::Local<Context> calling_context2;
+v8::Persistent<Context> calling_context0;
+v8::Persistent<Context> calling_context1;
+v8::Persistent<Context> calling_context2;
// Check that the call to the callback is initiated in
@@ -13914,15 +13917,11 @@ static v8::Handle<Value> GetCallingContextCallback(const v8::Arguments& args) {
THREADED_TEST(GetCallingContext) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope scope(isolate);
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
- 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;
+ calling_context0 = Context::New();
+ calling_context1 = Context::New();
+ calling_context2 = Context::New();
// Allow cross-domain access.
Local<String> token = v8_str("<security token>");
@@ -13953,9 +13952,14 @@ THREADED_TEST(GetCallingContext) {
calling_context1->Global());
CompileRun("context1.f()");
calling_context2->Exit();
- ::calling_context0.Clear();
- ::calling_context1.Clear();
- ::calling_context2.Clear();
+
+ // 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();
}
@@ -15800,20 +15804,17 @@ 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::HandleScope inner_scope(env->GetIsolate());
- v8::Local<v8::Context> ctx = v8::Context::New(isolate);
- ctx->Enter();
- CreateGarbageInOldSpace();
- ctx->Exit();
- }
+ v8::Persistent<v8::Context> ctx = v8::Context::New();
+ ctx->Enter();
+ CreateGarbageInOldSpace();
+ ctx->Exit();
+ ctx.Dispose(ctx->GetIsolate());
v8::V8::ContextDisposedNotification();
v8::V8::IdleNotification(kLongIdlePauseInMs);
}
@@ -16142,21 +16143,22 @@ THREADED_TEST(SpaghettiStackReThrow) {
TEST(Regress528) {
v8::V8::Initialize();
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- v8::HandleScope scope(isolate);
- v8::Local<Context> other_context;
+
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Persistent<Context> context;
+ v8::Persistent<Context> other_context;
int gc_count;
// Create a context used to keep the code from aging in the compilation
// cache.
- other_context = Context::New(isolate);
+ other_context = Context::New();
// 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(isolate);
- v8::Local<Context> context = Context::New(isolate);
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
context->Enter();
Local<v8::String> obj = v8::String::New("");
@@ -16164,6 +16166,7 @@ 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();
@@ -16178,14 +16181,15 @@ 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(isolate);
- v8::Local<Context> context = Context::New(isolate);
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
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();
@@ -16200,9 +16204,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(isolate);
- v8::Local<Context> context = Context::New(isolate);
+ v8::HandleScope scope(v8::Isolate::GetCurrent());
context->Enter();
v8::TryCatch try_catch;
@@ -16213,6 +16217,7 @@ 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();
@@ -16224,6 +16229,7 @@ TEST(Regress528) {
CHECK_GE(2, gc_count);
CHECK_EQ(1, GetGlobalObjectsCount());
+ other_context.Dispose(other_context->GetIsolate());
v8::V8::ContextDisposedNotification();
}
@@ -16940,11 +16946,7 @@ TEST(RunTwoIsolatesOnSingleThread) {
// Run isolate 1.
v8::Isolate* isolate1 = v8::Isolate::New();
isolate1->Enter();
- v8::Persistent<v8::Context> context1;
- {
- v8::HandleScope scope(isolate1);
- context1.Reset(isolate1, Context::New(isolate1));
- }
+ v8::Persistent<v8::Context> context1 = v8::Context::New();
{
v8::HandleScope scope(isolate1);
@@ -16960,8 +16962,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.
@@ -16979,13 +16981,7 @@ TEST(RunTwoIsolatesOnSingleThread) {
isolate1->Exit();
// Run some stuff in default isolate.
- 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::Persistent<v8::Context> context_default = v8::Context::New();
{
v8::HandleScope scope(v8::Isolate::GetCurrent());
@@ -17111,12 +17107,12 @@ TEST(MultipleIsolatesOnIndividualThreads) {
TEST(IsolateDifferentContexts) {
v8::Isolate* isolate = v8::Isolate::New();
- Local<v8::Context> context;
+ Persistent<v8::Context> context;
{
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- context = v8::Context::New(isolate);
- v8::Context::Scope context_scope(context);
+ context = v8::Context::New();
+ v8::Context::Scope context_scope(isolate, context);
Local<Value> v = CompileRun("2");
CHECK(v->IsNumber());
CHECK_EQ(2, static_cast<int>(v->NumberValue()));
@@ -17124,12 +17120,13 @@ TEST(IsolateDifferentContexts) {
{
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
- context = v8::Context::New(isolate);
- v8::Context::Scope context_scope(context);
+ context = v8::Context::New();
+ v8::Context::Scope context_scope(isolate, 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 {
@@ -18018,8 +18015,7 @@ static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global,
THREADED_TEST(Regress93759) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- HandleScope scope(isolate);
+ HandleScope scope(v8::Isolate::GetCurrent());
// Template for object with security check.
Local<ObjectTemplate> no_proto_template = v8::ObjectTemplate::New();
@@ -18040,7 +18036,7 @@ THREADED_TEST(Regress93759) {
protected_hidden_proto_template->SetHiddenPrototype(true);
// Context for "foreign" objects used in test.
- Local<Context> context = v8::Context::New(isolate);
+ Persistent<Context> context = v8::Context::New();
context->Enter();
// Plain object, no security check.
@@ -18104,6 +18100,8 @@ THREADED_TEST(Regress93759) {
Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)");
CHECK(result6->Equals(Undefined()));
+
+ context.Dispose(context->GetIsolate());
}
@@ -18142,15 +18140,14 @@ static void TestReceiver(Local<Value> expected_result,
THREADED_TEST(ForeignFunctionReceiver) {
- v8::Isolate* isolate = v8::Isolate::GetCurrent();
- HandleScope scope(isolate);
+ HandleScope scope(v8::Isolate::GetCurrent());
// 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).
- Local<Context> foreign_context = v8::Context::New(isolate);
+ Persistent<Context> foreign_context = v8::Context::New();
foreign_context->Enter();
Local<Value> foreign_function =
CompileRun("function func() { return { 0: this.id, "
@@ -18231,6 +18228,8 @@ THREADED_TEST(ForeignFunctionReceiver) {
TestReceiver(o, context->Global(), "func()");
// Calling with no base.
TestReceiver(o, context->Global(), "(1,func)()");
+
+ foreign_context.Dispose(foreign_context->GetIsolate());
}
« no previous file with comments | « test/cctest/cctest.h ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698