Commit a07bd45c authored by vitalyr@chromium.org's avatar vitalyr@chromium.org

Clean up a few TODO(isolates).

R=ager@chromium.org

Review URL: http://codereview.chromium.org/6993061

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8207 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f2d5710b
...@@ -98,13 +98,11 @@ namespace v8 { ...@@ -98,13 +98,11 @@ namespace v8 {
} \ } \
} while (false) } while (false)
// TODO(isolates): Add a parameter to this macro for an isolate.
#define API_ENTRY_CHECK(msg) \ #define API_ENTRY_CHECK(isolate, msg) \
do { \ do { \
if (v8::Locker::IsActive()) { \ if (v8::Locker::IsActive()) { \
ApiCheck(i::Isolate::Current()->thread_manager()-> \ ApiCheck(isolate->thread_manager()->IsLockedByCurrentThread(), \
IsLockedByCurrentThread(), \
msg, \ msg, \
"Entering the V8 API without proper locking in place"); \ "Entering the V8 API without proper locking in place"); \
} \ } \
...@@ -645,8 +643,8 @@ void V8::DisposeGlobal(i::Object** obj) { ...@@ -645,8 +643,8 @@ void V8::DisposeGlobal(i::Object** obj) {
HandleScope::HandleScope() { HandleScope::HandleScope() {
API_ENTRY_CHECK("HandleScope::HandleScope");
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
API_ENTRY_CHECK(isolate, "HandleScope::HandleScope");
v8::ImplementationUtilities::HandleScopeData* current = v8::ImplementationUtilities::HandleScopeData* current =
isolate->handle_scope_data(); isolate->handle_scope_data();
isolate_ = isolate; isolate_ = isolate;
...@@ -702,12 +700,11 @@ i::Object** HandleScope::CreateHandle(i::HeapObject* value) { ...@@ -702,12 +700,11 @@ i::Object** HandleScope::CreateHandle(i::HeapObject* value) {
void Context::Enter() { void Context::Enter() {
// TODO(isolates): Context should have a pointer to isolate. i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = env->GetIsolate();
if (IsDeadCheck(isolate, "v8::Context::Enter()")) return; if (IsDeadCheck(isolate, "v8::Context::Enter()")) return;
ENTER_V8(isolate); ENTER_V8(isolate);
i::Handle<i::Context> env = Utils::OpenHandle(this);
isolate->handle_scope_implementer()->EnterContext(env); isolate->handle_scope_implementer()->EnterContext(env);
isolate->handle_scope_implementer()->SaveContext(isolate->context()); isolate->handle_scope_implementer()->SaveContext(isolate->context());
...@@ -716,7 +713,9 @@ void Context::Enter() { ...@@ -716,7 +713,9 @@ void Context::Enter() {
void Context::Exit() { void Context::Exit() {
// TODO(isolates): Context should have a pointer to isolate. // Exit is essentially a static function and doesn't use the
// receiver, so we have to get the current isolate from the thread
// local.
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
if (!isolate->IsInitialized()) return; if (!isolate->IsInitialized()) return;
...@@ -734,41 +733,31 @@ void Context::Exit() { ...@@ -734,41 +733,31 @@ void Context::Exit() {
void Context::SetData(v8::Handle<String> data) { void Context::SetData(v8::Handle<String> data) {
// TODO(isolates): Context should have a pointer to isolate. i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = env->GetIsolate();
if (IsDeadCheck(isolate, "v8::Context::SetData()")) return; if (IsDeadCheck(isolate, "v8::Context::SetData()")) return;
ENTER_V8(isolate); i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
{ ASSERT(env->IsGlobalContext());
i::HandleScope scope(isolate); if (env->IsGlobalContext()) {
i::Handle<i::Context> env = Utils::OpenHandle(this); env->set_data(*raw_data);
i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
ASSERT(env->IsGlobalContext());
if (env->IsGlobalContext()) {
env->set_data(*raw_data);
}
} }
} }
v8::Local<v8::Value> Context::GetData() { v8::Local<v8::Value> Context::GetData() {
// TODO(isolates): Context should have a pointer to isolate. i::Handle<i::Context> env = Utils::OpenHandle(this);
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = env->GetIsolate();
if (IsDeadCheck(isolate, "v8::Context::GetData()")) { if (IsDeadCheck(isolate, "v8::Context::GetData()")) {
return v8::Local<Value>(); return v8::Local<Value>();
} }
ENTER_V8(isolate);
i::Object* raw_result = NULL; i::Object* raw_result = NULL;
{ ASSERT(env->IsGlobalContext());
i::HandleScope scope(isolate); if (env->IsGlobalContext()) {
i::Handle<i::Context> env = Utils::OpenHandle(this); raw_result = env->data();
ASSERT(env->IsGlobalContext()); } else {
if (env->IsGlobalContext()) { return Local<Value>();
raw_result = env->data();
} else {
return Local<Value>();
}
} }
i::Handle<i::Object> result(raw_result); i::Handle<i::Object> result(raw_result, isolate);
return Utils::ToLocal(result); return Utils::ToLocal(result);
} }
...@@ -4886,7 +4875,7 @@ int V8::GetCurrentThreadId() { ...@@ -4886,7 +4875,7 @@ int V8::GetCurrentThreadId() {
void V8::TerminateExecution(int thread_id) { void V8::TerminateExecution(int thread_id) {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
if (!isolate->IsInitialized()) return; if (!isolate->IsInitialized()) return;
API_ENTRY_CHECK("V8::TerminateExecution()"); API_ENTRY_CHECK(isolate, "V8::TerminateExecution()");
// If the thread_id identifies the current thread just terminate // If the thread_id identifies the current thread just terminate
// execution right away. Otherwise, ask the thread manager to // execution right away. Otherwise, ask the thread manager to
// terminate the thread with the given id if any. // terminate the thread with the given id if any.
......
...@@ -531,8 +531,6 @@ Isolate* Heap::isolate() { ...@@ -531,8 +531,6 @@ Isolate* Heap::isolate() {
} while (false) } while (false)
// TODO(isolates): cache isolate: either accept as a parameter or
// set to some known symbol (__CUR_ISOLATE__?)
#define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE) \ #define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE) \
CALL_AND_RETRY(ISOLATE, \ CALL_AND_RETRY(ISOLATE, \
FUNCTION_CALL, \ FUNCTION_CALL, \
......
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