Revision: 24376
Author:   [email protected]
Date:     Thu Oct  2 06:52:39 2014 UTC
Log:      Introduce v8::Object::GetIsolate().

API=v8::Object::GetIsolate()
LOG=Y
[email protected]

Review URL: https://codereview.chromium.org/617263003
https://code.google.com/p/v8/source/detail?r=24376

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Wed Oct  1 11:53:29 2014 UTC
+++ /branches/bleeding_edge/include/v8.h        Thu Oct  2 06:52:39 2014 UTC
@@ -2586,6 +2586,11 @@
    */
   Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]);

+  /**
+   * Return the isolate to which the Object belongs to.
+   */
+  Isolate* GetIsolate();
+
   static Local<Object> New(Isolate* isolate);

   V8_INLINE static Object* Cast(Value* obj);
=======================================
--- /branches/bleeding_edge/src/api.cc  Tue Sep 30 15:29:08 2014 UTC
+++ /branches/bleeding_edge/src/api.cc  Thu Oct  2 06:52:39 2014 UTC
@@ -5606,6 +5606,12 @@
   i::StringShape shape(*obj);
   return !shape.IsExternal();
 }
+
+
+Isolate* v8::Object::GetIsolate() {
+  i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
+  return reinterpret_cast<Isolate*>(i_isolate);
+}


 Local<v8::Object> v8::Object::New(Isolate* isolate) {
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc Tue Sep 30 15:29:08 2014 UTC +++ /branches/bleeding_edge/test/cctest/test-api.cc Thu Oct 2 06:52:39 2014 UTC
@@ -2822,6 +2822,16 @@
   CheckEmbedderData(&env, 1, v8::Number::New(isolate, 1.2345));
   CheckEmbedderData(&env, 0, v8::Boolean::New(isolate, true));
 }
+
+
+THREADED_TEST(GetIsolate) {
+  LocalContext env;
+  v8::Isolate* isolate = env->GetIsolate();
+  v8::HandleScope scope(isolate);
+  Local<v8::Object> obj = v8::Object::New(isolate);
+  CHECK_EQ(isolate, obj->GetIsolate());
+  CHECK_EQ(isolate, CcTest::global()->GetIsolate());
+}


 THREADED_TEST(IdentityHash) {
@@ -22948,6 +22958,7 @@
   Handle<v8::Promise::Resolver> rr = v8::Promise::Resolver::New(isolate);
   Handle<v8::Promise> p = pr->GetPromise();
   Handle<v8::Promise> r = rr->GetPromise();
+  CHECK_EQ(isolate, p->GetIsolate());

   // IsPromise predicate.
   CHECK(p->IsPromise());

--
--
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/d/optout.

Reply via email to