Reviewers: Mads Ager,

Description:
Make Logger::SuspectReadEvent extract the class name from the object.
This makes the lone caller cleaner, and also avoids a tiny bit of work
in the default case of not running with --log-suspect.

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

Affected files:
   M src/ic.cc
   M src/log.h
   M src/log.cc


Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index  
c0b762471b5addc9a41c3d7862eb4597ddec9a61..2dc9742a95578fc8495f546aa982d5c97b039aff
  
100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -514,11 +514,7 @@ Object* LoadIC::Load(State state, Handle<Object>  
object, Handle<String> name) {
      if (FLAG_strict || is_contextual()) {
        return ReferenceError("not_defined", name);
      }
-    String* class_name = object->IsJSObject()
-                         ? Handle<JSObject>::cast(object)->class_name()
-                         : Heap::empty_string();
-    LOG(SuspectReadEvent(*name, class_name));
-    USE(class_name);
+    LOG(SuspectReadEvent(*name, *object));
    }

    // Update inline cache and stub cache.
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index  
d145480f07ae3264df7a7ec1328f63058bcb9275..4fa398c8e2a6a45e17a4a61b68148365dfbba97a
  
100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -593,12 +593,15 @@ void Logger::ResourceEvent(const char* name, const  
char* tag) {
  }


-void Logger::SuspectReadEvent(String* name, String* obj) {
+void Logger::SuspectReadEvent(String* name, Object* obj) {
  #ifdef ENABLE_LOGGING_AND_PROFILING
    if (logfile_ == NULL || !FLAG_log_suspect) return;
+  String* class_name = obj->IsJSObject()
+                       ? JSObject::cast(obj)->class_name()
+                       : Heap::empty_string();
    ScopedLock sl(mutex_);
    fprintf(logfile_, "suspect-read,");
-  obj->PrintOn(logfile_);
+  class_name->PrintOn(logfile_);
    fprintf(logfile_, ",\"");
    name->PrintOn(logfile_);
    fprintf(logfile_, "\"\n");
Index: src/log.h
diff --git a/src/log.h b/src/log.h
index  
eb082dac6470b3fa05549e2e0ba2da0a2beeb956..89d3e8a3d01d98e59766cd3bc445e9aafbc08292
  
100644
--- a/src/log.h
+++ b/src/log.h
@@ -134,7 +134,7 @@ class Logger {

    // Emits an event that an undefined property was read from an
    // object.
-  static void SuspectReadEvent(String* name, String* obj);
+  static void SuspectReadEvent(String* name, Object* obj);

    // Emits an event when a message is put on or read from a debugging  
queue.
    // DebugTag lets us put a call-site specific label on the event.



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

Reply via email to