Reviewers: Yang,
Description:
Move context retrieval method around. Use delegation for implementation.
This is a refactoring of https://code.google.com/p/v8/source/detail?r=14146.
Please review this at https://codereview.chromium.org/13940003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
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
8dabef0d5885448bfdd590c37f88ab4dfe8218a0..ede5b56ea26148a5c6263ad644b455b2f1daf46f
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -3036,6 +3036,9 @@ class V8EXPORT Isolate {
*/
CpuProfiler* GetCpuProfiler();
+ /** Returns the context that is on the top of the stack. */
+ Local<Context> GetCurrentContext();
+
private:
Isolate();
Isolate(const Isolate&);
@@ -3890,9 +3893,9 @@ class V8EXPORT Context {
/** Returns the last entered context. */
static Local<Context> GetEntered();
- /** Returns the context that is on the top of the stack. */
+ // TODO(svenpanne) Actually deprecate this.
+ /** Deprecated. Use Isolate::GetCurrentContext instead. */
static Local<Context> GetCurrent();
- static Local<Context> GetCurrent(Isolate* isolate);
/**
* Returns the context of the calling JavaScript code. That is the
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
3fab8de82fe3a50b7b089810a734b6f4e7369bf0..2df32ca6fc814bdec05983fae63ceaeb14fd9d51
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5007,20 +5007,7 @@ v8::Local<v8::Context> Context::GetCurrent() {
if (IsDeadCheck(isolate, "v8::Context::GetCurrent()")) {
return Local<Context>();
}
- 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::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);
+ return reinterpret_cast<Isolate*>(isolate)->GetCurrentContext();
}
@@ -5825,6 +5812,15 @@ CpuProfiler* Isolate::GetCpuProfiler() {
}
+v8::Local<v8::Context> Isolate::GetCurrentContext() {
+ i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(this);
+ i::Handle<i::Object> current = internal_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);
+}
+
+
void V8::SetGlobalGCPrologueCallback(GCCallback callback) {
i::Isolate* isolate = i::Isolate::Current();
if (IsDeadCheck(isolate, "v8::V8::SetGlobalGCPrologueCallback()"))
return;
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
aa25b6265bf937f53af34f3e2b26903f3d16778d..1e789f30da847221395b9489802aacc8375187be
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -13410,7 +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(args.GetIsolate()->GetCurrentContext() == calling_context0);
CHECK(Context::GetCalling() == calling_context1);
CHECK(Context::GetEntered() == calling_context2);
return v8::Integer::New(42);
--
--
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/groups/opt_out.