Revision: 14168
Author:   [email protected]
Date:     Mon Apr  8 08:16:55 2013
Log:      Remove LOGGER macro

Use already saved isolate pointer and avoid TLS lookup when
retrieving Logger instance

BUG=None

Review URL: https://codereview.chromium.org/13529004
http://code.google.com/p/v8/source/detail?r=14168

Modified:
 /branches/bleeding_edge/src/isolate.h
 /branches/bleeding_edge/src/log.cc
 /branches/bleeding_edge/src/log.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/test/cctest/test-log.cc

=======================================
--- /branches/bleeding_edge/src/isolate.h       Tue Apr  2 01:03:01 2013
+++ /branches/bleeding_edge/src/isolate.h       Mon Apr  8 08:16:55 2013
@@ -1480,7 +1480,6 @@
 #define HEAP (v8::internal::Isolate::Current()->heap())
 #define FACTORY (v8::internal::Isolate::Current()->factory())
 #define ISOLATE (v8::internal::Isolate::Current())
-#define LOGGER (v8::internal::Isolate::Current()->logger())


 // Tells whether the native context is marked with out of memory.
=======================================
--- /branches/bleeding_edge/src/log.cc  Mon Apr  8 08:09:03 2013
+++ /branches/bleeding_edge/src/log.cc  Mon Apr  8 08:16:55 2013
@@ -216,9 +216,10 @@
   Start();

   // Register to get ticks.
-  LOGGER->ticker_->SetProfiler(this);
+  Logger* logger = isolate_->logger();
+  logger->ticker_->SetProfiler(this);

-  LOGGER->ProfilerBeginEvent();
+  logger->ProfilerBeginEvent();
 }


@@ -226,7 +227,7 @@
   if (!engaged_) return;

   // Stop receiving ticks.
-  LOGGER->ticker_->ClearProfiler();
+  isolate_->logger()->ticker_->ClearProfiler();

   // Terminate the worker thread by setting running_ to false,
   // inserting a fake element in the queue and then wait for
@@ -778,11 +779,10 @@
 }


-void Logger::LogRuntime(Isolate* isolate,
-                        Vector<const char> format,
+void Logger::LogRuntime(Vector<const char> format,
                         JSArray* args) {
   if (!log_->IsEnabled() || !FLAG_log_runtime) return;
-  HandleScope scope(isolate);
+  HandleScope scope(isolate_);
   LogMessageBuilder msg(this);
   for (int i = 0; i < format.length(); i++) {
     char c = format[i];
@@ -899,12 +899,12 @@


 void Logger::NewEventStatic(const char* name, void* object, size_t size) {
-  LOGGER->NewEvent(name, object, size);
+  Isolate::Current()->logger()->NewEvent(name, object, size);
 }


 void Logger::DeleteEventStatic(const char* name, void* object) {
-  LOGGER->DeleteEvent(name, object);
+  Isolate::Current()->logger()->DeleteEvent(name, object);
 }

 void Logger::CallbackEventInternal(const char* prefix, Name* name,
=======================================
--- /branches/bleeding_edge/src/log.h   Mon Apr  8 08:09:03 2013
+++ /branches/bleeding_edge/src/log.h   Mon Apr  8 08:16:55 2013
@@ -324,7 +324,7 @@
   void RegExpCompileEvent(Handle<JSRegExp> regexp, bool in_cache);

   // Log an event reported from generated code
- void LogRuntime(Isolate* isolate, Vector<const char> format, JSArray* args);
+  void LogRuntime(Vector<const char> format, JSArray* args);

   bool is_logging() {
     return logging_nesting_ > 0;
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Fri Apr  5 08:12:59 2013
+++ /branches/bleeding_edge/src/runtime.cc      Mon Apr  8 08:16:55 2013
@@ -12838,7 +12838,7 @@
   String::FlatContent format_content = format->GetFlatContent();
   RUNTIME_ASSERT(format_content.IsAscii());
   Vector<const uint8_t> chars = format_content.ToOneByteVector();
-  LOGGER->LogRuntime(isolate, Vector<const char>::cast(chars), elms);
+  isolate->logger()->LogRuntime(Vector<const char>::cast(chars), elms);
   return isolate->heap()->undefined_value();
 }

=======================================
--- /branches/bleeding_edge/test/cctest/test-log.cc     Fri Mar 15 05:06:53 2013
+++ /branches/bleeding_edge/test/cctest/test-log.cc     Mon Apr  8 08:16:55 2013
@@ -62,13 +62,14 @@
         // Need to run this prior to creating the scope.
         trick_to_run_init_flags_(init_flags_(prof_lazy)),
         scope_(v8::Isolate::GetCurrent()),
-        env_(v8::Context::New()) {
+        env_(v8::Context::New()),
+        logger_(i::Isolate::Current()->logger()) {
     env_->Enter();
   }

   ~ScopedLoggerInitializer() {
     env_->Exit();
-    LOGGER->TearDown();
+    logger_->TearDown();
     if (temp_file_ != NULL) fclose(temp_file_);
     i::FLAG_prof_lazy = saved_prof_lazy_;
     i::FLAG_prof = saved_prof_;
@@ -77,9 +78,11 @@
   }

   v8::Handle<v8::Context>& env() { return env_; }
+
+  Logger* logger() { return logger_; }

   FILE* StopLoggingGetTempFile() {
-    temp_file_ = LOGGER->TearDown();
+    temp_file_ = logger_->TearDown();
     CHECK_NE(NULL, temp_file_);
     fflush(temp_file_);
     rewind(temp_file_);
@@ -104,6 +107,7 @@
   const bool trick_to_run_init_flags_;
   v8::HandleScope scope_;
   v8::Handle<v8::Context> env_;
+  Logger* logger_;

   DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer);
 };
@@ -123,12 +127,13 @@

 TEST(ProfLazyMode) {
   ScopedLoggerInitializer initialize_logger(true);
+  Logger* logger = initialize_logger.logger();

   if (!i::V8::UseCrankshaft()) return;

-  LOGGER->StringEvent("test-start", "");
+  logger->StringEvent("test-start", "");
   CompileRun("var a = (function(x) { return x + 1; })(10);");
-  LOGGER->StringEvent("test-profiler-start", "");
+  logger->StringEvent("test-profiler-start", "");
   v8::V8::ResumeProfiler();
   CompileRun(
       "var b = (function(x) { return x + 2; })(10);\n"
@@ -136,10 +141,10 @@
       "var d = (function(x) { return x + 4; })(10);\n"
       "var e = (function(x) { return x + 5; })(10);");
   v8::V8::PauseProfiler();
-  LOGGER->StringEvent("test-profiler-stop", "");
+  logger->StringEvent("test-profiler-stop", "");
   CompileRun("var f = (function(x) { return x + 6; })(10);");
   // Check that profiling can be resumed again.
-  LOGGER->StringEvent("test-profiler-start-2", "");
+  logger->StringEvent("test-profiler-start-2", "");
   v8::V8::ResumeProfiler();
   CompileRun(
       "var g = (function(x) { return x + 7; })(10);\n"
@@ -147,8 +152,8 @@
       "var i = (function(x) { return x + 9; })(10);\n"
       "var j = (function(x) { return x + 10; })(10);");
   v8::V8::PauseProfiler();
-  LOGGER->StringEvent("test-profiler-stop-2", "");
-  LOGGER->StringEvent("test-stop", "");
+  logger->StringEvent("test-profiler-stop-2", "");
+  logger->StringEvent("test-stop", "");

   bool exists = false;
   i::Vector<const char> log(
@@ -383,7 +388,7 @@
   i_source->set_resource(NULL);

   // Must not crash.
-  LOGGER->LogCompiledFunctions();
+  i::Isolate::Current()->logger()->LogCompiledFunctions();
 }


@@ -393,6 +398,7 @@

 TEST(LogCallbacks) {
   ScopedLoggerInitializer initialize_logger(false);
+  Logger* logger = initialize_logger.logger();

   v8::Persistent<v8::FunctionTemplate> obj =
       v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
@@ -409,7 +415,7 @@
initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction());
   CompileRun("Obj.prototype.method1.toString();");

-  LOGGER->LogCompiledFunctions();
+  logger->LogCompiledFunctions();

   bool exists = false;
   i::Vector<const char> log(
@@ -444,6 +450,7 @@

 TEST(LogAccessorCallbacks) {
   ScopedLoggerInitializer initialize_logger(false);
+  Logger* logger = initialize_logger.logger();

   v8::Persistent<v8::FunctionTemplate> obj =
       v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(),
@@ -453,7 +460,7 @@
   inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
   inst->SetAccessor(v8_str("prop2"), Prop2Getter);

-  LOGGER->LogAccessorCallbacks();
+  logger->LogAccessorCallbacks();

   bool exists = false;
   i::Vector<const char> log(
@@ -487,12 +494,13 @@

 TEST(IsLoggingPreserved) {
   ScopedLoggerInitializer initialize_logger(false);
+  Logger* logger = initialize_logger.logger();

-  CHECK(LOGGER->is_logging());
-  LOGGER->ResumeProfiler();
-  CHECK(LOGGER->is_logging());
-  LOGGER->PauseProfiler();
-  CHECK(LOGGER->is_logging());
+  CHECK(logger->is_logging());
+  logger->ResumeProfiler();
+  CHECK(logger->is_logging());
+  logger->PauseProfiler();
+  CHECK(logger->is_logging());
 }


@@ -513,6 +521,7 @@

   // Start with profiling to capture all code events from the beginning.
   ScopedLoggerInitializer initialize_logger(false);
+  Logger* logger = initialize_logger.logger();

   // Compile and run a function that creates other functions.
   CompileRun(
@@ -522,11 +531,11 @@
       "})(this);");
   v8::V8::PauseProfiler();
   HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
-  LOGGER->StringEvent("test-logging-done", "");
+  logger->StringEvent("test-logging-done", "");

   // Iterate heap to find compiled functions, will write to log.
-  LOGGER->LogCompiledFunctions();
-  LOGGER->StringEvent("test-traversal-done", "");
+  logger->LogCompiledFunctions();
+  logger->StringEvent("test-traversal-done", "");

   bool exists = false;
   i::Vector<const char> log(

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