harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r643895 - /harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp
Date Wed, 02 Apr 2008 13:05:42 GMT
Author: gshimansky
Date: Wed Apr  2 06:05:41 2008
New Revision: 643895

URL: http://svn.apache.org/viewvc?rev=643895&view=rev
Log:
Applied patch from HARMONY-5673
[drlvm][encoder] New assertions in decoder break native stack unwinding


Modified:
    harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp?rev=643895&r1=643894&r2=643895&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/encoder/ia32_em64t/dec_base.cpp Wed Apr  2 06:05:41
2008
@@ -56,6 +56,7 @@
     return false;
 }
 
+// Returns prefix count from 0 to 4, or ((unsigned int)-1) on error
 unsigned int DecoderBase::fill_prefs(const unsigned char * bytes, Inst * pinst)
 {
     const unsigned char * my_bytes = bytes;
@@ -112,9 +113,16 @@
             return pinst->prefc;
         }
         }
-        assert( InstPrefix_Null == pinst->pref[where] ); //only one prefix in each group

+        // Assertions are not allowed here.
+        // Error situations should result in returning error status
+        if (InstPrefix_Null != pinst->pref[where]) //only one prefix in each group
+            return (unsigned int)-1;
+
         pinst->pref[where] = (InstPrefix)by1;
-        assert( pinst->prefc < 4 ); //no more than 4 prefixes
+
+        if (pinst->prefc >= 4) //no more than 4 prefixes
+            return (unsigned int)-1;
+
         pinst->prefc++;
         ++my_bytes;
     }
@@ -130,15 +138,15 @@
     
     const unsigned char * bytes = (unsigned char*)addr;
 
-    bytes += fill_prefs(bytes, &tmp); 
-    if (is_prefix(bytes)) {
-        // More than 4 prefixes together ?
-//        assert(false);
-        return 0;
-    }
-    
     // Load up to 4 prefixes
     // for each Mnemonic
+    unsigned int pref_count = fill_prefs(bytes, &tmp);
+
+    if (pref_count == (unsigned int)-1) // Wrong prefix sequence, or >4 prefixes
+        return 0; // Error
+
+    bytes += pref_count;
+    
     //  for each opcodedesc
     //      if (raw_len == 0) memcmp(, raw_len)
     //  else check the mixed state which is one of the following:
@@ -155,7 +163,7 @@
         }
     }
     if (!found) {
-//        assert(false);
+        // Unknown opcode
         return 0;
     }
     tmp.size = (unsigned)(bytes-(const unsigned char*)addr);
@@ -250,8 +258,8 @@
         }
         return true;
     case OpcodeByteKind_cw:
-//        assert(false); // not an error, but not expected in current env
-        break;
+        // not an error, but not expected in current env
+        return false;
     case OpcodeByteKind_cd:
         {
         int offset = *(int*)*pbuf;
@@ -314,11 +322,9 @@
             return true;
         }
     case OpcodeByteKind_ZeroOpcodeByte: // cant be here
-//        assert(false);
-        break;
+        return false;
     default:
         // unknown kind ? how comes ?
-//        assert(false);
         break;
     }
     return false;



Mime
View raw message