Reviewers: Sven Panne,
Description:
Introduce v8::Object::GetIsolate().
API=v8::Object::GetIsolate()
LOG=y
[email protected]
Please review this at https://codereview.chromium.org/617263003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+22, -0 lines):
M include/v8.h
M src/api.cc
M test/cctest/test-api.cc
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
c9b3862be5027216830f95536cfade85d77b1f7e..8d3b30706da8a713973b2e881739d6c10e0849f2
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -2586,6 +2586,11 @@ class V8_EXPORT Object : public Value {
*/
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);
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
f70d0e0e3dc418fc97a886ee9f8a59001cee7de2..512eaeb3475bd3d24a948bc74ec0a1b084c0f945
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5608,6 +5608,12 @@ bool v8::String::CanMakeExternal() {
}
+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) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
LOG_API(i_isolate, "Object::New");
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
b4af849328659373fda081c836f6e6ffae65e4fb..fc0281a0bdf6f3375db2d1627d4fb4a661ac548a
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -2824,6 +2824,16 @@ THREADED_TEST(EmbedderData) {
}
+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) {
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
@@ -22948,6 +22958,7 @@ TEST(Promises) {
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.