// is what we need for the reference to remain after we return from
// this method. That persistent handle has to be disposed in the
// destructor.
- context_ = Context::New(NULL, global);
+ context_.Reset(GetIsolate(), Context::New(GetIsolate(), NULL, global));
// Enter the new context so all the following operations take place
// within it.
Locker lock(isolate);
HandleScope scope(isolate);
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
- utility_context_ = Context::New(NULL, global_template);
+ utility_context_.Reset(isolate,
+ Context::New(isolate, NULL, global_template));
#ifdef ENABLE_DEBUGGER_SUPPORT
// Start the debugger agent if requested.
}
-Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
+Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
#ifndef V8_SHARED
// This needs to be a critical section since this is not thread-safe
i::ScopedLock lock(context_mutex_);
#endif // V8_SHARED
// Initialize the global objects
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
- Persistent<Context> context = Context::New(NULL, global_template);
- ASSERT(!context.IsEmpty());
HandleScope handle_scope(isolate);
- Context::Scope scope(isolate, context);
+ Local<Context> context = Context::New(isolate, NULL, global_template);
+ ASSERT(!context.IsEmpty());
+ Context::Scope scope(context);
#ifndef V8_SHARED
i::JSArguments js_args = i::FLAG_js_arguments;
context->Global()->Set(String::New("arguments"),
Utils::ToLocal(arguments_jsarray));
#endif // V8_SHARED
- return context;
+ return handle_scope.Close(context);
}
// Prepare the context for this thread.
Locker locker(isolate_);
HandleScope outer_scope(isolate_);
- Persistent<Context> thread_context =
+ Local<Context> thread_context =
Shell::CreateEvaluationContext(isolate_);
- Context::Scope context_scope(isolate_, thread_context);
+ Context::Scope context_scope(thread_context);
PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate_));
while ((ptr != NULL) && (*ptr != '\0')) {
Shell::ExecuteString(isolate_, str, String::New(filename), false, false);
}
- thread_context.Dispose(thread_context->GetIsolate());
ptr = next_line;
}
}
{
Isolate::Scope iscope(isolate);
Locker lock(isolate);
- HandleScope scope(isolate);
- PerIsolateData data(isolate);
- Persistent<Context> context = Shell::CreateEvaluationContext(isolate);
{
- Context::Scope cscope(isolate, context);
- PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
- Execute(isolate);
+ HandleScope scope(isolate);
+ PerIsolateData data(isolate);
+ Local<Context> context = Shell::CreateEvaluationContext(isolate);
+ {
+ Context::Scope cscope(context);
+ PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
+ Execute(isolate);
+ }
}
- context.Dispose(isolate);
if (Shell::options.send_idle_notification) {
const int kLongIdlePauseInMs = 1000;
V8::ContextDisposedNotification();
#endif // V8_SHARED
{ // NOLINT
Locker lock(isolate);
- HandleScope scope(isolate);
- Persistent<Context> context = CreateEvaluationContext(isolate);
- if (options.last_run) {
- // Keep using the same context in the interactive shell.
- evaluation_context_ = context;
+ {
+ HandleScope scope(isolate);
+ Local<Context> context = CreateEvaluationContext(isolate);
+ if (options.last_run) {
+ // Keep using the same context in the interactive shell.
+ evaluation_context_.Reset(isolate, context);
#if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
- // If the interactive debugger is enabled make sure to activate
- // it before running the files passed on the command line.
- if (i::FLAG_debugger) {
- InstallUtilityScript(isolate);
- }
+ // If the interactive debugger is enabled make sure to activate
+ // it before running the files passed on the command line.
+ if (i::FLAG_debugger) {
+ InstallUtilityScript(isolate);
+ }
#endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
- }
- {
- Context::Scope cscope(isolate, context);
- PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
- options.isolate_sources[0].Execute(isolate);
+ }
+ {
+ Context::Scope cscope(context);
+ PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
+ options.isolate_sources[0].Execute(isolate);
+ }
}
if (!options.last_run) {
- context.Dispose(isolate);
if (options.send_idle_notification) {
const int kLongIdlePauseInMs = 1000;
V8::ContextDisposedNotification();
static const char* ToCString(const v8::String::Utf8Value& value);
static void ReportException(Isolate* isolate, TryCatch* try_catch);
static Handle<String> ReadFile(Isolate* isolate, const char* name);
- static Persistent<Context> CreateEvaluationContext(Isolate* isolate);
+ static Local<Context> CreateEvaluationContext(Isolate* isolate);
static int RunMain(Isolate* isolate, int argc, char* argv[]);
static int Main(int argc, char* argv[]);
static void Exit(int exit_code);
}
#endif
i::Serializer::Enable();
- Persistent<Context> context = v8::Context::New();
+ Isolate* isolate = Isolate::GetCurrent();
+ Persistent<Context> context;
+ {
+ HandleScope handle_scope(isolate);
+ context.Reset(isolate, Context::New(isolate));
+ }
+
if (context.IsEmpty()) {
fprintf(stderr,
"\nException thrown while compiling natives - see above.\n\n");
exit(1);
}
- Isolate* isolate = context->GetIsolate();
if (i::FLAG_extra_code != NULL) {
context->Enter();
// Capture 100 frames if anything happens.
LocalContext(v8::ExtensionConfiguration* extensions = 0,
v8::Handle<v8::ObjectTemplate> global_template =
v8::Handle<v8::ObjectTemplate>(),
- v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
- : context_(v8::Context::New(extensions, global_template, global_object)) {
+ v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) {
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ HandleScope scope(isolate);
+ context_.Reset(isolate,
+ Context::New(isolate,
+ extensions,
+ global_template,
+ global_object));
context_->Enter();
// We can't do this later perhaps because of a fatal error.
isolate_ = context_->GetIsolate();
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();
context1->Enter();
CompileRun("var obj = { x : 0 }; delete obj.x;");
context1->Exit();
-
- context1.Dispose(context1->GetIsolate());
}
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());
}
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,
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();
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();
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,
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);
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));
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();
context1->Exit();
context0->Exit();
- context1.Dispose(context1->GetIsolate());
- context0.Dispose(context0->GetIsolate());
}
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();
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();
// 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();
context1->Exit();
context0->Exit();
- context1.Dispose(context1->GetIsolate());
- context0.Dispose(context0->GetIsolate());
}
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
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.
context1->Exit();
context0->Exit();
- context1.Dispose(context1->GetIsolate());
- context0.Dispose(context0->GetIsolate());
}
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
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.
context1->Exit();
context0->Exit();
- context1.Dispose(context1->GetIsolate());
- context0.Dispose(context0->GetIsolate());
}
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
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.
context1->Exit();
context0->Exit();
- context1.Dispose(context1->GetIsolate());
- context0.Dispose(context0->GetIsolate());
}
// 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();
CHECK(x_value.IsEmpty());
CHECK(catcher.HasCaught());
context1->Exit();
-
- context1.Dispose(context1->GetIsolate());
- context0.Dispose(context0->GetIsolate());
}
}
-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);
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());
}
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 =
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)));
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();
// 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);
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.
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));
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
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));
// 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>");
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());
}
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();
{
"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
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>");
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();
}
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);
}
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("");
CompileRun(source_simple);
context->Exit();
}
- context.Dispose(context->GetIsolate());
v8::V8::ContextDisposedNotification();
for (gc_count = 1; gc_count < 10; gc_count++) {
other_context->Enter();
// 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();
// 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;
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();
CHECK_GE(2, gc_count);
CHECK_EQ(1, GetGlobalObjectsCount());
- other_context.Dispose(other_context->GetIsolate());
v8::V8::ContextDisposedNotification();
}
// 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);
{
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.
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());
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()));
{
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 {
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();
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.
Local<Value> result6 = CompileRun("Object.getPrototypeOf(phidden)");
CHECK(result6->Equals(Undefined()));
-
- context.Dispose(context->GetIsolate());
}
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, "
TestReceiver(o, context->Global(), "func()");
// Calling with no base.
TestReceiver(o, context->Global(), "(1,func)()");
-
- foreign_context.Dispose(foreign_context->GetIsolate());
}
v8::Handle<v8::ObjectTemplate> global_template =
v8::Handle<v8::ObjectTemplate>(),
v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>())
- : context_(v8::Context::New(extensions, global_template, global_object)) {
+ : scope_(v8::Isolate::GetCurrent()),
+ context_(
+ v8::Context::New(v8::Isolate::GetCurrent(),
+ extensions,
+ global_template,
+ global_object)) {
context_->Enter();
}
inline ~DebugLocalContext() {
context_->Exit();
- context_.Dispose(context_->GetIsolate());
}
inline v8::Context* operator->() { return *context_; }
inline v8::Context* operator*() { return *context_; }
}
private:
- v8::Persistent<v8::Context> context_;
+ v8::HandleScope scope_;
+ v8::Local<v8::Context> context_;
};
// http://crbug.com/28933
// Test that debug break is disabled when bootstrapper is active.
TEST(NoBreakWhenBootstrapping) {
- v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
// Register a debug event listener which sets the break flag and counts.
v8::Debug::SetDebugEventListener(DebugEventCounter);
kSimpleExtensionSource));
const char* extension_names[] = { "simpletest" };
v8::ExtensionConfiguration extensions(1, extension_names);
- v8::Persistent<v8::Context> context = v8::Context::New(&extensions);
- context.Dispose(context->GetIsolate());
+ v8::HandleScope handle_scope(isolate);
+ v8::Context::New(isolate, &extensions);
}
// Check that no DebugBreak events occured during the context creation.
CHECK_EQ(0, break_point_hit_count);
}
-static v8::Persistent<v8::Context> expected_context;
+static v8::Handle<v8::Context> expected_context;
static v8::Handle<v8::Value> expected_context_data;
// Enter and run function in the first context.
{
v8::Context::Scope context_scope(context_1);
- expected_context = v8::Persistent<v8::Context>(*context_1);
+ expected_context = context_1;
expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(source, "f");
f->Call(context_1->Global(), 0, NULL);
// Enter and run function in the second context.
{
v8::Context::Scope context_scope(context_2);
- expected_context = v8::Persistent<v8::Context>(*context_2);
+ expected_context = context_2;
expected_context_data = data_2;
v8::Local<v8::Function> f = CompileFunction(source, "f");
f->Call(context_2->Global(), 0, NULL);
// Enter and run function in the context.
{
v8::Context::Scope context_scope(context_1);
- expected_context = v8::Persistent<v8::Context>(*context_1);
+ expected_context = v8::Local<v8::Context>(*context_1);
expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(source, "f");
f->Call(context_1->Global(), 0, NULL);
script_collected_message_count = 0;
v8::HandleScope scope(isolate);
- { // Scope for the DebugLocalContext.
- DebugLocalContext env;
+ v8::Persistent<v8::Context> context;
+ {
+ v8::HandleScope scope(isolate);
+ context.Reset(isolate, v8::Context::New(isolate));
+ }
+ context->Enter();
- // Request the loaded scripts to initialize the debugger script cache.
- debug->GetLoadedScripts();
+ // Request the loaded scripts to initialize the debugger script cache.
+ debug->GetLoadedScripts();
- // Do garbage collection to ensure that only the script in this test will be
- // collected afterwards.
- HEAP->CollectAllGarbage(Heap::kNoGCFlags);
+ // Do garbage collection to ensure that only the script in this test will be
+ // collected afterwards.
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
- v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
- {
- v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
- v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
- }
- }
+ v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
+ v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
+ v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
+
+ context->Exit();
+ context.Dispose(isolate);
// Do garbage collection to collect the script above which is no longer
// referenced.
// Check that event details contain context where debug event occured.
TEST(DebugEventContext) {
- v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
expected_callback_data = v8::Int32::New(2010);
v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
expected_callback_data);
- expected_context = v8::Context::New();
- v8::Context::Scope context_scope(
- v8::Isolate::GetCurrent(), expected_context);
+ expected_context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(expected_context);
v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run();
- expected_context.Dispose(expected_context->GetIsolate());
expected_context.Clear();
v8::Debug::SetDebugEventListener(NULL);
expected_context_data = v8::Handle<v8::Value>();
void DeclarationContext::InitializeIfNeeded() {
if (is_initialized_) return;
- HandleScope scope(Isolate::GetCurrent());
+ Isolate* isolate = Isolate::GetCurrent();
+ HandleScope scope(isolate);
Local<FunctionTemplate> function = FunctionTemplate::New();
Local<Value> data = External::New(this);
GetHolder(function)->SetNamedPropertyHandler(&HandleGet,
&HandleQuery,
0, 0,
data);
- context_ = Context::New(0, function->InstanceTemplate(), Local<Value>());
+ context_.Reset(isolate,
+ Context::New(isolate,
+ 0,
+ function->InstanceTemplate(),
+ Local<Value>()));
context_->Enter();
is_initialized_ = true;
- PostInitializeContext(Local<Context>::New(Isolate::GetCurrent(), context_));
+ PostInitializeContext(Local<Context>::New(isolate, context_));
}
class SimpleContext {
public:
- SimpleContext() {
- context_ = Context::New();
+ SimpleContext()
+ : handle_scope_(Isolate::GetCurrent()),
+ context_(Context::New(Isolate::GetCurrent())) {
context_->Enter();
}
- virtual ~SimpleContext() {
+ ~SimpleContext() {
context_->Exit();
- context_.Dispose(context_->GetIsolate());
}
void Check(const char* source,
}
private:
- Persistent<Context> context_;
+ HandleScope handle_scope_;
+ Local<Context> context_;
};
typedef uint32_t (*HASH_FUNCTION)();
-static v8::Persistent<v8::Context> env;
-
#define __ masm->
TEST(StringHash) {
- if (env.IsEmpty()) env = v8::Context::New();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope handle_scope(isolate);
+ v8::Context::Scope context_scope(v8::Context::New(isolate));
+
for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) {
// Numbers are hashed differently.
if (a >= '0' && a <= '9') continue;
TEST(NumberHash) {
- if (env.IsEmpty()) env = v8::Context::New();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope handle_scope(isolate);
+ v8::Context::Scope context_scope(v8::Context::New(isolate));
// Some specific numbers
for (uint32_t key = 0; key < 42; key += 7) {
// optimized code.
TEST(LeakNativeContextViaMap) {
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::Persistent<v8::Context> ctx1;
+ v8::Persistent<v8::Context> ctx2;
+ {
+ v8::HandleScope scope(isolate);
+ ctx1.Reset(isolate, v8::Context::New(isolate));
+ ctx2.Reset(isolate, v8::Context::New(isolate));
+ }
ctx1->Enter();
HEAP->CollectAllAvailableGarbage();
// optimized code.
TEST(LeakNativeContextViaFunction) {
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::Persistent<v8::Context> ctx1;
+ v8::Persistent<v8::Context> ctx2;
+ {
+ v8::HandleScope scope(isolate);
+ ctx1.Reset(isolate, v8::Context::New(isolate));
+ ctx2.Reset(isolate, v8::Context::New(isolate));
+ }
ctx1->Enter();
HEAP->CollectAllAvailableGarbage();
TEST(LeakNativeContextViaMapKeyed) {
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::Persistent<v8::Context> ctx1;
+ v8::Persistent<v8::Context> ctx2;
+ {
+ v8::HandleScope scope(isolate);
+ ctx1.Reset(isolate, v8::Context::New(isolate));
+ ctx2.Reset(isolate, v8::Context::New(isolate));
+ }
ctx1->Enter();
HEAP->CollectAllAvailableGarbage();
TEST(LeakNativeContextViaMapProto) {
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::Persistent<v8::Context> ctx1;
+ v8::Persistent<v8::Context> ctx2;
+ {
+ v8::HandleScope scope(isolate);
+ ctx1.Reset(isolate, v8::Context::New(isolate));
+ ctx2.Reset(isolate, v8::Context::New(isolate));
+ }
ctx1->Enter();
HEAP->CollectAllAvailableGarbage();
#else
const int kNThreads = 100;
#endif
- Persistent<v8::Context> context;
+ Local<v8::Context> context;
i::List<JoinableThread*> threads(kNThreads);
{
v8::Locker locker_(CcTest::default_isolate());
v8::HandleScope handle_scope(CcTest::default_isolate());
- context = v8::Context::New();
+ context = v8::Context::New(CcTest::default_isolate());
for (int i = 0; i < kNThreads; i++) {
- threads.Add(new LockUnlockLockDefaultIsolateThread(
- v8::Local<v8::Context>::New(CcTest::default_isolate(), context)));
+ threads.Add(new LockUnlockLockDefaultIsolateThread(context));
}
}
StartJoinAndDeleteThreads(threads);
v8::Isolate::Scope isolate_scope(isolate);
CHECK(!i::Isolate::Current()->has_installed_extensions());
v8::ExtensionConfiguration extensions(count_, extension_names_);
- v8::Persistent<v8::Context> context = v8::Context::New(&extensions);
+ v8::HandleScope handle_scope(isolate);
+ v8::Context::New(isolate, &extensions);
CHECK(i::Isolate::Current()->has_installed_extensions());
- context.Dispose(isolate);
}
isolate->Dispose();
}
// Need to run this prior to creating the scope.
trick_to_run_init_flags_(init_flags_(prof_lazy)),
scope_(v8::Isolate::GetCurrent()),
- env_(*v8::Context::New()),
+ env_(v8::Context::New(v8::Isolate::GetCurrent())),
logger_(i::Isolate::Current()->logger()) {
env_->Enter();
}
TEST(Preparsing) {
- v8::HandleScope handles(v8::Isolate::GetCurrent());
- v8::Persistent<v8::Context> context = v8::Context::New();
- v8::Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope handles(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
int marker;
i::Isolate::Current()->stack_guard()->SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
TEST(CharacterStreams) {
- v8::HandleScope handles(v8::Isolate::GetCurrent());
- v8::Persistent<v8::Context> context = v8::Context::New();
- v8::Context::Scope context_scope(v8::Isolate::GetCurrent(), context);
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope handles(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
TestCharacterStream("abc\0\n\r\x7f", 7);
static const unsigned kBigStringSize = 4096;
static ProfilerExtension kProfilerExtension;
v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
-static v8::Persistent<v8::Context> env;
static const ProfileNode* PickChild(const ProfileNode* parent,
const char* name) {
// don't appear in the stack trace.
i::FLAG_use_inlining = false;
- if (env.IsEmpty()) {
- v8::HandleScope scope(v8::Isolate::GetCurrent());
- const char* extensions[] = { "v8/profiler" };
- v8::ExtensionConfiguration config(1, extensions);
- env = v8::Context::New(&config);
- }
- v8::HandleScope scope(v8::Isolate::GetCurrent());
- (*env)->Enter();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ context->Enter();
CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
CHECK_EQ(0, profiler->GetProfilesCount());
using namespace v8::internal;
-static v8::Persistent<v8::Context> env;
-
void SetSeeds(Handle<ByteArray> seeds, uint32_t state0, uint32_t state1) {
for (int i = 0; i < 4; i++) {
TEST(CrankshaftRandom) {
- if (env.IsEmpty()) env = v8::Context::New();
+ v8::V8::Initialize();
// Skip test if crankshaft is disabled.
if (!V8::UseCrankshaft()) return;
- v8::HandleScope scope(env->GetIsolate());
- env->Enter();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ v8::Context::Scope context_scope(v8::Context::New(isolate));
Handle<Context> context(Isolate::Current()->context());
Handle<JSObject> global(context->global_object());
class ContextInitializer {
public:
ContextInitializer()
- : env_(),
- scope_(v8::Isolate::GetCurrent()),
+ : scope_(v8::Isolate::GetCurrent()),
+ env_(v8::Context::New(v8::Isolate::GetCurrent())),
zone_(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT) {
- env_ = v8::Context::New();
env_->Enter();
}
~ContextInitializer() {
env_->Exit();
- env_.Dispose(env_->GetIsolate());
}
private:
- v8::Persistent<v8::Context> env_;
v8::HandleScope scope_;
+ v8::Handle<v8::Context> env_;
v8::internal::ZoneScope zone_;
};
// can be loaded from v8natives.js and their addresses can be processed. This
// will clear the pending fixups array, which would otherwise contain GC roots
// that would confuse the serialization/deserialization process.
- v8::Persistent<v8::Context> env = v8::Context::New();
- env.Dispose(env->GetIsolate());
+ {
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ v8::Context::New(isolate);
+ }
WriteToFile(FLAG_testing_serialization_file);
}
// serialization. That doesn't matter. We don't need to be able to
// serialize a snapshot in a VM that is booted from a snapshot.
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
Deserialize();
- v8::Persistent<v8::Context> env = v8::Context::New();
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
env->Enter();
SanityCheck();
DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
Deserialize();
- v8::Persistent<v8::Context> env = v8::Context::New();
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
env->Enter();
SanityCheck();
DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
Deserialize();
- v8::Persistent<v8::Context> env = v8::Context::New();
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
env->Enter();
const char* c_source = "\"1234\".length";
DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
SerializeTwice) {
if (!Snapshot::HaveASnapshotToStartFrom()) {
- v8::HandleScope scope(v8::Isolate::GetCurrent());
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
Deserialize();
- v8::Persistent<v8::Context> env = v8::Context::New();
+ v8::Local<v8::Context> env = v8::Context::New(isolate);
env->Enter();
const char* c_source = "\"1234\".length";
Isolate* isolate = Isolate::Current();
Heap* heap = isolate->heap();
- v8::Persistent<v8::Context> env = v8::Context::New();
+ v8::Persistent<v8::Context> env;
+ {
+ HandleScope scope(isolate);
+ env.Reset(v8::Isolate::GetCurrent(),
+ v8::Context::New(v8::Isolate::GetCurrent()));
+ }
ASSERT(!env.IsEmpty());
env->Enter();
// Make sure all builtin scripts are cached.
Isolate* isolate = Isolate::Current();
Heap* heap = isolate->heap();
- v8::Persistent<v8::Context> env = v8::Context::New();
+ v8::Persistent<v8::Context> env;
+ {
+ HandleScope scope(isolate);
+ env.Reset(v8::Isolate::GetCurrent(),
+ v8::Context::New(v8::Isolate::GetCurrent()));
+ }
ASSERT(!env.IsEmpty());
env->Enter();
// Make sure all builtin scripts are cached.