OSDN Git Service

Better ClassCastException detail messages for x86.
authorElliott Hughes <enh@google.com>
Thu, 18 Nov 2010 23:23:49 +0000 (15:23 -0800)
committerElliott Hughes <enh@google.com>
Fri, 19 Nov 2010 00:24:56 +0000 (16:24 -0800)
Bug: 3210374
Change-Id: I5b6ff68b611f56276ef6e519511ed4dee22b0136

vm/mterp/out/InterpAsm-x86.S
vm/mterp/x86-atom/TODO.txt
vm/mterp/x86/OP_CHECK_CAST.S
vm/mterp/x86/footer.S

index c2ce035..6ddf10f 100644 (file)
@@ -6556,21 +6556,20 @@ dvmAsmSisterStart:
      *  rINST holds object
      */
 .LOP_CHECK_CAST_fullcheck:
+    movl    %eax,sReg0                 # we'll need the desired class on failure
     movl    %eax,OUT_ARG1(%esp)
     movl    %ecx,OUT_ARG0(%esp)
-    call    dvmInstanceofNonTrivial     # eax<- boolean result
-    testl   %eax,%eax                   # failed?
-    jne     .LOP_CHECK_CAST_okay            # no, success
+    call    dvmInstanceofNonTrivial    # eax<- boolean result
+    testl   %eax,%eax                  # failed?
+    jne     .LOP_CHECK_CAST_okay           # no, success
 
-    # A cast has failed.  We need to throw a ClassCastException with the
-    # class of the object that failed to be cast.
+    # A cast has failed.  We need to throw a ClassCastException.
     EXPORT_PC
-    movl    offObject_clazz(rINST),%ecx  # ecx<- obj->clazz
-    movl    $.LstrClassCastException,%eax
-    movl    offClassObject_descriptor(%ecx),%ecx
-    movl    %eax,OUT_ARG0(%esp)     # arg0<- message
-    movl    %ecx,OUT_ARG1(%esp)     # arg1<- obj->clazz->descriptor
-    call    dvmThrowExceptionWithClassMessage
+    movl    offObject_clazz(rINST),%eax
+    movl    %eax,OUT_ARG0(%esp)                 # arg0<- obj->clazz
+    movl    sReg0,%ecx
+    movl    %ecx,OUT_ARG1(%esp)                 # arg1<- desired class
+    call    dvmThrowClassCastException
     jmp     common_exceptionThrown
 
     /*
@@ -9598,8 +9597,6 @@ common_abort:
     .asciz  "Ljava/lang/NegativeArraySizeException;"
 .LstrInstantiationError:
     .asciz  "Ljava/lang/InstantiationError;"
-.LstrClassCastException:
-    .asciz  "Ljava/lang/ClassCastException;"
 .LstrNoSuchMethodError:
     .asciz  "Ljava/lang/NoSuchMethodError;"
 .LstrInternalErrorA:
index 0d50d2e..462728d 100644 (file)
@@ -11,7 +11,8 @@ Items requiring attention:
 
 (md) Correct OP_MONITOR_EXIT (need to adjust PC before throw)
 (md) OP_THROW needs to export the PC
-(md) Use dvmThrowAIOOBE(index, lentgh) for array bounds error.
+(md) Use dvmThrowAIOOBE(index, length) for array bounds errors.
+(md) Use dvmThrowClassCastException(actual, desired) for class cast errors.
 
 (lo) Implement OP_BREAKPOINT
 (lo) Implement OP_EXECUTE_INLINE_RANGE
index 176dc57..6fb8415 100644 (file)
      *  rINST holds object
      */
 .L${opcode}_fullcheck:
+    movl    %eax,sReg0                 # we'll need the desired class on failure
     movl    %eax,OUT_ARG1(%esp)
     movl    %ecx,OUT_ARG0(%esp)
-    call    dvmInstanceofNonTrivial     # eax<- boolean result
-    testl   %eax,%eax                   # failed?
-    jne     .L${opcode}_okay            # no, success
+    call    dvmInstanceofNonTrivial    # eax<- boolean result
+    testl   %eax,%eax                  # failed?
+    jne     .L${opcode}_okay           # no, success
 
-    # A cast has failed.  We need to throw a ClassCastException with the
-    # class of the object that failed to be cast.
+    # A cast has failed.  We need to throw a ClassCastException.
     EXPORT_PC
-    movl    offObject_clazz(rINST),%ecx  # ecx<- obj->clazz
-    movl    $$.LstrClassCastException,%eax
-    movl    offClassObject_descriptor(%ecx),%ecx
-    movl    %eax,OUT_ARG0(%esp)     # arg0<- message
-    movl    %ecx,OUT_ARG1(%esp)     # arg1<- obj->clazz->descriptor
-    call    dvmThrowExceptionWithClassMessage
+    movl    offObject_clazz(rINST),%eax
+    movl    %eax,OUT_ARG0(%esp)                 # arg0<- obj->clazz
+    movl    sReg0,%ecx
+    movl    %ecx,OUT_ARG1(%esp)                 # arg1<- desired class
+    call    dvmThrowClassCastException
     jmp     common_exceptionThrown
 
     /*
index fb6df27..1d63a52 100644 (file)
@@ -502,8 +502,6 @@ common_abort:
     .asciz  "Ljava/lang/NegativeArraySizeException;"
 .LstrInstantiationError:
     .asciz  "Ljava/lang/InstantiationError;"
-.LstrClassCastException:
-    .asciz  "Ljava/lang/ClassCastException;"
 .LstrNoSuchMethodError:
     .asciz  "Ljava/lang/NoSuchMethodError;"
 .LstrInternalErrorA: