Commit 321dad9b authored by yangguo@chromium.org's avatar yangguo@chromium.org

Introduce v8::Object::GetIsolate().

API=v8::Object::GetIsolate()
LOG=Y
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/617263003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24376 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e1a5abb6
......@@ -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);
......
......@@ -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");
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment