Revision: 7416
Author:   a...@chromium.org
Date:     Tue Mar 29 07:00:41 2011
Log:      Remove redundant usages of some macros and functions in debug.cc

Cleanup of HEAP and FACTORY macros and use isolate_ member of classes where it is possible.
Cleanup of debugger(), debug() and global_handles() functions.
Pass the isolate pointer to the HandleScope constructor.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/6708108
http://code.google.com/p/v8/source/detail?r=7416

Modified:
 /branches/bleeding_edge/src/debug.cc

=======================================
--- /branches/bleeding_edge/src/debug.cc        Wed Mar 23 06:40:07 2011
+++ /branches/bleeding_edge/src/debug.cc        Tue Mar 29 07:00:41 2011
@@ -633,7 +633,7 @@


 void ScriptCache::Add(Handle<Script> script) {
-  Isolate* isolate = Isolate::Current();
+  GlobalHandles* global_handles = Isolate::Current()->global_handles();
   // Create an entry in the hash map for the script.
   int id = Smi::cast(script->id())->value();
   HashMap::Entry* entry =
@@ -647,8 +647,8 @@
   // global handle as the value in the hash map.
   Handle<Script> script_ =
       Handle<Script>::cast(
-          (isolate->global_handles()->Create(*script)));
-  isolate->global_handles()->MakeWeak(
+          (global_handles->Create(*script)));
+  global_handles->MakeWeak(
       reinterpret_cast<Object**>(script_.location()),
       this,
       ScriptCache::HandleWeakScript);
@@ -671,23 +671,23 @@


 void ScriptCache::ProcessCollectedScripts() {
-  Isolate* isolate = Isolate::Current();
+  Debugger* debugger = Isolate::Current()->debugger();
   for (int i = 0; i < collected_scripts_.length(); i++) {
-    isolate->debugger()->OnScriptCollected(collected_scripts_[i]);
+    debugger->OnScriptCollected(collected_scripts_[i]);
   }
   collected_scripts_.Clear();
 }


 void ScriptCache::Clear() {
-  Isolate* isolate = Isolate::Current();
+  GlobalHandles* global_handles = Isolate::Current()->global_handles();
   // Iterate the script cache to get rid of all the weak handles.
for (HashMap::Entry* entry = Start(); entry != NULL; entry = Next(entry)) {
     ASSERT(entry != NULL);
     Object** location = reinterpret_cast<Object**>(entry->value);
     ASSERT((*location)->IsScript());
-    isolate->global_handles()->ClearWeakness(location);
-    isolate->global_handles()->Destroy(location);
+    global_handles->ClearWeakness(location);
+    global_handles->Destroy(location);
   }
   // Clear the content of the hash map.
   HashMap::Clear();
@@ -717,11 +717,11 @@
   if (create_heap_objects) {
     // Get code to handle debug break on return.
     debug_break_return_ =
- Isolate::Current()->builtins()->builtin(Builtins::kReturn_DebugBreak);
+        isolate_->builtins()->builtin(Builtins::kReturn_DebugBreak);
     ASSERT(debug_break_return_->IsCode());
     // Get code to handle debug break in debug break slots.
     debug_break_slot_ =
- Isolate::Current()->builtins()->builtin(Builtins::kSlot_DebugBreak);
+        isolate_->builtins()->builtin(Builtins::kSlot_DebugBreak);
     ASSERT(debug_break_slot_->IsCode());
   }
 }
@@ -748,11 +748,11 @@


 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) {
-  Isolate* isolate = Isolate::Current();
+  GlobalHandles* global_handles = Isolate::Current()->global_handles();
   // Globalize the request debug info object and make it weak.
   debug_info_ = Handle<DebugInfo>::cast(
-      (isolate->global_handles()->Create(debug_info)));
-  isolate->global_handles()->MakeWeak(
+      (global_handles->Create(debug_info)));
+  global_handles->MakeWeak(
       reinterpret_cast<Object**>(debug_info_.location()),
       this,
       Debug::HandleWeakDebugInfo);
@@ -766,7 +766,9 @@


 bool Debug::CompileDebuggerScript(int index) {
-  HandleScope scope;
+  Isolate* isolate = Isolate::Current();
+  Factory* factory = isolate->factory();
+  HandleScope scope(isolate);

   // Bail out if the index is invalid.
   if (index == -1) {
@@ -775,9 +777,9 @@

   // Find source and name for the requested script.
   Handle<String> source_code =
-      Isolate::Current()->bootstrapper()->NativesSourceLookup(index);
+      isolate->bootstrapper()->NativesSourceLookup(index);
   Vector<const char> name = Natives::GetScriptName(index);
-  Handle<String> script_name = FACTORY->NewStringFromAscii(name);
+  Handle<String> script_name = factory->NewStringFromAscii(name);

   // Compile the script.
   Handle<SharedFunctionInfo> function_info;
@@ -789,16 +791,16 @@

   // Silently ignore stack overflows during compilation.
   if (function_info.is_null()) {
-    ASSERT(Isolate::Current()->has_pending_exception());
-    Isolate::Current()->clear_pending_exception();
+    ASSERT(isolate->has_pending_exception());
+    isolate->clear_pending_exception();
     return false;
   }

   // Execute the shared function in the debugger context.
-  Handle<Context> context = Isolate::Current()->global_context();
+  Handle<Context> context = isolate->global_context();
   bool caught_exception = false;
   Handle<JSFunction> function =
-      FACTORY->NewFunctionFromSharedFunctionInfo(function_info, context);
+      factory->NewFunctionFromSharedFunctionInfo(function_info, context);
   Handle<Object> result =
       Execution::TryCall(function, Handle<Object>(context->global()),
                          0, NULL, &caught_exception);
@@ -823,43 +825,44 @@
   // Return if debugger is already loaded.
   if (IsLoaded()) return true;

-  Isolate* isolate = Isolate::Current();
+  ASSERT(Isolate::Current() == isolate_);
+  Debugger* debugger = isolate_->debugger();

   // Bail out if we're already in the process of compiling the native
   // JavaScript source code for the debugger.
-  if (isolate->debugger()->compiling_natives() ||
-      isolate->debugger()->is_loading_debugger())
+  if (debugger->compiling_natives() ||
+      debugger->is_loading_debugger())
     return false;
-  isolate->debugger()->set_loading_debugger(true);
+  debugger->set_loading_debugger(true);

   // Disable breakpoints and interrupts while compiling and running the
   // debugger scripts including the context creation code.
   DisableBreak disable(true);
-  PostponeInterruptsScope postpone(isolate);
+  PostponeInterruptsScope postpone(isolate_);

   // Create the debugger context.
-  HandleScope scope;
+  HandleScope scope(isolate_);
   Handle<Context> context =
-      isolate->bootstrapper()->CreateEnvironment(
+      isolate_->bootstrapper()->CreateEnvironment(
           Handle<Object>::null(),
           v8::Handle<ObjectTemplate>(),
           NULL);

   // Use the debugger context.
-  SaveContext save(isolate);
-  isolate->set_context(*context);
+  SaveContext save(isolate_);
+  isolate_->set_context(*context);

   // Expose the builtins object in the debugger context.
-  Handle<String> key = FACTORY->LookupAsciiSymbol("builtins");
+  Handle<String> key = isolate_->factory()->LookupAsciiSymbol("builtins");
   Handle<GlobalObject> global = Handle<GlobalObject>(context->global());
   RETURN_IF_EMPTY_HANDLE_VALUE(
-      isolate,
+      isolate_,
       SetProperty(global, key, Handle<Object>(global->builtins()),
                   NONE, kNonStrictMode),
       false);

   // Compile the JavaScript for the debugger in the debugger context.
-  isolate->debugger()->set_compiling_natives(true);
+  debugger->set_compiling_natives(true);
   bool caught_exception =
       !CompileDebuggerScript(Natives::GetIndex("mirror")) ||
       !CompileDebuggerScript(Natives::GetIndex("debug"));
@@ -869,11 +872,11 @@
         !CompileDebuggerScript(Natives::GetIndex("liveedit"));
   }

-  isolate->debugger()->set_compiling_natives(false);
+  debugger->set_compiling_natives(false);

   // Make sure we mark the debugger as not loading before we might
   // return.
-  isolate->debugger()->set_loading_debugger(false);
+  debugger->set_loading_debugger(false);

   // Check for caught exceptions.
   if (caught_exception) return false;
@@ -920,7 +923,7 @@

   Debug* debug = isolate->debug();
   Heap* heap = isolate->heap();
-  HandleScope scope;
+  HandleScope scope(isolate);
   ASSERT(args.length() == 0);

   debug->thread_local_.frame_drop_mode_ = FRAMES_UNTOUCHED;
@@ -1032,6 +1035,8 @@
 // triggered. This function returns a JSArray with the break point objects
 // which is triggered.
Handle<Object> Debug::CheckBreakPoints(Handle<Object> break_point_objects) {
+  Factory* factory = isolate_->factory();
+
// Count the number of break points hit. If there are multiple break points
   // they are in a FixedArray.
   Handle<FixedArray> break_points_hit;
@@ -1039,7 +1044,7 @@
   ASSERT(!break_point_objects->IsUndefined());
   if (break_point_objects->IsFixedArray()) {
     Handle<FixedArray> array(FixedArray::cast(*break_point_objects));
-    break_points_hit = FACTORY->NewFixedArray(array->length());
+    break_points_hit = factory->NewFixedArray(array->length());
     for (int i = 0; i < array->length(); i++) {
       Handle<Object> o(array->get(i));
       if (CheckBreakPoint(o)) {
@@ -1047,7 +1052,7 @@
       }
     }
   } else {
-    break_points_hit = FACTORY->NewFixedArray(1);
+    break_points_hit = factory->NewFixedArray(1);
     if (CheckBreakPoint(break_point_objects)) {
break_points_hit->set(break_points_hit_count++, *break_point_objects);
     }
@@ -1055,10 +1060,10 @@

   // Return undefined if no break points were triggered.
   if (break_points_hit_count == 0) {
-    return FACTORY->undefined_value();
+    return factory->undefined_value();
   }
   // Return break points hit as a JSArray.
- Handle<JSArray> result = FACTORY->NewJSArrayWithElements(break_points_hit); + Handle<JSArray> result = factory->NewJSArrayWithElements(break_points_hit);
   result->set_length(Smi::FromInt(break_points_hit_count));
   return result;
 }
@@ -1066,21 +1071,23 @@

 // Check whether a single break point object is triggered.
 bool Debug::CheckBreakPoint(Handle<Object> break_point_object) {
-  HandleScope scope;
+  ASSERT(Isolate::Current() == isolate_);
+  Factory* factory = isolate_->factory();
+  HandleScope scope(isolate_);

   // Ignore check if break point object is not a JSObject.
   if (!break_point_object->IsJSObject()) return true;

   // Get the function IsBreakPointTriggered (defined in debug-debugger.js).
   Handle<String> is_break_point_triggered_symbol =
-      FACTORY->LookupAsciiSymbol("IsBreakPointTriggered");
+      factory->LookupAsciiSymbol("IsBreakPointTriggered");
   Handle<JSFunction> check_break_point =
     Handle<JSFunction>(JSFunction::cast(
         debug_context()->global()->GetPropertyNoExceptionThrown(
             *is_break_point_triggered_symbol)));

   // Get the break id as an object.
-  Handle<Object> break_id = FACTORY->NewNumberFromInt(Debug::break_id());
+  Handle<Object> break_id = factory->NewNumberFromInt(Debug::break_id());

   // Call HandleBreakPointx.
   bool caught_exception = false;
@@ -1090,7 +1097,7 @@
     reinterpret_cast<Object**>(break_point_object.location())
   };
   Handle<Object> result = Execution::TryCall(check_break_point,
- Isolate::Current()->js_builtins_object(), argc, argv, &caught_exception);
+      isolate_->js_builtins_object(), argc, argv, &caught_exception);

   // If exception or non boolean result handle as not triggered
   if (caught_exception || !result->IsBoolean()) {
@@ -1120,7 +1127,7 @@
 void Debug::SetBreakPoint(Handle<SharedFunctionInfo> shared,
                           Handle<Object> break_point_object,
                           int* source_position) {
-  HandleScope scope;
+  HandleScope scope(isolate_);

   if (!EnsureDebugInfo(shared)) {
     // Return if retrieving debug info failed.
@@ -1144,7 +1151,7 @@


 void Debug::ClearBreakPoint(Handle<Object> break_point_object) {
-  HandleScope scope;
+  HandleScope scope(isolate_);

   DebugInfoListNode* node = debug_info_list_;
   while (node != NULL) {
@@ -1250,7 +1257,8 @@


 void Debug::PrepareStep(StepAction step_action, int step_count) {
-  HandleScope scope;
+  ASSERT(Isolate::Current() == isolate_);
+  HandleScope scope(isolate_);
   ASSERT(Debug::InDebugger());

   // Remember this step action and count.
@@ -1398,7 +1406,8 @@
       // Reverse lookup required as the minor key cannot be retrieved
       // from the code object.
       Handle<Object> obj(
-          HEAP->code_stubs()->SlowReverseLookup(*call_function_stub));
+          isolate_->heap()->code_stubs()->SlowReverseLookup(
+              *call_function_stub));
       ASSERT(!obj.is_null());
       ASSERT(!(*obj)->IsUndefined());
       ASSERT(obj->IsSmi());
@@ -1553,13 +1562,15 @@
// Simple function for returning the source positions for active break points.
 Handle<Object> Debug::GetSourceBreakLocations(
     Handle<SharedFunctionInfo> shared) {
- if (!HasDebugInfo(shared)) return Handle<Object>(HEAP->undefined_value());
+  Isolate* isolate = Isolate::Current();
+  Heap* heap = isolate->heap();
+ if (!HasDebugInfo(shared)) return Handle<Object>(heap->undefined_value());
   Handle<DebugInfo> debug_info = GetDebugInfo(shared);
   if (debug_info->GetBreakPointCount() == 0) {
-    return Handle<Object>(HEAP->undefined_value());
+    return Handle<Object>(heap->undefined_value());
   }
   Handle<FixedArray> locations =
-      FACTORY->NewFixedArray(debug_info->GetBreakPointCount());
+      isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount());
   int count = 0;
   for (int i = 0; i < debug_info->break_points()->length(); i++) {
     if (!debug_info->break_points()->get(i)->IsUndefined()) {
@@ -1732,7 +1743,8 @@
       } else {
         prev->set_next(current->next());
       }
- current->debug_info()->shared()->set_debug_info(HEAP->undefined_value());
+      current->debug_info()->shared()->set_debug_info(
+              isolate_->heap()->undefined_value());
       delete current;

       // If there are no more debug info objects there are not more break
@@ -1750,7 +1762,8 @@


 void Debug::SetAfterBreakTarget(JavaScriptFrame* frame) {
-  HandleScope scope;
+  ASSERT(Isolate::Current() == isolate_);
+  HandleScope scope(isolate_);

   // Get the executing function in which the debug break occurred.
   Handle<SharedFunctionInfo> shared =
@@ -1764,7 +1777,7 @@
   Handle<Code> original_code(debug_info->original_code());
 #ifdef DEBUG
   // Get the code which is actually executing.
-  Handle<Code> frame_code(frame->LookupCode(Isolate::Current()));
+  Handle<Code> frame_code(frame->LookupCode(isolate_));
   ASSERT(frame_code.is_identical_to(code));
 #endif

@@ -1833,7 +1846,7 @@


 bool Debug::IsBreakAtReturn(JavaScriptFrame* frame) {
-  HandleScope scope;
+  HandleScope scope(isolate_);

   // Get the executing function in which the debug break occurred.
   Handle<SharedFunctionInfo> shared =
@@ -1882,13 +1895,14 @@


 void Debug::ClearMirrorCache() {
+  ASSERT(Isolate::Current() == isolate_);
   PostponeInterruptsScope postpone(isolate_);
-  HandleScope scope;
-  ASSERT(Isolate::Current()->context() == *Debug::debug_context());
+  HandleScope scope(isolate_);
+  ASSERT(isolate_->context() == *Debug::debug_context());

   // Clear the mirror cache.
   Handle<String> function_name =
-      FACTORY->LookupSymbol(CStrVector("ClearMirrorCache"));
+      isolate_->factory()->LookupSymbol(CStrVector("ClearMirrorCache"));
Handle<Object> fun(Isolate::Current()->global()->GetPropertyNoExceptionThrown(
       *function_name));
   ASSERT(fun->IsJSFunction());
@@ -1901,13 +1915,15 @@


 void Debug::CreateScriptCache() {
-  HandleScope scope;
+  ASSERT(Isolate::Current() == isolate_);
+  Heap* heap = isolate_->heap();
+  HandleScope scope(isolate_);

// Perform two GCs to get rid of all unreferenced scripts. The first GC gets
   // rid of all the cached script wrappers and the second gets rid of the
   // scripts which are no longer referenced.
-  HEAP->CollectAllGarbage(false);
-  HEAP->CollectAllGarbage(false);
+  heap->CollectAllGarbage(false);
+  heap->CollectAllGarbage(false);

   ASSERT(script_cache_ == NULL);
   script_cache_ = new ScriptCache();
@@ -1941,6 +1957,7 @@


 Handle<FixedArray> Debug::GetLoadedScripts() {
+  ASSERT(Isolate::Current() == isolate_);
// Create and fill the script cache when the loaded scripts is requested for
   // the first time.
   if (script_cache_ == NULL) {
@@ -1950,12 +1967,12 @@
   // If the script cache is not active just return an empty array.
   ASSERT(script_cache_ != NULL);
   if (script_cache_ == NULL) {
-    FACTORY->NewFixedArray(0);
+    isolate_->factory()->NewFixedArray(0);
   }

   // Perform GC to get unreferenced scripts evicted from the cache before
   // returning the content.
-  HEAP->CollectAllGarbage(false);
+  isolate_->heap()->CollectAllGarbage(false);

   // Get the scripts from the cache.
   return script_cache_->GetScripts();
@@ -2008,13 +2025,14 @@
   ASSERT(isolate_->context() == *isolate_->debug()->debug_context());

   // Create the execution state object.
-  Handle<String> constructor_str = FACTORY->LookupSymbol(constructor_name);
+  Handle<String> constructor_str =
+      isolate_->factory()->LookupSymbol(constructor_name);
   Handle<Object> constructor(
       isolate_->global()->GetPropertyNoExceptionThrown(*constructor_str));
   ASSERT(constructor->IsJSFunction());
   if (!constructor->IsJSFunction()) {
     *caught_exception = true;
-    return FACTORY->undefined_value();
+    return isolate_->factory()->undefined_value();
   }
   Handle<Object> js_object = Execution::TryCall(
       Handle<JSFunction>::cast(constructor),
@@ -2027,7 +2045,7 @@
 Handle<Object> Debugger::MakeExecutionState(bool* caught_exception) {
   ASSERT(Isolate::Current() == isolate_);
   // Create the execution state object.
-  Handle<Object> break_id = FACTORY->NewNumberFromInt(
+  Handle<Object> break_id = isolate_->factory()->NewNumberFromInt(
       isolate_->debug()->break_id());
   const int argc = 1;
   Object** argv[argc] = { break_id.location() };
@@ -2056,12 +2074,13 @@
                                             bool uncaught,
                                             bool* caught_exception) {
   ASSERT(Isolate::Current() == isolate_);
+  Factory* factory = isolate_->factory();
   // Create the new exception event object.
   const int argc = 3;
   Object** argv[argc] = { exec_state.location(),
                           exception.location(),
-                          uncaught ? FACTORY->true_value().location() :
-                                     FACTORY->false_value().location()};
+                          uncaught ? factory->true_value().location() :
+                                     factory->false_value().location()};
   return MakeJSObject(CStrVector("MakeExceptionEvent"),
                       argc, argv, caught_exception);
 }
@@ -2082,14 +2101,15 @@
                                           bool before,
                                           bool* caught_exception) {
   ASSERT(Isolate::Current() == isolate_);
+  Factory* factory = isolate_->factory();
   // Create the compile event object.
   Handle<Object> exec_state = MakeExecutionState(caught_exception);
   Handle<Object> script_wrapper = GetScriptWrapper(script);
   const int argc = 3;
   Object** argv[argc] = { exec_state.location(),
                           script_wrapper.location(),
-                          before ? FACTORY->true_value().location() :
-                                   FACTORY->false_value().location() };
+                          before ? factory->true_value().location() :
+                                   factory->false_value().location() };

   return MakeJSObject(CStrVector("MakeCompileEvent"),
                       argc,
@@ -2116,20 +2136,21 @@

 void Debugger::OnException(Handle<Object> exception, bool uncaught) {
   ASSERT(Isolate::Current() == isolate_);
-  HandleScope scope;
+  HandleScope scope(isolate_);
+  Debug* debug = isolate_->debug();

   // Bail out based on state or if there is no listener for this event
-  if (isolate_->debug()->InDebugger()) return;
+  if (debug->InDebugger()) return;
   if (!Debugger::EventActive(v8::Exception)) return;

   // Bail out if exception breaks are not active
   if (uncaught) {
     // Uncaught exceptions are reported by either flags.
-    if (!(isolate_->debug()->break_on_uncaught_exception() ||
-          isolate_->debug()->break_on_exception())) return;
+    if (!(debug->break_on_uncaught_exception() ||
+          debug->break_on_exception())) return;
   } else {
     // Caught exceptions are reported is activated.
-    if (!isolate_->debug()->break_on_exception()) return;
+    if (!debug->break_on_exception()) return;
   }

   // Enter the debugger.
@@ -2137,7 +2158,7 @@
   if (debugger.FailedToEnter()) return;

   // Clear all current stepping setup.
-  isolate_->debug()->ClearStepping();
+  debug->ClearStepping();
   // Create the event data object.
   bool caught_exception = false;
   Handle<Object> exec_state = MakeExecutionState(&caught_exception);
@@ -2160,7 +2181,7 @@
 void Debugger::OnDebugBreak(Handle<Object> break_points_hit,
                             bool auto_continue) {
   ASSERT(Isolate::Current() == isolate_);
-  HandleScope scope;
+  HandleScope scope(isolate_);

   // Debugger has already been entered by caller.
   ASSERT(isolate_->context() == *isolate_->debug()->debug_context());
@@ -2193,7 +2214,7 @@

 void Debugger::OnBeforeCompile(Handle<Script> script) {
   ASSERT(Isolate::Current() == isolate_);
-  HandleScope scope;
+  HandleScope scope(isolate_);

   // Bail out based on state or if there is no listener for this event
   if (isolate_->debug()->InDebugger()) return;
@@ -2223,10 +2244,11 @@
 void Debugger::OnAfterCompile(Handle<Script> script,
                               AfterCompileFlags after_compile_flags) {
   ASSERT(Isolate::Current() == isolate_);
-  HandleScope scope;
+  HandleScope scope(isolate_);
+  Debug* debug = isolate_->debug();

   // Add the newly compiled script to the script cache.
-  isolate_->debug()->AddScriptToScriptCache(script);
+  debug->AddScriptToScriptCache(script);

   // No more to do if not debugging.
   if (!IsDebuggerActive()) return;
@@ -2235,7 +2257,7 @@
   if (compiling_natives()) return;

   // Store whether in debugger before entering debugger.
-  bool in_debugger = isolate_->debug()->InDebugger();
+  bool in_debugger = debug->InDebugger();

   // Enter the debugger.
   EnterDebugger debugger;
@@ -2246,9 +2268,9 @@

// Get the function UpdateScriptBreakPoints (defined in debug-debugger.js).
   Handle<String> update_script_break_points_symbol =
-      FACTORY->LookupAsciiSymbol("UpdateScriptBreakPoints");
+      isolate_->factory()->LookupAsciiSymbol("UpdateScriptBreakPoints");
   Handle<Object> update_script_break_points =
-      Handle<Object>(isolate_->debug()->debug_context()->global()->
+      Handle<Object>(debug->debug_context()->global()->
GetPropertyNoExceptionThrown(*update_script_break_points_symbol));
   if (!update_script_break_points->IsJSFunction()) {
     return;
@@ -2291,7 +2313,7 @@

 void Debugger::OnScriptCollected(int id) {
   ASSERT(Isolate::Current() == isolate_);
-  HandleScope scope;
+  HandleScope scope(isolate_);

   // No more to do if not debugging.
   if (!IsDebuggerActive()) return;
@@ -2321,7 +2343,7 @@
                                  Handle<JSObject> event_data,
                                  bool auto_continue) {
   ASSERT(Isolate::Current() == isolate_);
-  HandleScope scope;
+  HandleScope scope(isolate_);

   // Clear any pending debug break if this is a real break.
   if (!auto_continue) {
@@ -2421,13 +2443,14 @@

 void Debugger::UnloadDebugger() {
   ASSERT(Isolate::Current() == isolate_);
+  Debug* debug = isolate_->debug();

   // Make sure that there are no breakpoints left.
-  isolate_->debug()->ClearAllBreakPoints();
+  debug->ClearAllBreakPoints();

   // Unload the debugger if feasible.
   if (!never_unload_debugger_) {
-    isolate_->debug()->Unload();
+    debug->Unload();
   }

   // Clear the flag indicating that the debugger should be unloaded.
@@ -2440,7 +2463,7 @@
                                     Handle<JSObject> event_data,
                                     bool auto_continue) {
   ASSERT(Isolate::Current() == isolate_);
-  HandleScope scope;
+  HandleScope scope(isolate_);

   if (!isolate_->debug()->Load()) return;

@@ -2610,17 +2633,18 @@
 void Debugger::SetEventListener(Handle<Object> callback,
                                 Handle<Object> data) {
   ASSERT(Isolate::Current() == isolate_);
-  HandleScope scope;
+  HandleScope scope(isolate_);
+  GlobalHandles* global_handles = isolate_->global_handles();

// Clear the global handles for the event listener and the event listener data
   // object.
   if (!event_listener_.is_null()) {
-    isolate_->global_handles()->Destroy(
+    global_handles->Destroy(
         reinterpret_cast<Object**>(event_listener_.location()));
     event_listener_ = Handle<Object>();
   }
   if (!event_listener_data_.is_null()) {
-    isolate_->global_handles()->Destroy(
+    global_handles->Destroy(
         reinterpret_cast<Object**>(event_listener_data_.location()));
     event_listener_data_ = Handle<Object>();
   }
@@ -2629,12 +2653,12 @@
   // object.
   if (!callback->IsUndefined() && !callback->IsNull()) {
     event_listener_ = Handle<Object>::cast(
-        isolate_->global_handles()->Create(*callback));
+        global_handles->Create(*callback));
     if (data.is_null()) {
-      data = FACTORY->undefined_value();
+      data = isolate_->factory()->undefined_value();
     }
     event_listener_data_ = Handle<Object>::cast(
-        isolate_->global_handles()->Create(*data));
+        global_handles->Create(*data));
   }

   ListenersChanged();
@@ -2658,13 +2682,13 @@


 void Debugger::ListenersChanged() {
-  Isolate* isolate = Isolate::Current();
+  ASSERT(Isolate::Current() == isolate_);
   if (IsDebuggerActive()) {
     // Disable the compilation cache when the debugger is active.
-    isolate->compilation_cache()->Disable();
+    isolate_->compilation_cache()->Disable();
     debugger_unload_pending_ = false;
   } else {
-    isolate->compilation_cache()->Enable();
+    isolate_->compilation_cache()->Enable();
     // Unload the debugger if event listener and message handler cleared.
     // Schedule this for later, because we may be in non-V8 thread.
     debugger_unload_pending_ = true;
@@ -2776,14 +2800,14 @@
   // Enter the debugger.
   EnterDebugger debugger;
   if (debugger.FailedToEnter()) {
-    return FACTORY->undefined_value();
+    return isolate_->factory()->undefined_value();
   }

   // Create the execution state.
   bool caught_exception = false;
   Handle<Object> exec_state = MakeExecutionState(&caught_exception);
   if (caught_exception) {
-    return FACTORY->undefined_value();
+    return isolate_->factory()->undefined_value();
   }

   static const int kArgc = 2;

--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev

Reply via email to