Reviewers: Erik Corry, Mads Ager,

Description:
Fix test failures in debug mode w/snapshots. It turns out that not
all stubs have valid major_keys, and this is OK. So I've added
a check to avoid termination in debug mode.

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

Affected files:
  M src/code-stubs.h
  M src/code-stubs.cc
  M src/disassembler.cc
  M src/log.cc


Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index 09581aa82ac1ae1f4dba521dc2994cea55eab3dd..95f0760aec097c88aca4eae18e704c37d1c07f44 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -149,13 +149,16 @@ Object* CodeStub::TryGetCode() {
 }


-const char* CodeStub::MajorName(CodeStub::Major major_key) {
+const char* CodeStub::MajorName(CodeStub::Major major_key,
+                                bool allow_unknown_keys) {
   switch (major_key) {
 #define DEF_CASE(name) case name: return #name;
     CODE_STUB_LIST(DEF_CASE)
 #undef DEF_CASE
     default:
-      UNREACHABLE();
+      if (!allow_unknown_keys) {
+        UNREACHABLE();
+      }
       return NULL;
   }
 }
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index 16267f64e0e6c05f1213817fab5125d86f98b09f..d502f14cd2e775b772bf7b5fa4a5cf6b623d38bf 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -100,7 +100,7 @@ class CodeStub BASE_EMBEDDED {
   static int MinorKeyFromKey(uint32_t key) {
     return MinorKeyBits::decode(key);
   };
-  static const char* MajorName(Major major_key);
+  static const char* MajorName(Major major_key, bool allow_unknown_keys);

   virtual ~CodeStub() {}

@@ -138,7 +138,7 @@ class CodeStub BASE_EMBEDDED {
   virtual InLoopFlag InLoop() { return NOT_IN_LOOP; }

   // Returns a name for logging/debugging purposes.
-  virtual const char* GetName() { return MajorName(MajorKey()); }
+  virtual const char* GetName() { return MajorName(MajorKey(), false); }

 #ifdef DEBUG
   virtual void Print() { PrintF("%s\n", GetName()); }
Index: src/disassembler.cc
diff --git a/src/disassembler.cc b/src/disassembler.cc
index 50f3eb996bbd64eb0c43838aa2e4755e8eb5da94..8473cd9f95421498472ecc228a379011615d9ab7 100644
--- a/src/disassembler.cc
+++ b/src/disassembler.cc
@@ -261,7 +261,7 @@ static int DecodeIt(FILE* f,
             ASSERT(code->major_key() == CodeStub::MajorKeyFromKey(key));
             out.AddFormatted(" %s, %s, ",
                              Code::Kind2String(kind),
-                             CodeStub::MajorName(code->major_key()));
+ CodeStub::MajorName(code->major_key(), false));
             switch (code->major_key()) {
               case CodeStub::CallFunction:
                 out.AddFormatted("argc = %d", minor_key);
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 1281a863b64758158334bb98b1921d4dd9adb1bd..0e3f998bdf8b81113c9c60062cca62bc131fd903 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -1261,7 +1261,9 @@ void Logger::LogCodeObject(Object* object) {
       case Code::FUNCTION:
         return;  // We log this later using LogCompiledFunctions.
       case Code::STUB:
-        description = CodeStub::MajorName(code_object->major_key());
+        description = CodeStub::MajorName(code_object->major_key(), true);
+        if (description == NULL)
+          description = "A stub from the snapshot";
         tag = Logger::STUB_TAG;
         break;
       case Code::BUILTIN:


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

Reply via email to