src/cpu/mips/vm/templateTable_mips_64.cpp

Fri, 22 Sep 2017 14:09:57 +0800

author
fujie
date
Fri, 22 Sep 2017 14:09:57 +0800
changeset 6890
d911cc184106
parent 6889
a1eb29ee98ab
child 6891
807ff01c4c69
permissions
-rw-r--r--

[Interpreter] Optimize TemplateTable::xaload.

     1 /*
     2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     9  *
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13  * version 2 for more details (a copy is included in the LICENSE file that
    14  * accompanied this code).
    15  *
    16  * You should have received a copy of the GNU General Public License version
    17  * 2 along with this work; if not, write to the Free Software Foundation,
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19  *
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * or visit www.oracle.com if you need additional information or have any
    22  * questions.
    23  *
    24  */
    26 #include "precompiled.hpp"
    27 #include "asm/macroAssembler.hpp"
    28 #include "interpreter/interpreter.hpp"
    29 #include "interpreter/interpreterRuntime.hpp"
    30 #include "interpreter/templateTable.hpp"
    31 #include "memory/universe.inline.hpp"
    32 #include "oops/methodData.hpp"
    33 #include "oops/objArrayKlass.hpp"
    34 #include "oops/oop.inline.hpp"
    35 #include "prims/methodHandles.hpp"
    36 #include "runtime/sharedRuntime.hpp"
    37 #include "runtime/stubRoutines.hpp"
    38 #include "runtime/synchronizer.hpp"
    41 #ifndef CC_INTERP
    43 #define __ _masm->
    45 // Platform-dependent initialization
    47 void TemplateTable::pd_initialize() {
    48   // No mips specific initialization
    49 }
    51 // Address computation: local variables
    53 static inline Address iaddress(int n) {
    54   return Address(LVP, Interpreter::local_offset_in_bytes(n));
    55 }
    57 static inline Address laddress(int n) {
    58   return iaddress(n + 1);
    59 }
    61 static inline Address faddress(int n) {
    62   return iaddress(n);
    63 }
    65 static inline Address daddress(int n) {
    66   return laddress(n);
    67 }
    69 static inline Address aaddress(int n) {
    70   return iaddress(n);
    71 }
    72 static inline Address haddress(int n)            { return iaddress(n + 0); }
    75 static inline Address at_sp()             {  return Address(SP,   0); }
    76 static inline Address at_sp_p1()          { return Address(SP,  1 * wordSize); }
    77 static inline Address at_sp_p2()          { return Address(SP,  2 * wordSize); }
    79 // At top of Java expression stack which may be different than esp().  It
    80 // isn't for category 1 objects.
    81 static inline Address at_tos   () {
    82   Address tos = Address(SP,  Interpreter::expr_offset_in_bytes(0));
    83   return tos;
    84 }
    86 static inline Address at_tos_p1() {
    87   return Address(SP,  Interpreter::expr_offset_in_bytes(1));
    88 }
    90 static inline Address at_tos_p2() {
    91   return Address(SP,  Interpreter::expr_offset_in_bytes(2));
    92 }
    94 static inline Address at_tos_p3() {
    95   return Address(SP,  Interpreter::expr_offset_in_bytes(3));
    96 }
    98 // we use S0 as bcp, be sure you have bcp in S0 before you call any of the Template generator
    99 Address TemplateTable::at_bcp(int offset) {
   100   assert(_desc->uses_bcp(), "inconsistent uses_bcp information");
   101   return Address(BCP, offset);
   102 }
   104 // bytecode folding
   105 void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
   106                                    Register tmp_reg, bool load_bc_into_bc_reg/*=true*/,
   107                                    int byte_no) {
   108   if (!RewriteBytecodes)  return;
   109   Label L_patch_done;
   111   switch (bc) {
   112   case Bytecodes::_fast_aputfield:
   113   case Bytecodes::_fast_bputfield:
   114   case Bytecodes::_fast_cputfield:
   115   case Bytecodes::_fast_dputfield:
   116   case Bytecodes::_fast_fputfield:
   117   case Bytecodes::_fast_iputfield:
   118   case Bytecodes::_fast_lputfield:
   119   case Bytecodes::_fast_sputfield:
   120     {
   121       // We skip bytecode quickening for putfield instructions when
   122       // the put_code written to the constant pool cache is zero.
   123       // This is required so that every execution of this instruction
   124       // calls out to InterpreterRuntime::resolve_get_put to do
   125       // additional, required work.
   126       assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
   127       assert(load_bc_into_bc_reg, "we use bc_reg as temp");
   128       __ get_cache_and_index_and_bytecode_at_bcp(tmp_reg, bc_reg, tmp_reg, byte_no, 1);
   129       __ daddi(bc_reg, R0, bc);
   130       __ beq(tmp_reg, R0, L_patch_done);
   131       __ delayed()->nop();
   132     }
   133     break;
   134   default:
   135     assert(byte_no == -1, "sanity");
   136     // the pair bytecodes have already done the load.
   137     if (load_bc_into_bc_reg) {
   138       __ move(bc_reg, bc);
   139     }
   140   }
   142   if (JvmtiExport::can_post_breakpoint()) {
   143     Label L_fast_patch;
   144     // if a breakpoint is present we can't rewrite the stream directly
   145     __ lbu(tmp_reg, at_bcp(0));
   146     __ move(AT, Bytecodes::_breakpoint);
   147     __ bne(tmp_reg, AT, L_fast_patch);
   148     __ delayed()->nop();
   150     __ get_method(tmp_reg);
   151     // Let breakpoint table handling rewrite to quicker bytecode
   152     __ call_VM(NOREG, CAST_FROM_FN_PTR(address,
   153     InterpreterRuntime::set_original_bytecode_at), tmp_reg, BCP, bc_reg);
   155     __ b(L_patch_done);
   156     __ delayed()->nop();
   157     __ bind(L_fast_patch);
   158   }
   160 #ifdef ASSERT
   161   Label L_okay;
   162   __ lbu(tmp_reg, at_bcp(0));
   163   __ move(AT, (int)Bytecodes::java_code(bc));
   164   __ beq(tmp_reg, AT, L_okay);
   165   __ delayed()->nop();
   166   __ beq(tmp_reg, bc_reg, L_patch_done);
   167   __ delayed()->nop();
   168   __ stop("patching the wrong bytecode");
   169   __ bind(L_okay);
   170 #endif
   172   // patch bytecode
   173   __ sb(bc_reg, at_bcp(0));
   174   __ bind(L_patch_done);
   175 }
   178 // Individual instructions
   180 void TemplateTable::nop() {
   181   transition(vtos, vtos);
   182   // nothing to do
   183 }
   185 void TemplateTable::shouldnotreachhere() {
   186   transition(vtos, vtos);
   187   __ stop("shouldnotreachhere bytecode");
   188 }
   190 void TemplateTable::aconst_null() {
   191   transition(vtos, atos);
   192   __ move(FSR, R0);
   193 }
   195 void TemplateTable::iconst(int value) {
   196   transition(vtos, itos);
   197   if (value == 0) {
   198     __ move(FSR, R0);
   199   } else {
   200     __ move(FSR, value);
   201   }
   202 }
   204 void TemplateTable::lconst(int value) {
   205   transition(vtos, ltos);
   206   if (value == 0) {
   207     __ move(FSR, R0);
   208   } else {
   209     __ move(FSR, value);
   210   }
   211 }
   213 void TemplateTable::fconst(int value) {
   214   transition(vtos, ftos);
   215   switch( value ) {
   216     case 0:  __ mtc1(R0, FSF);    return;
   217     case 1:  __ addiu(AT, R0, 1); break;
   218     case 2:  __ addiu(AT, R0, 2); break;
   219     default: ShouldNotReachHere();
   220   }
   221   __ mtc1(AT, FSF);
   222   __ cvt_s_w(FSF, FSF);
   223 }
   225 void TemplateTable::dconst(int value) {
   226   transition(vtos, dtos);
   227   switch( value ) {
   228     case 0:  __ dmtc1(R0, FSF);  
   229              return;
   230     case 1:  __ daddiu(AT, R0, 1);
   231              __ dmtc1(AT, FSF);
   232              __ cvt_d_w(FSF, FSF);
   233              break;
   234     default: ShouldNotReachHere();
   235   }
   236 }
   238 void TemplateTable::bipush() {
   239   transition(vtos, itos);
   240   __ lb(FSR, at_bcp(1));
   241 }
   243 void TemplateTable::sipush() {
   244   transition(vtos, itos);
   245   __ lb(FSR, BCP, 1);
   246   __ lbu(AT, BCP, 2);
   247   __ dsll(FSR, FSR, 8); 
   248   __ orr(FSR, FSR, AT);
   249 }
   251 // T1 : tags
   252 // T2 : index
   253 // T3 : cpool
   254 // T8 : tag
   255 void TemplateTable::ldc(bool wide) {
   256   transition(vtos, vtos);
   257   Label call_ldc, notFloat, notClass, Done;
   258   // get index in cpool
   259   if (wide) {
   260     __ get_unsigned_2_byte_index_at_bcp(T2, 1);
   261   } else {
   262     __ lbu(T2, at_bcp(1));
   263   }
   265   __ get_cpool_and_tags(T3, T1);
   267   const int base_offset = ConstantPool::header_size() * wordSize;
   268   const int tags_offset = Array<u1>::base_offset_in_bytes();
   270   // get type
   271   if (UseLoongsonISA && Assembler::is_simm(sizeof(tags_offset), 8)) {
   272     __ gslbx(T1, T1, T2, tags_offset);
   273   } else {
   274     __ dadd(AT, T1, T2);
   275     __ lb(T1, AT, tags_offset);
   276   }
   277   //now T1 is the tag
   279   // unresolved class - get the resolved class
   280   __ daddiu(AT, T1, - JVM_CONSTANT_UnresolvedClass);
   281   __ beq(AT, R0, call_ldc);
   282   __ delayed()->nop();
   284   // unresolved class in error (resolution failed) - call into runtime
   285   // so that the same error from first resolution attempt is thrown.
   286   __ daddiu(AT, T1, -JVM_CONSTANT_UnresolvedClassInError);
   287   __ beq(AT, R0, call_ldc);
   288   __ delayed()->nop();
   290   // resolved class - need to call vm to get java mirror of the class
   291   __ daddiu(AT, T1, - JVM_CONSTANT_Class);
   292   __ bne(AT, R0, notClass);
   293   __ delayed()->dsll(T2, T2, Address::times_8);
   295   __ bind(call_ldc);
   296   __ move(A1, wide);
   297   call_VM(FSR, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), A1);
   298   //__ push(atos);
   299   __ sd(FSR, SP, - Interpreter::stackElementSize);
   300   __ b(Done);
   301   __ delayed()->daddiu(SP, SP, - Interpreter::stackElementSize);
   302   __ nop(); // added for performance issue
   304   __ bind(notClass);
   305   __ daddiu(AT, T1, -JVM_CONSTANT_Float);
   306   __ bne(AT, R0, notFloat);
   307   __ delayed()->nop();
   308   // ftos
   309   if (UseLoongsonISA && Assembler::is_simm(sizeof(base_offset), 8)) {
   310     __ gslwxc1(FSF, T3, T2, base_offset);
   311   } else {
   312     __ dadd(AT, T3, T2);
   313     __ lwc1(FSF, AT, base_offset);
   314   }
   315   //__ push_f();
   316   __ swc1(FSF, SP, - Interpreter::stackElementSize);
   317   __ b(Done);
   318   __ delayed()->daddiu(SP, SP, - Interpreter::stackElementSize);
   320   __ bind(notFloat);
   321 #ifdef ASSERT
   322   {
   323     Label L;
   324     __ daddiu(AT, T1, -JVM_CONSTANT_Integer);
   325     __ beq(AT, R0, L);
   326     __ delayed()->nop();
   327     __ stop("unexpected tag type in ldc");
   328     __ bind(L);
   329   }
   330 #endif
   331   // itos JVM_CONSTANT_Integer only
   332   if (UseLoongsonISA && Assembler::is_simm(sizeof(base_offset), 8)) {
   333     __ gslwx(FSR, T3, T2, base_offset);
   334   } else {
   335     __ dadd(T0, T3, T2);
   336     __ lw(FSR, T0, base_offset);
   337   }
   338   __ push(itos);
   339   __ bind(Done);
   340 }
   342 // Fast path for caching oop constants.
   343 void TemplateTable::fast_aldc(bool wide) {
   344   transition(vtos, atos);
   346   Register result = FSR;
   347   Register tmp = SSR;
   348   int index_size = wide ? sizeof(u2) : sizeof(u1);
   350   Label resolved;
   352   // We are resolved if the resolved reference cache entry contains a
   353   // non-null object (String, MethodType, etc.)
   354   assert_different_registers(result, tmp);
   355   __ get_cache_index_at_bcp(tmp, 1, index_size);
   356   __ load_resolved_reference_at_index(result, tmp);
   357   __ bne(result, R0, resolved);
   358   __ delayed()->nop();
   360   address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc);
   361   // first time invocation - must resolve first
   362   int i = (int)bytecode();
   363   __ move(tmp, i);
   364   __ call_VM(result, entry, tmp);
   366   __ bind(resolved);
   368   if (VerifyOops) {
   369     __ verify_oop(result);
   370   }
   371 }
   374 // used register: T2, T3, T1
   375 // T2 : index
   376 // T3 : cpool
   377 // T1 : tag
   378 void TemplateTable::ldc2_w() {
   379   transition(vtos, vtos);
   380   Label Long, Done;
   382   // get index in cpool
   383   __ get_unsigned_2_byte_index_at_bcp(T2, 1);
   385   __ get_cpool_and_tags(T3, T1);
   387   const int base_offset = ConstantPool::header_size() * wordSize;
   388   const int tags_offset = Array<u1>::base_offset_in_bytes();
   390   // get type in T1
   391   if (UseLoongsonISA && Assembler::is_simm(tags_offset, 8)) {
   392     __ gslbx(T1, T1, T2, tags_offset);
   393   } else {
   394     __ dadd(AT, T1, T2);
   395     __ lb(T1, AT, tags_offset);
   396   }
   398   __ daddiu(AT, T1, - JVM_CONSTANT_Double);
   399   __ bne(AT, R0, Long);
   400   __ delayed()->dsll(T2, T2, Address::times_8);
   402   // dtos
   403   if (UseLoongsonISA && Assembler::is_simm(base_offset, 8)) {
   404     __ gsldxc1(FSF, T3, T2, base_offset);
   405   } else {
   406     __ daddu(AT, T3, T2);
   407     __ ldc1(FSF, AT, base_offset);
   408   }
   409   __ sdc1(FSF, SP, - 2 * wordSize);
   410   __ b(Done);
   411   __ delayed()->daddi(SP, SP, - 2 * wordSize);
   413   // ltos
   414   __ bind(Long);
   415   if (UseLoongsonISA && Assembler::is_simm(base_offset, 8)) {
   416     __ gsldx(FSR, T3, T2, base_offset);
   417   } else {
   418     __ dadd(AT, T3, T2);
   419     __ ld(FSR, AT, base_offset);
   420   }
   421   __ push(ltos);
   423   __ bind(Done);
   424 }
   426 // we compute the actual local variable address here
   427 // the x86 dont do so for it has scaled index memory access model, we dont have, so do here
   428 void TemplateTable::locals_index(Register reg, int offset) {
   429   __ lbu(reg, at_bcp(offset));
   430   __ dsll(reg, reg, Address::times_8);
   431   __ dsub(reg, LVP, reg);
   432 }
   434 // this method will do bytecode folding of the two form:
   435 // iload iload      iload caload
   436 // used register : T2, T3
   437 // T2 : bytecode
   438 // T3 : folded code
   439 void TemplateTable::iload() {
   440   transition(vtos, itos);
   441   if (RewriteFrequentPairs) {
   442     Label rewrite, done;
   443     // get the next bytecode in T2
   444     __ lbu(T2, at_bcp(Bytecodes::length_for(Bytecodes::_iload)));
   445     // if _iload, wait to rewrite to iload2.  We only want to rewrite the
   446     // last two iloads in a pair.  Comparing against fast_iload means that
   447     // the next bytecode is neither an iload or a caload, and therefore
   448     // an iload pair.
   449     __ move(AT, Bytecodes::_iload);
   450     __ beq(AT, T2, done);
   451     __ delayed()->nop();
   453     __ move(T3, Bytecodes::_fast_iload2);
   454     __ move(AT, Bytecodes::_fast_iload);
   455     __ beq(AT, T2, rewrite);
   456     __ delayed()->nop();
   458     // if _caload, rewrite to fast_icaload
   459     __ move(T3, Bytecodes::_fast_icaload);
   460     __ move(AT, Bytecodes::_caload);
   461     __ beq(AT, T2, rewrite);
   462     __ delayed()->nop();
   464     // rewrite so iload doesn't check again.
   465     __ move(T3, Bytecodes::_fast_iload);
   467     // rewrite
   468     // T3 : fast bytecode
   469     __ bind(rewrite);
   470     patch_bytecode(Bytecodes::_iload, T3, T2, false);
   471     __ bind(done);
   472   }
   474   // Get the local value into tos
   475   locals_index(T2);
   476   __ lw(FSR, T2, 0);
   477 }
   479 // used register T2
   480 // T2 : index
   481 void TemplateTable::fast_iload2() {
   482   transition(vtos, itos);
   483   locals_index(T2);
   484   __ lw(FSR, T2, 0);
   485   __ push(itos);
   486   locals_index(T2, 3);
   487   __ lw(FSR, T2, 0);
   488 }
   490 // used register T2
   491 // T2 : index
   492 void TemplateTable::fast_iload() {
   493   transition(vtos, itos);
   494   locals_index(T2);
   495   __ lw(FSR, T2, 0);
   496 }
   498 // used register T2
   499 // T2 : index
   500 void TemplateTable::lload() {
   501   transition(vtos, ltos);
   502   locals_index(T2);
   503   __ ld(FSR, T2, -wordSize);
   504 }
   506 // used register T2
   507 // T2 : index
   508 void TemplateTable::fload() {
   509   transition(vtos, ftos);
   510   locals_index(T2);
   511   __ lwc1(FSF, T2, 0);
   512 }
   514 // used register T2
   515 // T2 : index
   516 void TemplateTable::dload() {
   517   transition(vtos, dtos);
   518   locals_index(T2);
   519   __ ldc1(FSF, T2, -wordSize);
   520 }
   522 // used register T2
   523 // T2 : index
   524 void TemplateTable::aload() {
   525   transition(vtos, atos);
   526   locals_index(T2);
   527   __ ld(FSR, T2, 0);
   528 }
   530 void TemplateTable::locals_index_wide(Register reg) {
   531   __ get_unsigned_2_byte_index_at_bcp(reg, 2);
   532   __ dsll(reg, reg, Address::times_8);
   533   __ dsub(reg, LVP, reg);
   534 }
   536 // used register T2
   537 // T2 : index
   538 void TemplateTable::wide_iload() {
   539   transition(vtos, itos);
   540   locals_index_wide(T2);
   541   __ ld(FSR, T2, 0);
   542 }
   544 // used register T2
   545 // T2 : index
   546 void TemplateTable::wide_lload() {
   547   transition(vtos, ltos);
   548   locals_index_wide(T2);
   549   __ ld(FSR, T2, -wordSize);
   550 }
   552 // used register T2
   553 // T2 : index
   554 void TemplateTable::wide_fload() {
   555   transition(vtos, ftos);
   556   locals_index_wide(T2);
   557   __ lwc1(FSF, T2, 0);
   558 }
   560 // used register T2
   561 // T2 : index
   562 void TemplateTable::wide_dload() {
   563   transition(vtos, dtos);
   564   locals_index_wide(T2);
   565   __ ldc1(FSF, T2, -wordSize);
   566 }
   568 // used register T2
   569 // T2 : index
   570 void TemplateTable::wide_aload() {
   571   transition(vtos, atos);
   572   locals_index_wide(T2);
   573   __ ld(FSR, T2, 0);
   574 }
   576 // we use A2 as the regiser for index, BE CAREFUL!
   577 // we dont use our tge 29 now, for later optimization
   578 void TemplateTable::index_check(Register array, Register index) {
   579   // Pop ptr into array
   580   __ pop_ptr(array);
   581   index_check_without_pop(array, index);
   582 }
   584 void TemplateTable::index_check_without_pop(Register array, Register index) {
   585   // destroys ebx
   586   // check array
   587   __ null_check(array, arrayOopDesc::length_offset_in_bytes());
   589 #ifdef _LP64
   590   // sign extend since tos (index) might contain garbage in upper bits
   591   __ sll(index, index, 0);
   592 #endif // _LP64
   594   // check index
   595   Label ok;
   596   __ lw(AT, array, arrayOopDesc::length_offset_in_bytes());
   597 #ifndef OPT_RANGECHECK
   598   __ sltu(AT, index, AT);
   599   __ bne(AT, R0, ok);
   600   __ delayed()->nop();
   602   //throw_ArrayIndexOutOfBoundsException assume abberrant index in A2
   603   if (A2 != index) __ move(A2, index);
   604   __ jmp(Interpreter::_throw_ArrayIndexOutOfBoundsException_entry);
   605   __ delayed()->nop();
   606   __ bind(ok);
   607 #else
   608   __ lw(AT, array, arrayOopDesc::length_offset_in_bytes());
   609   __ move(A2, index);
   610   __ tgeu(A2, AT, 29);
   611 #endif
   612 }
   614 void TemplateTable::iaload() {
   615   transition(itos, itos);
   616   if(UseBoundCheckInstruction) {
   617     __ pop(SSR); //SSR:array    FSR: index
   618     __ dsll(FSR, FSR, 2);
   619     __ dadd(FSR, SSR, FSR);
   620     __ addi(FSR, FSR, arrayOopDesc::base_offset_in_bytes(T_INT));
   622     __ lw(AT, SSR, arrayOopDesc::length_offset_in_bytes());  //bound
   623     __ dsll(AT, AT, 2);
   624     __ dadd(AT, SSR, AT);
   625     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_INT));
   627     __ gslwle(FSR, FSR, AT);
   628   } else {
   629     index_check(SSR, FSR);
   630     __ dsll(FSR, FSR, 2);
   631     if (UseLoongsonISA && Assembler::is_simm(arrayOopDesc::base_offset_in_bytes(T_INT), 8)) {
   632       __ gslwx(FSR, FSR, SSR, arrayOopDesc::base_offset_in_bytes(T_INT));
   633     } else {
   634       __ dadd(FSR, SSR, FSR);
   635       __ lw(FSR, FSR, arrayOopDesc::base_offset_in_bytes(T_INT));
   636     }
   637   }
   638 }
   640 void TemplateTable::laload() {
   641   transition(itos, ltos);
   642   if(UseBoundCheckInstruction) {
   643     __ pop(SSR); //SSR:array    FSR: index
   644     __ dsll(FSR, FSR, Address::times_8);
   645     __ dadd(FSR, SSR, FSR);
   646     __ addi(FSR, FSR, arrayOopDesc::base_offset_in_bytes(T_LONG) + 0 * wordSize);
   648     __ lw(AT, SSR, arrayOopDesc::length_offset_in_bytes());  //bound
   649     __ dsll(AT, AT, Address::times_8);
   650     __ dadd(AT, SSR, AT);
   651     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_LONG) + 0 * wordSize);
   653     __ gsldle(FSR, FSR, AT);
   654   } else {
   655     index_check(SSR, FSR);
   656     __ dsll(AT, FSR, Address::times_8);
   657     if (UseLoongsonISA && Assembler::is_simm(arrayOopDesc::base_offset_in_bytes(T_LONG), 8)) {
   658       __ gsldx(FSR, SSR, AT, arrayOopDesc::base_offset_in_bytes(T_LONG));
   659     } else {
   660       __ dadd(AT, SSR, AT);
   661       __ ld(FSR, AT, arrayOopDesc::base_offset_in_bytes(T_LONG));
   662     }
   663   }
   664 }
   666 void TemplateTable::faload() {
   667   transition(itos, ftos);
   668   if(UseBoundCheckInstruction) {
   669     __ pop(SSR); //SSR:array    FSR: index
   670     __ shl(FSR, 2);
   671     __ dadd(FSR, SSR, FSR);
   672     __ addi(FSR, FSR, arrayOopDesc::base_offset_in_bytes(T_FLOAT));
   674     __ lw(AT, SSR, arrayOopDesc::length_offset_in_bytes());  //bound
   675     __ shl(AT, 2);
   676     __ dadd(AT, SSR, AT);
   677     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_FLOAT));
   679     __ gslwlec1(FSF, FSR, AT);
   680   } else {
   681     index_check(SSR, FSR);
   682     __ shl(FSR, 2);
   683     if (UseLoongsonISA && Assembler::is_simm(arrayOopDesc::base_offset_in_bytes(T_FLOAT), 8)) {
   684       __ gslwxc1(FSF, SSR, FSR, arrayOopDesc::base_offset_in_bytes(T_FLOAT));
   685     } else {
   686       __ dadd(FSR, SSR, FSR);
   687       __ lwc1(FSF, FSR, arrayOopDesc::base_offset_in_bytes(T_FLOAT));
   688     }
   689   }
   690 }
   692 void TemplateTable::daload() {
   693   transition(itos, dtos);
   694   if(UseBoundCheckInstruction) {
   695     __ pop(SSR); //SSR:array    FSR: index
   696     __ dsll(FSR, FSR, 3);
   697     __ dadd(FSR, SSR, FSR);
   698     __ addi(FSR, FSR, arrayOopDesc::base_offset_in_bytes(T_DOUBLE) + 0 * wordSize);
   700     __ lw(AT, SSR, arrayOopDesc::length_offset_in_bytes());  //bound
   701     __ dsll(AT, AT, 3);
   702     __ dadd(AT, SSR, AT);
   703     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_DOUBLE) + 0 * wordSize);
   705     __ gsldlec1(FSF, FSR, AT);
   706   } else {
   707     index_check(SSR, FSR);
   708     __ dsll(AT, FSR, 3);
   709     if (UseLoongsonISA && Assembler::is_simm(arrayOopDesc::base_offset_in_bytes(T_DOUBLE), 8)) {
   710       __ gsldxc1(FSF, SSR, AT, arrayOopDesc::base_offset_in_bytes(T_DOUBLE));
   711     } else {
   712       __ dadd(AT, SSR, AT);
   713       __ ldc1(FSF, AT, arrayOopDesc::base_offset_in_bytes(T_DOUBLE));
   714     }
   715   }
   716 }
   718 void TemplateTable::aaload() {
   719   transition(itos, atos);
   720   index_check(SSR, FSR);
   721   __ dsll(FSR, FSR, UseCompressedOops ? Address::times_4 : Address::times_8);
   722   __ dadd(FSR, SSR, FSR);
   723   //add for compressedoops
   724   __ load_heap_oop(FSR, Address(FSR, arrayOopDesc::base_offset_in_bytes(T_OBJECT)));
   725 }
   727 void TemplateTable::baload() {
   728   transition(itos, itos);
   729   if(UseBoundCheckInstruction) {
   730     __ pop(SSR); //SSR:array   FSR:index
   731     __ dadd(FSR, SSR, FSR);
   732     __ addi(FSR, FSR, arrayOopDesc::base_offset_in_bytes(T_BYTE)); //base
   734     __ lw(AT, SSR, arrayOopDesc::length_offset_in_bytes());
   735     __ dadd(AT, SSR, AT);
   736     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_BYTE)); //bound
   738     __ gslble(FSR, FSR, AT);
   739   } else {
   740     index_check(SSR, FSR);
   741     if (UseLoongsonISA && Assembler::is_simm(arrayOopDesc::base_offset_in_bytes(T_BYTE), 8)) {
   742       __ gslbx(FSR, SSR, FSR, arrayOopDesc::base_offset_in_bytes(T_BYTE));
   743     } else {
   744       __ dadd(FSR, SSR, FSR);
   745       __ lb(FSR, FSR, arrayOopDesc::base_offset_in_bytes(T_BYTE));
   746     }
   747   }
   748 }
   750 void TemplateTable::caload() {
   751   transition(itos, itos);
   752   index_check(SSR, FSR);
   753   __ dsll(FSR, FSR, Address::times_2);
   754   __ dadd(FSR, SSR, FSR);
   755   __ lhu(FSR, FSR,  arrayOopDesc::base_offset_in_bytes(T_CHAR));
   756 }
   758 // iload followed by caload frequent pair
   759 // used register : T2
   760 // T2 : index
   761 void TemplateTable::fast_icaload() {
   762   transition(vtos, itos);
   763   // load index out of locals
   764   locals_index(T2);
   765   __ lw(FSR, T2, 0);
   766   index_check(SSR, FSR);
   767   __ dsll(FSR, FSR, 1);
   768   __ dadd(FSR, SSR, FSR);
   769   __ lhu(FSR, FSR,  arrayOopDesc::base_offset_in_bytes(T_CHAR));
   770 }
   772 void TemplateTable::saload() {
   773   transition(itos, itos);
   774   if(UseBoundCheckInstruction) {
   775     __ pop(SSR); //SSR:array    FSR: index
   776     __ dsll(FSR, FSR, Address::times_2);
   777     __ dadd(FSR, SSR, FSR);
   778     __ addi(FSR, FSR, arrayOopDesc::base_offset_in_bytes(T_SHORT));
   780     __ lw(AT, SSR, arrayOopDesc::length_offset_in_bytes());  //bound
   781     __ dsll(AT, AT, Address::times_2);
   782     __ dadd(AT, SSR, AT);
   783     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_SHORT));
   785     __ gslhle(FSR, FSR, AT);
   786   } else {
   787     index_check(SSR, FSR);
   788     __ dsll(FSR, FSR, Address::times_2);
   789     if (UseLoongsonISA && Assembler::is_simm(arrayOopDesc::base_offset_in_bytes(T_SHORT), 8)) {
   790       __ gslhx(FSR, SSR, FSR,  arrayOopDesc::base_offset_in_bytes(T_SHORT));
   791     } else {
   792       __ dadd(FSR, SSR, FSR);
   793       __ lh(FSR, FSR,  arrayOopDesc::base_offset_in_bytes(T_SHORT));
   794     }
   795   }
   796 }
   798 void TemplateTable::iload(int n) {
   799   transition(vtos, itos);
   800   __ lw(FSR, iaddress(n));
   801 }
   803 void TemplateTable::lload(int n) {
   804   transition(vtos, ltos);
   805   __ ld(FSR, laddress(n));
   806 }
   808 void TemplateTable::fload(int n) {
   809   transition(vtos, ftos);
   810   __ lwc1(FSF, faddress(n));
   811 }
   813 void TemplateTable::dload(int n) {
   814   transition(vtos, dtos);
   815   __ ldc1(FSF, laddress(n));
   816 }
   818 void TemplateTable::aload(int n) {
   819   transition(vtos, atos);
   820   __ ld(FSR, aaddress(n));
   821 }
   823 // used register : T2, T3
   824 // T2 : bytecode
   825 // T3 : folded code
   826 void TemplateTable::aload_0() {
   827   transition(vtos, atos);
   828   // According to bytecode histograms, the pairs:
   829   //
   830   // _aload_0, _fast_igetfield
   831   // _aload_0, _fast_agetfield
   832   // _aload_0, _fast_fgetfield
   833   //
   834   // occur frequently. If RewriteFrequentPairs is set, the (slow)
   835   // _aload_0 bytecode checks if the next bytecode is either
   836   // _fast_igetfield, _fast_agetfield or _fast_fgetfield and then
   837   // rewrites the current bytecode into a pair bytecode; otherwise it
   838   // rewrites the current bytecode into _fast_aload_0 that doesn't do
   839   // the pair check anymore.
   840   //
   841   // Note: If the next bytecode is _getfield, the rewrite must be
   842   //       delayed, otherwise we may miss an opportunity for a pair.
   843   //
   844   // Also rewrite frequent pairs
   845   //   aload_0, aload_1
   846   //   aload_0, iload_1
   847   // These bytecodes with a small amount of code are most profitable
   848   // to rewrite
   849   if (RewriteFrequentPairs) {
   850     Label rewrite, done;
   851     // get the next bytecode in T2
   852     __ lbu(T2, at_bcp(Bytecodes::length_for(Bytecodes::_aload_0)));
   854     // do actual aload_0
   855     aload(0);
   857     // if _getfield then wait with rewrite
   858     __ move(AT, Bytecodes::_getfield);
   859     __ beq(AT, T2, done);
   860     __ delayed()->nop();
   862     // if _igetfield then reqrite to _fast_iaccess_0
   863     assert(Bytecodes::java_code(Bytecodes::_fast_iaccess_0) ==
   864         Bytecodes::_aload_0,
   865         "fix bytecode definition");
   866     __ move(T3, Bytecodes::_fast_iaccess_0);
   867     __ move(AT, Bytecodes::_fast_igetfield);
   868     __ beq(AT, T2, rewrite);
   869     __ delayed()->nop();
   871     // if _agetfield then reqrite to _fast_aaccess_0
   872     assert(Bytecodes::java_code(Bytecodes::_fast_aaccess_0) ==
   873         Bytecodes::_aload_0,
   874         "fix bytecode definition");
   875     __ move(T3, Bytecodes::_fast_aaccess_0);
   876     __ move(AT, Bytecodes::_fast_agetfield);
   877     __ beq(AT, T2, rewrite);
   878     __ delayed()->nop();
   880     // if _fgetfield then reqrite to _fast_faccess_0
   881     assert(Bytecodes::java_code(Bytecodes::_fast_faccess_0) ==
   882         Bytecodes::_aload_0,
   883         "fix bytecode definition");
   884     __ move(T3, Bytecodes::_fast_faccess_0);
   885     __ move(AT, Bytecodes::_fast_fgetfield);
   886     __ beq(AT, T2, rewrite);
   887     __ delayed()->nop();
   889     // else rewrite to _fast_aload0
   890     assert(Bytecodes::java_code(Bytecodes::_fast_aload_0) ==
   891         Bytecodes::_aload_0,
   892         "fix bytecode definition");
   893     __ move(T3, Bytecodes::_fast_aload_0);
   895     // rewrite
   896     __ bind(rewrite);
   897     patch_bytecode(Bytecodes::_aload_0, T3, T2, false);
   899     __ bind(done);
   900   } else {
   901     aload(0);
   902   }
   903 }
   905 void TemplateTable::istore() {
   906   transition(itos, vtos);
   907   locals_index(T2);
   908   __ sw(FSR, T2, 0);
   909 }
   911 void TemplateTable::lstore() {
   912   transition(ltos, vtos);
   913   locals_index(T2);
   914   __ sd(FSR, T2, -wordSize);
   915 }
   917 void TemplateTable::fstore() {
   918   transition(ftos, vtos);
   919   locals_index(T2);
   920   __ swc1(FSF, T2, 0);
   921 }
   923 void TemplateTable::dstore() {
   924   transition(dtos, vtos);
   925   locals_index(T2);
   926   __ sdc1(FSF, T2, -wordSize);
   927 }
   929 void TemplateTable::astore() {
   930   transition(vtos, vtos);
   931   __ pop_ptr(FSR);
   932   locals_index(T2);
   933   __ sd(FSR, T2, 0);
   934 }
   936 void TemplateTable::wide_istore() {
   937   transition(vtos, vtos);
   938   __ pop_i(FSR);
   939   locals_index_wide(T2);
   940   __ sd(FSR, T2, 0);
   941 }
   943 void TemplateTable::wide_lstore() {
   944   transition(vtos, vtos);
   945   __ pop_l(FSR);
   946   locals_index_wide(T2);
   947   __ sd(FSR, T2, -wordSize);
   948 }
   950 void TemplateTable::wide_fstore() {
   951   wide_istore();
   952 }
   954 void TemplateTable::wide_dstore() {
   955   wide_lstore();
   956 }
   958 void TemplateTable::wide_astore() {
   959   transition(vtos, vtos);
   960   __ pop_ptr(FSR);
   961   locals_index_wide(T2);
   962   __ sd(FSR, T2, 0);
   963 }
   965 // used register : T2
   966 void TemplateTable::iastore() {
   967   transition(itos, vtos);
   968   __ pop_i(SSR);   // T2: array  SSR: index
   969   if(UseBoundCheckInstruction) {
   970     __ pop_ptr(T2);
   971     __ dsll(SSR, SSR, Address::times_4);
   972     __ dadd(SSR, T2, SSR);
   973     __ addi(SSR, SSR, arrayOopDesc::base_offset_in_bytes(T_INT));  // base
   975     __ lw(AT, T2, arrayOopDesc::length_offset_in_bytes());
   976     __ dsll(AT, AT, Address::times_4);
   977     __ dadd(AT, T2, AT);
   978     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_INT));  //bound
   980     __ gsswle(FSR, SSR, AT);
   981   } else {
   982     index_check(T2, SSR);  // prefer index in ebx
   983     __ dsll(SSR, SSR, Address::times_4);
   984     __ dadd(T2, T2, SSR);
   985     __ sw(FSR, T2, arrayOopDesc::base_offset_in_bytes(T_INT));
   986   }
   987 }
   991 // used register T2, T3
   992 void TemplateTable::lastore() {
   993   transition(ltos, vtos);
   994   __ pop_i (T2);
   995   if(UseBoundCheckInstruction) {
   996     __ pop_ptr(T3);
   997     __ dsll(T2, T2, Address::times_8);
   998     __ dadd(T2, T3, T2);
   999     __ addi(T2, T2, arrayOopDesc::base_offset_in_bytes(T_LONG) + 0 * wordSize);  // base
  1001     __ lw(AT, T3, arrayOopDesc::length_offset_in_bytes());
  1002     __ dsll(AT, AT, Address::times_8);
  1003     __ dadd(AT, T3, AT);
  1004     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_LONG) + 0 * wordSize);  //bound
  1006     __ gssdle(FSR, T2, AT);
  1007   } else {
  1008     index_check(T3, T2);
  1009     __ dsll(T2, T2, Address::times_8);
  1010     __ dadd(T3, T3, T2);
  1011     __ sd(FSR, T3, arrayOopDesc::base_offset_in_bytes(T_LONG) + 0 * wordSize);
  1015 // used register T2
  1016 void TemplateTable::fastore() {
  1017   transition(ftos, vtos);
  1018   __ pop_i(SSR);
  1019   if(UseBoundCheckInstruction) {
  1020     __ pop_ptr(T2);
  1021     __ dsll(SSR, SSR, Address::times_4);
  1022     __ dadd(SSR, T2, SSR);
  1023     __ addi(SSR, SSR, arrayOopDesc::base_offset_in_bytes(T_FLOAT));  // base
  1025     __ lw(AT, T2, arrayOopDesc::length_offset_in_bytes());
  1026     __ dsll(AT, AT, Address::times_4);
  1027     __ dadd(AT, T2, AT);
  1028     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_FLOAT));  //bound
  1030     __ gsswlec1(FSF, SSR, AT);
  1031   } else {
  1032     index_check(T2, SSR);
  1033     __ dsll(SSR, SSR, Address::times_4);
  1034     __ dadd(T2, T2, SSR);
  1035     __ swc1(FSF, T2, arrayOopDesc::base_offset_in_bytes(T_FLOAT));
  1039 // used register T2, T3
  1040 void TemplateTable::dastore() {
  1041   transition(dtos, vtos);
  1042   __ pop_i (T2);
  1043   if(UseBoundCheckInstruction) {
  1044     __ pop_ptr(T3);
  1045     __ dsll(T2, T2, Address::times_8);
  1046     __ dadd(T2, T3, T2);
  1047     __ addi(T2, T2, arrayOopDesc::base_offset_in_bytes(T_DOUBLE) + 0 * wordSize);  // base
  1049     __ lw(AT, T3, arrayOopDesc::length_offset_in_bytes());
  1050     __ dsll(AT, AT, Address::times_8);
  1051     __ dadd(AT, T3, AT);
  1052     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_DOUBLE) + 0 * wordSize);  //bound
  1054     __ gssdlec1(FSF, T2, AT);
  1055   } else {
  1056     index_check(T3, T2);
  1057     __ dsll(T2, T2, Address::times_8);
  1058     __ daddu(T3, T3, T2);
  1059     __ sdc1(FSF, T3, arrayOopDesc::base_offset_in_bytes(T_DOUBLE) + 0 * wordSize);
  1063 // used register : T2, T3, T8
  1064 // T2 : array
  1065 // T3 : subklass
  1066 // T8 : supklass
  1067 void TemplateTable::aastore() {
  1068   Label is_null, ok_is_subtype, done;
  1069   transition(vtos, vtos);
  1070   // stack: ..., array, index, value
  1071   __ ld(FSR, at_tos());     // Value
  1072   __ lw(SSR, at_tos_p1());  // Index
  1073   __ ld(T2, at_tos_p2());  // Array
  1075   // index_check(T2, SSR);
  1076   index_check_without_pop(T2, SSR);
  1077   // do array store check - check for NULL value first
  1078   __ beq(FSR, R0, is_null);
  1079   __ delayed()->nop();
  1081   // Move subklass into T3
  1082   //add for compressedoops
  1083   __ load_klass(T3, FSR);
  1084   // Move superklass into T8
  1085   //add for compressedoops
  1086   __ load_klass(T8, T2);
  1087   __ ld(T8, Address(T8,  ObjArrayKlass::element_klass_offset()));
  1088   // Compress array+index*4+12 into a single register. T2
  1089   __ dsll(AT, SSR, UseCompressedOops? Address::times_4 : Address::times_8);
  1090   __ dadd(T2, T2, AT);
  1091   __ daddi(T2, T2, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
  1093   // Generate subtype check.
  1094   // Superklass in T8.  Subklass in T3.
  1095   __ gen_subtype_check(T8, T3, ok_is_subtype);        // <-- Jin
  1096   // Come here on failure
  1097   // object is at FSR
  1098   __ jmp(Interpreter::_throw_ArrayStoreException_entry);    // <-- Jin
  1099   __ delayed()->nop();
  1100   // Come here on success
  1101   __ bind(ok_is_subtype);
  1102   //replace with do_oop_store->store_heap_oop
  1103   __ store_heap_oop(Address(T2, 0), FSR);          // <-- Jin
  1104   __ store_check(T2);
  1105   __ b(done);
  1106   __ delayed()->nop();
  1108   // Have a NULL in FSR, EDX=T2, SSR=index.  Store NULL at ary[idx]
  1109   __ bind(is_null);
  1110   __ profile_null_seen(T9);
  1111   __ dsll(AT, SSR, UseCompressedOops? Address::times_4 : Address::times_8);
  1112   __ dadd(T2, T2, AT);
  1113   __ store_heap_oop(Address(T2, arrayOopDesc::base_offset_in_bytes(T_OBJECT)), FSR);  /* FSR is null here */
  1115   __ bind(done);
  1116   __ daddi(SP, SP, 3 * Interpreter::stackElementSize);
  1119 void TemplateTable::bastore() {
  1120   transition(itos, vtos);
  1121   __ pop_i(SSR);
  1122   if(UseBoundCheckInstruction) {
  1123     __ pop_ptr(T2);
  1124     __ dadd(SSR, T2, SSR);
  1125     __ addi(SSR, SSR, arrayOopDesc::base_offset_in_bytes(T_BYTE));  // base
  1127     __ lw(AT, T2, arrayOopDesc::length_offset_in_bytes());
  1128     __ dadd(AT, T2, AT);
  1129     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_BYTE));  //bound
  1131     __ gssble(FSR, SSR, AT);
  1132   } else {
  1133     index_check(T2, SSR);
  1134     __ dadd(SSR, T2, SSR);
  1135     __ sb(FSR, SSR, arrayOopDesc::base_offset_in_bytes(T_BYTE));
  1139 void TemplateTable::castore() {
  1140   transition(itos, vtos);
  1141   __ pop_i(SSR);
  1142   if(UseBoundCheckInstruction) {
  1143     __ pop_ptr(T2);
  1144     __ dsll(SSR, SSR, Address::times_2);
  1145     __ dadd(SSR, T2, SSR);
  1146     __ addi(SSR, SSR, arrayOopDesc::base_offset_in_bytes(T_CHAR));  // base
  1148     __ lw(AT, T2, arrayOopDesc::length_offset_in_bytes());
  1149     __ dsll(AT, AT, Address::times_2);
  1150     __ dadd(AT, T2, AT);
  1151     __ addi(AT, AT, arrayOopDesc::base_offset_in_bytes(T_CHAR));  //bound
  1153     __ gsshle(FSR, SSR, AT);
  1154   } else {
  1155     index_check(T2, SSR);
  1156     __ dsll(SSR, SSR, Address::times_2);
  1157     __ dadd(SSR, T2, SSR);
  1158     __ sh(FSR, SSR, arrayOopDesc::base_offset_in_bytes(T_CHAR));
  1162 void TemplateTable::sastore() {
  1163   castore();
  1166 void TemplateTable::istore(int n) {
  1167   transition(itos, vtos);
  1168   __ sw(FSR, iaddress(n));
  1171 void TemplateTable::lstore(int n) {
  1172   transition(ltos, vtos);
  1173   __ sd(FSR, laddress(n));
  1176 void TemplateTable::fstore(int n) {
  1177   transition(ftos, vtos);
  1178   __ swc1(FSF, faddress(n));
  1181 void TemplateTable::dstore(int n) {
  1182   transition(dtos, vtos);
  1183   __ sdc1(FSF, laddress(n));
  1186 void TemplateTable::astore(int n) {
  1187   transition(vtos, vtos);
  1188   __ pop_ptr(FSR);
  1189   __ sd(FSR, aaddress(n));
  1192 void TemplateTable::pop() {
  1193   transition(vtos, vtos);
  1194   __ daddi(SP, SP, Interpreter::stackElementSize);
  1197 void TemplateTable::pop2() {
  1198   transition(vtos, vtos);
  1199   __ daddi(SP, SP, 2 * Interpreter::stackElementSize);
  1202 void TemplateTable::dup() {
  1203   transition(vtos, vtos);
  1204   // stack: ..., a
  1205   __ load_ptr(0, FSR);
  1206   __ push_ptr(FSR);
  1207   // stack: ..., a, a
  1210 // blows FSR
  1211 void TemplateTable::dup_x1() {
  1212   transition(vtos, vtos);
  1213   // stack: ..., a, b
  1214   __ load_ptr(0, FSR);  // load b
  1215   __ load_ptr(1, A5);  // load a
  1216   __ store_ptr(1, FSR); // store b
  1217   __ store_ptr(0, A5); // store a
  1218   __ push_ptr(FSR);             // push b
  1219   // stack: ..., b, a, b
  1222 // blows FSR
  1223 void TemplateTable::dup_x2() {
  1224   transition(vtos, vtos);
  1225   // stack: ..., a, b, c
  1226   __ load_ptr(0, FSR);  // load c
  1227   __ load_ptr(2, A5);  // load a
  1228   __ store_ptr(2, FSR); // store c in a
  1229   __ push_ptr(FSR);             // push c
  1230   // stack: ..., c, b, c, c
  1231   __ load_ptr(2, FSR);  // load b
  1232   __ store_ptr(2, A5); // store a in b
  1233   // stack: ..., c, a, c, c
  1234   __ store_ptr(1, FSR); // store b in c
  1235   // stack: ..., c, a, b, c
  1238 // blows FSR
  1239 void TemplateTable::dup2() {
  1240   transition(vtos, vtos);
  1241   // stack: ..., a, b
  1242   __ load_ptr(1, FSR);  // load a
  1243   __ push_ptr(FSR);             // push a
  1244   __ load_ptr(1, FSR);  // load b
  1245   __ push_ptr(FSR);             // push b
  1246   // stack: ..., a, b, a, b
  1249 // blows FSR
  1250 void TemplateTable::dup2_x1() {
  1251   transition(vtos, vtos);
  1252   // stack: ..., a, b, c
  1253   __ load_ptr(0, T2);  // load c
  1254   __ load_ptr(1, FSR);  // load b
  1255   __ push_ptr(FSR);             // push b
  1256   __ push_ptr(T2);             // push c
  1257   // stack: ..., a, b, c, b, c
  1258   __ store_ptr(3, T2); // store c in b
  1259   // stack: ..., a, c, c, b, c
  1260   __ load_ptr(4, T2);  // load a
  1261   __ store_ptr(2, T2); // store a in 2nd c
  1262   // stack: ..., a, c, a, b, c
  1263   __ store_ptr(4, FSR); // store b in a
  1264   // stack: ..., b, c, a, b, c
  1266   // stack: ..., b, c, a, b, c
  1269 // blows FSR, SSR
  1270 void TemplateTable::dup2_x2() {
  1271   transition(vtos, vtos);
  1272   // stack: ..., a, b, c, d
  1273   // stack: ..., a, b, c, d
  1274   __ load_ptr(0, T2);  // load d
  1275   __ load_ptr(1, FSR);  // load c
  1276   __ push_ptr(FSR);             // push c
  1277   __ push_ptr(T2);             // push d
  1278   // stack: ..., a, b, c, d, c, d
  1279   __ load_ptr(4, FSR);  // load b
  1280   __ store_ptr(2, FSR); // store b in d
  1281   __ store_ptr(4, T2); // store d in b
  1282   // stack: ..., a, d, c, b, c, d
  1283   __ load_ptr(5, T2);  // load a
  1284   __ load_ptr(3, FSR);  // load c
  1285   __ store_ptr(3, T2); // store a in c
  1286   __ store_ptr(5, FSR); // store c in a
  1287   // stack: ..., c, d, a, b, c, d
  1289   // stack: ..., c, d, a, b, c, d
  1292 // blows FSR
  1293 void TemplateTable::swap() {
  1294   transition(vtos, vtos);
  1295   // stack: ..., a, b
  1297   __ load_ptr(1, A5);  // load a
  1298   __ load_ptr(0, FSR);  // load b
  1299   __ store_ptr(0, A5); // store a in b
  1300   __ store_ptr(1, FSR); // store b in a
  1302   // stack: ..., b, a
  1305 void TemplateTable::iop2(Operation op) {
  1306   transition(itos, itos);
  1308   __ pop_i(SSR);
  1309   switch (op) {
  1310     case add  : __ addu32(FSR, SSR, FSR); break;
  1311     case sub  : __ subu32(FSR, SSR, FSR); break;
  1312     case mul  : __ mul(FSR, SSR, FSR);    break;
  1313     case _and : __ andr(FSR, SSR, FSR);   break;
  1314     case _or  : __ orr(FSR, SSR, FSR);    break;
  1315     case _xor : __ xorr(FSR, SSR, FSR);   break;
  1316     case shl  : __ sllv(FSR, SSR, FSR);   break; // implicit masking of lower 5 bits by Intel shift instr. mips also
  1317     case shr  : __ srav(FSR, SSR, FSR);   break; // implicit masking of lower 5 bits by Intel shift instr. mips also
  1318     case ushr : __ srlv(FSR, SSR, FSR);   break; // implicit masking of lower 5 bits by Intel shift instr. mips also
  1319     default   : ShouldNotReachHere();
  1323 // the result stored in FSR, SSR,
  1324 // used registers : T2, T3
  1325 void TemplateTable::lop2(Operation op) {
  1326   transition(ltos, ltos);
  1327   __ pop_l(T2, T3);
  1328 #ifdef ASSERT
  1330     Label  L;
  1331     __ beq(T3, R0, L);
  1332     __ delayed()->nop();
  1333     __ bind(L);
  1335 #endif
  1336   switch (op) {
  1337     case add : __ daddu(FSR, T2, FSR); break;
  1338     case sub : __ dsubu(FSR, T2, FSR); break;
  1339     case _and: __ andr(FSR, T2, FSR);  break;
  1340     case _or : __ orr(FSR, T2, FSR);   break;
  1341     case _xor: __ xorr(FSR, T2, FSR);  break;
  1342     default : ShouldNotReachHere();
  1346 // java require this bytecode could handle 0x80000000/-1, dont cause a overflow exception,
  1347 // the result is 0x80000000
  1348 // the godson2 cpu do the same, so we need not handle this specially like x86
  1349 void TemplateTable::idiv() {
  1350   transition(itos, itos);
  1351   Label not_zero;
  1353   __ bne(FSR, R0, not_zero);
  1354   __ delayed()->nop();
  1355   __ jmp(Interpreter::_throw_ArithmeticException_entry);
  1356   __ delayed()->nop();
  1357   __ bind(not_zero);
  1359   __ pop_i(SSR);
  1360   if (UseLoongsonISA) {
  1361     __ gsdiv(FSR, SSR, FSR);
  1362   } else {
  1363     __ div(SSR, FSR);
  1364     __ mflo(FSR);
  1368 void TemplateTable::irem() {
  1369   transition(itos, itos);
  1370   Label not_zero;
  1371   __ pop_i(SSR);
  1372   __ div(SSR, FSR);
  1374   __ bne(FSR, R0, not_zero);
  1375   __ delayed()->nop();
  1376   //__ brk(7);
  1377   __ jmp(Interpreter::_throw_ArithmeticException_entry);
  1378   __ delayed()->nop();
  1380   __ bind(not_zero);
  1381   __ mfhi(FSR);
  1384 void TemplateTable::lmul() {
  1385   transition(ltos, ltos);
  1386   __ pop_l(T2);
  1387   if(UseLoongsonISA){
  1388     __ gsdmult(FSR, T2, FSR);
  1389   } else {
  1390     __ dmult(T2, FSR);
  1391     __ mflo(FSR);
  1395 // NOTE: i DONT use the Interpreter::_throw_ArithmeticException_entry
  1396 void TemplateTable::ldiv() {
  1397   transition(ltos, ltos);
  1398   Label normal;
  1400   __ bne(FSR, R0, normal);
  1401   __ delayed()->nop();
  1403   //__ brk(7);    //generate FPE
  1404   __ jmp(Interpreter::_throw_ArithmeticException_entry);
  1405   __ delayed()->nop();
  1407   __ bind(normal);
  1408   __ pop_l(A2, A3);
  1409   if (UseLoongsonISA) {
  1410     __ gsddiv(FSR, A2, FSR);
  1411   } else {
  1412     __ ddiv(A2, FSR);
  1413     __ mflo(FSR);
  1417 // NOTE: i DONT use the Interpreter::_throw_ArithmeticException_entry
  1418 void TemplateTable::lrem() {
  1419   transition(ltos, ltos);
  1420   Label normal;
  1422   __ bne(FSR, R0, normal);
  1423   __ delayed()->nop();
  1425   __ jmp(Interpreter::_throw_ArithmeticException_entry);
  1426   __ delayed()->nop();
  1428   __ bind(normal);
  1429   __ pop_l (A2, A3);
  1431   if(UseLoongsonISA){
  1432     __ gsdmod(FSR, A2, FSR);
  1433   } else {
  1434     __ ddiv(A2, FSR);
  1435     __ mfhi(FSR);
  1439 // result in FSR
  1440 // used registers : T0
  1441 void TemplateTable::lshl() {
  1442   transition(itos, ltos);
  1443   __ pop_l(T0, T1);
  1444 #ifdef ASSERT
  1446     Label  L;
  1447     __ beq(T1, R0, L);
  1448     __ delayed()->nop();
  1449     //__ stop("lshl, wrong stack");  // <-- Fu 20130930
  1450     __ bind(L);
  1452 #endif
  1453   __ dsllv(FSR, T0, FSR);
  1456 // used registers : T0
  1457 void TemplateTable::lshr() {
  1458   transition(itos, ltos);
  1459   __ pop_l(T0, T1);
  1460 #ifdef ASSERT
  1462     Label  L;
  1463     __ beq(T1, R0, L);
  1464     __ delayed()->nop();
  1465     __ stop("lshr, wrong stack");
  1466     __ bind(L);
  1468 #endif
  1469   __ dsrav(FSR, T0, FSR);
  1472 // used registers : T0
  1473 void TemplateTable::lushr() {
  1474   transition(itos, ltos);
  1475   __ pop_l(T0, T1);
  1476 #ifdef ASSERT
  1478     Label  L;
  1479     __ beq(T1, R0, L);
  1480     __ delayed()->nop();
  1481     __ stop("lushr, wrong stack");
  1482     __ bind(L);
  1484 #endif
  1485   __ dsrlv(FSR, T0, FSR);
  1488 // result in FSF
  1489 void TemplateTable::fop2(Operation op) {
  1490   transition(ftos, ftos);
  1491   switch (op) {
  1492     case add:
  1493       __ lwc1(FTF, at_sp());
  1494       __ add_s(FSF, FTF, FSF);
  1495       break;
  1496     case sub:
  1497       __ lwc1(FTF, at_sp());
  1498       __ sub_s(FSF, FTF, FSF);
  1499       break;
  1500     case mul:
  1501       __ lwc1(FTF, at_sp());
  1502       __ mul_s(FSF, FTF, FSF);
  1503       break;
  1504     case div:
  1505       __ lwc1(FTF, at_sp());
  1506       __ div_s(FSF, FTF, FSF);
  1507       break;
  1508     case rem:
  1509       __ mov_s(F13, FSF);
  1510       __ lwc1(F12, at_sp());
  1511        __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::frem), 2);
  1512       break;
  1513     default : ShouldNotReachHere();
  1516   __ daddi(SP, SP, 1 * wordSize);
  1519 // result in SSF||FSF
  1520 // i dont handle the strict flags
  1521 void TemplateTable::dop2(Operation op) {
  1522   transition(dtos, dtos);
  1523   switch (op) {
  1524     case add:
  1525       __ ldc1(FTF, at_sp());
  1526       __ add_d(FSF, FTF, FSF);
  1527       break;
  1528     case sub:
  1529       __ ldc1(FTF, at_sp());
  1530       __ sub_d(FSF, FTF, FSF);
  1531       break;
  1532     case mul:
  1533       __ ldc1(FTF, at_sp());
  1534       __ mul_d(FSF, FTF, FSF);
  1535       break;
  1536     case div:
  1537       __ ldc1(FTF, at_sp());
  1538       __ div_d(FSF, FTF, FSF);
  1539       break;
  1540     case rem:
  1541       __ mov_d(F13, FSF);
  1542       __ ldc1(F12, at_sp());
  1543       __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::drem), 2);
  1544       break;
  1545     default : ShouldNotReachHere();
  1548   __ daddi(SP, SP, 2 * wordSize);
  1551 void TemplateTable::ineg() {
  1552   transition(itos, itos);
  1553   __ neg(FSR);
  1556 void TemplateTable::lneg() {
  1557   transition(ltos, ltos);
  1558   __ dsubu(FSR, R0, FSR);
  1561 void TemplateTable::fneg() {
  1562   transition(ftos, ftos);
  1563   __ neg_s(FSF, FSF);
  1566 void TemplateTable::dneg() {
  1567   transition(dtos, dtos);
  1568   __ neg_d(FSF, FSF);
  1571 // used registers : T2
  1572 void TemplateTable::iinc() {
  1573   transition(vtos, vtos);
  1574   locals_index(T2);
  1575   __ lw(FSR, T2, 0);
  1576   __ lb(AT, at_bcp(2));           // get constant
  1577   __ daddu(FSR, FSR, AT);
  1578   __ sw(FSR, T2, 0);
  1581 // used register : T2
  1582 void TemplateTable::wide_iinc() {
  1583   transition(vtos, vtos);
  1584   locals_index_wide(T2);
  1585   __ get_2_byte_integer_at_bcp(FSR, AT, 4);
  1586   __ hswap(FSR);
  1587   __ lw(AT, T2, 0);
  1588   __ daddu(FSR, AT, FSR);
  1589   __ sw(FSR, T2, 0);
  1592 void TemplateTable::convert() {
  1593   // Checking
  1594 #ifdef ASSERT
  1596     TosState tos_in  = ilgl;
  1597     TosState tos_out = ilgl;
  1598     switch (bytecode()) {
  1599       case Bytecodes::_i2l: // fall through
  1600       case Bytecodes::_i2f: // fall through
  1601       case Bytecodes::_i2d: // fall through
  1602       case Bytecodes::_i2b: // fall through
  1603       case Bytecodes::_i2c: // fall through
  1604       case Bytecodes::_i2s: tos_in = itos; break;
  1605       case Bytecodes::_l2i: // fall through
  1606       case Bytecodes::_l2f: // fall through
  1607       case Bytecodes::_l2d: tos_in = ltos; break;
  1608       case Bytecodes::_f2i: // fall through
  1609       case Bytecodes::_f2l: // fall through
  1610       case Bytecodes::_f2d: tos_in = ftos; break;
  1611       case Bytecodes::_d2i: // fall through
  1612       case Bytecodes::_d2l: // fall through
  1613       case Bytecodes::_d2f: tos_in = dtos; break;
  1614       default             : ShouldNotReachHere();
  1616     switch (bytecode()) {
  1617       case Bytecodes::_l2i: // fall through
  1618       case Bytecodes::_f2i: // fall through
  1619       case Bytecodes::_d2i: // fall through
  1620       case Bytecodes::_i2b: // fall through
  1621       case Bytecodes::_i2c: // fall through
  1622       case Bytecodes::_i2s: tos_out = itos; break;
  1623       case Bytecodes::_i2l: // fall through
  1624       case Bytecodes::_f2l: // fall through
  1625       case Bytecodes::_d2l: tos_out = ltos; break;
  1626       case Bytecodes::_i2f: // fall through
  1627       case Bytecodes::_l2f: // fall through
  1628       case Bytecodes::_d2f: tos_out = ftos; break;
  1629       case Bytecodes::_i2d: // fall through
  1630       case Bytecodes::_l2d: // fall through
  1631       case Bytecodes::_f2d: tos_out = dtos; break;
  1632       default             : ShouldNotReachHere();
  1634     transition(tos_in, tos_out);
  1636 #endif // ASSERT
  1638   // Conversion
  1639   // (Note: use pushl(ecx)/popl(ecx) for 1/2-word stack-ptr manipulation)
  1640   switch (bytecode()) {
  1641     case Bytecodes::_i2l:
  1642       __ sll(FSR, FSR, 0);
  1643       break;
  1644     case Bytecodes::_i2f:
  1645       __ mtc1(FSR, FSF);
  1646       __ cvt_s_w(FSF, FSF);
  1647       break;
  1648     case Bytecodes::_i2d:
  1649       __ mtc1(FSR, FSF);
  1650       __ cvt_d_w(FSF, FSF);
  1651       break;
  1652     case Bytecodes::_i2b:
  1653       __ seb(FSR, FSR);
  1654       break;
  1655     case Bytecodes::_i2c:
  1656       __ andi(FSR, FSR, 0xFFFF);  // truncate upper 56 bits
  1657       break;
  1658     case Bytecodes::_i2s:
  1659       __ seh(FSR, FSR);
  1660       break;
  1661     case Bytecodes::_l2i:
  1662       __ sll(FSR, FSR, 0);
  1663       break;
  1664     case Bytecodes::_l2f:
  1665       __ dmtc1(FSR, FSF);
  1666       __ cvt_s_l(FSF, FSF);
  1667       break;
  1668     case Bytecodes::_l2d:
  1669       __ dmtc1(FSR, FSF);
  1670       __ cvt_d_l(FSF, FSF);
  1671       break;
  1672     case Bytecodes::_f2i:
  1674       Label L;
  1676       __ trunc_w_s(F12, FSF);
  1677       __ move(AT, 0x7fffffff);
  1678       __ mfc1(FSR, F12);
  1679       __ c_un_s(FSF, FSF);    //NaN?
  1680       __ movt(FSR, R0);
  1682       __ bne(AT, FSR, L);
  1683       __ delayed()->lui(T9, 0x8000);
  1685       __ mfc1(AT, FSF);
  1686       __ andr(AT, AT, T9);
  1688       __ movn(FSR, T9, AT);
  1690       __ bind(L);
  1692       break;
  1693     case Bytecodes::_f2l:
  1695       Label L;
  1697       __ trunc_l_s(F12, FSF);
  1698       __ daddiu(AT, R0, -1);
  1699       __ dsrl(AT, AT, 1);
  1700       __ dmfc1(FSR, F12);
  1701       __ c_un_s(FSF, FSF);    //NaN?
  1702       __ movt(FSR, R0);
  1704       __ bne(AT, FSR, L);
  1705       __ delayed()->lui(T9, 0x8000);
  1707       __ mfc1(AT, FSF);
  1708       __ andr(AT, AT, T9);
  1710       __ dsll32(T9, T9, 0);
  1711       __ movn(FSR, T9, AT);
  1713       __ bind(L);
  1715       break;
  1716     case Bytecodes::_f2d:
  1717       __ cvt_d_s(FSF, FSF);
  1718       break;
  1719     case Bytecodes::_d2i:
  1721       Label L;
  1723       __ trunc_w_d(F12, FSF);
  1724       __ move(AT, 0x7fffffff);
  1725       __ mfc1(FSR, F12);
  1727       __ bne(FSR, AT, L);
  1728       __ delayed()->mtc1(R0, F12);
  1730       __ cvt_d_w(F12, F12);
  1731       __ c_ult_d(FSF, F12);
  1732       __ bc1f(L);
  1733       __ delayed()->addiu(T9, R0, -1);
  1735       __ c_un_d(FSF, FSF);    //NaN?
  1736       __ subu32(FSR, T9, AT);
  1737       __ movt(FSR, R0);
  1739       __ bind(L);
  1741       break;
  1742     case Bytecodes::_d2l:
  1744       Label L;
  1746       __ trunc_l_d(F12, FSF);
  1747       __ daddiu(AT, R0, -1);
  1748       __ dsrl(AT, AT, 1);
  1749       __ dmfc1(FSR, F12);
  1751       __ bne(FSR, AT, L);
  1752       __ delayed()->mtc1(R0, F12);
  1754       __ cvt_d_w(F12, F12);
  1755       __ c_ult_d(FSF, F12);
  1756       __ bc1f(L);
  1757       __ delayed()->daddiu(T9, R0, -1);
  1759       __ c_un_d(FSF, FSF);    //NaN?
  1760       __ subu(FSR, T9, AT);
  1761       __ movt(FSR, R0);
  1763     __ bind(L);
  1765       break;
  1766     case Bytecodes::_d2f:
  1767       __ cvt_s_d(FSF, FSF);
  1768       break;
  1769     default             :
  1770       ShouldNotReachHere();
  1774 void TemplateTable::lcmp() {
  1775   transition(ltos, itos);
  1777   Label low, high, done;
  1778   __ pop(T0);
  1779   __ pop(R0);
  1780   __ slt(AT, T0, FSR);
  1781   __ bne(AT, R0, low);
  1782   __ delayed()->nop();
  1784   __ bne(T0, FSR, high);
  1785   __ delayed()->nop();
  1787   __ li(FSR, (long)0);
  1788   __ b(done);
  1789   __ delayed()->nop();
  1791   __ bind(low);
  1792   __ li(FSR, (long)-1);
  1793   __ b(done);
  1794   __ delayed()->nop();
  1796   __ bind(high);
  1797   __ li(FSR, (long)1);
  1798   __ b(done);
  1799   __ delayed()->nop();
  1801   __ bind(done);
  1804 void TemplateTable::float_cmp(bool is_float, int unordered_result) {
  1805   Label less, done;
  1807   __ move(FSR, R0);
  1809   if (is_float) {
  1810     __ lwc1(FTF, at_sp());
  1811     __ c_eq_s(FTF, FSF);
  1812     __ bc1t(done);
  1813     __ delayed()->daddi(SP, SP, 1 * wordSize);
  1815     if (unordered_result<0)
  1816       __ c_ult_s(FTF, FSF);
  1817     else
  1818       __ c_olt_s(FTF, FSF);
  1819   } else {
  1820     __ ldc1(FTF, at_sp());
  1821     __ c_eq_d(FTF, FSF);
  1822     __ bc1t(done);
  1823     __ delayed()->daddi(SP, SP, 2 * wordSize);
  1825     if (unordered_result<0)
  1826       __ c_ult_d(FTF, FSF);
  1827     else
  1828       __ c_olt_d(FTF, FSF);
  1830   __ bc1t(less);
  1831   __ delayed()->nop();
  1832   __ move(FSR, 1);
  1833   __ b(done);
  1834   __ delayed()->nop();
  1835   __ bind(less);
  1836   __ move(FSR, -1);
  1837   __ bind(done);
  1841 // used registers : T3, A7, Rnext
  1842 // FSR : return bci, this is defined by the vm specification
  1843 // T2 : MDO taken count
  1844 // T3 : method
  1845 // A7 : offset
  1846 // Rnext : next bytecode, this is required by dispatch_base
  1847 void TemplateTable::branch(bool is_jsr, bool is_wide) {
  1848   __ get_method(T3);
  1849   __ profile_taken_branch(A7, T2);    // only C2 meaningful
  1851 #ifndef CORE
  1852   const ByteSize be_offset = MethodCounters::backedge_counter_offset() +
  1853                              InvocationCounter::counter_offset();
  1854   const ByteSize inv_offset = MethodCounters::invocation_counter_offset() +
  1855                               InvocationCounter::counter_offset();
  1856 #endif // CORE
  1858   // Load up T4 with the branch displacement
  1859   if (!is_wide) {
  1860     __ get_2_byte_integer_at_bcp(A7, AT, 1);
  1861     __ hswap(A7);
  1862   } else {
  1863     __ get_4_byte_integer_at_bcp(A7, AT, 1);
  1864     __ swap(A7);
  1867   // Handle all the JSR stuff here, then exit.
  1868   // It's much shorter and cleaner than intermingling with the non-JSR
  1869   // normal-branch stuff occuring below.
  1870   if (is_jsr) {
  1871     // Pre-load the next target bytecode into Rnext
  1872     __ dadd(AT, BCP, A7);
  1873     __ lbu(Rnext, AT, 0);
  1875     // compute return address as bci in FSR
  1876     __ daddi(FSR, BCP, (is_wide?5:3) - in_bytes(ConstMethod::codes_offset()));
  1877     __ ld(AT, T3, in_bytes(Method::const_offset()));
  1878     __ dsub(FSR, FSR, AT);
  1879     // Adjust the bcp in BCP by the displacement in A7
  1880     __ dadd(BCP, BCP, A7);
  1881     // jsr returns atos that is not an oop
  1882     // Push return address
  1883     __ push_i(FSR);
  1884     // jsr returns vtos
  1885     __ dispatch_only_noverify(vtos);
  1887     return;
  1890   // Normal (non-jsr) branch handling
  1892   // Adjust the bcp in S0 by the displacement in T4
  1893   __ dadd(BCP, BCP, A7);
  1895 #ifdef CORE
  1896   // Pre-load the next target bytecode into EBX
  1897   __ lbu(Rnext, BCP, 0);
  1898   // continue with the bytecode @ target
  1899   __ dispatch_only(vtos);
  1900 #else
  1901   assert(UseLoopCounter || !UseOnStackReplacement, "on-stack-replacement requires loop counters");
  1902   Label backedge_counter_overflow;
  1903   Label profile_method;
  1904   Label dispatch;
  1905   if (UseLoopCounter) {
  1906     // increment backedge counter for backward branches
  1907     // eax: MDO
  1908     // ebx: MDO bumped taken-count
  1909     // T3: method
  1910     // T4: target offset
  1911     // BCP: target bcp
  1912     // LVP: locals pointer
  1913     __ bgtz(A7, dispatch);  // check if forward or backward branch
  1914     __ delayed()->nop();
  1916     // check if MethodCounters exists
  1917     Label has_counters;
  1918     __ ld(AT, T3, in_bytes(Method::method_counters_offset()));  // use AT as MDO, TEMP
  1919     __ bne(AT, R0, has_counters);
  1920     __ nop();
  1921     __ push(T3);
  1922     //__ push(A7);
  1923     __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::build_method_counters),
  1924                T3);
  1925     //__ pop(A7);
  1926     __ pop(T3);
  1927     __ ld(AT, T3, in_bytes(Method::method_counters_offset()));  // use AT as MDO, TEMP
  1928     __ beq(AT, R0, dispatch);
  1929     __ nop();
  1930     __ bind(has_counters);
  1932     // increment back edge counter
  1933     __ ld(T1, T3, in_bytes(Method::method_counters_offset()));
  1934     __ lw(T0, T1, in_bytes(be_offset));
  1935     __ increment(T0, InvocationCounter::count_increment);
  1936     __ sw(T0, T1, in_bytes(be_offset));
  1938     // load invocation counter
  1939     __ lw(T1, T1, in_bytes(inv_offset));
  1940     // buffer bit added, mask no needed
  1942     // dadd backedge counter & invocation counter
  1943     __ dadd(T1, T1, T0);
  1945     if (ProfileInterpreter) {
  1946       // Test to see if we should create a method data oop
  1947       //__ lui(AT, Assembler::split_high(int(&InvocationCounter::InterpreterProfileLimit)));
  1948       //__ lw(AT, AT, Assembler::split_low(int(&InvocationCounter::InterpreterProfileLimit)));
  1949       // T1 : backedge counter & invocation counter
  1950       __ li(AT, (long)&InvocationCounter::InterpreterProfileLimit);
  1951       __ lw(AT, AT, 0);
  1952       __ slt(AT, T1, AT);
  1953       __ bne(AT, R0, dispatch);
  1954       __ delayed()->nop();
  1956       // if no method data exists, go to profile method
  1957       __ test_method_data_pointer(T1, profile_method);
  1959       if (UseOnStackReplacement) {
  1960         // check for overflow against ebx which is the MDO taken count
  1961         __ li(AT, (long)&InvocationCounter::InterpreterBackwardBranchLimit);
  1962         __ lw(AT, AT, 0);
  1963         // the value Rnext Is get from the beginning profile_taken_branch
  1964         __ slt(AT, T2, AT);
  1965         __ bne(AT, R0, dispatch);
  1966         __ delayed()->nop();
  1968         // When ProfileInterpreter is on, the backedge_count comes
  1969         // from the methodDataOop, which value does not get reset on
  1970         // the call to  frequency_counter_overflow().
  1971         // To avoid excessive calls to the overflow routine while
  1972         // the method is being compiled, dadd a second test to make
  1973         // sure the overflow function is called only once every
  1974         // overflow_frequency.
  1975         const int overflow_frequency = 1024;
  1976         __ andi(AT, T2, overflow_frequency-1);
  1977         __ beq(AT, R0, backedge_counter_overflow);
  1978         __ delayed()->nop();
  1980     } else {
  1981       if (UseOnStackReplacement) {
  1982         // check for overflow against eax, which is the sum of the counters
  1983         __ li(AT, (long)&InvocationCounter::InterpreterBackwardBranchLimit);
  1984         __ lw(AT, AT, 0);
  1985         __ slt(AT, T1, AT);
  1986         __ beq(AT, R0, backedge_counter_overflow);
  1987         __ delayed()->nop();
  1990     __ bind(dispatch);
  1993   // Pre-load the next target bytecode into Rnext
  1994   __ lbu(Rnext, BCP, 0);
  1996   // continue with the bytecode @ target
  1997   // FSR: return bci for jsr's, unused otherwise
  1998   // Rnext: target bytecode
  1999   // BCP: target bcp
  2000   __ dispatch_only(vtos);
  2002   if (UseLoopCounter) {
  2003     if (ProfileInterpreter) {
  2004       // Out-of-line code to allocate method data oop.
  2005       __ bind(profile_method);
  2006       __ call_VM(NOREG, CAST_FROM_FN_PTR(address, InterpreterRuntime::profile_method));
  2007       __ lbu(Rnext, BCP, 0);
  2008       __ set_method_data_pointer_for_bcp();
  2009       __ b(dispatch);
  2010       __ delayed()->nop();
  2013     if (UseOnStackReplacement) {
  2014       // invocation counter overflow
  2015       __ bind(backedge_counter_overflow);
  2016       __ sub(A7, BCP, A7);  // branch bcp
  2017       call_VM(NOREG, CAST_FROM_FN_PTR(address,
  2018       InterpreterRuntime::frequency_counter_overflow), A7);
  2019       __ lbu(Rnext, BCP, 0);
  2021       // V0: osr nmethod (osr ok) or NULL (osr not possible)
  2022       // V1: osr adapter frame return address
  2023       // Rnext: target bytecode
  2024       // LVP: locals pointer
  2025       // BCP: bcp
  2026       __ beq(V0, R0, dispatch);
  2027       __ delayed()->nop();
  2028       // nmethod may have been invalidated (VM may block upon call_VM return)
  2029       __ lw(T3, V0, nmethod::entry_bci_offset());
  2030       __ move(AT, InvalidOSREntryBci);
  2031       __ beq(AT, T3, dispatch);
  2032       __ delayed()->nop();
  2033       // We need to prepare to execute the OSR method. First we must
  2034       // migrate the locals and monitors off of the stack.
  2035       //eax V0: osr nmethod (osr ok) or NULL (osr not possible)
  2036       //ebx V1: osr adapter frame return address
  2037       //edx  Rnext: target bytecode
  2038       //edi  LVP: locals pointer
  2039       //esi  BCP: bcp
  2040       __ move(BCP, V0);
  2041       // const Register thread = ecx;
  2042       const Register thread = TREG;
  2043 #ifndef OPT_THREAD
  2044       __ get_thread(thread);
  2045 #endif
  2046       call_VM(noreg, CAST_FROM_FN_PTR(address,
  2047       SharedRuntime::OSR_migration_begin));
  2048       // eax is OSR buffer, move it to expected parameter location
  2049       //refer to osrBufferPointer in c1_LIRAssembler_mips.cpp
  2050       __ move(T0, V0);
  2052       // pop the interpreter frame
  2053       __ ld(A7, Address(FP, frame::interpreter_frame_sender_sp_offset * wordSize));
  2054       //FIXME, shall we keep the return address on the stack?
  2055       __ leave();                                // remove frame anchor
  2056       __ move(LVP, RA);
  2057       __ move(SP, A7);
  2059       __ move(AT, -(StackAlignmentInBytes));
  2060       __ andr(SP , SP , AT);
  2062       // push the (possibly adjusted) return address
  2063       //refer to osr_entry in c1_LIRAssembler_mips.cpp
  2064       __ ld(AT, BCP, nmethod::osr_entry_point_offset());
  2065       __ jr(AT);
  2066       __ delayed()->nop();
  2069 #endif // not CORE
  2073 void TemplateTable::if_0cmp(Condition cc) {
  2074   transition(itos, vtos);
  2075   // assume branch is more often taken than not (loops use backward branches)
  2076   Label not_taken;
  2077   switch(cc) {
  2078     case not_equal:
  2079       __ beq(FSR, R0, not_taken);
  2080       break;
  2081     case equal:
  2082       __ bne(FSR, R0, not_taken);
  2083       break;
  2084     case less:
  2085       __ bgez(FSR, not_taken);
  2086       break;
  2087     case less_equal:
  2088       __ bgtz(FSR, not_taken);
  2089       break;
  2090     case greater:
  2091       __ blez(FSR, not_taken);
  2092       break;
  2093     case greater_equal:
  2094       __ bltz(FSR, not_taken);
  2095       break;
  2097   __ delayed()->nop();
  2099   branch(false, false);
  2101   __ bind(not_taken);
  2102   __ profile_not_taken_branch(FSR);
  2105 void TemplateTable::if_icmp(Condition cc) {
  2106   transition(itos, vtos);
  2107   // assume branch is more often taken than not (loops use backward branches)
  2108   Label not_taken;
  2110   __ pop_i(SSR);
  2111   switch(cc) {
  2112     case not_equal:
  2113       __ beq(SSR, FSR, not_taken);
  2114       break;
  2115     case equal:
  2116       __ bne(SSR, FSR, not_taken);
  2117       break;
  2118     case less:
  2119       __ slt(AT, SSR, FSR);
  2120       __ beq(AT, R0, not_taken);
  2121       break;
  2122     case less_equal:
  2123       __ slt(AT, FSR, SSR);
  2124       __ bne(AT, R0, not_taken);
  2125       break;
  2126     case greater:
  2127       __ slt(AT, FSR, SSR);
  2128       __ beq(AT, R0, not_taken);
  2129       break;
  2130     case greater_equal:
  2131       __ slt(AT, SSR, FSR);
  2132       __ bne(AT, R0, not_taken);
  2133       break;
  2135   __ delayed()->nop();
  2137   branch(false, false);
  2138   __ bind(not_taken);
  2139   __ profile_not_taken_branch(FSR);
  2142 void TemplateTable::if_nullcmp(Condition cc) {
  2143   transition(atos, vtos);
  2144   // assume branch is more often taken than not (loops use backward branches)
  2145   Label not_taken;
  2146   switch(cc) {
  2147     case not_equal:
  2148       __ beq(FSR, R0, not_taken);
  2149       break;
  2150     case equal:
  2151       __ bne(FSR, R0, not_taken);
  2152       break;
  2153     default:
  2154       ShouldNotReachHere();
  2156   __ delayed()->nop();
  2158   branch(false, false);
  2159   __ bind(not_taken);
  2160   __ profile_not_taken_branch(FSR);
  2164 void TemplateTable::if_acmp(Condition cc) {
  2165   transition(atos, vtos);
  2166   // assume branch is more often taken than not (loops use backward branches)
  2167   Label not_taken;
  2168   //  __ lw(SSR, SP, 0);
  2169   __ pop_ptr(SSR);
  2170   switch(cc) {
  2171     case not_equal:
  2172       __ beq(SSR, FSR, not_taken);
  2173       break;
  2174     case equal:
  2175       __ bne(SSR, FSR, not_taken);
  2176       break;
  2177     default:
  2178       ShouldNotReachHere();
  2180   __ delayed()->nop();
  2182   branch(false, false);
  2184   __ bind(not_taken);
  2185   __ profile_not_taken_branch(FSR);
  2188 // used registers : T1, T2, T3
  2189 // T1 : method
  2190 // T2 : returb bci
  2191 void TemplateTable::ret() {
  2192   transition(vtos, vtos);
  2194   locals_index(T2);
  2195   __ ld(T2, T2, 0);
  2196   __ profile_ret(T2, T3);
  2198   __ get_method(T1);
  2199   __ ld(BCP, T1, in_bytes(Method::const_offset()));
  2200   __ dadd(BCP, BCP, T2);
  2201   __ daddi(BCP, BCP, in_bytes(ConstMethod::codes_offset()));
  2203   __ dispatch_next(vtos);
  2206 // used registers : T1, T2, T3
  2207 // T1 : method
  2208 // T2 : returb bci
  2209 void TemplateTable::wide_ret() {
  2210   transition(vtos, vtos);
  2212   locals_index_wide(T2);
  2213   __ ld(T2, T2, 0);                   // get return bci, compute return bcp
  2214   __ profile_ret(T2, T3);
  2216   __ get_method(T1);
  2217   __ ld(BCP, T1, in_bytes(Method::const_offset()));
  2218   __ dadd(BCP, BCP, T2);
  2219   __ daddi(BCP, BCP, in_bytes(ConstMethod::codes_offset()));
  2221   __ dispatch_next(vtos);
  2224 // used register T2, T3, A7, Rnext
  2225 // T2 : bytecode pointer
  2226 // T3 : low
  2227 // A7 : high
  2228 // Rnext : dest bytecode, required by dispatch_base
  2229 void TemplateTable::tableswitch() {
  2230   Label default_case, continue_execution;
  2231   transition(itos, vtos);
  2233   // align BCP
  2234   __ daddi(T2, BCP, BytesPerInt);
  2235   __ li(AT, -BytesPerInt);
  2236   __ andr(T2, T2, AT);
  2238   // load lo & hi
  2239   __ lw(T3, T2, 1 * BytesPerInt);
  2240   __ swap(T3);
  2241   __ lw(A7, T2, 2 * BytesPerInt);
  2242   __ swap(A7);
  2244   // check against lo & hi
  2245   __ slt(AT, FSR, T3);
  2246   __ bne(AT, R0, default_case);
  2247   __ delayed()->nop();
  2249   __ slt(AT, A7, FSR);
  2250   __ bne(AT, R0, default_case);
  2251   __ delayed()->nop();
  2253   // lookup dispatch offset, in A7 big endian
  2254   __ dsub(FSR, FSR, T3);
  2255   __ dsll(AT, FSR, Address::times_4);
  2256   __ dadd(AT, T2, AT);
  2257   __ lw(A7, AT, 3 * BytesPerInt);
  2258   __ profile_switch_case(FSR, T9, T3);
  2260   __ bind(continue_execution);
  2261   __ swap(A7);
  2262   __ dadd(BCP, BCP, A7);
  2263   __ lbu(Rnext, BCP, 0);
  2264   __ dispatch_only(vtos);
  2266   // handle default
  2267   __ bind(default_case);
  2268   __ profile_switch_default(FSR);
  2269   __ lw(A7, T2, 0);
  2270   __ b(continue_execution);
  2271   __ delayed()->nop();
  2274 void TemplateTable::lookupswitch() {
  2275   transition(itos, itos);
  2276   __ stop("lookupswitch bytecode should have been rewritten");
  2279 // used registers : T2, T3, A7, Rnext
  2280 // T2 : bytecode pointer
  2281 // T3 : pair index
  2282 // A7 : offset
  2283 // Rnext : dest bytecode
  2284 // the data after the opcode is the same as lookupswitch
  2285 // see Rewriter::rewrite_method for more information
  2286 void TemplateTable::fast_linearswitch() {
  2287   transition(itos, vtos);
  2288   Label loop_entry, loop, found, continue_execution;
  2290   // swap eax so we can avoid swapping the table entries
  2291   __ swap(FSR);
  2293   // align BCP
  2294   __ daddi(T2, BCP, BytesPerInt);
  2295   __ li(AT, -BytesPerInt);
  2296   __ andr(T2, T2, AT);
  2298   // set counter
  2299   __ lw(T3, T2, BytesPerInt);
  2300   __ swap(T3);
  2301   __ b(loop_entry);
  2302   __ delayed()->nop();
  2304   // table search
  2305   __ bind(loop);
  2306   // get the entry value
  2307   __ dsll(AT, T3, Address::times_8);
  2308   __ dadd(AT, T2, AT);
  2309   __ lw(AT, AT, 2 * BytesPerInt);
  2311   // found?
  2312   __ beq(FSR, AT, found);
  2313   __ delayed()->nop();
  2315   __ bind(loop_entry);
  2316   __ bgtz(T3, loop);
  2317   __ delayed()->daddiu(T3, T3, -1);
  2319   // default case
  2320   __ profile_switch_default(FSR);
  2321   __ lw(A7, T2, 0);
  2322   __ b(continue_execution);
  2323   __ delayed()->nop();
  2325   // entry found -> get offset
  2326   __ bind(found);
  2327   __ dsll(AT, T3, Address::times_8);
  2328   __ dadd(AT, T2, AT);
  2329   __ lw(A7, AT, 3 * BytesPerInt);
  2330   __ profile_switch_case(T3, FSR, T2);
  2332   // continue execution
  2333   __ bind(continue_execution);
  2334   __ swap(A7);
  2335   __ dadd(BCP, BCP, A7);
  2336   __ lbu(Rnext, BCP, 0);
  2337   __ dispatch_only(vtos);
  2340 // used registers : T0, T1, T2, T3, A7, Rnext
  2341 // T2 : pairs address(array)
  2342 // Rnext : dest bytecode
  2343 // the data after the opcode is the same as lookupswitch
  2344 // see Rewriter::rewrite_method for more information
  2345 void TemplateTable::fast_binaryswitch() {
  2346   transition(itos, vtos);
  2347   // Implementation using the following core algorithm:
  2348   //
  2349   // int binary_search(int key, LookupswitchPair* array, int n) {
  2350   //   // Binary search according to "Methodik des Programmierens" by
  2351   //   // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985.
  2352   //   int i = 0;
  2353   //   int j = n;
  2354   //   while (i+1 < j) {
  2355   //     // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q)
  2356   //     // with      Q: for all i: 0 <= i < n: key < a[i]
  2357   //     // where a stands for the array and assuming that the (inexisting)
  2358   //     // element a[n] is infinitely big.
  2359   //     int h = (i + j) >> 1;
  2360   //     // i < h < j
  2361   //     if (key < array[h].fast_match()) {
  2362   //       j = h;
  2363   //     } else {
  2364   //       i = h;
  2365   //     }
  2366   //   }
  2367   //   // R: a[i] <= key < a[i+1] or Q
  2368   //   // (i.e., if key is within array, i is the correct index)
  2369   //   return i;
  2370   // }
  2372   // register allocation
  2373   const Register array = T2;
  2374   const Register i = T3, j = A7;
  2375   const Register h = T1;
  2376   const Register temp = T0;
  2377   const Register key = FSR;
  2379   // setup array
  2380   __ daddi(array, BCP, 3*BytesPerInt);
  2381   __ li(AT, -BytesPerInt);
  2382   __ andr(array, array, AT);
  2384   // initialize i & j
  2385   __ move(i, R0);
  2386   __ lw(j, array, - 1 * BytesPerInt);
  2387   // Convert j into native byteordering
  2388   __ swap(j);
  2390   // and start
  2391   Label entry;
  2392   __ b(entry);
  2393   __ delayed()->nop();
  2395   // binary search loop
  2397     Label loop;
  2398     __ bind(loop);
  2399     // int h = (i + j) >> 1;
  2400     __ dadd(h, i, j);
  2401     __ dsrl(h, h, 1);
  2402     // if (key < array[h].fast_match()) {
  2403     //   j = h;
  2404     // } else {
  2405     //   i = h;
  2406     // }
  2407     // Convert array[h].match to native byte-ordering before compare
  2408     __ dsll(AT, h, Address::times_8);
  2409     __ dadd(AT, array, AT);
  2410     __ lw(temp, AT, 0 * BytesPerInt);
  2411     __ swap(temp);
  2414       Label set_i, end_of_if;
  2415       __ slt(AT, key, temp);
  2416       __ beq(AT, R0, set_i);
  2417       __ delayed()->nop();
  2419       __ b(end_of_if);
  2420       __ delayed(); __ move(j, h);
  2422       __ bind(set_i);
  2423       __ move(i, h);
  2425       __ bind(end_of_if);
  2427     // while (i+1 < j)
  2428     __ bind(entry);
  2429     __ daddi(h, i, 1);
  2430     __ slt(AT, h, j);
  2431     __ bne(AT, R0, loop);
  2432     __ delayed()->nop();
  2435   // end of binary search, result index is i (must check again!)
  2436   Label default_case;
  2437   // Convert array[i].match to native byte-ordering before compare
  2438   __ dsll(AT, i, Address::times_8);
  2439   __ dadd(AT, array, AT);
  2440   __ lw(temp, AT, 0 * BytesPerInt);
  2441   __ swap(temp);
  2442   __ bne(key, temp, default_case);
  2443   __ delayed()->nop();
  2445   // entry found -> j = offset
  2446   __ dsll(AT, i, Address::times_8);
  2447   __ dadd(AT, array, AT);
  2448   __ lw(j, AT, 1 * BytesPerInt);
  2449   __ profile_switch_case(i, key, array);
  2450   __ swap(j);
  2452   __ dadd(BCP, BCP, j);
  2453   __ lbu(Rnext, BCP, 0);
  2454   __ dispatch_only(vtos);
  2456   // default case -> j = default offset
  2457   __ bind(default_case);
  2458   __ profile_switch_default(i);
  2459   __ lw(j, array, - 2 * BytesPerInt);
  2460   __ swap(j);
  2461   __ dadd(BCP, BCP, j);
  2462   __ lbu(Rnext, BCP, 0);
  2463   __ dispatch_only(vtos);
  2466 void TemplateTable::_return(TosState state) {
  2467   transition(state, state);
  2468   assert(_desc->calls_vm(),
  2469       "inconsistent calls_vm information"); // call in remove_activation
  2471   if (_desc->bytecode() == Bytecodes::_return_register_finalizer) {
  2472     assert(state == vtos, "only valid state");
  2473     __ ld(T1, aaddress(0));
  2474     __ load_klass(LVP, T1);
  2475     __ lw(LVP, LVP, in_bytes(Klass::access_flags_offset()));
  2476     __ move(AT, JVM_ACC_HAS_FINALIZER);
  2477     __ andr(AT, AT, LVP);//by_css
  2478     Label skip_register_finalizer;
  2479     __ beq(AT, R0, skip_register_finalizer);
  2480     __ delayed()->nop();
  2481     __ call_VM(noreg, CAST_FROM_FN_PTR(address,
  2482     InterpreterRuntime::register_finalizer), T1);
  2483     __ bind(skip_register_finalizer);
  2485   __ remove_activation(state, T9);
  2486   __ sync();
  2488   __ jr(T9);
  2489   __ delayed()->nop();
  2492 // ----------------------------------------------------------------------------
  2493 // Volatile variables demand their effects be made known to all CPU's
  2494 // in order.  Store buffers on most chips allow reads & writes to
  2495 // reorder; the JMM's ReadAfterWrite.java test fails in -Xint mode
  2496 // without some kind of memory barrier (i.e., it's not sufficient that
  2497 // the interpreter does not reorder volatile references, the hardware
  2498 // also must not reorder them).
  2499 //
  2500 // According to the new Java Memory Model (JMM):
  2501 // (1) All volatiles are serialized wrt to each other.  ALSO reads &
  2502 //     writes act as aquire & release, so:
  2503 // (2) A read cannot let unrelated NON-volatile memory refs that
  2504 //     happen after the read float up to before the read.  It's OK for
  2505 //     non-volatile memory refs that happen before the volatile read to
  2506 //     float down below it.
  2507 // (3) Similar a volatile write cannot let unrelated NON-volatile
  2508 //     memory refs that happen BEFORE the write float down to after the
  2509 //     write.  It's OK for non-volatile memory refs that happen after the
  2510 //     volatile write to float up before it.
  2511 //
  2512 // We only put in barriers around volatile refs (they are expensive),
  2513 // not _between_ memory refs (that would require us to track the
  2514 // flavor of the previous memory refs).  Requirements (2) and (3)
  2515 // require some barriers before volatile stores and after volatile
  2516 // loads.  These nearly cover requirement (1) but miss the
  2517 // volatile-store-volatile-load case.  This final case is placed after
  2518 // volatile-stores although it could just as well go before
  2519 // volatile-loads.
  2520 //void TemplateTable::volatile_barrier(Assembler::Membar_mask_bits
  2521 //                                     order_constraint) {
  2522 void TemplateTable::volatile_barrier( ) {
  2523   // Helper function to insert a is-volatile test and memory barrier
  2524   //if (os::is_MP()) { // Not needed on single CPU
  2525   //  __ membar(order_constraint);
  2526   //}
  2527   if( !os::is_MP() ) return;  // Not needed on single CPU
  2528   __ sync();
  2531 // we dont shift left 2 bits in get_cache_and_index_at_bcp
  2532 // for we always need shift the index we use it. the ConstantPoolCacheEntry
  2533 // is 16-byte long, index is the index in
  2534 // ConstantPoolCache, so cache + base_offset() + index * 16 is
  2535 // the corresponding ConstantPoolCacheEntry
  2536 // used registers : T2
  2537 // NOTE : the returned index need also shift left 4 to get the address!
  2538 void TemplateTable::resolve_cache_and_index(int byte_no,
  2539                                             Register Rcache,
  2540                                             Register index,
  2541                                             size_t index_size) {
  2542   assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
  2543   const Register temp = A1;
  2544   assert_different_registers(Rcache, index);
  2546   Label resolved;
  2547   __ get_cache_and_index_and_bytecode_at_bcp(Rcache, index, temp, byte_no, 1, index_size);
  2548   // is resolved?
  2549   int i = (int)bytecode();
  2550   __ addi(temp, temp, -i);
  2551   __ beq(temp, R0, resolved);
  2552   __ delayed()->nop();
  2553   // resolve first time through
  2554   address entry;
  2555   switch (bytecode()) {
  2556     case Bytecodes::_getstatic      : // fall through
  2557     case Bytecodes::_putstatic      : // fall through
  2558     case Bytecodes::_getfield       : // fall through
  2559     case Bytecodes::_putfield       :
  2560       entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_get_put);
  2561       break;
  2562     case Bytecodes::_invokevirtual  : // fall through
  2563     case Bytecodes::_invokespecial  : // fall through
  2564     case Bytecodes::_invokestatic   : // fall through
  2565     case Bytecodes::_invokeinterface:
  2566       entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invoke);
  2567       break;
  2568     case Bytecodes::_invokehandle:
  2569       entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokehandle);
  2570       break;
  2571     case Bytecodes::_invokedynamic:
  2572       entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokedynamic);
  2573       break;
  2574     default                          :
  2575       fatal(err_msg("unexpected bytecode: %s", Bytecodes::name(bytecode())));
  2576       break;
  2579   __ move(temp, i);
  2580   __ call_VM(NOREG, entry, temp);
  2582   // Update registers with resolved info
  2583   __ get_cache_and_index_at_bcp(Rcache, index, 1, index_size);
  2584   __ bind(resolved);
  2587 // The Rcache and index registers must be set before call
  2588 void TemplateTable::load_field_cp_cache_entry(Register obj,
  2589                                               Register cache,
  2590                                               Register index,
  2591                                               Register off,
  2592                                               Register flags,
  2593                                               bool is_static = false) {
  2594   assert_different_registers(cache, index, flags, off);
  2596   ByteSize cp_base_offset = ConstantPoolCache::base_offset();
  2597   // Field offset
  2598   __ dsll(AT, index, Address::times_ptr);
  2599   __ dadd(AT, cache, AT);
  2600   __ ld(off, AT, in_bytes(cp_base_offset + ConstantPoolCacheEntry::f2_offset()));
  2601   // Flags
  2602   __ ld(flags, AT, in_bytes(cp_base_offset + ConstantPoolCacheEntry::flags_offset()));
  2604   // klass overwrite register
  2605   if (is_static) {
  2606     __ ld(obj, AT, in_bytes(cp_base_offset + ConstantPoolCacheEntry::f1_offset()));
  2607     const int mirror_offset = in_bytes(Klass::java_mirror_offset());
  2608     __ ld(obj, Address(obj, mirror_offset));
  2610     __ verify_oop(obj);
  2614 // get the method, itable_index and flags of the current invoke
  2615 void TemplateTable::load_invoke_cp_cache_entry(int byte_no,
  2616                                                Register method,
  2617                                                Register itable_index,
  2618                                                Register flags,
  2619                                                bool is_invokevirtual,
  2620                                                bool is_invokevfinal, /*unused*/
  2621                                                bool is_invokedynamic) {
  2622   // setup registers
  2623   const Register cache = T3;
  2624   const Register index = T1;
  2625   assert_different_registers(method, flags);
  2626   assert_different_registers(method, cache, index);
  2627   assert_different_registers(itable_index, flags);
  2628   assert_different_registers(itable_index, cache, index);
  2629   assert(is_invokevirtual == (byte_no == f2_byte), "is invokevirtual flag redundant");
  2630   // determine constant pool cache field offsets
  2631   const int method_offset = in_bytes(
  2632     ConstantPoolCache::base_offset() +
  2633       ((byte_no == f2_byte)
  2634        ? ConstantPoolCacheEntry::f2_offset()
  2635        : ConstantPoolCacheEntry::f1_offset()));
  2636   const int flags_offset = in_bytes(ConstantPoolCache::base_offset() +
  2637                                     ConstantPoolCacheEntry::flags_offset());
  2638   // access constant pool cache fields
  2639   const int index_offset = in_bytes(ConstantPoolCache::base_offset() +
  2640                                     ConstantPoolCacheEntry::f2_offset());
  2642   size_t index_size = (is_invokedynamic ? sizeof(u4): sizeof(u2));
  2643   resolve_cache_and_index(byte_no, cache, index, index_size);
  2645   //assert(wordSize == 8, "adjust code below");
  2646   // note we shift 4 not 2, for we get is the true inde
  2647   // of ConstantPoolCacheEntry, not the shifted 2-bit index as x86 version
  2648   __ dsll(AT, index, Address::times_ptr);
  2649   __ dadd(AT, cache, AT);
  2650   __ ld(method, AT, method_offset);
  2652   if (itable_index != NOREG) {
  2653     __ ld(itable_index, AT, index_offset);
  2655   __ ld(flags, AT, flags_offset);
  2658 // The registers cache and index expected to be set before call.
  2659 // Correct values of the cache and index registers are preserved.
  2660 void TemplateTable::jvmti_post_field_access(Register cache, Register index,
  2661                                             bool is_static, bool has_tos) {
  2662   // do the JVMTI work here to avoid disturbing the register state below
  2663   // We use c_rarg registers here because we want to use the register used in
  2664   // the call to the VM
  2665   if (JvmtiExport::can_post_field_access()) {
  2666     // Check to see if a field access watch has been set before we
  2667     // take the time to call into the VM.
  2668     Label L1;
  2669     // kill FSR
  2670     Register tmp1 = T2;
  2671     Register tmp2 = T1;
  2672     Register tmp3 = T3;
  2673     assert_different_registers(cache, index, AT);
  2674     __ li(AT, (intptr_t)JvmtiExport::get_field_access_count_addr());
  2675     __ lw(AT, AT, 0);
  2676     __ beq(AT, R0, L1);
  2677     __ delayed()->nop();
  2679     __ get_cache_and_index_at_bcp(tmp2, tmp3, 1);
  2681     // cache entry pointer
  2682     __ daddi(tmp2, tmp2, in_bytes(ConstantPoolCache::base_offset()));
  2683     __ shl(tmp3, LogBytesPerWord);
  2684     __ dadd(tmp2, tmp2, tmp3);
  2685     if (is_static) {
  2686       __ move(tmp1, R0);
  2687     } else {
  2688       __ ld(tmp1, SP, 0);
  2689       __ verify_oop(tmp1);
  2691     // tmp1: object pointer or NULL
  2692     // tmp2: cache entry pointer
  2693     // tmp3: jvalue object on the stack
  2694     __ call_VM(NOREG, CAST_FROM_FN_PTR(address,
  2695                                        InterpreterRuntime::post_field_access),
  2696                tmp1, tmp2, tmp3);
  2697     __ get_cache_and_index_at_bcp(cache, index, 1);
  2698     __ bind(L1);
  2702 void TemplateTable::pop_and_check_object(Register r) {
  2703   __ pop_ptr(r);
  2704   __ null_check(r);  // for field access must check obj.
  2705   __ verify_oop(r);
  2708 // used registers : T1, T2, T3, T1
  2709 // T1 : flags
  2710 // T2 : off
  2711 // T3 : obj
  2712 // T1 : field address
  2713 // The flags 31, 30, 29, 28 together build a 4 bit number 0 to 8 with the
  2714 // following mapping to the TosState states:
  2715 // btos: 0
  2716 // ctos: 1
  2717 // stos: 2
  2718 // itos: 3
  2719 // ltos: 4
  2720 // ftos: 5
  2721 // dtos: 6
  2722 // atos: 7
  2723 // vtos: 8
  2724 // see ConstantPoolCacheEntry::set_field for more info
  2725 void TemplateTable::getfield_or_static(int byte_no, bool is_static) {
  2726   transition(vtos, vtos);
  2728   const Register cache = T3;
  2729   const Register index = T0;
  2731   const Register obj   = T3;
  2732   const Register off   = T2;
  2733   const Register flags = T1;
  2734   resolve_cache_and_index(byte_no, cache, index, sizeof(u2));
  2735   jvmti_post_field_access(cache, index, is_static, false);
  2736   load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
  2738   if (!is_static) pop_and_check_object(obj);
  2739   __ dadd(index, obj, off);
  2742   Label Done, notByte, notInt, notShort, notChar,
  2743               notLong, notFloat, notObj, notDouble;
  2745   assert(btos == 0, "change code, btos != 0");
  2746   __ dsrl(flags, flags, ConstantPoolCacheEntry::tos_state_shift);
  2747   __ andi(flags, flags, 0xf);
  2748   __ bne(flags, R0, notByte);
  2749   __ delayed()->nop();
  2751   // btos
  2752   __ lb(FSR, index, 0);
  2753   __ sd(FSR, SP, - wordSize);
  2755   // Rewrite bytecode to be faster
  2756   if (!is_static) {
  2757     patch_bytecode(Bytecodes::_fast_bgetfield, T3, T2);
  2759   __ b(Done);
  2760   __ delayed()->daddi(SP, SP, - wordSize);
  2762   __ bind(notByte);
  2763   __ move(AT, itos);
  2764   __ bne(flags, AT, notInt);
  2765   __ delayed()->nop();
  2767   // itos
  2768   __ lw(FSR, index, 0);
  2769   __ sd(FSR, SP, - wordSize);
  2771   // Rewrite bytecode to be faster
  2772   if (!is_static) {
  2773     // patch_bytecode(Bytecodes::_fast_igetfield, T3, T2);
  2774     patch_bytecode(Bytecodes::_fast_igetfield, T3, T2);
  2776   __ b(Done);
  2777   __ delayed()->daddi(SP, SP, - wordSize);
  2779   __ bind(notInt);
  2780   __ move(AT, atos);
  2781   __ bne(flags, AT, notObj);
  2782   __ delayed()->nop();
  2784   // atos
  2785   //add for compressedoops
  2786   __ load_heap_oop(FSR, Address(index, 0));
  2787   __ sd(FSR, SP, - wordSize);
  2789   if (!is_static) {
  2790     //patch_bytecode(Bytecodes::_fast_agetfield, T3, T2);
  2791     patch_bytecode(Bytecodes::_fast_agetfield, T3, T2);
  2793   __ b(Done);
  2794   __ delayed()->daddi(SP, SP, - wordSize);
  2796   __ bind(notObj);
  2797   __ move(AT, ctos);
  2798   __ bne(flags, AT, notChar);
  2799   __ delayed()->nop();
  2801   // ctos
  2802   __ lhu(FSR, index, 0);
  2803   __ sd(FSR, SP, - wordSize);
  2805   if (!is_static) {
  2806     patch_bytecode(Bytecodes::_fast_cgetfield, T3, T2);
  2808   __ b(Done);
  2809   __ delayed()->daddi(SP, SP, - wordSize);
  2811   __ bind(notChar);
  2812   __ move(AT, stos);
  2813   __ bne(flags, AT, notShort);
  2814   __ delayed()->nop();
  2816   // stos
  2817   __ lh(FSR, index, 0);
  2818   __ sd(FSR, SP, - wordSize);
  2820   if (!is_static) {
  2821     patch_bytecode(Bytecodes::_fast_sgetfield, T3, T2);
  2823   __ b(Done);
  2824   __ delayed()->daddi(SP, SP, - wordSize);
  2826   __ bind(notShort);
  2827   __ move(AT, ltos);
  2828   __ bne(flags, AT, notLong);
  2829   __ delayed()->nop();
  2831   // FIXME : the load/store should be atomic, we have no simple method to do this in mips32
  2832   // ltos
  2833   __ ld(FSR, index, 0 * wordSize);
  2834   __ sd(FSR, SP, -2 * wordSize);
  2835   __ sd(R0, SP, -1 * wordSize);
  2837   // Don't rewrite to _fast_lgetfield for potential volatile case.
  2838   __ b(Done);
  2839   __ delayed()->daddi(SP, SP, - 2 * wordSize);
  2841   __ bind(notLong);
  2842   __ move(AT, ftos);
  2843   __ bne(flags, AT, notFloat);
  2844   __ delayed()->nop();
  2846   // ftos
  2847   __ lwc1(FSF, index, 0);
  2848   __ sdc1(FSF, SP, - wordSize);
  2850   if (!is_static) {
  2851     patch_bytecode(Bytecodes::_fast_fgetfield, T3, T2);
  2853   __ b(Done);
  2854   __ delayed()->daddi(SP, SP, - wordSize);
  2856   __ bind(notFloat);
  2857   __ move(AT, dtos);
  2858   __ bne(flags, AT, notDouble);
  2859   __ delayed()->nop();
  2861   // dtos
  2862   __ ldc1(FSF, index, 0 * wordSize);
  2863   __ sdc1(FSF, SP, - 2 * wordSize);
  2864   __ sd(R0, SP, - 1 * wordSize);
  2866   if (!is_static) {
  2867     patch_bytecode(Bytecodes::_fast_dgetfield, T3, T2);
  2869   __ b(Done);
  2870   __ delayed()->daddi(SP, SP, - 2 * wordSize);
  2872   __ bind(notDouble);
  2874   __ stop("Bad state");
  2876   __ bind(Done);
  2880 void TemplateTable::getfield(int byte_no) {
  2881   getfield_or_static(byte_no, false);
  2884 void TemplateTable::getstatic(int byte_no) {
  2885   getfield_or_static(byte_no, true);
  2888 // The registers cache and index expected to be set before call.
  2889 // The function may destroy various registers, just not the cache and index registers.
  2890 void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is_static) {
  2891   transition(vtos, vtos);
  2893   ByteSize cp_base_offset = ConstantPoolCache::base_offset();
  2895   if (JvmtiExport::can_post_field_modification()) {
  2896     // Check to see if a field modification watch has been set before
  2897     // we take the time to call into the VM.
  2898     Label L1;
  2899     //kill AT, T1, T2, T3, T9
  2900     Register tmp1 = T2;
  2901     Register tmp2 = T1;
  2902     Register tmp3 = T3;
  2903     Register tmp4 = T9;
  2904     assert_different_registers(cache, index, tmp4);
  2906     __ li(AT, JvmtiExport::get_field_modification_count_addr());
  2907     __ lw(AT, AT, 0);
  2908     __ beq(AT, R0, L1);
  2909     __ delayed()->nop();
  2911     __ get_cache_and_index_at_bcp(tmp2, tmp4, 1);
  2913     if (is_static) {
  2914       __ move(tmp1, R0);
  2915     } else {
  2916       // Life is harder. The stack holds the value on top, followed by
  2917       // the object.  We don't know the size of the value, though; it
  2918       // could be one or two words depending on its type. As a result,
  2919       // we must find the type to determine where the object is.
  2920       Label two_word, valsize_known;
  2921       __ dsll(AT, tmp4, Address::times_8);
  2922       __ dadd(AT, tmp2, AT);
  2923       __ ld(tmp3, AT, in_bytes(cp_base_offset +
  2924                                ConstantPoolCacheEntry::flags_offset()));
  2925       __ shr(tmp3, ConstantPoolCacheEntry::tos_state_shift);
  2927       // Make sure we don't need to mask ecx for tos_state_shift
  2928       // after the above shift
  2929       ConstantPoolCacheEntry::verify_tos_state_shift();
  2930       __ move(tmp1, SP);
  2931       __ move(AT, ltos);
  2932       __ beq(tmp3, AT, two_word);
  2933       __ delayed()->nop();
  2934       __ move(AT, dtos);
  2935       __ beq(tmp3, AT, two_word);
  2936       __ delayed()->nop();
  2937       __ b(valsize_known);
  2938       __ delayed()->daddi(tmp1, tmp1, Interpreter::expr_offset_in_bytes(1) );
  2940       __ bind(two_word);
  2941       __ daddi(tmp1, tmp1, Interpreter::expr_offset_in_bytes(2));
  2943       __ bind(valsize_known);
  2944       // setup object pointer
  2945       __ ld(tmp1, tmp1, 0*wordSize);
  2947     // cache entry pointer
  2948     __ daddi(tmp2, tmp2, in_bytes(cp_base_offset));
  2949     __ shl(tmp4, LogBytesPerWord);
  2950     __ daddu(tmp2, tmp2, tmp4);
  2951     // object (tos)
  2952     __ move(tmp3, SP);
  2953     // tmp1: object pointer set up above (NULL if static)
  2954     // tmp2: cache entry pointer
  2955     // tmp3: jvalue object on the stack
  2956     __ call_VM(NOREG,
  2957                CAST_FROM_FN_PTR(address,
  2958                                 InterpreterRuntime::post_field_modification),
  2959                tmp1, tmp2, tmp3);
  2960     __ get_cache_and_index_at_bcp(cache, index, 1);
  2961     __ bind(L1);
  2965 // used registers : T0, T1, T2, T3, T8
  2966 // T1 : flags
  2967 // T2 : off
  2968 // T3 : obj
  2969 // T8 : volatile bit
  2970 // see ConstantPoolCacheEntry::set_field for more info
  2971 void TemplateTable::putfield_or_static(int byte_no, bool is_static) {
  2972   transition(vtos, vtos);
  2974   const Register cache = T3;
  2975   const Register index = T0;
  2976   const Register obj   = T3;
  2977   const Register off   = T2;
  2978   const Register flags = T1;
  2979   const Register bc    = T3;
  2981   resolve_cache_and_index(byte_no, cache, index, sizeof(u2));
  2982   jvmti_post_field_mod(cache, index, is_static);
  2983   load_field_cp_cache_entry(obj, cache, index, off, flags, is_static);
  2985   Label notVolatile, Done;
  2986   __ move(AT, 1<<ConstantPoolCacheEntry::is_volatile_shift);
  2987   __ andr(T8, flags, AT);
  2989   Label notByte, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble;
  2991   assert(btos == 0, "change code, btos != 0");
  2992   // btos
  2993   __ dsrl(flags, flags, ConstantPoolCacheEntry::tos_state_shift);
  2994   __ andi(flags, flags, ConstantPoolCacheEntry::tos_state_mask);
  2995   __ bne(flags, R0, notByte);
  2996   __ delayed()->nop();
  2998   __ pop(btos);
  2999   if (!is_static) {
  3000     pop_and_check_object(obj);
  3002   __ dadd(AT, obj, off);
  3003   __ sb(FSR, AT, 0);
  3005   if (!is_static) {
  3006     patch_bytecode(Bytecodes::_fast_bputfield, bc, off, true, byte_no);
  3008   __ b(Done);
  3009   __ delayed()->nop();
  3011   __ bind(notByte);
  3012   // itos
  3013   __ move(AT, itos);
  3014   __ bne(flags, AT, notInt);
  3015   __ delayed()->nop();
  3017   __ pop(itos);
  3018   if (!is_static) {
  3019     pop_and_check_object(obj);
  3021   __ dadd(AT, obj, off);
  3022   __ sw(FSR, AT, 0);
  3024   if (!is_static) {
  3025     patch_bytecode(Bytecodes::_fast_iputfield, bc, off, true, byte_no);
  3027   __ b(Done);
  3028   __ delayed()->nop();
  3029   __ bind(notInt);
  3030   // atos
  3031   __ move(AT, atos);
  3032   __ bne(flags, AT, notObj);
  3033   __ delayed()->nop();
  3035   __ pop(atos);
  3036   if (!is_static) {
  3037     pop_and_check_object(obj);
  3040   __ dadd(AT, obj, off);
  3041   __ store_heap_oop(Address(AT, 0), FSR);
  3042   __ store_check(obj);
  3044   if (!is_static) {
  3045     patch_bytecode(Bytecodes::_fast_aputfield, bc, off, true, byte_no);
  3047   __ b(Done);
  3048   __ delayed()->nop();
  3049   __ bind(notObj);
  3050   // ctos
  3051   __ move(AT, ctos);
  3052   __ bne(flags, AT, notChar);
  3053   __ delayed()->nop();
  3055   __ pop(ctos);
  3056   if (!is_static) {
  3057     pop_and_check_object(obj);
  3059   __ dadd(AT, obj, off);
  3060   __ sh(FSR, AT, 0);
  3061   if (!is_static) {
  3062     patch_bytecode(Bytecodes::_fast_cputfield, bc, off, true, byte_no);
  3064   __ b(Done);
  3065   __ delayed()->nop();
  3066   __ bind(notChar);
  3067   // stos
  3068   __ move(AT, stos);
  3069   __ bne(flags, AT, notShort);
  3070   __ delayed()->nop();
  3072   __ pop(stos);
  3073   if (!is_static) {
  3074     pop_and_check_object(obj);
  3076   __ dadd(AT, obj, off);
  3077   __ sh(FSR, AT, 0);
  3078   if (!is_static) {
  3079     patch_bytecode(Bytecodes::_fast_sputfield, bc, off, true, byte_no);
  3081   __ b(Done);
  3082   __ delayed()->nop();
  3083   __ bind(notShort);
  3084   // ltos
  3085   __ move(AT, ltos);
  3086   __ bne(flags, AT, notLong);
  3087   __ delayed()->nop();
  3089   // FIXME: there is no simple method to load/store 64-bit data in a atomic operation
  3090   // we just ignore the volatile flag.
  3091   //Label notVolatileLong;
  3092   //__ beq(T1, R0, notVolatileLong);
  3093   //__ delayed()->nop();
  3095   //addent = 2 * wordSize;
  3096   // no need
  3097   //__ lw(FSR, SP, 0);
  3098   //__ lw(SSR, SP, 1 * wordSize);
  3099   //if (!is_static) {
  3100   //  __ lw(T3, SP, addent);
  3101   //  addent += 1 * wordSize;
  3102   //  __ verify_oop(T3);
  3103   //}
  3105   //__ daddu(AT, T3, T2);
  3107   // Replace with real volatile test
  3108   // NOTE : we assume that sdc1&ldc1 operate in 32-bit, this is true for Godson2 even in 64-bit kernel
  3109   // last modified by yjl 7/12/2005
  3110   //__ ldc1(FSF, SP, 0);
  3111   //__ sdc1(FSF, AT, 0);
  3112   //volatile_barrier();
  3114   // Don't rewrite volatile version
  3115   //__ b(notVolatile);
  3116   //__ delayed()->addiu(SP, SP, addent);
  3118   //__ bind(notVolatileLong);
  3120   //__ pop(ltos);  // overwrites edx
  3121   //  __ lw(FSR, SP, 0 * wordSize);
  3122   //  __ lw(SSR, SP, 1 * wordSize);
  3123   //  __ daddi(SP, SP, 2*wordSize);
  3124   __ pop(ltos);
  3125   if (!is_static) {
  3126     pop_and_check_object(obj);
  3128   __ dadd(AT, obj, off);
  3129   __ sd(FSR, AT, 0);
  3130   if (!is_static) {
  3131     patch_bytecode(Bytecodes::_fast_lputfield, bc, off, true, byte_no);
  3133   __ b(notVolatile);
  3134   __ delayed()->nop();
  3136   __ bind(notLong);
  3137   // ftos
  3138   __ move(AT, ftos);
  3139   __ bne(flags, AT, notFloat);
  3140   __ delayed()->nop();
  3142   __ pop(ftos);
  3143   if (!is_static) {
  3144     pop_and_check_object(obj);
  3146   __ dadd(AT, obj, off);
  3147   __ swc1(FSF, AT, 0);
  3148   if (!is_static) {
  3149     patch_bytecode(Bytecodes::_fast_fputfield, bc, off, true, byte_no);
  3151   __ b(Done);
  3152   __ delayed()->nop();
  3153   __ bind(notFloat);
  3154   // dtos
  3155   __ move(AT, dtos);
  3156   __ bne(flags, AT, notDouble);
  3157   __ delayed()->nop();
  3159   __ pop(dtos);
  3160   if (!is_static) {
  3161     pop_and_check_object(obj);
  3163   __ dadd(AT, obj, off);
  3164   __ sdc1(FSF, AT, 0);
  3165   if (!is_static) {
  3166     patch_bytecode(Bytecodes::_fast_dputfield, bc, off, true, byte_no);
  3169 #ifdef ASSERT
  3170   __ b(Done);
  3171   __ delayed()->nop();
  3173   __ bind(notDouble);
  3174   __ stop("Bad state");
  3175 #endif
  3177   __ bind(Done);
  3179   // Check for volatile store
  3180   __ beq(T8, R0, notVolatile);
  3181   __ delayed()->nop();
  3182   volatile_barrier( );
  3183   __ bind(notVolatile);
  3186 void TemplateTable::putfield(int byte_no) {
  3187   putfield_or_static(byte_no, false);
  3190 void TemplateTable::putstatic(int byte_no) {
  3191   putfield_or_static(byte_no, true);
  3194 // used registers : T1, T2, T3
  3195 // T1 : cp_entry
  3196 // T2 : obj
  3197 // T3 : value pointer
  3198 void TemplateTable::jvmti_post_fast_field_mod() {
  3199   if (JvmtiExport::can_post_field_modification()) {
  3200     // Check to see if a field modification watch has been set before
  3201     // we take the time to call into the VM.
  3202     Label L2;
  3203     //kill AT, T1, T2, T3, T9
  3204     Register tmp1 = T2;
  3205     Register tmp2 = T1;
  3206     Register tmp3 = T3;
  3207     Register tmp4 = T9;
  3208     __ li(AT, JvmtiExport::get_field_modification_count_addr());
  3209     __ lw(tmp3, AT, 0);
  3210     __ beq(tmp3, R0, L2);
  3211     __ delayed()->nop();
  3212     __ pop_ptr(tmp1);
  3213     __ verify_oop(tmp1);
  3214     __ push_ptr(tmp1);
  3215     switch (bytecode()) {          // load values into the jvalue object
  3216     case Bytecodes::_fast_aputfield: __ push_ptr(FSR); break;
  3217     case Bytecodes::_fast_bputfield: // fall through
  3218     case Bytecodes::_fast_sputfield: // fall through
  3219     case Bytecodes::_fast_cputfield: // fall through
  3220     case Bytecodes::_fast_iputfield: __ push_i(FSR); break;
  3221     case Bytecodes::_fast_dputfield: __ push_d(FSF); break;
  3222     case Bytecodes::_fast_fputfield: __ push_f(); break;
  3223     case Bytecodes::_fast_lputfield: __ push_l(FSR); break;
  3224       default:  ShouldNotReachHere();
  3226     __ move(tmp3, SP);
  3227     // access constant pool cache entry
  3228     __ get_cache_entry_pointer_at_bcp(tmp2, FSR, 1);
  3229     __ verify_oop(tmp1);
  3230     // tmp1: object pointer copied above
  3231     // tmp2: cache entry pointer
  3232     // tmp3: jvalue object on the stack
  3233     __ call_VM(NOREG,
  3234                CAST_FROM_FN_PTR(address,
  3235                                 InterpreterRuntime::post_field_modification),
  3236                tmp1, tmp2, tmp3);
  3238     switch (bytecode()) {             // restore tos values
  3239     case Bytecodes::_fast_aputfield: __ pop_ptr(FSR); break;
  3240     case Bytecodes::_fast_bputfield: // fall through
  3241     case Bytecodes::_fast_sputfield: // fall through
  3242     case Bytecodes::_fast_cputfield: // fall through
  3243     case Bytecodes::_fast_iputfield: __ pop_i(FSR); break;
  3244     case Bytecodes::_fast_dputfield: __ pop_d(); break;
  3245     case Bytecodes::_fast_fputfield: __ pop_f(); break;
  3246     case Bytecodes::_fast_lputfield: __ pop_l(FSR); break;
  3248     __ bind(L2);
  3252 // used registers : T2, T3, T1
  3253 // T2 : index & off & field address
  3254 // T3 : cache & obj
  3255 // T1 : flags
  3256 void TemplateTable::fast_storefield(TosState state) {
  3257   transition(state, vtos);
  3259   ByteSize base = ConstantPoolCache::base_offset();
  3261   jvmti_post_fast_field_mod();
  3263   // access constant pool cache
  3264   __ get_cache_and_index_at_bcp(T3, T2, 1);
  3266   // test for volatile with edx but edx is tos register for lputfield.
  3267   __ dsll(AT, T2, Address::times_8);
  3268   __ dadd(AT, T3, AT);
  3269   __ ld(T1, AT, in_bytes(base + ConstantPoolCacheEntry::flags_offset()));
  3271   // replace index with field offset from cache entry
  3272   __ ld(T2, AT, in_bytes(base + ConstantPoolCacheEntry::f2_offset()));
  3274   // Doug Lea believes this is not needed with current Sparcs (TSO) and Intel (PSO).
  3275   // volatile_barrier( );
  3277   Label notVolatile, Done;
  3278   // Check for volatile store
  3279   __ move(AT, 1<<ConstantPoolCacheEntry::is_volatile_shift);
  3280   __ andr(AT, T1, AT);
  3281   __ beq(AT, R0, notVolatile);
  3282   __ delayed()->nop();
  3285   // Get object from stack
  3286   pop_and_check_object(T3);
  3288   // field address
  3289   __ dadd(T2, T3, T2);
  3291   // access field
  3292   switch (bytecode()) {
  3293     case Bytecodes::_fast_bputfield:
  3294       __ sb(FSR, T2, 0);
  3295       break;
  3296     case Bytecodes::_fast_sputfield: // fall through
  3297     case Bytecodes::_fast_cputfield:
  3298       __ sh(FSR, T2, 0);
  3299       break;
  3300     case Bytecodes::_fast_iputfield:
  3301       __ sw(FSR, T2, 0);
  3302       break;
  3303     case Bytecodes::_fast_lputfield:
  3304       __ sd(FSR, T2, 0 * wordSize);
  3305       break;
  3306     case Bytecodes::_fast_fputfield:
  3307       __ swc1(FSF, T2, 0);
  3308       break;
  3309     case Bytecodes::_fast_dputfield:
  3310       __ sdc1(FSF, T2, 0 * wordSize);
  3311       break;
  3312     case Bytecodes::_fast_aputfield:
  3313       __ store_heap_oop(Address(T2, 0), FSR);
  3314       __ store_check(T3);
  3315       break;
  3316     default:
  3317       ShouldNotReachHere();
  3320   Label done;
  3321   volatile_barrier( );
  3322   __ b(done);
  3323   __ delayed()->nop();
  3325   // Same code as above, but don't need edx to test for volatile.
  3326   __ bind(notVolatile);
  3327   pop_and_check_object(T3);
  3328   //get the field address
  3329   __ dadd(T2, T3, T2);
  3331   // access field
  3332   switch (bytecode()) {
  3333     case Bytecodes::_fast_bputfield:
  3334       __ sb(FSR, T2, 0);
  3335       break;
  3336     case Bytecodes::_fast_sputfield: // fall through
  3337     case Bytecodes::_fast_cputfield:
  3338       __ sh(FSR, T2, 0);
  3339       break;
  3340     case Bytecodes::_fast_iputfield:
  3341       __ sw(FSR, T2, 0);
  3342       break;
  3343     case Bytecodes::_fast_lputfield:
  3344       __ sd(FSR, T2, 0 * wordSize);
  3345       break;
  3346     case Bytecodes::_fast_fputfield:
  3347       __ swc1(FSF, T2, 0);
  3348       break;
  3349     case Bytecodes::_fast_dputfield:
  3350       __ sdc1(FSF, T2, 0 * wordSize);
  3351       break;
  3352     case Bytecodes::_fast_aputfield:
  3353       //add for compressedoops
  3354       __ store_heap_oop(Address(T2, 0), FSR);
  3355       __ store_check(T3);
  3356       break;
  3357     default:
  3358       ShouldNotReachHere();
  3360   __ bind(done);
  3363 // used registers : T2, T3, T1
  3364 // T3 : cp_entry & cache
  3365 // T2 : index & offset
  3366 void TemplateTable::fast_accessfield(TosState state) {
  3367   transition(atos, state);
  3369   // do the JVMTI work here to avoid disturbing the register state below
  3370   if (JvmtiExport::can_post_field_access()) {
  3371     // Check to see if a field access watch has been set before we take
  3372     // the time to call into the VM.
  3373     Label L1;
  3374     __ li(AT, (intptr_t)JvmtiExport::get_field_access_count_addr());
  3375     __ lw(T3, AT, 0);
  3376     __ beq(T3, R0, L1);
  3377     __ delayed()->nop();
  3378     // access constant pool cache entry
  3379     __ get_cache_entry_pointer_at_bcp(T3, T1, 1);
  3380     __ move(TSR, FSR);
  3381     __ verify_oop(FSR);
  3382     // FSR: object pointer copied above
  3383     // T3: cache entry pointer
  3384     __ call_VM(NOREG,
  3385                CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_access),
  3386                FSR, T3);
  3387     __ move(FSR, TSR);
  3388     __ bind(L1);
  3391   // access constant pool cache
  3392   __ get_cache_and_index_at_bcp(T3, T2, 1);
  3393   // replace index with field offset from cache entry
  3394   __ dsll(AT, T2, Address::times_8);
  3395   __ dadd(AT, T3, AT);
  3396   __ ld(T2, AT, in_bytes(ConstantPoolCache::base_offset()
  3397                          + ConstantPoolCacheEntry::f2_offset()));
  3399   // eax: object
  3400   __ verify_oop(FSR);
  3401   __ null_check(FSR);
  3402   // field addresses
  3403   __ dadd(FSR, FSR, T2);
  3405   // access field
  3406   switch (bytecode()) {
  3407     case Bytecodes::_fast_bgetfield:
  3408       __ lb(FSR, FSR, 0);
  3409       break;
  3410     case Bytecodes::_fast_sgetfield:
  3411       __ lh(FSR, FSR, 0);
  3412       break;
  3413     case Bytecodes::_fast_cgetfield:
  3414       __ lhu(FSR, FSR, 0);
  3415       break;
  3416     case Bytecodes::_fast_igetfield:
  3417       __ lw(FSR, FSR, 0);
  3418       break;
  3419     case Bytecodes::_fast_lgetfield:
  3420       __ stop("should not be rewritten");
  3421       break;
  3422     case Bytecodes::_fast_fgetfield:
  3423       __ lwc1(FSF, FSR, 0);
  3424       break;
  3425     case Bytecodes::_fast_dgetfield:
  3426       __ ldc1(FSF, FSR, 0);
  3427       break;
  3428     case Bytecodes::_fast_agetfield:
  3429       //add for compressedoops
  3430       __ load_heap_oop(FSR, Address(FSR, 0));
  3431       __ verify_oop(FSR);
  3432       break;
  3433     default:
  3434       ShouldNotReachHere();
  3437   // Doug Lea believes this is not needed with current Sparcs(TSO) and Intel(PSO)
  3438   // volatile_barrier( );
  3441 // generator for _fast_iaccess_0, _fast_aaccess_0, _fast_faccess_0
  3442 // used registers : T1, T2, T3, T1
  3443 // T1 : obj & field address
  3444 // T2 : off
  3445 // T3 : cache
  3446 // T1 : index
  3447 void TemplateTable::fast_xaccess(TosState state) {
  3448   transition(vtos, state);
  3450   // get receiver
  3451   __ ld(T1, aaddress(0));
  3452   // access constant pool cache
  3453   __ get_cache_and_index_at_bcp(T3, T2, 2);
  3454   __ dsll(AT, T2, Address::times_8);
  3455   __ dadd(AT, T3, AT);
  3456   __ ld(T2, AT, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::f2_offset()));
  3458   // make sure exception is reported in correct bcp range (getfield is
  3459   // next instruction)
  3460   __ daddi(BCP, BCP, 1);
  3461   __ null_check(T1);
  3462   __ dadd(T1, T1, T2);
  3464   if (state == itos) {
  3465     __ lw(FSR, T1, 0);
  3466   } else if (state == atos) {
  3467     __ load_heap_oop(FSR, Address(T1, 0));
  3468     __ verify_oop(FSR);
  3469   } else if (state == ftos) {
  3470     __ lwc1(FSF, T1, 0);
  3471   } else {
  3472     ShouldNotReachHere();
  3474   __ daddi(BCP, BCP, -1);
  3479 //-----------------------------------------------------------------------------
  3480 // Calls
  3482 void TemplateTable::count_calls(Register method, Register temp) {
  3483   // implemented elsewhere
  3484   ShouldNotReachHere();
  3487 // method, index, recv, flags: T1, T2, T3, T1
  3488 // byte_no = 2 for _invokevirtual, 1 else
  3489 // T0 : return address
  3490 // get the method & index of the invoke, and push the return address of
  3491 // the invoke(first word in the frame)
  3492 // this address is where the return code jmp to.
  3493 // NOTE : this method will set T3&T1 as recv&flags
  3494 void TemplateTable::prepare_invoke(int byte_no,
  3495                                    Register method,  // linked method (or i-klass)
  3496                                    Register index,   // itable index, MethodType, etc.
  3497                                    Register recv,    // if caller wants to see it
  3498                                    Register flags    // if caller wants to test it
  3499                                    ) {
  3500   // determine flags
  3501   const Bytecodes::Code code = bytecode();
  3502   const bool is_invokeinterface  = code == Bytecodes::_invokeinterface;
  3503   const bool is_invokedynamic    = code == Bytecodes::_invokedynamic;
  3504   const bool is_invokehandle     = code == Bytecodes::_invokehandle;
  3505   const bool is_invokevirtual    = code == Bytecodes::_invokevirtual;
  3506   const bool is_invokespecial    = code == Bytecodes::_invokespecial;
  3507   const bool load_receiver       = (recv  != noreg);
  3508   const bool save_flags          = (flags != noreg);
  3509   assert(load_receiver == (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic),"");
  3510   assert(save_flags    == (is_invokeinterface || is_invokevirtual), "need flags for vfinal");
  3511   assert(flags == noreg || flags == T1, "error flags reg.");
  3512   assert(recv  == noreg || recv  == T3, "error recv reg.");
  3514   // setup registers & access constant pool cache
  3515   if(recv == noreg) recv  = T3;
  3516   if(flags == noreg) flags  = T1;
  3517   assert_different_registers(method, index, recv, flags);
  3519   // save 'interpreter return address'
  3520   __ save_bcp();
  3522   load_invoke_cp_cache_entry(byte_no, method, index, flags, is_invokevirtual, false, is_invokedynamic);
  3524   if (is_invokedynamic || is_invokehandle) {
  3525    Label L_no_push;
  3526      __ move(AT, (1 << ConstantPoolCacheEntry::has_appendix_shift));
  3527      __ andr(AT, AT, flags);
  3528      __ beq(AT, R0, L_no_push);
  3529      __ delayed()->nop();
  3530      // Push the appendix as a trailing parameter.
  3531      // This must be done before we get the receiver,
  3532      // since the parameter_size includes it.
  3533      Register tmp = SSR;
  3534      __ push(tmp);
  3535      __ move(tmp, index);
  3536      assert(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset == 0, "appendix expected at index+0");
  3537      __ load_resolved_reference_at_index(index, tmp);
  3538      __ pop(tmp);
  3539      __ push(index);  // push appendix (MethodType, CallSite, etc.)
  3540      __ bind(L_no_push);
  3543   // load receiver if needed (after appendix is pushed so parameter size is correct)
  3544   // Note: no return address pushed yet
  3545   if (load_receiver) {
  3546     __ move(AT, ConstantPoolCacheEntry::parameter_size_mask);
  3547     __ andr(recv, flags, AT);
  3548     // 2014/07/31 Fu: Since we won't push RA on stack, no_return_pc_pushed_yet should be 0.
  3549     const int no_return_pc_pushed_yet = 0;  // argument slot correction before we push return address
  3550     const int receiver_is_at_end      = -1;  // back off one slot to get receiver
  3551     Address recv_addr = __ argument_address(recv, no_return_pc_pushed_yet + receiver_is_at_end);
  3552     __ ld(recv, recv_addr);
  3553     __ verify_oop(recv);
  3555   if(save_flags) {
  3556     __ move(BCP, flags);
  3559   // compute return type
  3560   __ dsrl(flags, flags, ConstantPoolCacheEntry::tos_state_shift);
  3561   __ andi(flags, flags, 0xf);
  3563   // Make sure we don't need to mask flags for tos_state_shift after the above shift
  3564   ConstantPoolCacheEntry::verify_tos_state_shift();
  3565   // load return address
  3567     const address table = (address) Interpreter::invoke_return_entry_table_for(code);
  3568     __ li(AT, (long)table);
  3569     __ dsll(flags, flags, LogBytesPerWord);
  3570     __ dadd(AT, AT, flags);
  3571     __ ld(RA, AT, 0);
  3574   if (save_flags) {
  3575     __ move(flags, BCP);
  3576     __ restore_bcp();
  3580 // used registers : T0, T3, T1, T2
  3581 // T3 : recv, this two register using convention is by prepare_invoke
  3582 // T1 : flags, klass
  3583 // Rmethod : method, index must be Rmethod
  3584 void TemplateTable::invokevirtual_helper(Register index,
  3585                                          Register recv,
  3586                                          Register flags) {
  3588   assert_different_registers(index, recv, flags, T2);
  3590   // Test for an invoke of a final method
  3591   Label notFinal;
  3592   __ move(AT, (1 << ConstantPoolCacheEntry::is_vfinal_shift));
  3593   __ andr(AT, flags, AT);
  3594   __ beq(AT, R0, notFinal);
  3595   __ delayed()->nop();
  3597   Register method = index;  // method must be Rmethod
  3598   assert(method == Rmethod, "methodOop must be Rmethod for interpreter calling convention");
  3600   // do the call - the index is actually the method to call
  3601   // the index is indeed methodOop, for this is vfinal,
  3602   // see ConstantPoolCacheEntry::set_method for more info
  3604   __ verify_oop(method);
  3606   // It's final, need a null check here!
  3607   __ null_check(recv);
  3609   // profile this call
  3610   __ profile_final_call(T2);
  3612   // 2014/11/24 Fu
  3613   // T2: tmp, used for mdp
  3614   // method: callee
  3615   // T9: tmp
  3616   // is_virtual: true
  3617   __ profile_arguments_type(T2, method, T9, true);
  3619   __ jump_from_interpreted(method, T2);
  3621   __ bind(notFinal);
  3623   // get receiver klass
  3624   __ null_check(recv, oopDesc::klass_offset_in_bytes());
  3625   __ load_klass(T2, recv);
  3626   __ verify_oop(T2);
  3628   // profile this call
  3629   __ profile_virtual_call(T2, T0, T1);
  3631   // get target methodOop & entry point
  3632   const int base = InstanceKlass::vtable_start_offset() * wordSize;
  3633   assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
  3634   __ dsll(AT, index, Address::times_ptr);
  3635   // T2: receiver
  3636   __ dadd(AT, T2, AT);
  3637   //this is a ualign read
  3638   __ ld(method, AT, base + vtableEntry::method_offset_in_bytes());
  3639   __ profile_arguments_type(T2, method, T9, true);
  3640   __ jump_from_interpreted(method, T2);
  3644 void TemplateTable::invokevirtual(int byte_no) {
  3645   transition(vtos, vtos);
  3646   assert(byte_no == f2_byte, "use this argument");
  3647   prepare_invoke(byte_no, Rmethod, NOREG, T3, T1);
  3648   // now recv & flags in T3, T1
  3649   invokevirtual_helper(Rmethod, T3, T1);
  3652 // T9 : entry
  3653 // Rmethod : method
  3654 void TemplateTable::invokespecial(int byte_no) {
  3655   transition(vtos, vtos);
  3656   assert(byte_no == f1_byte, "use this argument");
  3657   prepare_invoke(byte_no, Rmethod, NOREG, T3);
  3658   // now recv & flags in T3, T1
  3659   __ verify_oop(T3);
  3660   __ null_check(T3);
  3661   __ profile_call(T9);
  3663   // 2014/11/24 Fu
  3664   // T8: tmp, used for mdp
  3665   // Rmethod: callee
  3666   // T9: tmp
  3667   // is_virtual: false
  3668   __ profile_arguments_type(T8, Rmethod, T9, false);
  3670   __ jump_from_interpreted(Rmethod, T9);
  3671   __ move(T0, T3);//aoqi ?
  3674 void TemplateTable::invokestatic(int byte_no) {
  3675   transition(vtos, vtos);
  3676   assert(byte_no == f1_byte, "use this argument");
  3677   prepare_invoke(byte_no, Rmethod, NOREG);
  3678   __ verify_oop(Rmethod);
  3680   __ profile_call(T9);
  3682   // 2014/11/24 Fu
  3683   // T8: tmp, used for mdp
  3684   // Rmethod: callee
  3685   // T9: tmp
  3686   // is_virtual: false
  3687   __ profile_arguments_type(T8, Rmethod, T9, false);
  3689   __ jump_from_interpreted(Rmethod, T9);
  3692 // i have no idea what to do here, now. for future change. FIXME.
  3693 void TemplateTable::fast_invokevfinal(int byte_no) {
  3694   transition(vtos, vtos);
  3695   assert(byte_no == f2_byte, "use this argument");
  3696   __ stop("fast_invokevfinal not used on mips64");
  3699 // used registers : T0, T1, T2, T3, T1, A7
  3700 // T0 : itable, vtable, entry
  3701 // T1 : interface
  3702 // T3 : receiver
  3703 // T1 : flags, klass
  3704 // Rmethod : index, method, this is required by interpreter_entry
  3705 void TemplateTable::invokeinterface(int byte_no) {
  3706   transition(vtos, vtos);
  3707   //this method will use T1-T4 and T0
  3708   assert(byte_no == f1_byte, "use this argument");
  3709   prepare_invoke(byte_no, T2, Rmethod, T3, T1);
  3710   // T2: Interface
  3711   // Rmethod: index
  3712   // T3: receiver
  3713   // T1: flags
  3715   // Special case of invokeinterface called for virtual method of
  3716   // java.lang.Object.  See cpCacheOop.cpp for details.
  3717   // This code isn't produced by javac, but could be produced by
  3718   // another compliant java compiler.
  3719   Label notMethod;
  3720   __ move(AT, (1 << ConstantPoolCacheEntry::is_forced_virtual_shift));
  3721   __ andr(AT, T1, AT);
  3722   __ beq(AT, R0, notMethod);
  3723   __ delayed()->nop();
  3725   invokevirtual_helper(Rmethod, T3, T1);
  3726   __ bind(notMethod);
  3727   // Get receiver klass into T1 - also a null check
  3728   //add for compressedoops
  3729   __ load_klass(T1, T3);
  3730   __ verify_oop(T1);
  3732   // profile this call
  3733   __ profile_virtual_call(T1, T0, FSR);
  3735   // Compute start of first itableOffsetEntry (which is at the end of the vtable)
  3736   // TODO: x86 add a new method lookup_interface_method  // LEE
  3737   const int base = InstanceKlass::vtable_start_offset() * wordSize;
  3738   assert(vtableEntry::size() * wordSize == 8, "adjust the scaling in the code below");
  3739   __ lw(AT, T1, InstanceKlass::vtable_length_offset() * wordSize);
  3740   __ dsll(AT, AT, Address::times_8);
  3741   __ dadd(T0, T1, AT);
  3742   __ daddi(T0, T0, base);
  3743   if (HeapWordsPerLong > 1) {
  3744     // Round up to align_object_offset boundary
  3745     __ round_to(T0, BytesPerLong);
  3747   // now T0 is the begin of the itable
  3749   Label entry, search, interface_ok;
  3751   ///__ jmp(entry);
  3752   __ b(entry);
  3753   __ delayed()->nop();
  3755   __ bind(search);
  3756   __ increment(T0, itableOffsetEntry::size() * wordSize);
  3758   __ bind(entry);
  3760   // Check that the entry is non-null.  A null entry means that the receiver
  3761   // class doesn't implement the interface, and wasn't the same as the
  3762   // receiver class checked when the interface was resolved.
  3763   __ ld(AT, T0, itableOffsetEntry::interface_offset_in_bytes());
  3764   __ bne(AT, R0, interface_ok);
  3765   __ delayed()->nop();
  3766   // throw exception
  3767   // the call_VM checks for exception, so we should never return here.
  3769   //__ pop();//FIXME here,
  3770   // pop return address (pushed by prepare_invoke).
  3771   // no need now, we just save the value in RA now
  3773   __ call_VM(NOREG, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_IncompatibleClassChangeError));
  3774   __ should_not_reach_here();
  3776   __ bind(interface_ok);
  3777   //NOTICE here, no pop as x86 do
  3778   __ bne(AT, T2, search);
  3779   __ delayed()->nop();
  3781   // now we get vtable of the interface
  3782   __ ld(T0, T0, itableOffsetEntry::offset_offset_in_bytes());
  3783   __ daddu(T0, T1, T0);
  3784   assert(itableMethodEntry::size() * wordSize == 8, "adjust the scaling in the code below");
  3785   __ dsll(AT, Rmethod, Address::times_8);
  3786   __ daddu(AT, T0, AT);
  3787   // now we get the method
  3788   __ ld(Rmethod, AT, 0);
  3789   // Rnext: methodOop to call
  3790   // T3: receiver
  3791   // Check for abstract method error
  3792   // Note: This should be done more efficiently via a throw_abstract_method_error
  3793   //       interpreter entry point and a conditional jump to it in case of a null
  3794   //       method.
  3796     Label L;
  3797     __ bne(Rmethod, R0, L);
  3798     __ delayed()->nop();
  3800     // throw exception
  3801     // note: must restore interpreter registers to canonical
  3802     //       state for exception handling to work correctly!
  3803     ///__ popl(ebx);          // pop return address (pushed by prepare_invoke)
  3804     //__ restore_bcp();      // esi must be correct for exception handler
  3805     //(was destroyed)
  3806     //__ restore_locals();   // make sure locals pointer
  3807     //is correct as well (was destroyed)
  3808     ///__ call_VM(noreg, CAST_FROM_FN_PTR(address,
  3809     //InterpreterRuntime::throw_AbstractMethodError));
  3810     __ call_VM(NOREG, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
  3811     // the call_VM checks for exception, so we should never return here.
  3812     __ should_not_reach_here();
  3813     __ bind(L);
  3816   // 2014/11/24 Fu
  3817   // T8: tmp, used for mdp
  3818   // Rmethod: callee
  3819   // T9: tmp
  3820   // is_virtual: true
  3821   __ profile_arguments_type(T8, Rmethod, T9, true);
  3823   __ jump_from_interpreted(Rmethod, T9);
  3827 void TemplateTable::invokehandle(int byte_no) {
  3828   transition(vtos, vtos);
  3829   assert(byte_no == f1_byte, "use this argument");
  3830   const Register T2_method = Rmethod;
  3831   const Register FSR_mtype  = FSR;
  3832   const Register T3_recv   = T3;
  3834   if (!EnableInvokeDynamic) {
  3835      // rewriter does not generate this bytecode
  3836      __ should_not_reach_here();
  3837      return;
  3840    prepare_invoke(byte_no, T2_method, FSR_mtype, T3_recv);
  3841    //??__ verify_method_ptr(T2_method);
  3842    __ verify_oop(T3_recv);
  3843    __ null_check(T3_recv);
  3845    // rax: MethodType object (from cpool->resolved_references[f1], if necessary)
  3846    // rbx: MH.invokeExact_MT method (from f2)
  3848    // Note:  rax_mtype is already pushed (if necessary) by prepare_invoke
  3850    // FIXME: profile the LambdaForm also
  3851    __ profile_final_call(T9);
  3853    // 2014/11/24 Fu
  3854    // T8: tmp, used for mdp
  3855    // T2_method: callee
  3856    // T9: tmp
  3857    // is_virtual: true
  3858    __ profile_arguments_type(T8, T2_method, T9, true);
  3860   __ jump_from_interpreted(T2_method, T9);
  3863  void TemplateTable::invokedynamic(int byte_no) {
  3864    transition(vtos, vtos);
  3865    assert(byte_no == f1_byte, "use this argument");
  3867    if (!EnableInvokeDynamic) {
  3868      // We should not encounter this bytecode if !EnableInvokeDynamic.
  3869      // The verifier will stop it.  However, if we get past the verifier,
  3870      // this will stop the thread in a reasonable way, without crashing the JVM.
  3871      __ call_VM(noreg, CAST_FROM_FN_PTR(address,
  3872                       InterpreterRuntime::throw_IncompatibleClassChangeError));
  3873      // the call_VM checks for exception, so we should never return here.
  3874      __ should_not_reach_here();
  3875      return;
  3878    //const Register Rmethod   = T2;
  3879    const Register T2_callsite = T2;
  3881    prepare_invoke(byte_no, Rmethod, T2_callsite);
  3883    // rax: CallSite object (from cpool->resolved_references[f1])
  3884    // rbx: MH.linkToCallSite method (from f2)
  3886    // Note:  rax_callsite is already pushed by prepare_invoke
  3887    // %%% should make a type profile for any invokedynamic that takes a ref argument
  3888    // profile this call
  3889    __ profile_call(T9);
  3891    // 2014/11/24 Fu
  3892    // T8: tmp, used for mdp
  3893    // Rmethod: callee
  3894    // T9: tmp
  3895    // is_virtual: false
  3896    __ profile_arguments_type(T8, Rmethod, T9, false);
  3898    __ verify_oop(T2_callsite);
  3900    __ jump_from_interpreted(Rmethod, T9);
  3903 //-----------------------------------------------------------------------------
  3904 // Allocation
  3905 // T1 : tags & buffer end & thread
  3906 // T2 : object end
  3907 // T3 : klass
  3908 // T1 : object size
  3909 // A1 : cpool
  3910 // A2 : cp index
  3911 // return object in FSR
  3912 void TemplateTable::_new() {
  3913   transition(vtos, atos);
  3914   __ get_unsigned_2_byte_index_at_bcp(A2, 1);
  3916   Label slow_case;
  3917   Label done;
  3918   Label initialize_header;
  3919   Label initialize_object; // including clearing the fields
  3920   Label allocate_shared;
  3922   // get InstanceKlass in T3
  3923   __ get_cpool_and_tags(A1, T1);
  3925   __ dsll(AT, A2, Address::times_8);
  3926   if (UseLoongsonISA && Assembler::is_simm(sizeof(ConstantPool), 8)) {
  3927     __ gsldx(T3, A1, AT, sizeof(ConstantPool));
  3928   } else {
  3929     __ dadd(AT, A1, AT);
  3930     __ ld(T3, AT, sizeof(ConstantPool));
  3933   // make sure the class we're about to instantiate has been resolved.
  3934   // Note: slow_case does a pop of stack, which is why we loaded class/pushed above
  3935   const int tags_offset = Array<u1>::base_offset_in_bytes();
  3936   if (UseLoongsonISA && Assembler::is_simm(tags_offset, 8)) {
  3937     __ gslbx(AT, T1, A2, tags_offset);
  3938   } else {
  3939     __ dadd(T1, T1, A2);
  3940     __ lb(AT, T1, tags_offset);
  3942   __ daddiu(AT, AT, - (int)JVM_CONSTANT_Class);
  3943   __ bne(AT, R0, slow_case);
  3944   //__ delayed()->nop();
  3947   // make sure klass is initialized & doesn't have finalizer
  3948   // make sure klass is fully initialized
  3949   __ lhu(T1, T3, in_bytes(InstanceKlass::init_state_offset()));
  3950   __ daddiu(AT, T1, - (int)InstanceKlass::fully_initialized);
  3951   __ bne(AT, R0, slow_case);
  3952   //__ delayed()->nop();
  3954   // has_finalizer
  3955   __ lw(T0, T3, in_bytes(Klass::layout_helper_offset()) );
  3956   __ andi(AT, T0, Klass::_lh_instance_slow_path_bit);
  3957   __ bne(AT, R0, slow_case);
  3958   //__ delayed()->nop();
  3960   // Allocate the instance
  3961   // 1) Try to allocate in the TLAB
  3962   // 2) if fail and the object is large allocate in the shared Eden
  3963   // 3) if the above fails (or is not applicable), go to a slow case
  3964   // (creates a new TLAB, etc.)
  3966   const bool allow_shared_alloc =
  3967     Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode;
  3969   if (UseTLAB) {
  3970 #ifndef OPT_THREAD
  3971     const Register thread = T8;
  3972     __ get_thread(thread);
  3973 #else
  3974     const Register thread = TREG;
  3975 #endif
  3976     // get tlab_top
  3977     __ ld(FSR, thread, in_bytes(JavaThread::tlab_top_offset()));
  3978     // get tlab_end
  3979     __ ld(AT, thread, in_bytes(JavaThread::tlab_end_offset()));
  3980     __ dadd(T2, FSR, T0);
  3981     __ slt(AT, AT, T2);
  3982     __ bne(AT, R0, allow_shared_alloc ? allocate_shared : slow_case);
  3983     __ delayed()->nop();
  3984     __ sd(T2, thread, in_bytes(JavaThread::tlab_top_offset()));
  3986     if (ZeroTLAB) {
  3987       // the fields have been already cleared
  3988       __ beq(R0, R0, initialize_header);
  3989     } else {
  3990       // initialize both the header and fields
  3991       __ beq(R0, R0, initialize_object);
  3993     __ delayed()->nop();
  3996   // Allocation in the shared Eden , if allowed
  3997   // T0 : instance size in words
  3998   if(allow_shared_alloc){
  3999     __ bind(allocate_shared);
  4001     Label retry;
  4002     Address heap_top(T1);
  4003     __ set64(T1, (long)Universe::heap()->top_addr());
  4004     __ ld(FSR, heap_top);
  4006     __ bind(retry);
  4007     __ set64(AT, (long)Universe::heap()->end_addr());
  4008     __ ld(AT, AT, 0);
  4009     __ dadd(T2, FSR, T0);
  4010     __ slt(AT, AT, T2);
  4011     __ bne(AT, R0, slow_case);
  4012     __ delayed()->nop();
  4014     // Compare FSR with the top addr, and if still equal, store the new
  4015     // top addr in ebx at the address of the top addr pointer. Sets ZF if was
  4016     // equal, and clears it otherwise. Use lock prefix for atomicity on MPs.
  4017     //
  4018     // FSR: object begin
  4019     // T2: object end
  4020     // T0: instance size in words
  4022     // if someone beat us on the allocation, try again, otherwise continue
  4023     __ cmpxchg(T2, heap_top, FSR);
  4024     __ beq(AT, R0, retry);
  4025     __ delayed()->nop();
  4028   if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
  4029     // The object is initialized before the header.  If the object size is
  4030     // zero, go directly to the header initialization.
  4031     __ bind(initialize_object);
  4032     __ set64(AT, - sizeof(oopDesc));
  4033     __ daddu(T0, T0, AT);
  4034     __ beq(T0, R0, initialize_header);
  4035     __ delayed()->nop();
  4037     // initialize remaining object fields: T0 is a multiple of 2
  4039       Label loop;
  4040       __ dadd(T1, FSR, T0);
  4041       __ daddi(T1, T1, -oopSize);
  4043       __ bind(loop);
  4044       __ sd(R0, T1, sizeof(oopDesc) + 0 * oopSize);
  4045       __ bne(T1, FSR, loop); //dont clear header
  4046       __ delayed()->daddi(T1, T1, -oopSize);
  4049     //klass in T3,
  4050     // initialize object header only.
  4051     __ bind(initialize_header);
  4052     if (UseBiasedLocking) {
  4053       __ ld(AT, T3, in_bytes(Klass::prototype_header_offset()));
  4054       __ sd(AT, FSR, oopDesc::mark_offset_in_bytes ());
  4055     } else {
  4056       __ set64(AT, (long)markOopDesc::prototype());
  4057       __ sd(AT, FSR, oopDesc::mark_offset_in_bytes());
  4060     __ store_klass_gap(FSR, R0);
  4061     __ store_klass(FSR, T3);
  4064       SkipIfEqual skip_if(_masm, &DTraceAllocProbes, 0);
  4065       // Trigger dtrace event for fastpath
  4066       __ push(atos);
  4067       __ call_VM_leaf(
  4068            CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), FSR);
  4069       __ pop(atos);
  4072     __ b(done);
  4073     __ delayed()->nop();
  4076   // slow case
  4077   __ bind(slow_case);
  4078   call_VM(FSR, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), A1, A2);
  4080   // continue
  4081   __ bind(done);
  4082   __ sync();
  4085 void TemplateTable::newarray() {
  4086   transition(itos, atos);
  4087   __ lbu(A1, at_bcp(1));
  4088   //type, count
  4089   call_VM(FSR, CAST_FROM_FN_PTR(address, InterpreterRuntime::newarray), A1, FSR);
  4090   __ sync();
  4093 void TemplateTable::anewarray() {
  4094   transition(itos, atos);
  4095   __ get_2_byte_integer_at_bcp(A2, AT, 1);
  4096   __ huswap(A2);
  4097   __ get_constant_pool(A1);
  4098   // cp, index, count
  4099   call_VM(FSR, CAST_FROM_FN_PTR(address, InterpreterRuntime::anewarray), A1, A2, FSR);
  4100   __ sync();
  4103 void TemplateTable::arraylength() {
  4104   transition(atos, itos);
  4105   __ null_check(FSR, arrayOopDesc::length_offset_in_bytes());
  4106   __ lw(FSR, FSR, arrayOopDesc::length_offset_in_bytes());
  4109 // i use T2 as ebx, T3 as ecx, T1 as edx
  4110 // when invoke gen_subtype_check, super in T3, sub in T2, object in FSR(it's always)
  4111 // T2 : sub klass
  4112 // T3 : cpool
  4113 // T3 : super klass
  4114 void TemplateTable::checkcast() {
  4115   transition(atos, atos);
  4116   Label done, is_null, ok_is_subtype, quicked, resolved;
  4117   __ beq(FSR, R0, is_null);
  4118   __ delayed()->nop();
  4120   // Get cpool & tags index
  4121   __ get_cpool_and_tags(T3, T1);
  4122   __ get_2_byte_integer_at_bcp(T2, AT, 1);
  4123   __ huswap(T2);
  4125   // See if bytecode has already been quicked
  4126   __ dadd(AT, T1, T2);
  4127   __ lb(AT, AT, Array<u1>::base_offset_in_bytes());
  4128   __ daddiu(AT, AT, - (int)JVM_CONSTANT_Class);
  4129   __ beq(AT, R0, quicked);
  4130   __ delayed()->nop();
  4132   /* 2012/6/2 Jin: In InterpreterRuntime::quicken_io_cc, lots of new classes may be loaded.
  4133    *  Then, GC will move the object in V0 to another places in heap.
  4134    *  Therefore, We should never save such an object in register.
  4135    *  Instead, we should save it in the stack. It can be modified automatically by the GC thread.
  4136    *  After GC, the object address in FSR is changed to a new place.
  4137    */
  4138   __ push(atos);
  4139   const Register thread = TREG;
  4140 #ifndef OPT_THREAD
  4141   __ get_thread(thread);
  4142 #endif
  4143   call_VM(NOREG, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
  4144   __ get_vm_result_2(T3, thread);
  4145   __ pop_ptr(FSR);
  4146   __ b(resolved);
  4147   __ delayed()->nop();
  4149   // klass already in cp, get superklass in T3
  4150   __ bind(quicked);
  4151   __ dsll(AT, T2, Address::times_8);
  4152   __ dadd(AT, T3, AT);
  4153   __ ld(T3, AT, sizeof(ConstantPool));
  4155   __ bind(resolved);
  4157   // get subklass in T2
  4158   //add for compressedoops
  4159   __ load_klass(T2, FSR);
  4160   // Superklass in T3.  Subklass in T2.
  4161   __ gen_subtype_check(T3, T2, ok_is_subtype);
  4163   // Come here on failure
  4164   // object is at FSR
  4165   __ jmp(Interpreter::_throw_ClassCastException_entry);
  4166   __ delayed()->nop();
  4168   // Come here on success
  4169   __ bind(ok_is_subtype);
  4171   // Collect counts on whether this check-cast sees NULLs a lot or not.
  4172   if (ProfileInterpreter) {
  4173     __ b(done);
  4174     __ delayed()->nop();
  4175     __ bind(is_null);
  4176     __ profile_null_seen(T3);
  4177   } else {
  4178     __ bind(is_null);
  4180   __ bind(done);
  4183 // i use T3 as cpool, T1 as tags, T2 as index
  4184 // object always in FSR, superklass in T3, subklass in T2
  4185 void TemplateTable::instanceof() {
  4186   transition(atos, itos);
  4187   Label done, is_null, ok_is_subtype, quicked, resolved;
  4189   __ beq(FSR, R0, is_null);
  4190   __ delayed()->nop();
  4192   // Get cpool & tags index
  4193   __ get_cpool_and_tags(T3, T1);
  4194   // get index
  4195   __ get_2_byte_integer_at_bcp(T2, AT, 1);
  4196   __ hswap(T2);
  4198   // See if bytecode has already been quicked
  4199   // quicked
  4200   __ daddu(AT, T1, T2);
  4201   __ lb(AT, AT, Array<u1>::base_offset_in_bytes());
  4202   __ daddiu(AT, AT, - (int)JVM_CONSTANT_Class);
  4203   __ beq(AT, R0, quicked);
  4204   __ delayed()->nop();
  4206   __ push(atos);
  4207   const Register thread = TREG;
  4208 #ifndef OPT_THREAD
  4209   __ get_thread(thread);
  4210 #endif
  4211   call_VM(NOREG, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
  4212   __ get_vm_result_2(T3, thread);
  4213   __ pop_ptr(FSR);
  4214   __ b(resolved);
  4215   __ delayed()->nop();
  4217   // get superklass in T3, subklass in T2
  4218   __ bind(quicked);
  4219   __ dsll(AT, T2, Address::times_8);
  4220   __ daddu(AT, T3, AT);
  4221   __ ld(T3, AT, sizeof(ConstantPool));
  4223   __ bind(resolved);
  4224   // get subklass in T2
  4225   //add for compressedoops
  4226   __ load_klass(T2, FSR);
  4228   // Superklass in T3.  Subklass in T2.
  4229   __ gen_subtype_check(T3, T2, ok_is_subtype);
  4230   // Come here on failure
  4231   __ b(done);
  4232   __ delayed(); __ move(FSR, R0);
  4234   // Come here on success
  4235   __ bind(ok_is_subtype);
  4236   __ move(FSR, 1);
  4238   // Collect counts on whether this test sees NULLs a lot or not.
  4239   if (ProfileInterpreter) {
  4240     __ beq(R0, R0, done);
  4241     __ nop();
  4242     __ bind(is_null);
  4243     __ profile_null_seen(T3);
  4244   } else {
  4245     __ bind(is_null);   // same as 'done'
  4247   __ bind(done);
  4248   // FSR = 0: obj == NULL or  obj is not an instanceof the specified klass
  4249   // FSR = 1: obj != NULL and obj is     an instanceof the specified klass
  4252 //--------------------------------------------------------
  4253 //--------------------------------------------
  4254 // Breakpoints
  4255 void TemplateTable::_breakpoint() {
  4256   // Note: We get here even if we are single stepping..
  4257   // jbug inists on setting breakpoints at every bytecode
  4258   // even if we are in single step mode.
  4260   transition(vtos, vtos);
  4262   // get the unpatched byte code
  4263   __ get_method(A1);
  4264   __ call_VM(NOREG,
  4265              CAST_FROM_FN_PTR(address,
  4266                               InterpreterRuntime::get_original_bytecode_at),
  4267              A1, BCP);
  4268   __ move(Rnext, V0); // Jin: Rnext will be used in dispatch_only_normal
  4270   // post the breakpoint event
  4271   __ get_method(A1);
  4272   __ call_VM(NOREG, CAST_FROM_FN_PTR(address, InterpreterRuntime::_breakpoint), A1, BCP);
  4274   // complete the execution of original bytecode
  4275   __ dispatch_only_normal(vtos);
  4278 //-----------------------------------------------------------------------------
  4279 // Exceptions
  4281 void TemplateTable::athrow() {
  4282   transition(atos, vtos);
  4283   __ null_check(FSR);
  4284   __ jmp(Interpreter::throw_exception_entry());
  4285   __ delayed()->nop();
  4288 //-----------------------------------------------------------------------------
  4289 // Synchronization
  4290 //
  4291 // Note: monitorenter & exit are symmetric routines; which is reflected
  4292 //       in the assembly code structure as well
  4293 //
  4294 // Stack layout:
  4295 //
  4296 // [expressions  ] <--- SP               = expression stack top
  4297 // ..
  4298 // [expressions  ]
  4299 // [monitor entry] <--- monitor block top = expression stack bot
  4300 // ..
  4301 // [monitor entry]
  4302 // [frame data   ] <--- monitor block bot
  4303 // ...
  4304 // [return addr  ] <--- FP
  4306 // we use T2 as monitor entry pointer, T3 as monitor top pointer, c_rarg0 as free slot pointer
  4307 // object always in FSR
  4308 void TemplateTable::monitorenter() {
  4309   transition(atos, vtos);
  4311   // check for NULL object
  4312   __ null_check(FSR);
  4314   const Address monitor_block_top(FP, frame::interpreter_frame_monitor_block_top_offset
  4315       * wordSize);
  4316   const int entry_size = (frame::interpreter_frame_monitor_size()* wordSize);
  4317   Label allocated;
  4319   // initialize entry pointer
  4320   __ move(c_rarg0, R0);
  4322   // find a free slot in the monitor block (result in edx)
  4324     Label entry, loop, exit, next;
  4325     __ ld(T2, monitor_block_top);
  4326     __ b(entry);
  4327     __ delayed()->daddi(T3, FP, frame::interpreter_frame_initial_sp_offset * wordSize);
  4329     // free slot?
  4330     __ bind(loop);
  4331     __ ld(AT, T2, BasicObjectLock::obj_offset_in_bytes());
  4332     __ bne(AT, R0, next);
  4333     __ delayed()->nop();
  4334     __ move(c_rarg0, T2);
  4336     __ bind(next);
  4337     __ beq(FSR, AT, exit);
  4338     __ delayed()->nop();
  4339     __ daddi(T2, T2, entry_size);
  4341     __ bind(entry);
  4342     __ bne(T3, T2, loop);
  4343     __ delayed()->nop();
  4344     __ bind(exit);
  4347   __ bne(c_rarg0, R0, allocated);
  4348   __ delayed()->nop();
  4350   // allocate one if there's no free slot
  4352     Label entry, loop;
  4353     // 1. compute new pointers                   // SP: old expression stack top
  4354     __ ld(c_rarg0, monitor_block_top);
  4355     __ daddi(SP, SP, - entry_size);
  4356     __ daddi(c_rarg0, c_rarg0, - entry_size);
  4357     __ sd(c_rarg0, monitor_block_top);
  4358     __ b(entry);
  4359     __ delayed(); __ move(T3, SP);
  4361     // 2. move expression stack contents
  4362     __ bind(loop);
  4363     __ ld(AT, T3, entry_size);
  4364     __ sd(AT, T3, 0);
  4365     __ daddi(T3, T3, wordSize);
  4366     __ bind(entry);
  4367     __ bne(T3, c_rarg0, loop);
  4368     __ delayed()->nop();
  4371   __ bind(allocated);
  4372   // Increment bcp to point to the next bytecode,
  4373   // so exception handling for async. exceptions work correctly.
  4374   // The object has already been poped from the stack, so the
  4375   // expression stack looks correct.
  4376   __ daddi(BCP, BCP, 1);
  4377   __ sd(FSR, c_rarg0, BasicObjectLock::obj_offset_in_bytes());
  4378   __ lock_object(c_rarg0);
  4379   // check to make sure this monitor doesn't cause stack overflow after locking
  4380   __ save_bcp();  // in case of exception
  4381   __ generate_stack_overflow_check(0);
  4382   // The bcp has already been incremented. Just need to dispatch to next instruction.
  4384   __ dispatch_next(vtos);
  4387 // T2 : top
  4388 // c_rarg0 : entry
  4389 void TemplateTable::monitorexit() {
  4390   transition(atos, vtos);
  4392   __ null_check(FSR);
  4394   const int entry_size =(frame::interpreter_frame_monitor_size()* wordSize);
  4395   Label found;
  4397   // find matching slot
  4399     Label entry, loop;
  4400     __ ld(c_rarg0, FP, frame::interpreter_frame_monitor_block_top_offset * wordSize);
  4401     __ b(entry);
  4402     __ delayed()->daddiu(T2, FP, frame::interpreter_frame_initial_sp_offset * wordSize);
  4404     __ bind(loop);
  4405     __ ld(AT, c_rarg0, BasicObjectLock::obj_offset_in_bytes());
  4406     __ beq(FSR, AT, found);
  4407     __ delayed()->nop();
  4408     __ daddiu(c_rarg0, c_rarg0, entry_size);
  4409     __ bind(entry);
  4410     __ bne(T2, c_rarg0, loop);
  4411     __ delayed()->nop();
  4414   // error handling. Unlocking was not block-structured
  4415   Label end;
  4416   __ call_VM(NOREG, CAST_FROM_FN_PTR(address,
  4417   InterpreterRuntime::throw_illegal_monitor_state_exception));
  4418   __ should_not_reach_here();
  4420   // call run-time routine
  4421   // c_rarg0: points to monitor entry
  4422   __ bind(found);
  4423   __ move(TSR, FSR);
  4424   __ unlock_object(c_rarg0);
  4425   __ move(FSR, TSR);
  4426   __ bind(end);
  4430 // Wide instructions
  4431 void TemplateTable::wide() {
  4432   transition(vtos, vtos);
  4433   // Note: the esi increment step is part of the individual wide bytecode implementations
  4434   __ lbu(Rnext, at_bcp(1));
  4435   __ dsll(T9, Rnext, Address::times_8);
  4436   __ li(AT, (long)Interpreter::_wentry_point);
  4437   __ dadd(AT, T9, AT);
  4438   __ ld(T9, AT, 0);
  4439   __ jr(T9);
  4440   __ delayed()->nop();
  4444 void TemplateTable::multianewarray() {
  4445   transition(vtos, atos);
  4446   // last dim is on top of stack; we want address of first one:
  4447   // first_addr = last_addr + (ndims - 1) * wordSize
  4448   __ lbu(A1, at_bcp(3));  // dimension
  4449   __ daddi(A1, A1, -1);
  4450   __ dsll(A1, A1, Address::times_8);
  4451   __ dadd(A1, SP, A1);    // now A1 pointer to the count array on the stack
  4452   call_VM(FSR, CAST_FROM_FN_PTR(address, InterpreterRuntime::multianewarray), A1);
  4453   __ lbu(AT, at_bcp(3));
  4454   __ dsll(AT, AT, Address::times_8);
  4455   __ dadd(SP, SP, AT);
  4456   __ sync();
  4458 #endif // !CC_INTERP

mercurial