Fix test failures in debug mode w/snapshots. It turns out that not
authormikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Feb 2010 13:07:00 +0000 (13:07 +0000)
committermikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Feb 2010 13:07:00 +0000 (13:07 +0000)
all stubs have valid major_keys, and this is OK. So I've added
a check to avoid termination in debug mode.

Review URL: http://codereview.chromium.org/572034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3807 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/code-stubs.cc
src/code-stubs.h
src/disassembler.cc
src/log.cc

index 09581aa..95f0760 100644 (file)
@@ -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 16267f6..d502f14 100644 (file)
@@ -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 50f3eb9..8473cd9 100644 (file)
@@ -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 1281a86..0e3f998 100644 (file)
@@ -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: