Commit d4fd9db3 authored by dcarney@chromium.org's avatar dcarney@chromium.org

fix nosnapshot test failure in 14793004, do not deprecate function

BUG=
TBR=svenpanne@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14585 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e5a29e8f
...@@ -168,7 +168,7 @@ bool JsHttpRequestProcessor::Initialize(map<string, string>* opts, ...@@ -168,7 +168,7 @@ bool JsHttpRequestProcessor::Initialize(map<string, string>* opts,
// is what we need for the reference to remain after we return from // is what we need for the reference to remain after we return from
// this method. That persistent handle has to be disposed in the // this method. That persistent handle has to be disposed in the
// destructor. // 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 // Enter the new context so all the following operations take place
// within it. // within it.
......
...@@ -1539,7 +1539,8 @@ void Shell::InitializeDebugger(Isolate* isolate) { ...@@ -1539,7 +1539,8 @@ void Shell::InitializeDebugger(Isolate* isolate) {
Locker lock(isolate); Locker lock(isolate);
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(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 #ifdef ENABLE_DEBUGGER_SUPPORT
// Start the debugger agent if requested. // Start the debugger agent if requested.
...@@ -1552,17 +1553,17 @@ void Shell::InitializeDebugger(Isolate* isolate) { ...@@ -1552,17 +1553,17 @@ void Shell::InitializeDebugger(Isolate* isolate) {
} }
Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) { Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
#ifndef V8_SHARED #ifndef V8_SHARED
// This needs to be a critical section since this is not thread-safe // This needs to be a critical section since this is not thread-safe
i::ScopedLock lock(context_mutex_); i::ScopedLock lock(context_mutex_);
#endif // V8_SHARED #endif // V8_SHARED
// Initialize the global objects // Initialize the global objects
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
Persistent<Context> context = Context::New(NULL, global_template);
ASSERT(!context.IsEmpty());
HandleScope handle_scope(isolate); 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 #ifndef V8_SHARED
i::JSArguments js_args = i::FLAG_js_arguments; i::JSArguments js_args = i::FLAG_js_arguments;
...@@ -1578,7 +1579,7 @@ Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) { ...@@ -1578,7 +1579,7 @@ Persistent<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
context->Global()->Set(String::New("arguments"), context->Global()->Set(String::New("arguments"),
Utils::ToLocal(arguments_jsarray)); Utils::ToLocal(arguments_jsarray));
#endif // V8_SHARED #endif // V8_SHARED
return context; return handle_scope.Close(context);
} }
...@@ -1809,9 +1810,9 @@ void ShellThread::Run() { ...@@ -1809,9 +1810,9 @@ void ShellThread::Run() {
// Prepare the context for this thread. // Prepare the context for this thread.
Locker locker(isolate_); Locker locker(isolate_);
HandleScope outer_scope(isolate_); HandleScope outer_scope(isolate_);
Persistent<Context> thread_context = Local<Context> thread_context =
Shell::CreateEvaluationContext(isolate_); Shell::CreateEvaluationContext(isolate_);
Context::Scope context_scope(isolate_, thread_context); Context::Scope context_scope(thread_context);
PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate_)); PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate_));
while ((ptr != NULL) && (*ptr != '\0')) { while ((ptr != NULL) && (*ptr != '\0')) {
...@@ -1833,7 +1834,6 @@ void ShellThread::Run() { ...@@ -1833,7 +1834,6 @@ void ShellThread::Run() {
Shell::ExecuteString(isolate_, str, String::New(filename), false, false); Shell::ExecuteString(isolate_, str, String::New(filename), false, false);
} }
thread_context.Dispose(thread_context->GetIsolate());
ptr = next_line; ptr = next_line;
} }
} }
...@@ -1910,15 +1910,16 @@ void SourceGroup::ExecuteInThread() { ...@@ -1910,15 +1910,16 @@ void SourceGroup::ExecuteInThread() {
{ {
Isolate::Scope iscope(isolate); Isolate::Scope iscope(isolate);
Locker lock(isolate); Locker lock(isolate);
HandleScope scope(isolate);
PerIsolateData data(isolate);
Persistent<Context> context = Shell::CreateEvaluationContext(isolate);
{ {
Context::Scope cscope(isolate, context); HandleScope scope(isolate);
PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); PerIsolateData data(isolate);
Execute(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) { if (Shell::options.send_idle_notification) {
const int kLongIdlePauseInMs = 1000; const int kLongIdlePauseInMs = 1000;
V8::ContextDisposedNotification(); V8::ContextDisposedNotification();
...@@ -2109,26 +2110,27 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) { ...@@ -2109,26 +2110,27 @@ int Shell::RunMain(Isolate* isolate, int argc, char* argv[]) {
#endif // V8_SHARED #endif // V8_SHARED
{ // NOLINT { // NOLINT
Locker lock(isolate); Locker lock(isolate);
HandleScope scope(isolate); {
Persistent<Context> context = CreateEvaluationContext(isolate); HandleScope scope(isolate);
if (options.last_run) { Local<Context> context = CreateEvaluationContext(isolate);
// Keep using the same context in the interactive shell. if (options.last_run) {
evaluation_context_ = context; // Keep using the same context in the interactive shell.
evaluation_context_.Reset(isolate, context);
#if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT) #if !defined(V8_SHARED) && defined(ENABLE_DEBUGGER_SUPPORT)
// If the interactive debugger is enabled make sure to activate // If the interactive debugger is enabled make sure to activate
// it before running the files passed on the command line. // it before running the files passed on the command line.
if (i::FLAG_debugger) { if (i::FLAG_debugger) {
InstallUtilityScript(isolate); InstallUtilityScript(isolate);
} }
#endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT #endif // !V8_SHARED && ENABLE_DEBUGGER_SUPPORT
} }
{ {
Context::Scope cscope(isolate, context); Context::Scope cscope(context);
PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate)); PerIsolateData::RealmScope realm_scope(PerIsolateData::Get(isolate));
options.isolate_sources[0].Execute(isolate); options.isolate_sources[0].Execute(isolate);
}
} }
if (!options.last_run) { if (!options.last_run) {
context.Dispose(isolate);
if (options.send_idle_notification) { if (options.send_idle_notification) {
const int kLongIdlePauseInMs = 1000; const int kLongIdlePauseInMs = 1000;
V8::ContextDisposedNotification(); V8::ContextDisposedNotification();
......
...@@ -273,7 +273,7 @@ class Shell : public i::AllStatic { ...@@ -273,7 +273,7 @@ class Shell : public i::AllStatic {
static const char* ToCString(const v8::String::Utf8Value& value); static const char* ToCString(const v8::String::Utf8Value& value);
static void ReportException(Isolate* isolate, TryCatch* try_catch); static void ReportException(Isolate* isolate, TryCatch* try_catch);
static Handle<String> ReadFile(Isolate* isolate, const char* name); 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 RunMain(Isolate* isolate, int argc, char* argv[]);
static int Main(int argc, char* argv[]); static int Main(int argc, char* argv[]);
static void Exit(int exit_code); static void Exit(int exit_code);
......
...@@ -328,13 +328,18 @@ int main(int argc, char** argv) { ...@@ -328,13 +328,18 @@ int main(int argc, char** argv) {
} }
#endif #endif
i::Serializer::Enable(); 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()) { if (context.IsEmpty()) {
fprintf(stderr, fprintf(stderr,
"\nException thrown while compiling natives - see above.\n\n"); "\nException thrown while compiling natives - see above.\n\n");
exit(1); exit(1);
} }
Isolate* isolate = context->GetIsolate();
if (i::FLAG_extra_code != NULL) { if (i::FLAG_extra_code != NULL) {
context->Enter(); context->Enter();
// Capture 100 frames if anything happens. // Capture 100 frames if anything happens.
......
...@@ -207,8 +207,14 @@ class LocalContext { ...@@ -207,8 +207,14 @@ class LocalContext {
LocalContext(v8::ExtensionConfiguration* extensions = 0, LocalContext(v8::ExtensionConfiguration* extensions = 0,
v8::Handle<v8::ObjectTemplate> global_template = v8::Handle<v8::ObjectTemplate> global_template =
v8::Handle<v8::ObjectTemplate>(), v8::Handle<v8::ObjectTemplate>(),
v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) {
: context_(v8::Context::New(extensions, global_template, global_object)) { v8::Isolate* isolate = v8::Isolate::GetCurrent();
HandleScope scope(isolate);
context_.Reset(isolate,
Context::New(isolate,
extensions,
global_template,
global_object));
context_->Enter(); context_->Enter();
// We can't do this later perhaps because of a fatal error. // We can't do this later perhaps because of a fatal error.
isolate_ = context_->GetIsolate(); isolate_ = context_->GetIsolate();
......
This diff is collapsed.
...@@ -136,12 +136,16 @@ class DebugLocalContext { ...@@ -136,12 +136,16 @@ class DebugLocalContext {
v8::Handle<v8::ObjectTemplate> global_template = v8::Handle<v8::ObjectTemplate> global_template =
v8::Handle<v8::ObjectTemplate>(), v8::Handle<v8::ObjectTemplate>(),
v8::Handle<v8::Value> global_object = v8::Handle<v8::Value>()) 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(); context_->Enter();
} }
inline ~DebugLocalContext() { inline ~DebugLocalContext() {
context_->Exit(); context_->Exit();
context_.Dispose(context_->GetIsolate());
} }
inline v8::Context* operator->() { return *context_; } inline v8::Context* operator->() { return *context_; }
inline v8::Context* operator*() { return *context_; } inline v8::Context* operator*() { return *context_; }
...@@ -166,7 +170,8 @@ class DebugLocalContext { ...@@ -166,7 +170,8 @@ class DebugLocalContext {
} }
private: private:
v8::Persistent<v8::Context> context_; v8::HandleScope scope_;
v8::Local<v8::Context> context_;
}; };
...@@ -4234,7 +4239,8 @@ static const char* kSimpleExtensionSource = ...@@ -4234,7 +4239,8 @@ static const char* kSimpleExtensionSource =
// http://crbug.com/28933 // http://crbug.com/28933
// Test that debug break is disabled when bootstrapper is active. // Test that debug break is disabled when bootstrapper is active.
TEST(NoBreakWhenBootstrapping) { 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. // Register a debug event listener which sets the break flag and counts.
v8::Debug::SetDebugEventListener(DebugEventCounter); v8::Debug::SetDebugEventListener(DebugEventCounter);
...@@ -4249,8 +4255,8 @@ TEST(NoBreakWhenBootstrapping) { ...@@ -4249,8 +4255,8 @@ TEST(NoBreakWhenBootstrapping) {
kSimpleExtensionSource)); kSimpleExtensionSource));
const char* extension_names[] = { "simpletest" }; const char* extension_names[] = { "simpletest" };
v8::ExtensionConfiguration extensions(1, extension_names); v8::ExtensionConfiguration extensions(1, extension_names);
v8::Persistent<v8::Context> context = v8::Context::New(&extensions); v8::HandleScope handle_scope(isolate);
context.Dispose(context->GetIsolate()); v8::Context::New(isolate, &extensions);
} }
// Check that no DebugBreak events occured during the context creation. // Check that no DebugBreak events occured during the context creation.
CHECK_EQ(0, break_point_hit_count); CHECK_EQ(0, break_point_hit_count);
...@@ -6235,7 +6241,7 @@ TEST(ScriptNameAndData) { ...@@ -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; static v8::Handle<v8::Value> expected_context_data;
...@@ -6293,7 +6299,7 @@ TEST(ContextData) { ...@@ -6293,7 +6299,7 @@ TEST(ContextData) {
// Enter and run function in the first context. // Enter and run function in the first context.
{ {
v8::Context::Scope context_scope(context_1); v8::Context::Scope context_scope(context_1);
expected_context = v8::Persistent<v8::Context>(*context_1); expected_context = context_1;
expected_context_data = data_1; expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(source, "f"); v8::Local<v8::Function> f = CompileFunction(source, "f");
f->Call(context_1->Global(), 0, NULL); f->Call(context_1->Global(), 0, NULL);
...@@ -6303,7 +6309,7 @@ TEST(ContextData) { ...@@ -6303,7 +6309,7 @@ TEST(ContextData) {
// Enter and run function in the second context. // Enter and run function in the second context.
{ {
v8::Context::Scope context_scope(context_2); v8::Context::Scope context_scope(context_2);
expected_context = v8::Persistent<v8::Context>(*context_2); expected_context = context_2;
expected_context_data = data_2; expected_context_data = data_2;
v8::Local<v8::Function> f = CompileFunction(source, "f"); v8::Local<v8::Function> f = CompileFunction(source, "f");
f->Call(context_2->Global(), 0, NULL); f->Call(context_2->Global(), 0, NULL);
...@@ -6454,7 +6460,7 @@ static void ExecuteScriptForContextCheck() { ...@@ -6454,7 +6460,7 @@ static void ExecuteScriptForContextCheck() {
// Enter and run function in the context. // Enter and run function in the context.
{ {
v8::Context::Scope context_scope(context_1); 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; expected_context_data = data_1;
v8::Local<v8::Function> f = CompileFunction(source, "f"); v8::Local<v8::Function> f = CompileFunction(source, "f");
f->Call(context_1->Global(), 0, NULL); f->Call(context_1->Global(), 0, NULL);
...@@ -6615,22 +6621,26 @@ TEST(ScriptCollectedEventContext) { ...@@ -6615,22 +6621,26 @@ TEST(ScriptCollectedEventContext) {
script_collected_message_count = 0; script_collected_message_count = 0;
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
{ // Scope for the DebugLocalContext. v8::Persistent<v8::Context> context;
DebugLocalContext env; {
v8::HandleScope scope(isolate);
context.Reset(isolate, v8::Context::New(isolate));
}
context->Enter();
// Request the loaded scripts to initialize the debugger script cache. // Request the loaded scripts to initialize the debugger script cache.
debug->GetLoadedScripts(); debug->GetLoadedScripts();
// Do garbage collection to ensure that only the script in this test will be // Do garbage collection to ensure that only the script in this test will be
// collected afterwards. // collected afterwards.
HEAP->CollectAllGarbage(Heap::kNoGCFlags); HEAP->CollectAllGarbage(Heap::kNoGCFlags);
v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
{ v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
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=2')"))->Run();
} context->Exit();
} context.Dispose(isolate);
// Do garbage collection to collect the script above which is no longer // Do garbage collection to collect the script above which is no longer
// referenced. // referenced.
...@@ -7089,15 +7099,14 @@ static void DebugEventContextChecker(const v8::Debug::EventDetails& details) { ...@@ -7089,15 +7099,14 @@ static void DebugEventContextChecker(const v8::Debug::EventDetails& details) {
// Check that event details contain context where debug event occured. // Check that event details contain context where debug event occured.
TEST(DebugEventContext) { 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); expected_callback_data = v8::Int32::New(2010);
v8::Debug::SetDebugEventListener2(DebugEventContextChecker, v8::Debug::SetDebugEventListener2(DebugEventContextChecker,
expected_callback_data); expected_callback_data);
expected_context = v8::Context::New(); expected_context = v8::Context::New(isolate);
v8::Context::Scope context_scope( v8::Context::Scope context_scope(expected_context);
v8::Isolate::GetCurrent(), expected_context);
v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run(); v8::Script::Compile(v8::String::New("(function(){debugger;})();"))->Run();
expected_context.Dispose(expected_context->GetIsolate());
expected_context.Clear(); expected_context.Clear();
v8::Debug::SetDebugEventListener(NULL); v8::Debug::SetDebugEventListener(NULL);
expected_context_data = v8::Handle<v8::Value>(); expected_context_data = v8::Handle<v8::Value>();
......
...@@ -118,7 +118,8 @@ DeclarationContext::DeclarationContext() ...@@ -118,7 +118,8 @@ DeclarationContext::DeclarationContext()
void DeclarationContext::InitializeIfNeeded() { void DeclarationContext::InitializeIfNeeded() {
if (is_initialized_) return; if (is_initialized_) return;
HandleScope scope(Isolate::GetCurrent()); Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
Local<FunctionTemplate> function = FunctionTemplate::New(); Local<FunctionTemplate> function = FunctionTemplate::New();
Local<Value> data = External::New(this); Local<Value> data = External::New(this);
GetHolder(function)->SetNamedPropertyHandler(&HandleGet, GetHolder(function)->SetNamedPropertyHandler(&HandleGet,
...@@ -126,10 +127,14 @@ void DeclarationContext::InitializeIfNeeded() { ...@@ -126,10 +127,14 @@ void DeclarationContext::InitializeIfNeeded() {
&HandleQuery, &HandleQuery,
0, 0, 0, 0,
data); data);
context_ = Context::New(0, function->InstanceTemplate(), Local<Value>()); context_.Reset(isolate,
Context::New(isolate,
0,
function->InstanceTemplate(),
Local<Value>()));
context_->Enter(); context_->Enter();
is_initialized_ = true; is_initialized_ = true;
PostInitializeContext(Local<Context>::New(Isolate::GetCurrent(), context_)); PostInitializeContext(Local<Context>::New(isolate, context_));
} }
...@@ -699,14 +704,14 @@ TEST(ExistsInHiddenPrototype) { ...@@ -699,14 +704,14 @@ TEST(ExistsInHiddenPrototype) {
class SimpleContext { class SimpleContext {
public: public:
SimpleContext() { SimpleContext()
context_ = Context::New(); : handle_scope_(Isolate::GetCurrent()),
context_(Context::New(Isolate::GetCurrent())) {
context_->Enter(); context_->Enter();
} }
virtual ~SimpleContext() { ~SimpleContext() {
context_->Exit(); context_->Exit();
context_.Dispose(context_->GetIsolate());
} }
void Check(const char* source, void Check(const char* source,
...@@ -737,7 +742,8 @@ class SimpleContext { ...@@ -737,7 +742,8 @@ class SimpleContext {
} }
private: private:
Persistent<Context> context_; HandleScope handle_scope_;
Local<Context> context_;
}; };
......
...@@ -47,8 +47,6 @@ using namespace v8::internal; ...@@ -47,8 +47,6 @@ using namespace v8::internal;
typedef uint32_t (*HASH_FUNCTION)(); typedef uint32_t (*HASH_FUNCTION)();
static v8::Persistent<v8::Context> env;
#define __ masm-> #define __ masm->
...@@ -235,7 +233,10 @@ static uint32_t PseudoRandom(uint32_t i, uint32_t j) { ...@@ -235,7 +233,10 @@ static uint32_t PseudoRandom(uint32_t i, uint32_t j) {
TEST(StringHash) { 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++) { for (uint8_t a = 0; a < String::kMaxOneByteCharCode; a++) {
// Numbers are hashed differently. // Numbers are hashed differently.
if (a >= '0' && a <= '9') continue; if (a >= '0' && a <= '9') continue;
...@@ -253,7 +254,9 @@ TEST(StringHash) { ...@@ -253,7 +254,9 @@ TEST(StringHash) {
TEST(NumberHash) { 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 // Some specific numbers
for (uint32_t key = 0; key < 42; key += 7) { for (uint32_t key = 0; key < 42; key += 7) {
......
...@@ -1661,9 +1661,15 @@ static int NumberOfGlobalObjects() { ...@@ -1661,9 +1661,15 @@ static int NumberOfGlobalObjects() {
// optimized code. // optimized code.
TEST(LeakNativeContextViaMap) { TEST(LeakNativeContextViaMap) {
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Persistent<v8::Context> ctx1 = v8::Context::New(); v8::HandleScope outer_scope(isolate);
v8::Persistent<v8::Context> ctx2 = v8::Context::New(); 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(); ctx1->Enter();
HEAP->CollectAllAvailableGarbage(); HEAP->CollectAllAvailableGarbage();
...@@ -1699,9 +1705,15 @@ TEST(LeakNativeContextViaMap) { ...@@ -1699,9 +1705,15 @@ TEST(LeakNativeContextViaMap) {
// optimized code. // optimized code.
TEST(LeakNativeContextViaFunction) { TEST(LeakNativeContextViaFunction) {
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Persistent<v8::Context> ctx1 = v8::Context::New(); v8::HandleScope outer_scope(isolate);
v8::Persistent<v8::Context> ctx2 = v8::Context::New(); 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(); ctx1->Enter();
HEAP->CollectAllAvailableGarbage(); HEAP->CollectAllAvailableGarbage();
...@@ -1735,9 +1747,15 @@ TEST(LeakNativeContextViaFunction) { ...@@ -1735,9 +1747,15 @@ TEST(LeakNativeContextViaFunction) {
TEST(LeakNativeContextViaMapKeyed) { TEST(LeakNativeContextViaMapKeyed) {
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Persistent<v8::Context> ctx1 = v8::Context::New(); v8::HandleScope outer_scope(isolate);
v8::Persistent<v8::Context> ctx2 = v8::Context::New(); 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(); ctx1->Enter();
HEAP->CollectAllAvailableGarbage(); HEAP->CollectAllAvailableGarbage();
...@@ -1771,9 +1789,15 @@ TEST(LeakNativeContextViaMapKeyed) { ...@@ -1771,9 +1789,15 @@ TEST(LeakNativeContextViaMapKeyed) {
TEST(LeakNativeContextViaMapProto) { TEST(LeakNativeContextViaMapProto) {
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Persistent<v8::Context> ctx1 = v8::Context::New(); v8::HandleScope outer_scope(isolate);
v8::Persistent<v8::Context> ctx2 = v8::Context::New(); 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(); ctx1->Enter();
HEAP->CollectAllAvailableGarbage(); HEAP->CollectAllAvailableGarbage();
......
...@@ -622,15 +622,14 @@ TEST(LockUnlockLockDefaultIsolateMultithreaded) { ...@@ -622,15 +622,14 @@ TEST(LockUnlockLockDefaultIsolateMultithreaded) {
#else #else
const int kNThreads = 100; const int kNThreads = 100;
#endif #endif
Persistent<v8::Context> context; Local<v8::Context> context;
i::List<JoinableThread*> threads(kNThreads); i::List<JoinableThread*> threads(kNThreads);
{ {
v8::Locker locker_(CcTest::default_isolate()); v8::Locker locker_(CcTest::default_isolate());
v8::HandleScope handle_scope(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++) { for (int i = 0; i < kNThreads; i++) {
threads.Add(new LockUnlockLockDefaultIsolateThread( threads.Add(new LockUnlockLockDefaultIsolateThread(context));
v8::Local<v8::Context>::New(CcTest::default_isolate(), context)));
} }
} }
StartJoinAndDeleteThreads(threads); StartJoinAndDeleteThreads(threads);
...@@ -675,9 +674,9 @@ class IsolateGenesisThread : public JoinableThread { ...@@ -675,9 +674,9 @@ class IsolateGenesisThread : public JoinableThread {
v8::Isolate::Scope isolate_scope(isolate); v8::Isolate::Scope isolate_scope(isolate);
CHECK(!i::Isolate::Current()->has_installed_extensions()); CHECK(!i::Isolate::Current()->has_installed_extensions());
v8::ExtensionConfiguration extensions(count_, extension_names_); 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()); CHECK(i::Isolate::Current()->has_installed_extensions());
context.Dispose(isolate);
} }
isolate->Dispose(); isolate->Dispose();
} }
......
...@@ -67,7 +67,7 @@ class ScopedLoggerInitializer { ...@@ -67,7 +67,7 @@ class ScopedLoggerInitializer {
// Need to run this prior to creating the scope. // Need to run this prior to creating the scope.
trick_to_run_init_flags_(init_flags_(prof_lazy)), trick_to_run_init_flags_(init_flags_(prof_lazy)),
scope_(v8::Isolate::GetCurrent()), scope_(v8::Isolate::GetCurrent()),
env_(*v8::Context::New()), env_(v8::Context::New(v8::Isolate::GetCurrent())),
logger_(i::Isolate::Current()->logger()) { logger_(i::Isolate::Current()->logger()) {
env_->Enter(); env_->Enter();
} }
......
...@@ -176,9 +176,10 @@ class ScriptResource : public v8::String::ExternalAsciiStringResource { ...@@ -176,9 +176,10 @@ class ScriptResource : public v8::String::ExternalAsciiStringResource {
TEST(Preparsing) { TEST(Preparsing) {
v8::HandleScope handles(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Persistent<v8::Context> context = v8::Context::New(); v8::HandleScope handles(isolate);
v8::Context::Scope context_scope(v8::Isolate::GetCurrent(), context); v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
int marker; int marker;
i::Isolate::Current()->stack_guard()->SetStackLimit( i::Isolate::Current()->stack_guard()->SetStackLimit(
reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
...@@ -542,9 +543,10 @@ void TestCharacterStream(const char* ascii_source, ...@@ -542,9 +543,10 @@ void TestCharacterStream(const char* ascii_source,
TEST(CharacterStreams) { TEST(CharacterStreams) {
v8::HandleScope handles(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Persistent<v8::Context> context = v8::Context::New(); v8::HandleScope handles(isolate);
v8::Context::Scope context_scope(v8::Isolate::GetCurrent(), context); v8::Local<v8::Context> context = v8::Context::New(isolate);
v8::Context::Scope context_scope(context);
TestCharacterStream("abc\0\n\r\x7f", 7); TestCharacterStream("abc\0\n\r\x7f", 7);
static const unsigned kBigStringSize = 4096; static const unsigned kBigStringSize = 4096;
......
...@@ -855,7 +855,6 @@ v8::Handle<v8::Value> ProfilerExtension::StopProfiling( ...@@ -855,7 +855,6 @@ v8::Handle<v8::Value> ProfilerExtension::StopProfiling(
static ProfilerExtension kProfilerExtension; static ProfilerExtension kProfilerExtension;
v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension); v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
static v8::Persistent<v8::Context> env;
static const ProfileNode* PickChild(const ProfileNode* parent, static const ProfileNode* PickChild(const ProfileNode* parent,
const char* name) { const char* name) {
...@@ -872,14 +871,12 @@ TEST(RecordStackTraceAtStartProfiling) { ...@@ -872,14 +871,12 @@ TEST(RecordStackTraceAtStartProfiling) {
// don't appear in the stack trace. // don't appear in the stack trace.
i::FLAG_use_inlining = false; i::FLAG_use_inlining = false;
if (env.IsEmpty()) { v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(v8::Isolate::GetCurrent()); v8::HandleScope scope(isolate);
const char* extensions[] = { "v8/profiler" }; const char* extensions[] = { "v8/profiler" };
v8::ExtensionConfiguration config(1, extensions); v8::ExtensionConfiguration config(1, extensions);
env = v8::Context::New(&config); v8::Local<v8::Context> context = v8::Context::New(isolate);
} context->Enter();
v8::HandleScope scope(v8::Isolate::GetCurrent());
(*env)->Enter();
CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
CHECK_EQ(0, profiler->GetProfilesCount()); CHECK_EQ(0, profiler->GetProfilesCount());
......
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
using namespace v8::internal; using namespace v8::internal;
static v8::Persistent<v8::Context> env;
void SetSeeds(Handle<ByteArray> seeds, uint32_t state0, uint32_t state1) { void SetSeeds(Handle<ByteArray> seeds, uint32_t state0, uint32_t state1) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
...@@ -73,11 +71,12 @@ void TestSeeds(Handle<JSFunction> fun, ...@@ -73,11 +71,12 @@ void TestSeeds(Handle<JSFunction> fun,
TEST(CrankshaftRandom) { TEST(CrankshaftRandom) {
if (env.IsEmpty()) env = v8::Context::New(); v8::V8::Initialize();
// Skip test if crankshaft is disabled. // Skip test if crankshaft is disabled.
if (!V8::UseCrankshaft()) return; if (!V8::UseCrankshaft()) return;
v8::HandleScope scope(env->GetIsolate()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
env->Enter(); v8::HandleScope scope(isolate);
v8::Context::Scope context_scope(v8::Context::New(isolate));
Handle<Context> context(Isolate::Current()->context()); Handle<Context> context(Isolate::Current()->context());
Handle<JSObject> global(context->global_object()); Handle<JSObject> global(context->global_object());
......
...@@ -711,19 +711,17 @@ typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler; ...@@ -711,19 +711,17 @@ typedef RegExpMacroAssemblerMIPS ArchRegExpMacroAssembler;
class ContextInitializer { class ContextInitializer {
public: public:
ContextInitializer() 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) { zone_(Isolate::Current()->runtime_zone(), DELETE_ON_EXIT) {
env_ = v8::Context::New();
env_->Enter(); env_->Enter();
} }
~ContextInitializer() { ~ContextInitializer() {
env_->Exit(); env_->Exit();
env_.Dispose(env_->GetIsolate());
} }
private: private:
v8::Persistent<v8::Context> env_;
v8::HandleScope scope_; v8::HandleScope scope_;
v8::Handle<v8::Context> env_;
v8::internal::ZoneScope zone_; v8::internal::ZoneScope zone_;
}; };
......
...@@ -251,8 +251,11 @@ static void Serialize() { ...@@ -251,8 +251,11 @@ static void Serialize() {
// can be loaded from v8natives.js and their addresses can be processed. This // 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 // will clear the pending fixups array, which would otherwise contain GC roots
// that would confuse the serialization/deserialization process. // 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); WriteToFile(FLAG_testing_serialization_file);
} }
...@@ -304,10 +307,11 @@ DEPENDENT_TEST(Deserialize, Serialize) { ...@@ -304,10 +307,11 @@ DEPENDENT_TEST(Deserialize, Serialize) {
// serialization. That doesn't matter. We don't need to be able to // 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. // serialize a snapshot in a VM that is booted from a snapshot.
if (!Snapshot::HaveASnapshotToStartFrom()) { if (!Snapshot::HaveASnapshotToStartFrom()) {
v8::HandleScope scope(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
Deserialize(); Deserialize();
v8::Persistent<v8::Context> env = v8::Context::New(); v8::Local<v8::Context> env = v8::Context::New(isolate);
env->Enter(); env->Enter();
SanityCheck(); SanityCheck();
...@@ -317,10 +321,11 @@ DEPENDENT_TEST(Deserialize, Serialize) { ...@@ -317,10 +321,11 @@ DEPENDENT_TEST(Deserialize, Serialize) {
DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) {
if (!Snapshot::HaveASnapshotToStartFrom()) { if (!Snapshot::HaveASnapshotToStartFrom()) {
v8::HandleScope scope(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
Deserialize(); Deserialize();
v8::Persistent<v8::Context> env = v8::Context::New(); v8::Local<v8::Context> env = v8::Context::New(isolate);
env->Enter(); env->Enter();
SanityCheck(); SanityCheck();
...@@ -330,10 +335,11 @@ DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) { ...@@ -330,10 +335,11 @@ DEPENDENT_TEST(DeserializeFromSecondSerialization, SerializeTwice) {
DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
if (!Snapshot::HaveASnapshotToStartFrom()) { if (!Snapshot::HaveASnapshotToStartFrom()) {
v8::HandleScope scope(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
Deserialize(); Deserialize();
v8::Persistent<v8::Context> env = v8::Context::New(); v8::Local<v8::Context> env = v8::Context::New(isolate);
env->Enter(); env->Enter();
const char* c_source = "\"1234\".length"; const char* c_source = "\"1234\".length";
...@@ -347,10 +353,11 @@ DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { ...@@ -347,10 +353,11 @@ DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
SerializeTwice) { SerializeTwice) {
if (!Snapshot::HaveASnapshotToStartFrom()) { if (!Snapshot::HaveASnapshotToStartFrom()) {
v8::HandleScope scope(v8::Isolate::GetCurrent()); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
Deserialize(); Deserialize();
v8::Persistent<v8::Context> env = v8::Context::New(); v8::Local<v8::Context> env = v8::Context::New(isolate);
env->Enter(); env->Enter();
const char* c_source = "\"1234\".length"; const char* c_source = "\"1234\".length";
...@@ -368,7 +375,12 @@ TEST(PartialSerialization) { ...@@ -368,7 +375,12 @@ TEST(PartialSerialization) {
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
Heap* heap = isolate->heap(); 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()); ASSERT(!env.IsEmpty());
env->Enter(); env->Enter();
// Make sure all builtin scripts are cached. // Make sure all builtin scripts are cached.
...@@ -502,7 +514,12 @@ TEST(ContextSerialization) { ...@@ -502,7 +514,12 @@ TEST(ContextSerialization) {
Isolate* isolate = Isolate::Current(); Isolate* isolate = Isolate::Current();
Heap* heap = isolate->heap(); 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()); ASSERT(!env.IsEmpty());
env->Enter(); env->Enter();
// Make sure all builtin scripts are cached. // 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