Merge from subtype.
authorStefan Ring <stefan@complang.tuwien.ac.at>
Fri, 28 Nov 2008 09:58:39 +0000 (10:58 +0100)
committerStefan Ring <stefan@complang.tuwien.ac.at>
Fri, 28 Nov 2008 09:58:39 +0000 (10:58 +0100)
--HG--
branch : subtype-trunk

1  2 
src/vm/jit/i386/codegen.c
src/vm/jit/i386/emit.c

index c7ff11e595dd541cf8726e0b9e01acaacaed81de,83682c7c62d0e2bc764b85bbb27dbb91becf3a36..a367f37aa4a05b5cd11801c2ca5a16bacd01d923
  #include "vm/jit/i386/emit.h"
  
  #include "mm/memory.h"
 -#include "native/jni.h"
 -#include "native/localref.h"
 -#include "native/native.h"
  
 -#include "threads/lock-common.h"
 +#include "native/localref.hpp"
 +#include "native/native.hpp"
  
 -#include "vm/builtin.h"
 -#include "vm/exceptions.h"
 +#include "threads/lock.hpp"
 +
 +#include "vm/jit/builtin.hpp"
 +#include "vm/exceptions.hpp"
  #include "vm/global.h"
 -#include "vm/primitive.h"
 -#include "vm/stringlocal.h"
 -#include "vm/vm.h"
 +#include "vm/loader.hpp"
 +#include "vm/options.h"
 +#include "vm/primitive.hpp"
 +#include "vm/utf8.h"
 +#include "vm/vm.hpp"
  
  #include "vm/jit/abi.h"
  #include "vm/jit/asmpart.h"
 -#include "vm/jit/codegen-common.h"
 +#include "vm/jit/codegen-common.hpp"
  #include "vm/jit/dseg.h"
 -#include "vm/jit/emit-common.h"
 -#include "vm/jit/jit.h"
 -#include "vm/jit/linenumbertable.h"
 -#include "vm/jit/parse.h"
 -#include "vm/jit/patcher-common.h"
 +#include "vm/jit/emit-common.hpp"
 +#include "vm/jit/jit.hpp"
 +#include "vm/jit/linenumbertable.hpp"
 +#include "vm/jit/parse.hpp"
 +#include "vm/jit/patcher-common.hpp"
  #include "vm/jit/reg.h"
 -#include "vm/jit/replace.h"
 -#include "vm/jit/stacktrace.h"
 +#include "vm/jit/replace.hpp"
 +#include "vm/jit/stacktrace.hpp"
  #include "vm/jit/trap.h"
  
  #if defined(ENABLE_SSA)
  # include "vm/jit/allocator/lsra.h"
  #endif
  
 -#include "vmcore/loader.h"
 -#include "vmcore/options.h"
 -#include "vmcore/utf8.h"
 -
  
  /* codegen_emit ****************************************************************
  
@@@ -406,7 -408,9 +406,7 @@@ bool codegen_emit(jitdata *jd
                if (bptr->bitflags & BBFLAG_REPLACEMENT) {
                        if (cd->replacementpoint[-1].flags & RPLPOINT_FLAG_COUNTDOWN) {
                                MCODECHECK(32);
 -                              disp = (s4) &(m->hitcountdown);
 -                              M_ISUB_IMM_MEMABS(1, disp);
 -                              M_BS(0);
 +                              emit_trap_countdown(cd, &(m->hitcountdown));
                        }
                }
  #endif
                        break;
  
                case ICMD_PUTSTATIC:  /* ..., value  ==> ...                          */
 -
 +                      
                        if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
                                uf        = iptr->sx.s23.s3.uf;
                                fieldtype = uf->fieldref->parseddesc.fd->type;
@@@ -2887,21 -2891,6 +2887,21 @@@ nowperformreturn
  
                        bte = iptr->sx.s23.s3.bte;
                        md = bte->md;
 +
 +#if defined(ENABLE_ESCAPE_REASON)
 +                      if (bte->fp == BUILTIN_escape_reason_new) {
 +                              void set_escape_reasons(void *);
 +                              M_ASUB_IMM(8, REG_SP);
 +                              M_MOV_IMM(iptr->escape_reasons, REG_ITMP1);
 +                              M_AST(EDX, REG_SP, 4);
 +                              M_AST(REG_ITMP1, REG_SP, 0);
 +                              M_MOV_IMM(set_escape_reasons, REG_ITMP1);
 +                              M_CALL(REG_ITMP1);
 +                              M_ALD(EDX, REG_SP, 4);
 +                              M_AADD_IMM(8, REG_SP);
 +                      }
 +#endif
 +
                        goto gen_method;
  
                case ICMD_INVOKESTATIC: /* ..., [arg1, [arg2 ...]] ==> ...            */
@@@ -3381,11 -3370,17 +3381,17 @@@ gen_method
  
                                        M_ALD(REG_ITMP2, REG_ITMP2, OFFSET(vftbl_t, subtype_overflow));
                                        M_CMP_MEMINDEX(REG_ITMP2, -4*DISPLAY_SIZE, REG_ITMP1, 2, REG_ITMP3);
-                                       M_SETE(d);
-                                       if (d == REG_ITMP2) {
-                                               M_BSEXT(d, d);
+                                       if (d >= 4) {
+                                               M_SETE(REG_ITMP1);
+                                               M_BSEXT(REG_ITMP1, d);
+                                       }
+                                       else {
+                                               M_SETE(d);
+                                               if (d == REG_ITMP2) {
+                                                       M_BSEXT(d, d);
  
-                                               emit_label_br(cd, BRANCH_LABEL_7); /* jump over M_CLR */
+                                                       emit_label_br(cd, BRANCH_LABEL_7); /* jump over M_CLR */
+                                               }
                                        }
  
                                        emit_label(cd, BRANCH_LABEL_9);
                                else {
                                        M_CMP_MEMBASE(REG_ITMP2, super->vftbl->subtype_offset, REG_ITMP3);
  
-                                       M_SETE(d);
-                                       if (d == REG_ITMP2)
-                                               M_BSEXT(d, d);
+                                       if (d >= 4) {
+                                               M_SETE(REG_ITMP1);
+                                               M_BSEXT(REG_ITMP1, d);
+                                       }
+                                       else {
+                                               M_SETE(d);
+                                               if (d == REG_ITMP2)
+                                                       M_BSEXT(d, d);
+                                       }
                                }
  
                                if (super != NULL)
@@@ -3669,7 -3670,7 +3681,7 @@@ void codegen_emit_stub_native(jitdata *
  
                /* put env into first argument */
  
 -              M_AST_IMM(_Jv_env, REG_SP, 0 * 4);
 +              M_AST_IMM(VM_get_jnienv(), REG_SP, 0 * 4);
        }
  
        /* Call the native function. */
        switch (md->returntype.type) {
        case TYPE_INT:
        case TYPE_ADR:
 -              switch (md->returntype.decltype) {
 +              switch (md->returntype.primitivetype) {
                case PRIMITIVETYPE_BOOLEAN:
                        M_BZEXT(REG_RESULT, REG_RESULT);
                        break;
diff --combined src/vm/jit/i386/emit.c
index c3bf7e4eebdbd6a314776363d80a4aebcaba3de5,8703bd2c17aca011acf93156bcc1379654677e74..d7140291a69a36eb02f0ad3c28563c7d14053561
  
  #include "mm/memory.h"
  
 -#include "threads/lock-common.h"
 +#include "threads/lock.hpp"
  
 -#include "vm/exceptions.h"
 +#include "vm/options.h"
 +#include "vm/statistics.h"
  
  #include "vm/jit/abi.h"
  #include "vm/jit/asmpart.h"
  #include "vm/jit/dseg.h"
 -#include "vm/jit/emit-common.h"
 -#include "vm/jit/jit.h"
 -#include "vm/jit/patcher-common.h"
 -#include "vm/jit/replace.h"
 -#include "vm/jit/trace.h"
 +#include "vm/jit/emit-common.hpp"
 +#include "vm/jit/jit.hpp"
 +#include "vm/jit/patcher-common.hpp"
 +#include "vm/jit/replace.hpp"
 +#include "vm/jit/trace.hpp"
  #include "vm/jit/trap.h"
  
 -#include "vmcore/options.h"
 -#include "vmcore/statistics.h"
 -
  
  /* emit_load ******************************************************************
  
@@@ -521,20 -523,6 +521,20 @@@ void emit_trap_compiler(codegendata *cd
        M_ALD_MEM(REG_METHODPTR, TRAP_COMPILER);
  }
  
 +/* emit_trap_countdown *********************************************************
 +
 +   Emit a countdown trap.
 +
 +   counter....absolute address of the counter variable
 +
 +*******************************************************************************/
 +
 +void emit_trap_countdown(codegendata *cd, s4 *counter)
 +{
 +      M_ISUB_IMM_MEMABS(1, (s4) counter);
 +      M_BNS(6);
 +      M_ALD_MEM(REG_METHODPTR, TRAP_COUNTDOWN);
 +}
  
  /* emit_trap *******************************************************************
  
@@@ -1313,6 -1301,7 +1313,7 @@@ void emit_jcc(codegendata *cd, s4 opc, 
   */
  void emit_setcc_reg(codegendata *cd, s4 opc, s4 reg)
  {
+       assert(reg < 4);                     /* Can only operate on al, bl, cl, dl. */
        *(cd->mcodeptr++) = 0x0f;
        *(cd->mcodeptr++) = 0x90 + (u1) (opc);
        emit_reg(0,(reg));