Revision: 16877
Author: [email protected]
Date: Mon Sep 23 11:25:52 2013 UTC
Log: remove Isolate::GetCurrent from Context api functions
[email protected]
BUG=
Review URL: https://codereview.chromium.org/24345003
http://code.google.com/p/v8/source/detail?r=16877
Modified:
/branches/bleeding_edge/include/v8.h
/branches/bleeding_edge/samples/lineprocessor.cc
/branches/bleeding_edge/src/api.cc
/branches/bleeding_edge/src/api.h
/branches/bleeding_edge/src/d8.cc
/branches/bleeding_edge/test/cctest/cctest.h
/branches/bleeding_edge/test/cctest/test-api.cc
/branches/bleeding_edge/test/cctest/test-debug.cc
/branches/bleeding_edge/test/cctest/test-heap.cc
/branches/bleeding_edge/test/cctest/test-object-observe.cc
=======================================
--- /branches/bleeding_edge/include/v8.h Tue Sep 17 12:37:22 2013 UTC
+++ /branches/bleeding_edge/include/v8.h Mon Sep 23 11:25:52 2013 UTC
@@ -4018,9 +4018,22 @@
*/
CpuProfiler* GetCpuProfiler();
+ /** Returns true if this isolate has a current context. */
+ bool InContext();
+
/** Returns the context that is on the top of the stack. */
Local<Context> GetCurrentContext();
+ /**
+ * Returns the context of the calling JavaScript code. That is the
+ * context of the top-most JavaScript frame. If there are no
+ * JavaScript frames an empty handle is returned.
+ */
+ Local<Context> GetCallingContext();
+
+ /** Returns the last entered context. */
+ Local<Context> GetEnteredContext();
+
/**
* Allows the host application to group objects together. If one
* object in the group is alive, all objects in the group are alive.
@@ -4923,24 +4936,16 @@
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
Handle<Value> global_object = Handle<Value>());
- /** Deprecated. Use Isolate version instead. */
- 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. */
+ // TODO(dcarney): Remove this function.
+ /** Deprecated. Use Isolate::GetEnteredContext */
static Local<Context> GetEntered();
- // TODO(svenpanne) Actually deprecate this.
+ // TODO(dcarney) Remove this function.
/** Deprecated. Use Isolate::GetCurrentContext instead. */
static Local<Context> GetCurrent();
- /**
- * Returns the context of the calling JavaScript code. That is the
- * context of the top-most JavaScript frame. If there are no
- * JavaScript frames an empty handle is returned.
- */
+ // TODO(dcarney) Remove this function.
+ /** Deprecated. Use Isolate::GetCallingContext instead. */
static Local<Context> GetCalling();
/**
@@ -4972,7 +4977,8 @@
/** Returns true if the context has experienced an out of memory
situation. */
bool HasOutOfMemoryException();
- /** Returns true if V8 has a current context. */
+ // TODO(dcarney) Remove this function.
+ /** Deprecated. Use Isolate::InContext instead. */
static bool InContext();
/** Returns an isolate associated with a current context. */
=======================================
--- /branches/bleeding_edge/samples/lineprocessor.cc Thu Jul 11 09:58:54
2013 UTC
+++ /branches/bleeding_edge/samples/lineprocessor.cc Mon Sep 23 11:25:52
2013 UTC
@@ -259,7 +259,7 @@
if (cycle_type == CycleInCpp) {
bool res = RunCppCycle(script,
- v8::Context::GetCurrent(),
+ isolate->GetCurrentContext(),
report_exceptions);
return !res;
} else {
@@ -306,7 +306,7 @@
v8::Handle<v8::Value> result;
{
v8::TryCatch try_catch;
- result = process_fun->Call(v8::Context::GetCurrent()->Global(),
+ result = process_fun->Call(isolate->GetCurrentContext()->Global(),
argc, argv);
if (try_catch.HasCaught()) {
if (report_exceptions)
=======================================
--- /branches/bleeding_edge/src/api.cc Thu Sep 19 07:33:45 2013 UTC
+++ /branches/bleeding_edge/src/api.cc Mon Sep 23 11:25:52 2013 UTC
@@ -750,29 +750,22 @@
void Context::Enter() {
i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Isolate* isolate = env->GetIsolate();
- if (IsDeadCheck(isolate, "v8::Context::Enter()")) return;
ENTER_V8(isolate);
-
isolate->handle_scope_implementer()->EnterContext(env);
-
isolate->handle_scope_implementer()->SaveContext(isolate->context());
isolate->set_context(*env);
}
void Context::Exit() {
- // Exit is essentially a static function and doesn't use the
- // receiver, so we have to get the current isolate from the thread
- // local.
- i::Isolate* isolate = i::Isolate::Current();
- if (!isolate->IsInitialized()) return;
-
- if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(),
+ i::Handle<i::Context> context = Utils::OpenHandle(this);
+ i::Isolate* isolate = context->GetIsolate();
+ ENTER_V8(isolate);
+ if (!ApiCheck(isolate->handle_scope_implementer()->LeaveContext(context),
"v8::Context::Exit()",
"Cannot exit non-entered context")) {
return;
}
-
// Content of 'last_context' could be NULL.
i::Context* last_context =
isolate->handle_scope_implementer()->RestoreContext();
@@ -5494,11 +5487,7 @@
if (!EnsureInitializedForIsolate(isolate, "v8::Context::GetEntered()")) {
return Local<Context>();
}
- i::Handle<i::Object> last =
- isolate->handle_scope_implementer()->LastEnteredContext();
- if (last.is_null()) return Local<Context>();
- i::Handle<i::Context> context = i::Handle<i::Context>::cast(last);
- return Utils::ToLocal(context);
+ return reinterpret_cast<Isolate*>(isolate)->GetEnteredContext();
}
@@ -5516,45 +5505,30 @@
if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) {
return Local<Context>();
}
- i::Handle<i::Object> calling =
- isolate->GetCallingNativeContext();
- if (calling.is_null()) return Local<Context>();
- i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling);
- return Utils::ToLocal(context);
+ return reinterpret_cast<Isolate*>(isolate)->GetCallingContext();
}
v8::Local<v8::Object> Context::Global() {
- i::Isolate* isolate = i::Isolate::Current();
- if (IsDeadCheck(isolate, "v8::Context::Global()")) {
- return Local<v8::Object>();
- }
- i::Object** ctx = reinterpret_cast<i::Object**>(this);
- i::Handle<i::Context> context =
- i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
+ i::Handle<i::Context> context = Utils::OpenHandle(this);
+ i::Isolate* isolate = context->GetIsolate();
i::Handle<i::Object> global(context->global_proxy(), isolate);
return Utils::ToLocal(i::Handle<i::JSObject>::cast(global));
}
void Context::DetachGlobal() {
- i::Isolate* isolate = i::Isolate::Current();
- if (IsDeadCheck(isolate, "v8::Context::DetachGlobal()")) return;
+ i::Handle<i::Context> context = Utils::OpenHandle(this);
+ i::Isolate* isolate = context->GetIsolate();
ENTER_V8(isolate);
- i::Object** ctx = reinterpret_cast<i::Object**>(this);
- i::Handle<i::Context> context =
- i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
isolate->bootstrapper()->DetachGlobal(context);
}
void Context::ReattachGlobal(Handle<Object> global_object) {
- i::Isolate* isolate = i::Isolate::Current();
- if (IsDeadCheck(isolate, "v8::Context::ReattachGlobal()")) return;
+ i::Handle<i::Context> context = Utils::OpenHandle(this);
+ i::Isolate* isolate = context->GetIsolate();
ENTER_V8(isolate);
- i::Object** ctx = reinterpret_cast<i::Object**>(this);
- i::Handle<i::Context> context =
- i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
i::Handle<i::JSGlobalProxy> global_proxy =
i::Handle<i::JSGlobalProxy>::cast(Utils::OpenHandle(*global_object));
isolate->bootstrapper()->ReattachGlobal(context, global_proxy);
@@ -5562,44 +5536,23 @@
void Context::AllowCodeGenerationFromStrings(bool allow) {
- i::Isolate* isolate = i::Isolate::Current();
- if
(IsDeadCheck(isolate, "v8::Context::AllowCodeGenerationFromStrings()")) {
- return;
- }
+ i::Handle<i::Context> context = Utils::OpenHandle(this);
+ i::Isolate* isolate = context->GetIsolate();
ENTER_V8(isolate);
- i::Object** ctx = reinterpret_cast<i::Object**>(this);
- i::Handle<i::Context> context =
- i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
context->set_allow_code_gen_from_strings(
allow ? isolate->heap()->true_value() :
isolate->heap()->false_value());
}
bool Context::IsCodeGenerationFromStringsAllowed() {
- i::Isolate* isolate = i::Isolate::Current();
- if (IsDeadCheck(isolate,
- "v8::Context::IsCodeGenerationFromStringsAllowed()")) {
- return false;
- }
- ENTER_V8(isolate);
- i::Object** ctx = reinterpret_cast<i::Object**>(this);
- i::Handle<i::Context> context =
- i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
+ i::Handle<i::Context> context = Utils::OpenHandle(this);
return !context->allow_code_gen_from_strings()->IsFalse();
}
void Context::SetErrorMessageForCodeGenerationFromStrings(
Handle<String> error) {
- i::Isolate* isolate = i::Isolate::Current();
- if (IsDeadCheck(isolate,
- "v8::Context::SetErrorMessageForCodeGenerationFromStrings()")) {
- return;
- }
- ENTER_V8(isolate);
- i::Object** ctx = reinterpret_cast<i::Object**>(this);
- i::Handle<i::Context> context =
- i::Handle<i::Context>::cast(i::Handle<i::Object>(ctx));
+ i::Handle<i::Context> context = Utils::OpenHandle(this);
i::Handle<i::String> error_handle = Utils::OpenHandle(*error);
context->set_error_message_for_code_gen_from_strings(*error_handle);
}
@@ -6645,16 +6598,39 @@
reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
return reinterpret_cast<CpuProfiler*>(cpu_profiler);
}
+
+
+bool Isolate::InContext() {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ return isolate->context() != NULL;
+}
v8::Local<v8::Context> Isolate::GetCurrentContext() {
- i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
- i::Context* context = internal_isolate->context();
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ i::Context* context = isolate->context();
if (context == NULL) return Local<Context>();
i::Context* native_context = context->global_object()->native_context();
if (native_context == NULL) return Local<Context>();
return Utils::ToLocal(i::Handle<i::Context>(native_context));
}
+
+
+v8::Local<v8::Context> Isolate::GetCallingContext() {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ i::Handle<i::Object> calling = isolate->GetCallingNativeContext();
+ if (calling.is_null()) return Local<Context>();
+ return Utils::ToLocal(i::Handle<i::Context>::cast(calling));
+}
+
+
+v8::Local<v8::Context> Isolate::GetEnteredContext() {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+ i::Handle<i::Object> last =
+ isolate->handle_scope_implementer()->LastEnteredContext();
+ if (last.is_null()) return Local<Context>();
+ return Utils::ToLocal(i::Handle<i::Context>::cast(last));
+}
void Isolate::SetObjectGroupId(const Persistent<Value>& object,
=======================================
--- /branches/bleeding_edge/src/api.h Mon Sep 2 09:27:27 2013 UTC
+++ /branches/bleeding_edge/src/api.h Mon Sep 23 11:25:52 2013 UTC
@@ -543,7 +543,7 @@
inline bool CallDepthIsZero() { return call_depth_ == 0; }
inline void EnterContext(Handle<Object> context);
- inline bool LeaveLastContext();
+ inline bool LeaveContext(Handle<Object> context);
// Returns the last entered context or an empty handle if no
// contexts have been entered.
@@ -635,8 +635,10 @@
}
-bool HandleScopeImplementer::LeaveLastContext() {
+bool HandleScopeImplementer::LeaveContext(Handle<Object> context) {
if (entered_contexts_.is_empty()) return false;
+ // TODO(dcarney): figure out what's wrong here
+ // if (*entered_contexts_.last() != *context) return false;
entered_contexts_.RemoveLast();
return true;
}
=======================================
--- /branches/bleeding_edge/src/d8.cc Tue Sep 17 13:48:17 2013 UTC
+++ /branches/bleeding_edge/src/d8.cc Mon Sep 23 11:25:52 2013 UTC
@@ -263,7 +263,8 @@
data_->realm_current_ = 0;
data_->realm_switch_ = 0;
data_->realms_ = new Persistent<Context>[1];
- data_->realms_[0].Reset(data_->isolate_, Context::GetEntered());
+ data_->realms_[0].Reset(data_->isolate_,
+ data_->isolate_->GetEnteredContext());
data_->realm_shared_.Clear();
}
@@ -290,7 +291,7 @@
void Shell::RealmCurrent(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
PerIsolateData* data = PerIsolateData::Get(isolate);
- int index = data->RealmFind(Context::GetEntered());
+ int index = data->RealmFind(isolate->GetEnteredContext());
if (index == -1) return;
args.GetReturnValue().Set(index);
}
=======================================
--- /branches/bleeding_edge/test/cctest/cctest.h Fri Sep 20 10:52:20 2013
UTC
+++ /branches/bleeding_edge/test/cctest/cctest.h Mon Sep 23 11:25:52 2013
UTC
@@ -105,6 +105,10 @@
static i::Heap* heap() {
return i_isolate()->heap();
}
+
+ static v8::Local<v8::Object> global() {
+ return isolate()->GetCurrentContext()->Global();
+ }
// TODO(dcarney): Remove.
// This must be called first in a test.
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Fri Sep 20 11:29:20
2013 UTC
+++ /branches/bleeding_edge/test/cctest/test-api.cc Mon Sep 23 11:25:52
2013 UTC
@@ -4661,7 +4661,8 @@
v8::ThrowException(v8_str("FromC"));
return;
} else {
- Local<v8::Object> global = Context::GetCurrent()->Global();
+ Local<v8::Object> global =
+ args.GetIsolate()->GetCurrentContext()->Global();
Local<Value> fun = global->Get(v8_str("JSThrowCountDown"));
v8::Handle<Value> argv[] = { v8_num(count - 1),
args[1],
@@ -7078,7 +7079,8 @@
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
p_getter_count++;
- v8::Handle<v8::Object> global = Context::GetCurrent()->Global();
+ v8::Handle<v8::Object> global =
+ info.GetIsolate()->GetCurrentContext()->Global();
CHECK_EQ(info.Holder(), global->Get(v8_str("o1")));
if (name->Equals(v8_str("p1"))) {
CHECK_EQ(info.This(), global->Get(v8_str("o1")));
@@ -7112,7 +7114,8 @@
const v8::PropertyCallbackInfo<v8::Value>& info) {
ApiTestFuzzer::Fuzz();
p_getter_count2++;
- v8::Handle<v8::Object> global = Context::GetCurrent()->Global();
+ v8::Handle<v8::Object> global =
+ info.GetIsolate()->GetCurrentContext()->Global();
CHECK_EQ(info.Holder(), global->Get(v8_str("o1")));
if (name->Equals(v8_str("p1"))) {
CHECK_EQ(info.This(), global->Get(v8_str("o1")));
@@ -7218,7 +7221,7 @@
"for (var i = 0; i < 0xd800; i += 4) {"
" right = String.fromCharCode(i) + right;"
"}");
- v8::Handle<v8::Object> global = Context::GetCurrent()->Global();
+ v8::Handle<v8::Object> global = context->Global();
Handle<String> left_tree = global->Get(v8_str("left")).As<String>();
Handle<String> right_tree = global->Get(v8_str("right")).As<String>();
@@ -7805,7 +7808,8 @@
trouble_nesting++;
// Call a JS function that throws an uncaught exception.
- Local<v8::Object> arg_this = Context::GetCurrent()->Global();
+ Local<v8::Object> arg_this =
+ args.GetIsolate()->GetCurrentContext()->Global();
Local<Value> trouble_callee = (trouble_nesting == 3) ?
arg_this->Get(v8_str("trouble_callee")) :
arg_this->Get(v8_str("trouble_caller"));
@@ -8327,7 +8331,7 @@
Local<Value> name,
v8::AccessType type,
Local<Value> data) {
- return Context::GetCurrent()->Global()->Equals(global) ||
+ return CcTest::isolate()->GetCurrentContext()->Global()->Equals(global) |
|
allowed_access_type[type];
}
@@ -8336,7 +8340,7 @@
uint32_t key,
v8::AccessType type,
Local<Value> data) {
- return Context::GetCurrent()->Global()->Equals(global) ||
+ return CcTest::isolate()->GetCurrentContext()->Global()->Equals(global) |
|
allowed_access_type[type];
}
@@ -13482,28 +13486,6 @@
CHECK_EQ(baseline,
cast(isolate->AdjustAmountOfExternalAllocatedMemory(-kSize)));
}
-
-
-THREADED_TEST(DisposeEnteredContext) {
- LocalContext outer;
- v8::Isolate* isolate = outer->GetIsolate();
- v8::Persistent<v8::Context> inner;
- {
- v8::HandleScope scope(isolate);
- inner.Reset(isolate, v8::Context::New(isolate));
- }
- v8::HandleScope scope(isolate);
- {
- // Don't want a handle here, so do this unsafely
- v8::Handle<v8::Context> inner_local =
- v8::Utils::Convert<i::Object, v8::Context>(
- v8::Utils::OpenPersistent(inner));
- inner_local->Enter();
- inner.Dispose();
- inner.Clear();
- inner_local->Exit();
- }
-}
// Regression test for issue 54, object templates with internal fields
@@ -15041,10 +15023,9 @@
static void GetCallingContextCallback(
const v8::FunctionCallbackInfo<v8::Value>& args) {
ApiTestFuzzer::Fuzz();
- CHECK(Context::GetCurrent() == calling_context0);
CHECK(args.GetIsolate()->GetCurrentContext() == calling_context0);
- CHECK(Context::GetCalling() == calling_context1);
- CHECK(Context::GetEntered() == calling_context2);
+ CHECK(args.GetIsolate()->GetCallingContext() == calling_context1);
+ CHECK(args.GetIsolate()->GetEnteredContext() == calling_context2);
args.GetReturnValue().Set(42);
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-debug.cc Fri Sep 20 10:52:20
2013 UTC
+++ /branches/bleeding_edge/test/cctest/test-debug.cc Mon Sep 23 11:25:52
2013 UTC
@@ -200,8 +200,10 @@
static v8::Local<v8::Function> CompileFunction(const char* source,
const char* function_name) {
v8::Script::Compile(v8::String::New(source))->Run();
+ v8::Local<v8::Object> global =
+ CcTest::isolate()->GetCurrentContext()->Global();
return v8::Local<v8::Function>::Cast(
-
v8::Context::GetCurrent()->Global()->Get(v8::String::New(function_name)));
+ global->Get(v8::String::New(function_name)));
}
@@ -7007,10 +7009,10 @@
v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(name), "a"));
- v8::Handle<v8::Context> current = v8::Context::GetCurrent();
+ v8::Handle<v8::Context> current = info.GetIsolate()->GetCurrentContext();
CHECK(current == debugee_context);
CHECK(current != debugger_context);
- v8::Handle<v8::Context> calling = v8::Context::GetCalling();
+ v8::Handle<v8::Context> calling = info.GetIsolate()->GetCallingContext();
CHECK(calling == debugee_context);
CHECK(calling != debugger_context);
info.GetReturnValue().Set(1);
@@ -7026,7 +7028,7 @@
v8::Handle<v8::Object> exec_state = event_details.GetExecutionState();
if (event == v8::Break) {
break_point_hit_count++;
- CHECK(debugger_context == v8::Context::GetCurrent());
+ CHECK(debugger_context == CcTest::isolate()->GetCurrentContext());
v8::Handle<v8::Function> func =
v8::Handle<v8::Function>::Cast(CompileRun(
"(function(exec_state) {\n"
" return (exec_state.frame(0).argumentValue(0).property('a').\n"
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Thu Sep 19 13:30:47
2013 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap.cc Mon Sep 23 11:25:52
2013 UTC
@@ -1897,7 +1897,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
CHECK(f->IsOptimized());
@@ -1912,7 +1912,7 @@
{
v8::HandleScope scope(CcTest::isolate());
- v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global();
+ v8::Handle<v8::Object> global = CcTest::global();
v8::Handle<v8::Function> g =
v8::Handle<v8::Function>::Cast(global->Get(v8_str("g")));
g->Call(global, 0, NULL);
@@ -1942,7 +1942,7 @@
Handle<JSObject> baseObject =
v8::Utils::OpenHandle(
*v8::Handle<v8::Object>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("base"))));
+ CcTest::global()->Get(v8_str("base"))));
// Verify that only dead prototype transitions are cleared.
CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions());
@@ -2009,7 +2009,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
CHECK(f->IsOptimized());
IncrementalMarking* marking = CcTest::heap()->incremental_marking();
@@ -2066,7 +2066,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
CHECK(f->IsOptimized());
CcTest::heap()->incremental_marking()->Abort();
@@ -2475,7 +2475,7 @@
Handle<JSObject> root =
v8::Utils::OpenHandle(
*v8::Handle<v8::Object>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("root"))));
+ CcTest::global()->Get(v8_str("root"))));
// Count number of live transitions before marking.
int transitions_before = CountMapTransitions(root->map());
@@ -2525,7 +2525,7 @@
Handle<JSObject> root =
v8::Utils::OpenHandle(
*v8::Handle<v8::Object>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("root"))));
+ CcTest::global()->Get(v8_str("root"))));
// The root object should be in a sane state.
CHECK(root->IsJSObject());
@@ -2569,7 +2569,7 @@
Handle<JSObject> root =
v8::Utils::OpenHandle(
*v8::Handle<v8::Object>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("root"))));
+ CcTest::global()->Get(v8_str("root"))));
// The root object should be in a sane state.
CHECK(root->IsJSObject());
@@ -2665,7 +2665,7 @@
Handle<JSFunction> g =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("g"))));
+ CcTest::global()->Get(v8_str("g"))));
DisallowHeapAllocation no_allocation;
g->shared()->PrintLn();
@@ -2728,13 +2728,13 @@
// Prepare function f that contains type feedback for closures
// originating from two different native contexts.
- v8::Context::GetCurrent()->Global()->Set(v8_str("fun1"), fun1);
- v8::Context::GetCurrent()->Global()->Set(v8_str("fun2"), fun2);
+ CcTest::global()->Set(v8_str("fun1"), fun1);
+ CcTest::global()->Set(v8_str("fun2"), fun2);
CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);");
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast(
f->shared()->code()->type_feedback_info())->type_feedback_cells());
@@ -2779,7 +2779,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CHECK(ic_before->ic_state() == MONOMORPHIC);
@@ -2806,12 +2806,12 @@
// Prepare function f that contains a monomorphic IC for object
// originating from a different native context.
- v8::Context::GetCurrent()->Global()->Set(v8_str("obj1"), obj1);
+ CcTest::global()->Set(v8_str("obj1"), obj1);
CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);");
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CHECK(ic_before->ic_state() == MONOMORPHIC);
@@ -2846,13 +2846,13 @@
// Prepare function f that contains a polymorphic IC for objects
// originating from two different native contexts.
- v8::Context::GetCurrent()->Global()->Set(v8_str("obj1"), obj1);
- v8::Context::GetCurrent()->Global()->Set(v8_str("obj2"), obj2);
+ CcTest::global()->Set(v8_str("obj1"), obj1);
+ CcTest::global()->Set(v8_str("obj2"), obj2);
CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CHECK(ic_before->ic_state() == POLYMORPHIC);
@@ -3057,14 +3057,14 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
CHECK(f->is_compiled());
CompileRun("f = null;");
Handle<JSFunction> g =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("g"))));
+ CcTest::global()->Get(v8_str("g"))));
CHECK(g->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -3112,7 +3112,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
CHECK(f->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -3160,7 +3160,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
CHECK(f->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -3181,7 +3181,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
-
v8::Context::GetCurrent()->Global()->Get(v8_str("flushMe"))));
+ CcTest::global()->Get(v8_str("flushMe"))));
CHECK(f->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -3251,7 +3251,7 @@
v8_str("fastliteralcase(mote, 2.5);");
v8::Local<v8::String> array_name = v8_str("mote");
- v8::Context::GetCurrent()->Global()->Set(array_name, v8::Int32::New(0));
+ CcTest::global()->Set(array_name, v8::Int32::New(0));
// First make sure we flip spaces
CcTest::heap()->CollectGarbage(NEW_SPACE);
@@ -3285,7 +3285,7 @@
// Give the array a name, making sure not to allocate strings.
v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array);
- v8::Context::GetCurrent()->Global()->Set(array_name, array_obj);
+ CcTest::global()->Set(array_name, array_obj);
// This should crash with a protection violation if we are running a
build
// with the bug.
@@ -3323,7 +3323,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
CHECK(f->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
@@ -3379,7 +3379,7 @@
Handle<JSFunction> f =
v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(
- v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
+ CcTest::global()->Get(v8_str("f"))));
CHECK(f->is_compiled());
const int kAgingThreshold = 6;
for (int i = 0; i < kAgingThreshold; i++) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-object-observe.cc Thu Sep 19
10:31:04 2013 UTC
+++ /branches/bleeding_edge/test/cctest/test-object-observe.cc Mon Sep 23
11:25:52 2013 UTC
@@ -472,7 +472,9 @@
AccessType type,
Local<Value>) {
if (type != g_access_block_type) return true;
- Handle<Object> global = Context::GetCurrent()->Global();
+ v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(
+ Utils::OpenHandle(*host)->GetIsolate());
+ Handle<Object> global = isolate->GetCurrentContext()->Global();
Handle<Value> blacklist = global->Get(String::New("blacklist"));
if (!blacklist->IsObject()) return true;
if (key->IsString()) return !blacklist.As<Object>()->Has(key);
@@ -485,7 +487,9 @@
AccessType type,
Local<Value>) {
if (type != ACCESS_GET) return true;
- Handle<Object> global = Context::GetCurrent()->Global();
+ v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(
+ Utils::OpenHandle(*host)->GetIsolate());
+ Handle<Object> global = isolate->GetCurrentContext()->Global();
Handle<Value> blacklist = global->Get(String::New("blacklist"));
if (!blacklist->IsObject()) return true;
return !blacklist.As<Object>()->Has(index);
@@ -494,7 +498,9 @@
static bool BlockAccessKeys(Local<Object> host, Local<Value> key,
AccessType type, Local<Value>) {
- Handle<Object> global = Context::GetCurrent()->Global();
+ v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(
+ Utils::OpenHandle(*host)->GetIsolate());
+ Handle<Object> global = isolate->GetCurrentContext()->Global();
Handle<Value> blacklist = global->Get(String::New("blacklist"));
if (!blacklist->IsObject()) return true;
return type != ACCESS_KEYS ||
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.