Revision: 24837
Author:   [email protected]
Date:     Thu Oct 23 11:31:33 2014 UTC
Log:      More details printed for Map, DescriptorArray and TransitionArray.

[email protected]

Review URL: https://codereview.chromium.org/659363002
https://code.google.com/p/v8/source/detail?r=24837

Modified:
 /branches/bleeding_edge/src/objects-printer.cc
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/property-details.h
 /branches/bleeding_edge/src/property.cc
 /branches/bleeding_edge/src/transitions-inl.h
 /branches/bleeding_edge/src/transitions.h
 /branches/bleeding_edge/tools/gdbinit

=======================================
--- /branches/bleeding_edge/src/objects-printer.cc Tue Oct 14 14:43:45 2014 UTC +++ /branches/bleeding_edge/src/objects-printer.cc Thu Oct 23 11:31:33 2014 UTC
@@ -347,39 +347,7 @@

 void JSObject::PrintTransitions(std::ostream& os) {  // NOLINT
   if (!map()->HasTransitionArray()) return;
-  TransitionArray* transitions = map()->transitions();
-  for (int i = 0; i < transitions->number_of_transitions(); i++) {
-    Name* key = transitions->GetKey(i);
-    os << "   ";
-    key->NamePrint(os);
-    os << ": ";
-    if (key == GetHeap()->frozen_symbol()) {
-      os << " (transition to frozen)\n";
-    } else if (key == GetHeap()->elements_transition_symbol()) {
-      os << " (transition to "
- << ElementsKindToString(transitions->GetTarget(i)->elements_kind())
-         << ")\n";
-    } else if (key == GetHeap()->observed_symbol()) {
-      os << " (transition to Object.observe)\n";
-    } else {
-      switch (transitions->GetTargetDetails(i).type()) {
-        case FIELD: {
-          os << " (transition to field)\n";
-          break;
-        }
-        case CONSTANT:
-          os << " (transition to constant)\n";
-          break;
-        case CALLBACKS:
-          os << " (transition to callback)\n";
-          break;
-        // Values below are never in the target descriptor array.
-        case NORMAL:
-          UNREACHABLE();
-          break;
-      }
-    }
-  }
+  map()->transitions()->PrintTransitions(os, false);
 }


@@ -442,6 +410,8 @@
   os << "\n - pre-allocated property fields: "
      << pre_allocated_property_fields() << "\n";
   os << " - unused property fields: " << unused_property_fields() << "\n";
+  if (is_dictionary_map()) os << " - dictionary_map\n";
+  if (is_prototype_map()) os << " - prototype_map\n";
   if (is_hidden_prototype()) os << " - hidden_prototype\n";
   if (has_named_interceptor()) os << " - named_interceptor\n";
   if (has_indexed_interceptor()) os << " - indexed_interceptor\n";
@@ -605,10 +575,13 @@


 void Name::NamePrint(std::ostream& os) {  // NOLINT
-  if (IsString())
+  if (IsString()) {
     String::cast(this)->StringPrint(os);
-  else
+  } else if (IsSymbol()) {
+    Symbol::cast(this)->name()->Print(os);
+  } else {
     os << Brief(this);
+  }
 }


@@ -1080,43 +1053,72 @@
   os << "\n - break_point_objects: " << Brief(break_point_objects());
   os << "\n";
 }
+
+
+void DescriptorArray::Print() {
+  OFStream os(stdout);
+  this->PrintDescriptors(os);
+  os << std::flush;
+}


 void DescriptorArray::PrintDescriptors(std::ostream& os) {  // NOLINT
-  os << "Descriptor array  " << number_of_descriptors() << "\n";
+  os << "Descriptor array " << number_of_descriptors() << "\n";
   for (int i = 0; i < number_of_descriptors(); i++) {
     Descriptor desc;
     Get(i, &desc);
-    os << " " << i << ": " << desc;
+    os << " " << i << ": " << desc << "\n";
   }
   os << "\n";
 }


-void TransitionArray::PrintTransitions(std::ostream& os) {  // NOLINT
-  os << "Transition array  %d\n", number_of_transitions();
+void TransitionArray::Print() {
+  OFStream os(stdout);
+  this->PrintTransitions(os);
+  os << std::flush;
+}
+
+
+void TransitionArray::PrintTransitions(std::ostream& os,
+                                       bool print_header) {  // NOLINT
+  if (print_header) {
+    os << "Transition array " << number_of_transitions() << "\n";
+  }
   for (int i = 0; i < number_of_transitions(); i++) {
-    os << " " << i << ": ";
-    GetKey(i)->NamePrint(os);
+    Name* key = GetKey(i);
+    os << "   ";
+    key->NamePrint(os);
     os << ": ";
-    switch (GetTargetDetails(i).type()) {
-      case FIELD: {
-        os << " (transition to field)\n";
-        break;
+    if (key == GetHeap()->frozen_symbol()) {
+      os << " (transition to frozen)";
+    } else if (key == GetHeap()->elements_transition_symbol()) {
+      os << " (transition to "
+         << ElementsKindToString(GetTarget(i)->elements_kind()) << ")";
+    } else if (key == GetHeap()->observed_symbol()) {
+      os << " (transition to Object.observe)";
+    } else {
+      PropertyDetails details = GetTargetDetails(i);
+      switch (details.type()) {
+        case FIELD: {
+          os << " (transition to field)";
+          break;
+        }
+        case CONSTANT:
+ os << " (transition to constant " << Brief(GetTargetValue(i)) << ")";
+          break;
+        case CALLBACKS:
+ os << " (transition to callback " << Brief(GetTargetValue(i)) << ")";
+          break;
+        // Values below are never in the target descriptor array.
+        case NORMAL:
+          UNREACHABLE();
+          break;
       }
-      case CONSTANT:
-        os << " (transition to constant)\n";
-        break;
-      case CALLBACKS:
-        os << " (transition to callback)\n";
-        break;
-      // Values below are never in the target descriptor array.
-      case NORMAL:
-        UNREACHABLE();
-        break;
+      os << ", attrs: " << details.attributes();
     }
+    os << " -> " << Brief(GetTarget(i)) << "\n";
   }
-  os << "\n";
 }


=======================================
--- /branches/bleeding_edge/src/objects.cc      Thu Oct 23 08:25:42 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc      Thu Oct 23 11:31:33 2014 UTC
@@ -13138,7 +13138,7 @@
       } else {
         os << Brief(k);
       }
-      os << ": " << Brief(ValueAt(i)) << "\n";
+      os << ": " << Brief(ValueAt(i)) << " " << DetailsAt(i) << "\n";
     }
   }
 }
=======================================
--- /branches/bleeding_edge/src/objects.h       Thu Oct 23 08:25:42 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Thu Oct 23 11:31:33 2014 UTC
@@ -3051,6 +3051,9 @@
   static const int kDescriptorSize = 3;

 #ifdef OBJECT_PRINT
+  // For our gdb macros, we should perhaps change these in the future.
+  void Print();
+
   // Print all the descriptors.
   void PrintDescriptors(std::ostream& os);  // NOLINT
 #endif
=======================================
--- /branches/bleeding_edge/src/property-details.h Tue Aug 26 16:32:51 2014 UTC +++ /branches/bleeding_edge/src/property-details.h Thu Oct 23 11:31:33 2014 UTC
@@ -295,6 +295,10 @@
   uint32_t value_;
 };

+
+std::ostream& operator<<(std::ostream& os,
+                         const PropertyAttributes& attributes);
+std::ostream& operator<<(std::ostream& os, const PropertyDetails& details);
 } }  // namespace v8::internal

 #endif  // V8_PROPERTY_DETAILS_H_
=======================================
--- /branches/bleeding_edge/src/property.cc     Tue Sep 30 10:29:32 2014 UTC
+++ /branches/bleeding_edge/src/property.cc     Thu Oct 23 11:31:33 2014 UTC
@@ -29,11 +29,45 @@
   }
   return os;
 }
+
+
+std::ostream& operator<<(std::ostream& os,
+                         const PropertyAttributes& attributes) {
+  os << "[";
+  os << (((attributes & READ_ONLY) == 0) ? "W" : "_");    // writable
+  os << (((attributes & DONT_ENUM) == 0) ? "E" : "_");    // enumerable
+  os << (((attributes & DONT_DELETE) == 0) ? "C" : "_");  // configurable
+  os << "]";
+  return os;
+}
+
+
+std::ostream& operator<<(std::ostream& os, const PropertyDetails& details) {
+  os << "(";
+  switch (details.type()) {
+    case NORMAL:
+      os << "normal: dictionary_index: " << details.dictionary_index();
+      break;
+    case CONSTANT:
+      os << "constant: p: " << details.pointer();
+      break;
+    case FIELD:
+      os << "field: " << details.representation().Mnemonic()
+         << ", field_index: " << details.field_index()
+         << ", p: " << details.pointer();
+      break;
+    case CALLBACKS:
+      os << "callbacks: p: " << details.pointer();
+      break;
+  }
+  os << ", attrs: " << details.attributes() << ")";
+  return os;
+}


 std::ostream& operator<<(std::ostream& os, const Descriptor& d) {
   return os << "Descriptor " << Brief(*d.GetKey()) << " @ "
-            << Brief(*d.GetValue());
+            << Brief(*d.GetValue()) << " " << d.GetDetails();
 }

 } }  // namespace v8::internal
=======================================
--- /branches/bleeding_edge/src/transitions-inl.h Mon Aug 4 11:34:54 2014 UTC +++ /branches/bleeding_edge/src/transitions-inl.h Thu Oct 23 11:31:33 2014 UTC
@@ -132,6 +132,12 @@
   Map* map = GetTarget(transition_number);
   return map->GetLastDescriptorDetails();
 }
+
+
+Object* TransitionArray::GetTargetValue(int transition_number) {
+  Map* map = GetTarget(transition_number);
+  return map->instance_descriptors()->GetValue(map->LastAdded());
+}


 int TransitionArray::Search(Name* name) {
=======================================
--- /branches/bleeding_edge/src/transitions.h   Tue Sep 30 10:29:32 2014 UTC
+++ /branches/bleeding_edge/src/transitions.h   Thu Oct 23 11:31:33 2014 UTC
@@ -48,6 +48,7 @@
   inline void SetTarget(int transition_number, Map* target);

   inline PropertyDetails GetTargetDetails(int transition_number);
+  inline Object* GetTargetValue(int transition_number);

   inline bool HasElementsTransition();

@@ -139,8 +140,11 @@
   static const int kTransitionSize = 2;

 #ifdef OBJECT_PRINT
+  // For our gdb macros, we should perhaps change these in the future.
+  void Print();
+
   // Print all the transitions.
-  void PrintTransitions(std::ostream& os);  // NOLINT
+ void PrintTransitions(std::ostream& os, bool print_header = true); // NOLINT
 #endif

 #ifdef DEBUG
=======================================
--- /branches/bleeding_edge/tools/gdbinit       Wed Jul  9 10:55:55 2014 UTC
+++ /branches/bleeding_edge/tools/gdbinit       Thu Oct 23 11:31:33 2014 UTC
@@ -20,6 +20,24 @@
 Usage: jco pc
 end

+# Print DescriptorArray.
+define jda
+print ((v8::internal::DescriptorArray*)($arg0))->Print()
+end
+document jda
+Print a v8 DescriptorArray object
+Usage: jda tagged_ptr
+end
+
+# Print TransitionArray.
+define jta
+print ((v8::internal::TransitionArray*)($arg0))->Print()
+end
+document jta
+Print a v8 TransitionArray object
+Usage: jta tagged_ptr
+end
+
 # Print JavaScript stack trace.
 define jst
 print v8::internal::Isolate::Current()->PrintStack(stdout)

--
--
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/d/optout.

Reply via email to