Commit 386de801 authored by dcarney@chromium.org's avatar dcarney@chromium.org

deprecate Context::New which returns Persistent

BUG=
TBR=marja@chromium.org

Review URL: https://codereview.chromium.org/14793004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14573 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d898bded
......@@ -4609,11 +4609,11 @@ class V8EXPORT Context {
Handle<Value> global_object = Handle<Value>());
/** Deprecated. Use Isolate version instead. */
// TODO(mstarzinger): Put this behind the V8_DEPRECATED guard.
static Persistent<Context> New(
ExtensionConfiguration* extensions = NULL,
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
Handle<Value> global_object = Handle<Value>());
V8_DEPRECATED(
static Persistent<Context> New(
ExtensionConfiguration* extensions = NULL,
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
Handle<Value> global_object = Handle<Value>()));
/** Returns the last entered context. */
static Local<Context> GetEntered();
......
......@@ -168,7 +168,7 @@ bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
// 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.
......
......@@ -1539,7 +1539,8 @@ void Shell::InitializeDebugger(Isolate* isolate) {
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.
......@@ -1552,17 +1553,17 @@ void Shell::InitializeDebugger(Isolate* isolate) {
}
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;
......@@ -1578,7 +1579,7 @@ Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
context->Global()->Set(String::New("arguments"),
Utils::ToLocal(arguments_jsarray));
#endif // V8_SHARED
return context;
return handle_scope.Close(context);
}
......@@ -1809,9 +1810,9 @@ void ShellThread::Run() {
// 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')) {
......@@ -1833,7 +1834,6 @@ void ShellThread::Run() {
Shell::ExecuteString(isolate_, str, String::New(filename), false, false);
}
thread_context.Dispose(thread_context->GetIsolate());
ptr = next_line;
}
}
......@@ -1910,15 +1910,16 @@ void SourceGroup::ExecuteInThread() {
{
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();
......@@ -2109,26 +2110,27 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
#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();
......
......@@ -273,7 +273,7 @@ class Shell : public i::AllStatic {
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);
......
......@@ -328,13 +328,18 @@ int main(int argc, char** argv) {
}
#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.
......
......@@ -207,8 +207,14 @@ class LocalContext {
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();
......
This diff is collapsed.
......@@ -136,12 +136,16 @@ class DebugLocalContext {
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_; }
......@@ -166,7 +170,8 @@ class DebugLocalContext {
}
private:
v8::Persistent<v8::Context> context_;
v8::HandleScope scope_;
v8::Local<v8::Context> context_;
};
......@@ -4234,7 +4239,8 @@ static const char* kSimpleExtensionSource =
// 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);
......@@ -4249,8 +4255,8 @@ TEST(NoBreakWhenBootstrapping) {
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);
......@@ -6235,7 +6241,7 @@ TEST(ScriptNameAndData) {
}
static v8::Persistent<v8::Context> expected_context;
static v8::Handle<v8::Context> expected_context;
static v8::Handle<v8::Value> expected_context_data;
......@@ -6293,7 +6299,7 @@ TEST(ContextData) {
// 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);
......@@ -6303,7 +6309,7 @@ TEST(ContextData) {
// 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);
......@@ -6454,7 +6460,7 @@ static void ExecuteScriptForContextCheck() {
// 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);
......@@ -6613,7 +6619,6 @@ TEST(ScriptCollectedEventContext) {
v8::internal::Debug* debug =
reinterpret_cast<v8::internal::Isolate*>(isolate)->debug();
script_collected_message_count = 0;
v8::HandleScope scope(isolate);
{ // Scope for the DebugLocalContext.
DebugLocalContext env;
......@@ -6626,17 +6631,15 @@ TEST(ScriptCollectedEventContext) {
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::Script::Compile(v8::String::New("eval('a=1')"))->Run();
v8::Script::Compile(v8::String::New("eval('a=2')"))->Run();
}
// Do garbage collection to collect the script above which is no longer
// referenced.
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CHECK_EQ(2, script_collected_message_count);
CHECK_EQ(4, script_collected_message_count);
v8::Debug::SetMessageHandler2(NULL);
}
......@@ -7089,15 +7092,14 @@ static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
// 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>();
......
......@@ -118,7 +118,8 @@ DeclarationContext::DeclarationContext()
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,
......@@ -126,10 +127,14 @@ void DeclarationContext::InitializeIfNeeded() {
&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_));
}
......@@ -699,14 +704,14 @@ TEST(ExistsInHiddenPrototype) {
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,
......@@ -737,7 +742,8 @@ class SimpleContext {
}
private:
Persistent<Context> context_;
HandleScope handle_scope_;
Local<Context> context_;
};
......
......@@ -47,8 +47,6 @@ using namespace v8::internal;
typedef uint32_t (*HASH_FUNCTION)();
static v8::Persistent<v8::Context> env;
#define __ masm->
......@@ -235,7 +233,10 @@ static uint32_t PseudoRandom(uint32_t i, uint32_t j) {
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;
......@@ -253,7 +254,9 @@ TEST(StringHash) {
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) {
......
......@@ -1661,9 +1661,15 @@ static int NumberOfGlobalObjects() {
// 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();
......@@ -1699,9 +1705,15 @@ TEST(LeakNativeContextViaMap) {
// 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();
......@@ -1735,9 +1747,15 @@ TEST(LeakNativeContextViaFunction) {
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();
......@@ -1771,9 +1789,15 @@ TEST(LeakNativeContextViaMapKeyed) {
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();
......
......@@ -622,15 +622,14 @@ TEST(LockUnlockLockDefaultIsolateMultithreaded) {
#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);
......@@ -675,9 +674,9 @@ class IsolateGenesisThread : public JoinableThread {
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();
}
......
......@@ -67,7 +67,7 @@ class ScopedLoggerInitializer {
// 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();
}
......
......@@ -176,9 +176,10 @@ class ScriptResource : public v8::String::ExternalAsciiStringResource {
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);
......@@ -542,9 +543,10 @@ void TestCharacterStream(const char* ascii_source,
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;
......
......@@ -855,7 +855,6 @@ v8::Handle<v8::Value> ProfilerExtension::StopProfiling(
static ProfilerExtension kProfilerExtension;
v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
static v8::Persistent<v8::Context> env;
static const ProfileNode* PickChild(const ProfileNode* parent,
const char* name) {
......@@ -872,14 +871,12 @@ TEST(RecordStackTraceAtStartProfiling) {
// 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());
......
......@@ -39,8 +39,6 @@
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++) {
......@@ -73,11 +71,12 @@ void TestSeeds(Handle<JSFunction> fun,
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());
......
......@@ -711,19 +711,17 @@ typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler;
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_;
};
......
......@@ -251,8 +251,11 @@ static void Serialize() {
// 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);
}
......@@ -304,10 +307,11 @@ DEPENDENT_TEST(Deserialize, Serialize) {
// 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();
......@@ -317,10 +321,11 @@ DEPENDENT_TEST(Deserialize, Serialize) {
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();
......@@ -330,10 +335,11 @@ DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) {
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";
......@@ -347,10 +353,11 @@ DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
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";
......@@ -368,7 +375,12 @@ TEST(PartialSerialization) {
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.
......@@ -502,7 +514,12 @@ TEST(ContextSerialization) {
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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment