OSDN Git Service

[x86] Terminate trace if SGET/SPUT have unresolved fields in codegen
authorUdayan Banerji <udayan.banerji@intel.com>
Fri, 29 Mar 2013 20:32:10 +0000 (13:32 -0700)
committerElliott Hughes <enh@google.com>
Mon, 1 Apr 2013 23:09:04 +0000 (16:09 -0700)
The interpreter doesn't allow SGET/SPUT bytecodes in a trace till the field
is resolved. However, exhaustTrace can pick up bytecodes beyond the trace
sent by the interpreter. Terminate the loop formation if this is seen.

Signed-off-by: Udayan Banerji <udayan.banerji@intel.com>
(cherry picked from commit 4eb6d969de37f9b82aaa4089490900f620e50f46)

Change-Id: If5480640375a5152748e74e00be200d80f313b31

vm/compiler/codegen/x86/LowerGetPut.cpp

index c87b174..be519b1 100644 (file)
@@ -668,7 +668,17 @@ int sget_sput_common(int flag, u2 vA, u2 tmp, bool isObj, bool isVolatile) {
     void *fieldPtr = (void*)
         (currentMethod->clazz->pDvmDex->pResFields[tmp]);
 #endif
-    assert(fieldPtr != NULL);
+
+    /* Usually, fieldPtr should not be null. The interpreter should resolve
+     * it before we come here, or not allow this opcode in a trace. However,
+     * we can be in a loop trace and this opcode might have been picked up
+     * by exhaustTrace. Sending a -1 here will terminate the loop formation
+     * and fall back to normal trace, which will not have this opcode.
+     */
+    if (!fieldPtr) {
+        return -1;
+    }
+
     move_imm_to_reg(OpndSize_32, (int)fieldPtr, PhysicalReg_EAX, true);
     if(flag == SGET) {
         move_mem_to_reg(OpndSize_32, offStaticField_value, PhysicalReg_EAX, true, 7, false); //access field