Permalink
Browse files

Pass an isolate to GetCurrent()

TEST=test-api.cc:GetCallingContextCallback

Review URL: https://chromiumcodereview.appspot.com//13426002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@14146 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information...
1 parent dc0d1ca commit 0ba258795e6510ca29b8ba95212a69060b13b493 haraken@chromium.org committed Apr 5, 2013
Showing with 12 additions and 0 deletions.
  1. +1 −0 include/v8.h
  2. +10 −0 src/api.cc
  3. +1 −0 test/cctest/test-api.cc
View
@@ -3892,6 +3892,7 @@ class V8EXPORT Context {
/** Returns the context that is on the top of the stack. */
static Local<Context> GetCurrent();
+ static Local<Context> GetCurrent(Isolate* isolate);
/**
* Returns the context of the calling JavaScript code. That is the
View
@@ -5014,6 +5014,16 @@ v8::Local<v8::Context> Context::GetCurrent() {
}
+v8::Local<v8::Context> Context::GetCurrent(Isolate* exported_isolate) {
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(exported_isolate);
+ ASSERT(isolate == i::Isolate::Current());
+ i::Handle<i::Object> current = isolate->native_context();
+ if (current.is_null()) return Local<Context>();
+ i::Handle<i::Context> context = i::Handle<i::Context>::cast(current);
+ return Utils::ToLocal(context);
+}
+
+
v8::Local<v8::Context> Context::GetCalling() {
i::Isolate* isolate = i::Isolate::Current();
if (IsDeadCheck(isolate, "v8::Context::GetCalling()")) {
View
@@ -13410,6 +13410,7 @@ v8::Persistent<Context> calling_context2;
static v8::Handle<Value> GetCallingContextCallback(const v8::Arguments& args) {
ApiTestFuzzer::Fuzz();
CHECK(Context::GetCurrent() == calling_context0);
+ CHECK(Context::GetCurrent(args.GetIsolate()) == calling_context0);
CHECK(Context::GetCalling() == calling_context1);
CHECK(Context::GetEntered() == calling_context2);
return v8::Integer::New(42);

0 comments on commit 0ba2587

Please sign in to comment.