harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Fursov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3571) [drlvm][em64t] Jitrino.OPT emits incorrect code for instanceof bytecode
Date Wed, 04 Apr 2007 09:56:32 GMT
[drlvm][em64t] Jitrino.OPT emits incorrect code for instanceof bytecode

                 Key: HARMONY-3571
                 URL: https://issues.apache.org/jira/browse/HARMONY-3571
             Project: Harmony
          Issue Type: Bug
          Components: DRLVM
            Reporter: Mikhail Fursov

For the example below:
    static int foo2(String name, String defaultValue) {
        Object result = get(name);
        String property = result instanceof String ? (String) result : null;
        return property.hashCode();

   0:	aload_0
   1:	invokestatic	#9; //Method get:(Ljava/lang/String;)Ljava/lang/Object;
   4:	astore_2
   5:	aload_2
   6:	instanceof	#8; //class java/lang/String
   9:	ifeq	19
   12:	aload_2
   13:	checkcast	#8; //class java/lang/String
   16:	goto	20
   19:	aconst_null
   20:	astore_3
   21:	aload_3
   22:	invokevirtual	#10; //Method java/lang/String.hashCode:()I
   25:	ireturn

Jitrino generates the following code
Block ENTRY:  
  Successors: L11 UNWIND
  I0:--- MethodEntry(java/util/Properties::getProperty): ()
  I9:defarg.ths -) t1:cls:java/util/Properties
  I10:tauisnonnull      t1 -) t2:tau
  I11:tauhastype      t1,cls:java/util/Properties -) t3:tau
  I12:defarg -) t4:cls:java/lang/String
  I13:tauhastype      t4,cls:java/lang/String -) t5:tau
  I14:defarg -) t6:cls:java/lang/String
  I15:tauhastype      t6,cls:java/lang/String -) t7:tau
  I16:tauunsafe() -) t8:tau
  I17:call      java/util/Hashtable::get(t1, t4) ((t2,t8)) -) t9:cls:java/lang/Object
  GOTO L11

Block L11:  
  Predecessors: ENTRY
  Successors: L9 L12
  I21:ldci4     #0 -) t10:int32
  I22:if ceq.i   t10, t9 goto L9
  GOTO L12

The I22 is nullcheck  caused by instanceof bytecode processing.
Because of the numeric type the NULL is not converted to MANAGED_NULL in CG:

	00000000033B9F40 I118: (ID:v12(EFLGS):uint32) =XOR t93(ECX):int32,t93(ECX):int32 
	00000000033B9F42 I2: MOVSX t11(RCX):int64,t93(ECX):int32 
	00000000033B9F45 I3: (ID:v12(EFLGS):uint32) =CMP t11(RCX):int64,v9(RAX):cls:java/lang/Object

	00000000033B9F48 I4: JZ BB_4 t13(318):int32 (IU:v12(EFLGS):uint32) 

I'm not sure if this issue can affect any of scenarios, but it must be fixed anyway.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message