Revision: 14421
Author:   [email protected]
Date:     Wed Apr 24 07:44:08 2013
Log:      Clean up VMState a little bit.

[email protected]
BUG=

Review URL: https://chromiumcodereview.appspot.com/14139033
http://code.google.com/p/v8/source/detail?r=14421

Modified:
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/src/arm/macro-assembler-arm.cc
 /branches/bleeding_edge/src/builtins.cc
 /branches/bleeding_edge/src/compiler.cc
 /branches/bleeding_edge/src/execution.cc
 /branches/bleeding_edge/src/flag-definitions.h
 /branches/bleeding_edge/src/global-handles.cc
 /branches/bleeding_edge/src/handles.cc
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc
 /branches/bleeding_edge/src/isolate.cc
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/src/log-utils.cc
 /branches/bleeding_edge/src/log-utils.h
 /branches/bleeding_edge/src/log.cc
 /branches/bleeding_edge/src/log.h
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/profile-generator-inl.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/stub-cache.cc
 /branches/bleeding_edge/src/v8globals.h
 /branches/bleeding_edge/src/vm-state-inl.h
 /branches/bleeding_edge/src/vm-state.h
 /branches/bleeding_edge/src/x64/macro-assembler-x64.cc
 /branches/bleeding_edge/tools/tickprocessor.js

=======================================
--- /branches/bleeding_edge/src/api.cc  Mon Apr 22 08:20:28 2013
+++ /branches/bleeding_edge/src/api.cc  Wed Apr 24 07:44:08 2013
@@ -63,11 +63,9 @@

 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))

-#define ENTER_V8(isolate)                                        \
-  ASSERT((isolate)->IsInitialized());                           \
-  i::VMState __state__((isolate), i::OTHER)
-#define LEAVE_V8(isolate) \
-  i::VMState __state__((isolate), i::EXTERNAL)
+#define ENTER_V8(isolate)                                          \
+  ASSERT((isolate)->IsInitialized());                              \
+  i::VMState<i::OTHER> __state__((isolate))

 namespace v8 {

@@ -131,7 +129,7 @@
                                      const char* message) {
   i::Isolate* isolate = i::Isolate::Current();
   if (isolate->IsInitialized()) {
-    i::VMState __state__(isolate, i::OTHER);
+    i::VMState<i::OTHER> state(isolate);
     API_Fatal(location, message);
   } else {
     API_Fatal(location, message);
@@ -216,14 +214,7 @@
   i::V8::SetFatalError();
   FatalErrorCallback callback = GetFatalErrorHandler();
   const char* message = "Allocation failed - process out of memory";
-  {
-    if (isolate->IsInitialized()) {
-      LEAVE_V8(isolate);
-      callback(location, message);
-    } else {
-      callback(location, message);
-    }
-  }
+  callback(location, message);
   // If the callback returns, we stop execution.
   UNREACHABLE();
 }
=======================================
--- /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Wed Apr 24 00:39:35 2013 +++ /branches/bleeding_edge/src/arm/macro-assembler-arm.cc Wed Apr 24 07:44:08 2013
@@ -2264,8 +2264,9 @@
   if (FLAG_log_timer_events) {
     FrameScope frame(this, StackFrame::MANUAL);
     PushSafepointRegisters();
-    PrepareCallCFunction(0, r0);
- CallCFunction(ExternalReference::log_enter_external_function(isolate()), 0);
+    PrepareCallCFunction(1, r0);
+    mov(r0, Operand(ExternalReference::isolate_address(isolate())));
+ CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1);
     PopSafepointRegisters();
   }

@@ -2278,8 +2279,9 @@
   if (FLAG_log_timer_events) {
     FrameScope frame(this, StackFrame::MANUAL);
     PushSafepointRegisters();
-    PrepareCallCFunction(0, r0);
- CallCFunction(ExternalReference::log_leave_external_function(isolate()), 0);
+    PrepareCallCFunction(1, r0);
+    mov(r0, Operand(ExternalReference::isolate_address(isolate())));
+ CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
     PopSafepointRegisters();
   }

=======================================
--- /branches/bleeding_edge/src/builtins.cc     Wed Apr 17 06:51:08 2013
+++ /branches/bleeding_edge/src/builtins.cc     Wed Apr 24 07:44:08 2013
@@ -1321,7 +1321,7 @@
     v8::Handle<v8::Value> value;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       ExternalCallbackScope call_scope(isolate,
                                        v8::ToCData<Address>(callback_obj));
       value = callback(new_args);
@@ -1398,7 +1398,7 @@
     v8::Handle<v8::Value> value;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       ExternalCallbackScope call_scope(isolate,
                                        v8::ToCData<Address>(callback_obj));
       value = callback(new_args);
=======================================
--- /branches/bleeding_edge/src/compiler.cc     Wed Apr 24 04:32:17 2013
+++ /branches/bleeding_edge/src/compiler.cc     Wed Apr 24 07:44:08 2013
@@ -627,7 +627,7 @@
   isolate->counters()->total_compile_size()->Increment(source_length);

   // The VM is in the COMPILER state until exiting this function.
-  VMState state(isolate, COMPILER);
+  VMState<COMPILER> state(isolate);

   CompilationCache* compilation_cache = isolate->compilation_cache();

@@ -701,7 +701,7 @@
   isolate->counters()->total_compile_size()->Increment(source_length);

   // The VM is in the COMPILER state until exiting this function.
-  VMState state(isolate, COMPILER);
+  VMState<COMPILER> state(isolate);

// Do a lookup in the compilation cache; if the entry is not there, invoke
   // the compiler and add the result to the cache.
@@ -864,7 +864,7 @@
   ZoneScope zone_scope(info->zone(), DELETE_ON_EXIT);

   // The VM is in the COMPILER state until exiting this function.
-  VMState state(isolate, COMPILER);
+  VMState<COMPILER> state(isolate);

   PostponeInterruptsScope postpone(isolate);

@@ -928,7 +928,7 @@
   }

   SmartPointer<CompilationInfo> info(new CompilationInfoWithZone(closure));
-  VMState state(isolate, PARALLEL_COMPILER);
+  VMState<COMPILER> state(isolate);
   PostponeInterruptsScope postpone(isolate);

   Handle<SharedFunctionInfo> shared = info->shared_info();
@@ -1003,7 +1003,7 @@
   }

   Isolate* isolate = info->isolate();
-  VMState state(isolate, PARALLEL_COMPILER);
+  VMState<COMPILER> state(isolate);
   Logger::TimerEventScope timer(
       isolate, Logger::TimerEventScope::v8_recompile_synchronous);
   // If crankshaft succeeded, install the optimized code else install
=======================================
--- /branches/bleeding_edge/src/execution.cc    Mon Apr 22 08:01:45 2013
+++ /branches/bleeding_edge/src/execution.cc    Wed Apr 24 07:44:08 2013
@@ -76,7 +76,7 @@
   Isolate* isolate = function->GetIsolate();

   // Entering JavaScript.
-  VMState state(isolate, JS);
+  VMState<JS> state(isolate);

   // Placeholder for return value.
   MaybeObject* value = reinterpret_cast<Object*>(kZapValue);
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h      Tue Apr 23 09:30:51 2013
+++ /branches/bleeding_edge/src/flag-definitions.h      Wed Apr 24 07:44:08 2013
@@ -673,9 +673,6 @@

 DEFINE_bool(trace_isolates, false, "trace isolate state changes")

-// VM state
-DEFINE_bool(log_state_changes, false, "Log state changes.")
-
 // Regexp
 DEFINE_bool(regexp_possessive_quantifier,
             false,
@@ -723,6 +720,7 @@
 DEFINE_bool(log_timer_events, false,
             "Time events including external callbacks.")
 DEFINE_implication(log_timer_events, log_internal_timer_events)
+DEFINE_implication(log_internal_timer_events, prof)

 //
 // Disassembler only flags
=======================================
--- /branches/bleeding_edge/src/global-handles.cc       Tue Apr 16 09:37:04 2013
+++ /branches/bleeding_edge/src/global-handles.cc       Wed Apr 24 07:44:08 2013
@@ -267,7 +267,7 @@
       ASSERT(!object_->IsExternalTwoByteString() ||
              ExternalTwoByteString::cast(object_)->resource() != NULL);
       // Leaving V8.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       if (near_death_callback_ != NULL) {
         if (IsWeakCallback::decode(flags_)) {
           WeakReferenceCallback callback =
=======================================
--- /branches/bleeding_edge/src/handles.cc      Wed Apr 10 06:52:08 2013
+++ /branches/bleeding_edge/src/handles.cc      Wed Apr 24 07:44:08 2013
@@ -565,7 +565,7 @@
     LOG(isolate, ApiObjectAccess("interceptor-named-enum", *object));
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = enum_fun(info);
     }
   }
@@ -590,7 +590,7 @@
     LOG(isolate, ApiObjectAccess("interceptor-indexed-enum", *object));
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = enum_fun(info);
 #if ENABLE_EXTRA_CHECKS
CHECK(result.IsEmpty() || v8::Utils::OpenHandle(*result)->IsJSObject());
=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Apr 23 08:21:11 2013
+++ /branches/bleeding_edge/src/heap.cc Wed Apr 24 07:44:08 2013
@@ -606,7 +606,7 @@
                           const char* gc_reason,
                           const char* collector_reason) {
   // The VM is in the GC state until exiting this function.
-  VMState state(isolate_, GC);
+  VMState<GC> state(isolate_);

 #ifdef DEBUG
   // Reset the allocation timeout to the GC interval, but make sure to
@@ -892,7 +892,7 @@

   {
     GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
-    VMState state(isolate_, EXTERNAL);
+    VMState<EXTERNAL> state(isolate_);
     CallGCPrologueCallbacks(gc_type);
   }

@@ -1014,7 +1014,7 @@

   {
     GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL);
-    VMState state(isolate_, EXTERNAL);
+    VMState<EXTERNAL> state(isolate_);
     CallGCEpilogueCallbacks(gc_type);
   }

=======================================
--- /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Wed Apr 24 00:39:35 2013 +++ /branches/bleeding_edge/src/ia32/macro-assembler-ia32.cc Wed Apr 24 07:44:08 2013
@@ -1984,8 +1984,10 @@
   if (FLAG_log_timer_events) {
     FrameScope frame(this, StackFrame::MANUAL);
     PushSafepointRegisters();
-    PrepareCallCFunction(0, eax);
- CallCFunction(ExternalReference::log_enter_external_function(isolate()), 0);
+    PrepareCallCFunction(1, eax);
+    mov(Operand(esp, 0),
+        Immediate(ExternalReference::isolate_address(isolate())));
+ CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1);
     PopSafepointRegisters();
   }

@@ -1995,8 +1997,10 @@
   if (FLAG_log_timer_events) {
     FrameScope frame(this, StackFrame::MANUAL);
     PushSafepointRegisters();
-    PrepareCallCFunction(0, eax);
- CallCFunction(ExternalReference::log_leave_external_function(isolate()), 0);
+    PrepareCallCFunction(1, eax);
+    mov(Operand(esp, 0),
+        Immediate(ExternalReference::isolate_address(isolate())));
+ CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
     PopSafepointRegisters();
   }

=======================================
--- /branches/bleeding_edge/src/isolate.cc      Wed Apr 24 06:52:26 2013
+++ /branches/bleeding_edge/src/isolate.cc      Wed Apr 24 07:44:08 2013
@@ -930,7 +930,7 @@
   HandleScope scope(this);
   Handle<JSObject> receiver_handle(receiver);
   Handle<Object> data(AccessCheckInfo::cast(data_obj)->data(), this);
-  { VMState state(this, EXTERNAL);
+  { VMState<EXTERNAL> state(this);
     thread_local_top()->failed_access_check_callback_(
       v8::Utils::ToLocal(receiver_handle),
       type,
@@ -1009,7 +1009,7 @@
   bool result = false;
   {
     // Leaving JavaScript.
-    VMState state(this, EXTERNAL);
+    VMState<EXTERNAL> state(this);
     result = callback(v8::Utils::ToLocal(receiver_handle),
                       v8::Utils::ToLocal(key_handle),
                       type,
@@ -1051,7 +1051,7 @@
   bool result = false;
   {
     // Leaving JavaScript.
-    VMState state(this, EXTERNAL);
+    VMState<EXTERNAL> state(this);
     result = callback(v8::Utils::ToLocal(receiver_handle),
                       index,
                       type,
@@ -2116,7 +2116,7 @@
   heap_profiler_ = new HeapProfiler(heap());

   // Enable logging before setting up the heap
-  logger_->SetUp();
+  logger_->SetUp(this);

   // Initialize other runtime facilities
 #if defined(USE_SIMULATOR)
=======================================
--- /branches/bleeding_edge/src/isolate.h       Tue Apr 23 02:23:07 2013
+++ /branches/bleeding_edge/src/isolate.h       Wed Apr 24 07:44:08 2013
@@ -85,7 +85,7 @@
 class ThreadManager;
 class ThreadState;
 class ThreadVisitor;  // Defined in v8threads.h
-class VMState;
+template <StateTag Tag> class VMState;

 // 'void function pointer', used to roundtrip the
 // ExternalReference::ExternalReferenceRedirector since we can not include
@@ -1031,7 +1031,7 @@
     return thread_local_top_.current_vm_state_;
   }

-  void SetCurrentVMState(StateTag state) {
+  void set_current_vm_state(StateTag state) {
     thread_local_top_.current_vm_state_ = state;
   }

=======================================
--- /branches/bleeding_edge/src/log-utils.cc    Tue Apr 16 05:30:51 2013
+++ /branches/bleeding_edge/src/log-utils.cc    Wed Apr 24 07:44:08 2013
@@ -78,14 +78,9 @@
     FLAG_log_code = false;
     FLAG_prof_auto = false;
   }
-
-  bool open_log_file = FLAG_log || FLAG_log_runtime || FLAG_log_api
- || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect
-      || FLAG_log_regexp || FLAG_log_state_changes || FLAG_ll_prof
-      || FLAG_log_internal_timer_events;

   // If we're logging anything, we need to open the log file.
-  if (open_log_file) {
+  if (Log::InitLogAtStart()) {
     if (strcmp(FLAG_logfile, "-") == 0) {
       OpenStdout();
     } else if (strcmp(FLAG_logfile, kLogToTemporaryFile) == 0) {
=======================================
--- /branches/bleeding_edge/src/log-utils.h     Thu Sep  8 12:57:14 2011
+++ /branches/bleeding_edge/src/log-utils.h     Wed Apr 24 07:44:08 2013
@@ -43,6 +43,12 @@

   // Disables logging, but preserves acquired resources.
   void stop() { is_stopped_ = true; }
+
+  static bool InitLogAtStart() {
+    return FLAG_log || FLAG_log_runtime || FLAG_log_api
+ || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect + || FLAG_log_regexp || FLAG_ll_prof || FLAG_log_internal_timer_events;
+  }

   // Frees all resources acquired in Initialize and Open... functions.
// When a temporary file is used for the log, returns its stream descriptor,
=======================================
--- /branches/bleeding_edge/src/log.cc  Wed Apr 24 04:32:17 2013
+++ /branches/bleeding_edge/src/log.cc  Wed Apr 24 07:44:08 2013
@@ -658,13 +658,17 @@
 }


-void Logger::EnterExternal() {
-  LOG(ISOLATE, TimerEvent(START, TimerEventScope::v8_external));
+void Logger::EnterExternal(Isolate* isolate) {
+  LOG(isolate, TimerEvent(START, TimerEventScope::v8_external));
+  ASSERT(isolate->current_vm_state() == JS);
+  isolate->set_current_vm_state(EXTERNAL);
 }


-void Logger::LeaveExternal() {
-  LOG(ISOLATE, TimerEvent(END, TimerEventScope::v8_external));
+void Logger::LeaveExternal(Isolate* isolate) {
+  LOG(isolate, TimerEvent(END, TimerEventScope::v8_external));
+  ASSERT(isolate->current_vm_state() == EXTERNAL);
+  isolate->set_current_vm_state(JS);
 }


@@ -1817,7 +1821,7 @@
 }


-bool Logger::SetUp() {
+bool Logger::SetUp(Isolate* isolate) {
// Tests and EnsureInitialize() can call this twice in a row. It's harmless.
   if (is_initialized_) return true;
   is_initialized_ = true;
@@ -1832,24 +1836,14 @@
     FLAG_log_code = false;
     FLAG_prof_auto = false;
   }
-
-  // TODO(isolates): this assert introduces cyclic dependency (logger
-  // -> thread local top -> heap -> logger).
-  // ASSERT(VMState::is_outermost_external());

   log_->Initialize();

   if (FLAG_ll_prof) LogCodeInfo();

-  Isolate* isolate = Isolate::Current();
   ticker_ = new Ticker(isolate, kSamplingIntervalMs);

-  bool start_logging = FLAG_log || FLAG_log_runtime || FLAG_log_api
-    || FLAG_log_code || FLAG_log_gc || FLAG_log_handles || FLAG_log_suspect
-    || FLAG_log_regexp || FLAG_log_state_changes || FLAG_ll_prof
-    || FLAG_log_internal_timer_events;
-
-  if (start_logging) {
+  if (Log::InitLogAtStart()) {
     logging_nesting_ = 1;
   }

=======================================
--- /branches/bleeding_edge/src/log.h   Wed Apr 17 00:53:12 2013
+++ /branches/bleeding_edge/src/log.h   Wed Apr 24 07:44:08 2013
@@ -163,7 +163,7 @@
 #undef DECLARE_ENUM

   // Acquires resources for logging if the right flags are set.
-  bool SetUp();
+  bool SetUp(Isolate* isolate);

   // Sets the current code event handler.
   void SetCodeEventHandler(uint32_t options,
@@ -292,8 +292,8 @@

   void TimerEvent(StartEnd se, const char* name);

-  static void EnterExternal();
-  static void LeaveExternal();
+  static void EnterExternal(Isolate* isolate);
+  static void LeaveExternal(Isolate* isolate);

   class TimerEventScope {
    public:
@@ -466,7 +466,7 @@
   friend class LogMessageBuilder;
   friend class TimeLog;
   friend class Profiler;
-  friend class VMState;
+  template <StateTag Tag> friend class VMState;

   friend class LoggerTestHelper;

=======================================
--- /branches/bleeding_edge/src/objects.cc      Wed Apr 24 04:32:17 2013
+++ /branches/bleeding_edge/src/objects.cc      Wed Apr 24 07:44:08 2013
@@ -344,7 +344,7 @@
     v8::Handle<v8::Value> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = call_fun(v8::Utils::ToLocal(key), info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION(isolate);
@@ -2119,7 +2119,7 @@
     v8::Handle<v8::Value> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       Handle<Object> value_unhole(value->IsTheHole() ?
                                   isolate->heap()->undefined_value() :
                                   value,
@@ -2230,7 +2230,7 @@
     v8::AccessorInfo info(args.end());
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       call_fun(v8::Utils::ToLocal(key),
                v8::Utils::ToLocal(value_handle),
                info);
@@ -3494,7 +3494,7 @@
     v8::Handle<v8::Integer> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = query(v8::Utils::ToLocal(name_handle), info);
     }
     if (!result.IsEmpty()) {
@@ -3509,7 +3509,7 @@
     v8::Handle<v8::Value> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = getter(v8::Utils::ToLocal(name_handle), info);
     }
     if (!result.IsEmpty()) return DONT_ENUM;
@@ -3635,7 +3635,7 @@
     v8::Handle<v8::Integer> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = query(index, info);
     }
     if (!result.IsEmpty())
@@ -3648,7 +3648,7 @@
     v8::Handle<v8::Value> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = getter(index, info);
     }
     if (!result.IsEmpty()) return NONE;
@@ -4318,7 +4318,7 @@
     v8::Handle<v8::Boolean> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = deleter(v8::Utils::ToLocal(name_handle), info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION(isolate);
@@ -4355,7 +4355,7 @@
   v8::Handle<v8::Boolean> result;
   {
     // Leaving JavaScript.
-    VMState state(isolate, EXTERNAL);
+    VMState<EXTERNAL> state(isolate);
     result = deleter(index, info);
   }
   RETURN_IF_SCHEDULED_EXCEPTION(isolate);
@@ -10289,7 +10289,7 @@
     v8::Handle<v8::Value> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = setter(index, v8::Utils::ToLocal(value_handle), info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION(isolate);
@@ -10332,7 +10332,7 @@
     v8::Handle<v8::Value> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = call_fun(v8::Utils::ToLocal(key), info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION(isolate);
@@ -10398,7 +10398,7 @@
     v8::AccessorInfo info(args.end());
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       call_fun(v8::Utils::ToLocal(key),
                v8::Utils::ToLocal(value_handle),
                info);
@@ -11278,7 +11278,7 @@
     v8::Handle<v8::Value> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = getter(index, info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION(isolate);
@@ -11588,7 +11588,7 @@
     v8::Handle<v8::Value> result;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       result = getter(v8::Utils::ToLocal(name_handle), info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION(isolate);
=======================================
--- /branches/bleeding_edge/src/profile-generator-inl.h Tue Apr 2 00:48:25 2013 +++ /branches/bleeding_edge/src/profile-generator-inl.h Wed Apr 24 07:44:08 2013
@@ -85,7 +85,6 @@
       return gc_entry_;
     case JS:
     case COMPILER:
-    case PARALLEL_COMPILER:
     // DOM events handlers are reported as OTHER / EXTERNAL entries.
     // To avoid confusing people, let's put all these entries into
     // one bucket.
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Wed Apr 24 06:00:16 2013
+++ /branches/bleeding_edge/src/runtime.cc      Wed Apr 24 07:44:08 2013
@@ -8953,7 +8953,7 @@
     return false;
   } else {
     // Callback set. Let it decide if code generation is allowed.
-    VMState state(isolate, EXTERNAL);
+    VMState<EXTERNAL> state(isolate);
     return callback(v8::Utils::ToLocal(context));
   }
 }
=======================================
--- /branches/bleeding_edge/src/stub-cache.cc   Wed Apr 24 04:32:17 2013
+++ /branches/bleeding_edge/src/stub-cache.cc   Wed Apr 24 07:44:08 2013
@@ -1111,7 +1111,7 @@
   v8::AccessorInfo info(custom_args.end());
   {
     // Leaving JavaScript.
-    VMState state(isolate, EXTERNAL);
+    VMState<EXTERNAL> state(isolate);
     ExternalCallbackScope call_scope(isolate, setter_address);
     fun(v8::Utils::ToLocal(str), v8::Utils::ToLocal(value), info);
   }
@@ -1157,7 +1157,7 @@
     v8::Handle<v8::Value> r;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       r = getter(v8::Utils::ToLocal(name), info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION(isolate);
@@ -1220,7 +1220,7 @@
     v8::Handle<v8::Value> r;
     {
       // Leaving JavaScript.
-      VMState state(isolate, EXTERNAL);
+      VMState<EXTERNAL> state(isolate);
       r = getter(v8::Utils::ToLocal(name), info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION(isolate);
=======================================
--- /branches/bleeding_edge/src/v8globals.h     Mon Apr 15 06:57:41 2013
+++ /branches/bleeding_edge/src/v8globals.h     Wed Apr 24 07:44:08 2013
@@ -363,7 +363,6 @@
   JS,
   GC,
   COMPILER,
-  PARALLEL_COMPILER,
   OTHER,
   EXTERNAL
 };
=======================================
--- /branches/bleeding_edge/src/vm-state-inl.h  Mon Jan 28 05:55:40 2013
+++ /branches/bleeding_edge/src/vm-state-inl.h  Wed Apr 24 07:44:08 2013
@@ -47,8 +47,6 @@
       return "GC";
     case COMPILER:
       return "COMPILER";
-    case PARALLEL_COMPILER:
-      return "PARALLEL_COMPILER";
     case OTHER:
       return "OTHER";
     case EXTERNAL:
@@ -60,36 +58,24 @@
 }


-VMState::VMState(Isolate* isolate, StateTag tag)
+template <StateTag Tag>
+VMState<Tag>::VMState(Isolate* isolate)
     : isolate_(isolate), previous_tag_(isolate->current_vm_state()) {
-  if (FLAG_log_state_changes) {
-    LOG(isolate, UncheckedStringEvent("Entering", StateToString(tag)));
- LOG(isolate, UncheckedStringEvent("From", StateToString(previous_tag_))); + if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) {
+    LOG(isolate_,
+        TimerEvent(Logger::START, Logger::TimerEventScope::v8_external));
   }
-
- if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && tag == EXTERNAL) {
-    LOG(isolate_, EnterExternal());
-  }
-
-  isolate_->SetCurrentVMState(tag);
+  isolate_->set_current_vm_state(Tag);
 }


-VMState::~VMState() {
-  if (FLAG_log_state_changes) {
-    LOG(isolate_,
-        UncheckedStringEvent("Leaving",
- StateToString(isolate_->current_vm_state())));
+template <StateTag Tag>
+VMState<Tag>::~VMState() {
+ if (FLAG_log_timer_events && previous_tag_ != EXTERNAL && Tag == EXTERNAL) {
     LOG(isolate_,
-        UncheckedStringEvent("To", StateToString(previous_tag_)));
-  }
-
-  if (FLAG_log_timer_events &&
- previous_tag_ != EXTERNAL && isolate_->current_vm_state() == EXTERNAL) {
-    LOG(isolate_, LeaveExternal());
+        TimerEvent(Logger::END, Logger::TimerEventScope::v8_external));
   }
-
-  isolate_->SetCurrentVMState(previous_tag_);
+  isolate_->set_current_vm_state(previous_tag_);
 }


=======================================
--- /branches/bleeding_edge/src/vm-state.h      Wed Jul 13 02:09:04 2011
+++ /branches/bleeding_edge/src/vm-state.h      Wed Apr 24 07:44:08 2013
@@ -34,9 +34,10 @@
 namespace v8 {
 namespace internal {

+template <StateTag Tag>
 class VMState BASE_EMBEDDED {
  public:
-  inline VMState(Isolate* isolate, StateTag tag);
+  explicit inline VMState(Isolate* isolate);
   inline ~VMState();

  private:
=======================================
--- /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Wed Apr 24 05:01:08 2013 +++ /branches/bleeding_edge/src/x64/macro-assembler-x64.cc Wed Apr 24 07:44:08 2013
@@ -725,8 +725,9 @@
   if (FLAG_log_timer_events) {
     FrameScope frame(this, StackFrame::MANUAL);
     PushSafepointRegisters();
-    PrepareCallCFunction(0);
- CallCFunction(ExternalReference::log_enter_external_function(isolate()), 0);
+    PrepareCallCFunction(1);
+    LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate()));
+ CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1);
     PopSafepointRegisters();
   }

@@ -738,8 +739,9 @@
   if (FLAG_log_timer_events) {
     FrameScope frame(this, StackFrame::MANUAL);
     PushSafepointRegisters();
-    PrepareCallCFunction(0);
- CallCFunction(ExternalReference::log_leave_external_function(isolate()), 0);
+    PrepareCallCFunction(1);
+    LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate()));
+ CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
     PopSafepointRegisters();
   }

=======================================
--- /branches/bleeding_edge/tools/tickprocessor.js      Fri Apr 19 04:55:01 2013
+++ /branches/bleeding_edge/tools/tickprocessor.js      Wed Apr 24 07:44:08 2013
@@ -248,9 +248,8 @@
   JS: 0,
   GC: 1,
   COMPILER: 2,
-  PARALLEL_COMPILER: 3,
-  OTHER: 4,
-  EXTERNAL: 5
+  OTHER: 3,
+  EXTERNAL: 4
 };


--
--
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.


Reply via email to