Pass an isolate to GetCurrent()
authorharaken@chromium.org <haraken@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Apr 2013 02:17:56 +0000 (02:17 +0000)
committerharaken@chromium.org <haraken@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Apr 2013 02:17:56 +0000 (02:17 +0000)
TEST=test-api.cc:GetCallingContextCallback

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14146 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

include/v8.h
src/api.cc
test/cctest/test-api.cc

index 10b38fa..8dabef0 100644 (file)
@@ -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
index 7354ada..48882ba 100644 (file)
@@ -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()")) {
index a9780f0..aa25b62 100644 (file)
@@ -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);