Reviewers: Mads Ager,

Description:
Clean up a few TODO(isolates).


[email protected]


Please review this at http://codereview.chromium.org/6993061/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/api.cc
  M src/heap-inl.h


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 89435d113a0cf03ace3b568ec83fbde496f6e051..6a0406a61f53efb02143348d856e5ab785daf24c 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -97,13 +97,11 @@ namespace v8 {
} \
   } 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 { \ if (v8::Locker::IsActive()) { \ - ApiCheck(i::Isolate::Current()->thread_manager()-> \ - IsLockedByCurrentThread(), \ + ApiCheck(isolate->thread_manager()-> IsLockedByCurrentThread(), \ msg, \ "Entering the V8 API without proper locking in place"); \ } \
@@ -573,8 +571,8 @@ void V8::DisposeGlobal(i::Object** obj) {


 HandleScope::HandleScope() {
-  API_ENTRY_CHECK("HandleScope::HandleScope");
   i::Isolate* isolate = i::Isolate::Current();
+  API_ENTRY_CHECK(isolate, "HandleScope::HandleScope");
   v8::ImplementationUtilities::HandleScopeData* current =
       isolate->handle_scope_data();
   isolate_ = isolate;
@@ -630,12 +628,11 @@ i::Object** HandleScope::CreateHandle(i::HeapObject* value) {


 void Context::Enter() {
-  // TODO(isolates): Context should have a pointer to isolate.
-  i::Isolate* isolate = i::Isolate::Current();
+  i::Handle<i::Context> env = Utils::OpenHandle(this);
+  i::Isolate* isolate = env->GetIsolate();
   if (IsDeadCheck(isolate, "v8::Context::Enter()")) return;
   ENTER_V8(isolate);

-  i::Handle<i::Context> env = Utils::OpenHandle(this);
   isolate->handle_scope_implementer()->EnterContext(env);

   isolate->handle_scope_implementer()->SaveContext(isolate->context());
@@ -644,8 +641,8 @@ void Context::Enter() {


 void Context::Exit() {
-  // TODO(isolates): Context should have a pointer to isolate.
-  i::Isolate* isolate = i::Isolate::Current();
+  i::Handle<i::Context> env = Utils::OpenHandle(this);
+  i::Isolate* isolate = env->GetIsolate();
   if (!isolate->IsInitialized()) return;

   if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(),
@@ -662,41 +659,31 @@ void Context::Exit() {


 void Context::SetData(v8::Handle<String> data) {
-  // TODO(isolates): Context should have a pointer to isolate.
-  i::Isolate* isolate = i::Isolate::Current();
+  i::Handle<i::Context> env = Utils::OpenHandle(this);
+  i::Isolate* isolate = env->GetIsolate();
   if (IsDeadCheck(isolate, "v8::Context::SetData()")) return;
-  ENTER_V8(isolate);
-  {
-    i::HandleScope scope(isolate);
-    i::Handle<i::Context> env = Utils::OpenHandle(this);
-    i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
-    ASSERT(env->IsGlobalContext());
-    if (env->IsGlobalContext()) {
-      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() {
-  // TODO(isolates): Context should have a pointer to isolate.
-  i::Isolate* isolate = i::Isolate::Current();
+  i::Handle<i::Context> env = Utils::OpenHandle(this);
+  i::Isolate* isolate = env->GetIsolate();
   if (IsDeadCheck(isolate, "v8::Context::GetData()")) {
     return v8::Local<Value>();
   }
-  ENTER_V8(isolate);
   i::Object* raw_result = NULL;
-  {
-    i::HandleScope scope(isolate);
-    i::Handle<i::Context> env = Utils::OpenHandle(this);
-    ASSERT(env->IsGlobalContext());
-    if (env->IsGlobalContext()) {
-      raw_result = env->data();
-    } else {
-      return Local<Value>();
-    }
+  ASSERT(env->IsGlobalContext());
+  if (env->IsGlobalContext()) {
+    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);
 }

@@ -4814,7 +4801,7 @@ int V8::GetCurrentThreadId() {
 void V8::TerminateExecution(int thread_id) {
   i::Isolate* isolate = i::Isolate::Current();
   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
   // execution right away.  Otherwise, ask the thread manager to
   // terminate the thread with the given id if any.
Index: src/heap-inl.h
diff --git a/src/heap-inl.h b/src/heap-inl.h
index 44faf751ab6d8c9e5ed49b3eed3af75501e2708f..3f5554e2c2ea0049935701dc41ef6eca35e85c84 100644
--- a/src/heap-inl.h
+++ b/src/heap-inl.h
@@ -531,8 +531,6 @@ Isolate* Heap::isolate() {
   } 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)       \
   CALL_AND_RETRY(ISOLATE,                                      \
                  FUNCTION_CALL,                                \


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to