#5963 wrong frame offset (SP) in StackOverflowError handler

Mon, 13 Nov 2017 15:49:42 +0800

author
aoqi
date
Mon, 13 Nov 2017 15:49:42 +0800
changeset 8009
0477693968a6
parent 8008
2c1fab4a6f4e
child 8010
e1b12c6ec026

#5963 wrong frame offset (SP) in StackOverflowError handler
Summary: push/pop before/after bang_stack_with_offset is removed. compiler/6865265/StackOverflowBug.java passed.
This patch also includes code cleanup and code style fix.

src/cpu/mips/vm/frame_mips.cpp file | annotate | diff | comparison | revisions
src/cpu/mips/vm/macroAssembler_mips.cpp file | annotate | diff | comparison | revisions
src/cpu/mips/vm/sharedRuntime_mips_64.cpp file | annotate | diff | comparison | revisions
src/cpu/mips/vm/stubGenerator_mips_64.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/mips/vm/frame_mips.cpp	Thu Nov 16 17:27:00 2017 +0800
     1.2 +++ b/src/cpu/mips/vm/frame_mips.cpp	Mon Nov 13 15:49:42 2017 +0800
     1.3 @@ -291,16 +291,13 @@
     1.4  frame frame::sender_for_compiled_frame(RegisterMap* map) const {
     1.5    assert(map != NULL, "map must be set");
     1.6  
     1.7 +  // frame owned by optimizing compiler
     1.8 +  assert(_cb->frame_size() >= 0, "must have non-zero frame size");
     1.9 +
    1.10 +  intptr_t* sender_sp = sender_sp = sp() + _cb->frame_size();
    1.11 +#ifdef ASSERT
    1.12    const bool c1_compiled = _cb->is_compiled_by_c1();
    1.13 -  // frame owned by optimizing compiler
    1.14 -  intptr_t* sender_sp = NULL;
    1.15    bool native = _cb->is_nmethod() && ((nmethod*)_cb)->is_native_method();
    1.16 -
    1.17 -  assert(_cb->frame_size() >= 0, "must have non-zero frame size");
    1.18 -  //FIXME , may be error here , do MIPS have the return address and link address on the stack?
    1.19 -
    1.20 -  sender_sp = sp() + _cb->frame_size();
    1.21 -#ifdef ASSERT
    1.22    if (c1_compiled && native) {
    1.23      assert(sender_sp == fp() + frame::sender_sp_offset, "incorrect frame size");
    1.24    }
    1.25 @@ -312,29 +309,24 @@
    1.26    // spark
    1.27    address sender_pc = (address) *(sender_sp-1);
    1.28  
    1.29 -  intptr_t *saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset);
    1.30 -
    1.31 -  // so getting sender for compiled frame is not same as interpreter frame.
    1.32 -  // we hard code here temporarily
    1.33 -  // spark
    1.34 +  intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
    1.35  
    1.36    if (map->update_map()) {
    1.37      // Tell GC to use argument oopmaps for some runtime stubs that need it.
    1.38      // For C1, the runtime stub might not have oop maps, so set this flag
    1.39      // outside of update_register_map.
    1.40 -
    1.41      map->set_include_argument_oops(_cb->caller_must_gc_arguments(map->thread()));
    1.42      if (_cb->oop_maps() != NULL) {
    1.43        OopMapSet::update_register_map(this, map);
    1.44      }
    1.45 +
    1.46      // Since the prolog does the save and restore of epb there is no oopmap
    1.47      // for it so we must fill in its location as if there was an oopmap entry
    1.48      // since if our caller was compiled code there could be live jvm state in it.
    1.49 -    //   map->set_location(ebp->as_VMReg(), (address) (sender_sp - frame::sender_sp_offset));
    1.50 -    map->set_location(FP->as_VMReg(), (address) (sender_sp - frame::sender_sp_offset));
    1.51 +    map->set_location(FP->as_VMReg(), (address) saved_fp_addr);
    1.52    }
    1.53    assert(sender_sp != sp(), "must have changed");
    1.54 -  return frame(sender_sp, saved_fp, sender_pc);
    1.55 +  return frame(sender_sp, *saved_fp_addr, sender_pc);
    1.56  }
    1.57  
    1.58  frame frame::sender(RegisterMap* map) const {
     2.1 --- a/src/cpu/mips/vm/macroAssembler_mips.cpp	Thu Nov 16 17:27:00 2017 +0800
     2.2 +++ b/src/cpu/mips/vm/macroAssembler_mips.cpp	Mon Nov 13 15:49:42 2017 +0800
     2.3 @@ -117,13 +117,10 @@
     2.4            && special(pc[5]) == daddu_op)) { tty->print_cr("Not a branch label patch"); }
     2.5  
     2.6      int offset = target - branch;
     2.7 -    if (!is_simm16(offset))
     2.8 -    {
     2.9 +    if (!is_simm16(offset)) {
    2.10        pc[3] = (pc[3] & 0xffff0000) | high16(offset - 12);
    2.11        pc[4] = (pc[4] & 0xffff0000) | low16(offset - 12);
    2.12 -    }
    2.13 -    else
    2.14 -    {
    2.15 +    } else {
    2.16        /* revert to "beq + nop" */
    2.17        CodeBuffer cb(branch, 4 * 10);
    2.18        MacroAssembler masm(&cb);
    2.19 @@ -141,12 +138,10 @@
    2.20    }
    2.21  
    2.22  #ifndef PRODUCT
    2.23 -  if (!is_simm16((target - branch - 4) >> 2))
    2.24 -  {
    2.25 +  if (!is_simm16((target - branch - 4) >> 2)) {
    2.26      tty->print_cr("Illegal patching: target=0x%lx", target);
    2.27      int *p = (int *)branch;
    2.28 -    for (int i = -10; i < 10; i++)
    2.29 -    {
    2.30 +    for (int i = -10; i < 10; i++) {
    2.31         tty->print("0x%lx, ", p[i]);
    2.32      }
    2.33      tty->print_cr("");
    2.34 @@ -265,17 +260,13 @@
    2.35    return 6;
    2.36  }
    2.37  
    2.38 -void MacroAssembler::beq_far(Register rs, Register rt, address entry)
    2.39 -{
    2.40 +void MacroAssembler::beq_far(Register rs, Register rt, address entry) {
    2.41    u_char * cur_pc = pc();
    2.42  
    2.43    /* Jin: Near/Far jump */
    2.44 -  if(is_simm16((entry - pc() - 4) / 4))
    2.45 -  {
    2.46 +  if(is_simm16((entry - pc() - 4) / 4)) {
    2.47      Assembler::beq(rs, rt, offset(entry));
    2.48 -  }
    2.49 -  else
    2.50 -  {
    2.51 +  } else {
    2.52      Label not_jump;
    2.53      bne(rs, rt, not_jump);
    2.54      delayed()->nop();
    2.55 @@ -288,8 +279,7 @@
    2.56    }
    2.57  }
    2.58  
    2.59 -void MacroAssembler::beq_far(Register rs, Register rt, Label& L)
    2.60 -{
    2.61 +void MacroAssembler::beq_far(Register rs, Register rt, Label& L) {
    2.62    if (L.is_bound()) {
    2.63      beq_far(rs, rt, target(L));
    2.64    } else {
    2.65 @@ -306,17 +296,13 @@
    2.66    }
    2.67  }
    2.68  
    2.69 -void MacroAssembler::bne_far(Register rs, Register rt, address entry)
    2.70 -{
    2.71 +void MacroAssembler::bne_far(Register rs, Register rt, address entry) {
    2.72    u_char * cur_pc = pc();
    2.73  
    2.74    /* Jin: Near/Far jump */
    2.75 -  if(is_simm16((entry - pc() - 4) / 4))
    2.76 -  {
    2.77 +  if(is_simm16((entry - pc() - 4) / 4)) {
    2.78      Assembler::bne(rs, rt, offset(entry));
    2.79 -  }
    2.80 -  else
    2.81 -  {
    2.82 +  } else {
    2.83      Label not_jump;
    2.84      beq(rs, rt, not_jump);
    2.85      delayed()->nop();
    2.86 @@ -329,8 +315,7 @@
    2.87    }
    2.88  }
    2.89  
    2.90 -void MacroAssembler::bne_far(Register rs, Register rt, Label& L)
    2.91 -{
    2.92 +void MacroAssembler::bne_far(Register rs, Register rt, Label& L) {
    2.93    if (L.is_bound()) {
    2.94      bne_far(rs, rt, target(L));
    2.95    } else {
    2.96 @@ -347,12 +332,11 @@
    2.97    }
    2.98  }
    2.99  
   2.100 -void MacroAssembler::b_far(Label& L)
   2.101 -{
   2.102 +void MacroAssembler::b_far(Label& L) {
   2.103    if (L.is_bound()) {
   2.104      b_far(target(L));
   2.105    } else {
   2.106 -  volatile address dest = target(L);
   2.107 +    volatile address dest = target(L);
   2.108  /*
   2.109  MacroAssembler::pd_patch_instruction branch=55651ed514, target=55651ef6d8
   2.110     0x00000055651ed514: dadd at, ra, zero
   2.111 @@ -366,31 +350,27 @@
   2.112     0x00000055651ed530: jr t9
   2.113     0x00000055651ed534: sll zero, zero, 0
   2.114  */
   2.115 -  move(AT, RA);
   2.116 -  emit_long(insn_ORRI(regimm_op, 0, bgezal_op, 1));
   2.117 -  nop();
   2.118 -        lui(T9, 0); // to be patched
   2.119 -        ori(T9, T9, 0);
   2.120 -  daddu(T9, T9, RA);
   2.121 -  move(RA, AT);
   2.122 -  jr(T9);
   2.123 +    move(AT, RA);
   2.124 +    emit_long(insn_ORRI(regimm_op, 0, bgezal_op, 1));
   2.125 +    nop();
   2.126 +    lui(T9, 0); // to be patched
   2.127 +    ori(T9, T9, 0);
   2.128 +    daddu(T9, T9, RA);
   2.129 +    move(RA, AT);
   2.130 +    jr(T9);
   2.131    }
   2.132  }
   2.133  
   2.134 -void MacroAssembler::b_far(address entry)
   2.135 -{
   2.136 +void MacroAssembler::b_far(address entry) {
   2.137    u_char * cur_pc = pc();
   2.138  
   2.139    /* Jin: Near/Far jump */
   2.140 -  if(is_simm16((entry - pc() - 4) / 4))
   2.141 -  {
   2.142 +  if(is_simm16((entry - pc() - 4) / 4)) {
   2.143      b(offset(entry));
   2.144 -  }
   2.145 -  else
   2.146 -  {
   2.147 +  } else {
   2.148      /* address must be bounded */
   2.149      move(AT, RA);
   2.150 -     emit_long(insn_ORRI(regimm_op, 0, bgezal_op, 1));
   2.151 +    emit_long(insn_ORRI(regimm_op, 0, bgezal_op, 1));
   2.152      nop();
   2.153      li32(T9, entry - pc());
   2.154      daddu(T9, T9, RA);
   2.155 @@ -721,13 +701,9 @@
   2.156    delayed()->nop();
   2.157  }
   2.158  
   2.159 -// NOTE: we dont increment the SP after call like the x86 version, maybe this is a problem, FIXME.
   2.160  // the stack pointer adjustment is needed. see InterpreterMacroAssembler::super_call_VM_leaf
   2.161  // this method will handle the stack problem, you need not to preserve the stack space for the argument now
   2.162 -void MacroAssembler::call_VM_leaf_base(address entry_point,
   2.163 -    int number_of_arguments) {
   2.164 -  //call(RuntimeAddress(entry_point));
   2.165 -  //increment(rsp, number_of_arguments * wordSize);
   2.166 +void MacroAssembler::call_VM_leaf_base(address entry_point, int number_of_arguments) {
   2.167    Label L, E;
   2.168  
   2.169    assert(number_of_arguments <= 4, "just check");
   2.170 @@ -1158,7 +1134,7 @@
   2.171                                    Register last_java_sp,
   2.172                                    address  entry_point,
   2.173                                    int      number_of_arguments,
   2.174 -          bool     check_exceptions) {
   2.175 +                                  bool     check_exceptions) {
   2.176  
   2.177    address before_call_pc;
   2.178    // determine java_thread register
   2.179 @@ -1190,6 +1166,7 @@
   2.180    move(A0, java_thread);
   2.181    call(entry_point, relocInfo::runtime_call_type);
   2.182    delayed()->nop();
   2.183 +  //MacroAssembler::call_VM_leaf_base(entry_point, number_of_arguments);
   2.184  
   2.185    // restore the thread (cannot use the pushed argument since arguments
   2.186    // may be overwritten by C code generated by an optimizing compiler);
   2.187 @@ -1203,7 +1180,7 @@
   2.188      get_thread(AT);
   2.189      beq(java_thread, AT, L);
   2.190      delayed()->nop();
   2.191 -    stop("MacroAssembler::call_VM_base: edi not callee saved?");
   2.192 +    stop("MacroAssembler::call_VM_base: TREG not callee saved?");
   2.193      bind(L);
   2.194    }
   2.195  #endif
   2.196 @@ -1474,7 +1451,6 @@
   2.197    sd(last_java_sp, Address(thread, JavaThread::last_Java_sp_offset()));
   2.198  }
   2.199  
   2.200 -
   2.201  //////////////////////////////////////////////////////////////////////////////////
   2.202  #if INCLUDE_ALL_GCS
   2.203  
   2.204 @@ -1621,7 +1597,7 @@
   2.205    dsrl(AT, AT, HeapRegion::LogOfHRGrainBytes);
   2.206    beq(AT, R0, done);
   2.207    nop();
   2.208 -  
   2.209 +
   2.210  
   2.211    // crosses regions, storing NULL?
   2.212    beq(new_val, R0, done);
   2.213 @@ -1652,7 +1628,7 @@
   2.214  
   2.215    // storing a region crossing, non-NULL oop, card is clean.
   2.216    // dirty card and log.
   2.217 -  move(AT, (int)CardTableModRefBS::dirty_card_val()); 
   2.218 +  move(AT, (int)CardTableModRefBS::dirty_card_val());
   2.219    sb(AT, card_addr, 0);
   2.220  
   2.221    lw(AT, queue_index);
   2.222 @@ -3219,23 +3195,23 @@
   2.223  //for UseCompressedOops Option
   2.224  void MacroAssembler::load_klass(Register dst, Register src) {
   2.225  #ifdef _LP64
   2.226 -    if(UseCompressedClassPointers){
   2.227 -        lwu(dst, Address(src, oopDesc::klass_offset_in_bytes()));
   2.228 -  decode_klass_not_null(dst);
   2.229 -    } else
   2.230 +  if(UseCompressedClassPointers){
   2.231 +    lwu(dst, Address(src, oopDesc::klass_offset_in_bytes()));
   2.232 +    decode_klass_not_null(dst);
   2.233 +  } else
   2.234  #endif
   2.235 -        ld(dst, src, oopDesc::klass_offset_in_bytes());
   2.236 +  ld(dst, src, oopDesc::klass_offset_in_bytes());
   2.237  }
   2.238  
   2.239  void MacroAssembler::store_klass(Register dst, Register src) {
   2.240  #ifdef _LP64
   2.241 -    if(UseCompressedClassPointers){
   2.242 +  if(UseCompressedClassPointers){
   2.243      encode_klass_not_null(src);
   2.244      sw(src, dst, oopDesc::klass_offset_in_bytes());
   2.245 -    } else {
   2.246 +  } else {
   2.247  #endif
   2.248      sd(src, dst, oopDesc::klass_offset_in_bytes());
   2.249 -    }
   2.250 +  }
   2.251  }
   2.252  
   2.253  void MacroAssembler::load_prototype_header(Register dst, Register src) {
   2.254 @@ -3251,30 +3227,30 @@
   2.255  }
   2.256  
   2.257  void MacroAssembler::load_heap_oop(Register dst, Address src) {
   2.258 -    if(UseCompressedOops){
   2.259 -  lwu(dst, src);
   2.260 -  decode_heap_oop(dst);
   2.261 -    } else{
   2.262 -  ld(dst, src);
   2.263 -    }
   2.264 +  if(UseCompressedOops){
   2.265 +    lwu(dst, src);
   2.266 +    decode_heap_oop(dst);
   2.267 +  } else {
   2.268 +    ld(dst, src);
   2.269 +  }
   2.270  }
   2.271  
   2.272  void MacroAssembler::store_heap_oop(Address dst, Register src){
   2.273 -    if(UseCompressedOops){
   2.274 -       assert(!dst.uses(src), "not enough registers");
   2.275 -       encode_heap_oop(src);
   2.276 -       sw(src, dst);
   2.277 -    } else{
   2.278 -       sd(src, dst);
   2.279 -    }
   2.280 +  if(UseCompressedOops){
   2.281 +    assert(!dst.uses(src), "not enough registers");
   2.282 +    encode_heap_oop(src);
   2.283 +    sw(src, dst);
   2.284 +  } else {
   2.285 +    sd(src, dst);
   2.286 +  }
   2.287  }
   2.288  
   2.289  void MacroAssembler::store_heap_oop_null(Address dst){
   2.290 -    if(UseCompressedOops){
   2.291 -       sw(R0, dst);
   2.292 -    } else{
   2.293 -       sd(R0, dst);
   2.294 -    }
   2.295 +  if(UseCompressedOops){
   2.296 +    sw(R0, dst);
   2.297 +  } else {
   2.298 +    sd(R0, dst);
   2.299 +  }
   2.300  }
   2.301  
   2.302  #ifdef ASSERT
   2.303 @@ -3299,12 +3275,12 @@
   2.304      return;
   2.305    }
   2.306  
   2.307 -    movz(r, S5_heapbase, r);
   2.308 -    dsub(r, r, S5_heapbase);
   2.309 -    if (Universe::narrow_oop_shift() != 0) {
   2.310 -      assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
   2.311 -      shr(r, LogMinObjAlignmentInBytes);
   2.312 -    }
   2.313 +  movz(r, S5_heapbase, r);
   2.314 +  dsub(r, r, S5_heapbase);
   2.315 +  if (Universe::narrow_oop_shift() != 0) {
   2.316 +    assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
   2.317 +    shr(r, LogMinObjAlignmentInBytes);
   2.318 +  }
   2.319  }
   2.320  
   2.321  void MacroAssembler::encode_heap_oop(Register dst, Register src) {
   2.322 @@ -3339,15 +3315,15 @@
   2.323  }
   2.324  
   2.325  void MacroAssembler::encode_heap_oop_not_null(Register r) {
   2.326 -    assert (UseCompressedOops, "should be compressed");
   2.327 +  assert (UseCompressedOops, "should be compressed");
   2.328  #ifdef ASSERT
   2.329 -    if (CheckCompressedOops) {
   2.330 -  Label ok;
   2.331 -  bne(r, R0, ok);
   2.332 -  delayed()->nop();
   2.333 -  stop("null oop passed to encode_heap_oop_not_null");
   2.334 -  bind(ok);
   2.335 -    }
   2.336 +  if (CheckCompressedOops) {
   2.337 +    Label ok;
   2.338 +    bne(r, R0, ok);
   2.339 +    delayed()->nop();
   2.340 +    stop("null oop passed to encode_heap_oop_not_null");
   2.341 +    bind(ok);
   2.342 +  }
   2.343  #endif
   2.344    verify_oop(r, "broken oop in encode_heap_oop_not_null");
   2.345    if (Universe::narrow_oop_base() != NULL) {
   2.346 @@ -3361,32 +3337,32 @@
   2.347  }
   2.348  
   2.349  void MacroAssembler::encode_heap_oop_not_null(Register dst, Register src) {
   2.350 -    assert (UseCompressedOops, "should be compressed");
   2.351 +  assert (UseCompressedOops, "should be compressed");
   2.352  #ifdef ASSERT
   2.353 -    if (CheckCompressedOops) {
   2.354 -  Label ok;
   2.355 -  bne(src, R0, ok);
   2.356 -  delayed()->nop();
   2.357 -  stop("null oop passed to encode_heap_oop_not_null2");
   2.358 -  bind(ok);
   2.359 +  if (CheckCompressedOops) {
   2.360 +    Label ok;
   2.361 +    bne(src, R0, ok);
   2.362 +    delayed()->nop();
   2.363 +    stop("null oop passed to encode_heap_oop_not_null2");
   2.364 +    bind(ok);
   2.365 +  }
   2.366 +#endif
   2.367 +  verify_oop(src, "broken oop in encode_heap_oop_not_null2");
   2.368 +
   2.369 +  if (Universe::narrow_oop_base() != NULL) {
   2.370 +    dsub(dst, src, S5_heapbase);
   2.371 +    if (Universe::narrow_oop_shift() != 0) {
   2.372 +      assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
   2.373 +      shr(dst, LogMinObjAlignmentInBytes);
   2.374      }
   2.375 -#endif
   2.376 -    verify_oop(src, "broken oop in encode_heap_oop_not_null2");
   2.377 -
   2.378 -    if (Universe::narrow_oop_base() != NULL) {
   2.379 -      dsub(dst, src, S5_heapbase);
   2.380 -        if (Universe::narrow_oop_shift() != 0) {
   2.381 -        assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
   2.382 -        shr(dst, LogMinObjAlignmentInBytes);
   2.383 -        }
   2.384 +  } else {
   2.385 +    if (Universe::narrow_oop_shift() != 0) {
   2.386 +      assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
   2.387 +      dsrl(dst, src, LogMinObjAlignmentInBytes);
   2.388      } else {
   2.389 -        if (Universe::narrow_oop_shift() != 0) {
   2.390 -        assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
   2.391 -          dsrl(dst, src, LogMinObjAlignmentInBytes);
   2.392 -        } else {
   2.393 -          if (dst != src) move(dst, src);
   2.394 -        }
   2.395 +      if (dst != src) move(dst, src);
   2.396      }
   2.397 +  }
   2.398  }
   2.399  
   2.400  void  MacroAssembler::decode_heap_oop(Register r) {
   2.401 @@ -3500,10 +3476,6 @@
   2.402      assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
   2.403      shr(r, LogKlassAlignmentInBytes);
   2.404    }
   2.405 -  // Not neccessary for MIPS at all.
   2.406 -  //if (Universe::narrow_klass_base() != NULL) {
   2.407 -  //  reinit_heapbase();
   2.408 -  //}
   2.409  }
   2.410  
   2.411  void MacroAssembler::encode_klass_not_null(Register dst, Register src) {
   2.412 @@ -3609,7 +3581,7 @@
   2.413    if (value <  0) { incrementl(reg, -value); return; }
   2.414    if (value == 0) {                        ; return; }
   2.415  
   2.416 -  if(Assembler::is_simm16(value)) {
   2.417 +  if (Assembler::is_simm16(value)) {
   2.418       NOT_LP64(addiu(reg, reg, -value));
   2.419       LP64_ONLY(move(AT, value); subu32(reg, reg, AT));
   2.420    } else {
   2.421 @@ -3686,14 +3658,12 @@
   2.422    // We move this check to the front of the fast path because many
   2.423    // type checks are in fact trivially successful in this manner,
   2.424    // so we get a nicely predicted branch right at the start of the check.
   2.425 -  //cmpptr(sub_klass, super_klass);
   2.426 -  //local_jcc(Assembler::equal, *L_success);
   2.427    beq(sub_klass, super_klass, *L_success);
   2.428    delayed()->nop();
   2.429    // Check the supertype display:
   2.430    if (must_load_sco) {
   2.431      // Positive movl does right thing on LP64.
   2.432 -  lwu(temp_reg, super_klass, sco_offset);
   2.433 +    lwu(temp_reg, super_klass, sco_offset);
   2.434      super_check_offset = RegisterOrConstant(temp_reg);
   2.435    }
   2.436    dsll(AT, super_check_offset.register_or_noreg(), Address::times_1);
   2.437 @@ -3712,39 +3682,39 @@
   2.438    // Otherwise, it's the slow path for us (no success at this point).
   2.439  
   2.440    if (super_check_offset.is_register()) {
   2.441 -  beq(super_klass, AT, *L_success);
   2.442 -  delayed()->nop();
   2.443 -  addi(AT, super_check_offset.as_register(), -sc_offset);
   2.444 +    beq(super_klass, AT, *L_success);
   2.445 +    delayed()->nop();
   2.446 +    addi(AT, super_check_offset.as_register(), -sc_offset);
   2.447      if (L_failure == &L_fallthrough) {
   2.448 -    beq(AT, R0, *L_slow_path);
   2.449 -    delayed()->nop();
   2.450 +      beq(AT, R0, *L_slow_path);
   2.451 +      delayed()->nop();
   2.452      } else {
   2.453 -    bne(AT, R0, *L_failure);
   2.454 -    delayed()->nop();
   2.455 -    b(*L_slow_path);
   2.456 -    delayed()->nop();
   2.457 +      bne(AT, R0, *L_failure);
   2.458 +      delayed()->nop();
   2.459 +      b(*L_slow_path);
   2.460 +      delayed()->nop();
   2.461      }
   2.462    } else if (super_check_offset.as_constant() == sc_offset) {
   2.463      // Need a slow path; fast failure is impossible.
   2.464      if (L_slow_path == &L_fallthrough) {
   2.465 -    beq(super_klass, AT, *L_success);
   2.466 -    delayed()->nop();
   2.467 +      beq(super_klass, AT, *L_success);
   2.468 +      delayed()->nop();
   2.469      } else {
   2.470 -    bne(super_klass, AT, *L_slow_path);
   2.471 -    delayed()->nop();
   2.472 -    b(*L_success);
   2.473 -    delayed()->nop();
   2.474 +      bne(super_klass, AT, *L_slow_path);
   2.475 +      delayed()->nop();
   2.476 +      b(*L_success);
   2.477 +      delayed()->nop();
   2.478      }
   2.479    } else {
   2.480      // No slow path; it's a fast decision.
   2.481      if (L_failure == &L_fallthrough) {
   2.482 -    beq(super_klass, AT, *L_success);
   2.483 -    delayed()->nop();
   2.484 +      beq(super_klass, AT, *L_success);
   2.485 +      delayed()->nop();
   2.486      } else {
   2.487 -    bne(super_klass, AT, *L_failure);
   2.488 -    delayed()->nop();
   2.489 -    b(*L_success);
   2.490 -    delayed()->nop();
   2.491 +      bne(super_klass, AT, *L_failure);
   2.492 +      delayed()->nop();
   2.493 +      b(*L_success);
   2.494 +      delayed()->nop();
   2.495      }
   2.496    }
   2.497  
   2.498 @@ -3784,18 +3754,11 @@
   2.499    // The repne_scan instruction uses fixed registers, which we must spill.
   2.500    // Don't worry too much about pre-existing connections with the input regs.
   2.501  
   2.502 -#if 0
   2.503 -  assert(sub_klass != T9, "killed reg"); // killed by mov(rax, super)
   2.504 -  assert(sub_klass != T1, "killed reg"); // killed by lea(rcx, &pst_counter)
   2.505 -#endif
   2.506 -
   2.507    // Get super_klass value into rax (even if it was in rdi or rcx).
   2.508  #ifndef PRODUCT
   2.509    int* pst_counter = &SharedRuntime::_partial_subtype_ctr;
   2.510    ExternalAddress pst_counter_addr((address) pst_counter);
   2.511    NOT_LP64(  incrementl(pst_counter_addr) );
   2.512 -  //LP64_ONLY( lea(rcx, pst_counter_addr) );
   2.513 -  //LP64_ONLY( incrementl(Address(rcx, 0)) );
   2.514  #endif //PRODUCT
   2.515  
   2.516    // We will consult the secondary-super array.
   2.517 @@ -3834,6 +3797,7 @@
   2.518  
   2.519    bind(L_fallthrough);
   2.520  }
   2.521 +
   2.522  void MacroAssembler::get_vm_result(Register oop_result, Register java_thread) {
   2.523    ld(oop_result, Address(java_thread, JavaThread::vm_result_offset()));
   2.524    sd(R0, Address(java_thread, JavaThread::vm_result_offset()));
   2.525 @@ -3949,7 +3913,6 @@
   2.526  
   2.527    // Adjust recv_klass by scaled itable_index, so we can free itable_index.
   2.528    assert(itableMethodEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
   2.529 -//  lea(recv_klass, Address(recv_klass, itable_index, Address::times_ptr, itentry_off));
   2.530    if (itable_index.is_constant()) {
   2.531      set64(AT, (int)itable_index.is_constant());
   2.532      dsll(AT, AT, (int)Address::times_ptr);
   2.533 @@ -3959,11 +3922,6 @@
   2.534    daddu(AT, AT, recv_klass);
   2.535    daddiu(recv_klass, AT, itentry_off);
   2.536  
   2.537 -  // for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) {
   2.538 -  //   if (scan->interface() == intf) {
   2.539 -  //     result = (klass + scan->offset() + itable_index);
   2.540 -  //   }
   2.541 -  // }
   2.542    Label search, found_method;
   2.543  
   2.544    for (int peel = 1; peel >= 0; peel--) {
   2.545 @@ -3994,7 +3952,6 @@
   2.546  
   2.547    // Got a hit.
   2.548    lw(scan_temp, Address(scan_temp, itableOffsetEntry::offset_offset_in_bytes()));
   2.549 -  //ld(method_result, Address(recv_klass, scan_temp, Address::times_1));
   2.550    if(UseLoongsonISA) {
   2.551      gsldx(method_result, recv_klass, scan_temp, 0);
   2.552    } else {
   2.553 @@ -4003,7 +3960,6 @@
   2.554    }
   2.555  }
   2.556  
   2.557 -
   2.558  // virtual method calling
   2.559  void MacroAssembler::lookup_virtual_method(Register recv_klass,
   2.560                                             RegisterOrConstant vtable_index,
     3.1 --- a/src/cpu/mips/vm/sharedRuntime_mips_64.cpp	Thu Nov 16 17:27:00 2017 +0800
     3.2 +++ b/src/cpu/mips/vm/sharedRuntime_mips_64.cpp	Mon Nov 13 15:49:42 2017 +0800
     3.3 @@ -808,7 +808,6 @@
     3.4    // push the return address on the stack (note that pushing, rather
     3.5    // than storing it, yields the correct frame alignment for the callee)
     3.6    // Put saved SP in another register
     3.7 -  // const Register saved_sp = eax;
     3.8    const Register saved_sp = V0;
     3.9    __ move(saved_sp, T9);
    3.10  
    3.11 @@ -1154,15 +1153,15 @@
    3.12        break;
    3.13      case T_VOID:  break;
    3.14      case T_LONG:
    3.15 -            __ sd(V0, FP, -wordSize);
    3.16 -            break;
    3.17 +      __ sd(V0, FP, -wordSize);
    3.18 +      break;
    3.19      case T_OBJECT:
    3.20      case T_ARRAY:
    3.21        __ sd(V0, FP, -wordSize);
    3.22        break;
    3.23      default: {
    3.24 -         __ sw(V0, FP, -wordSize);
    3.25 -       }
    3.26 +      __ sw(V0, FP, -wordSize);
    3.27 +      }
    3.28    }
    3.29  }
    3.30  
    3.31 @@ -1185,8 +1184,8 @@
    3.32        __ ld(V0, FP, -wordSize);
    3.33        break;
    3.34      default: {
    3.35 -         __ lw(V0, FP, -wordSize);
    3.36 -       }
    3.37 +      __ lw(V0, FP, -wordSize);
    3.38 +      }
    3.39    }
    3.40  }
    3.41  
    3.42 @@ -1577,7 +1576,6 @@
    3.43    // the 1st six register arguments). It's weird see int_stk_helper.
    3.44    //
    3.45    int out_arg_slots;
    3.46 -  //out_arg_slots = c_calling_convention(out_sig_bt, out_regs, total_c_args);
    3.47    out_arg_slots = c_calling_convention(out_sig_bt, out_regs, NULL, total_c_args);
    3.48  
    3.49    // Compute framesize for the wrapper.  We need to handlize all oops in
    3.50 @@ -1765,10 +1763,7 @@
    3.51    // Generate stack overflow check
    3.52  
    3.53    if (UseStackBanging) {
    3.54 -  //this function will modify the value in A0
    3.55 -    __ push(A0);
    3.56      __ bang_stack_with_offset(StackShadowPages*os::vm_page_size());
    3.57 -    __ pop(A0);
    3.58    } else {
    3.59      // need a 5 byte instruction to allow MT safe patching to non-entrant
    3.60      __ nop();
    3.61 @@ -1784,11 +1779,11 @@
    3.62  #endif
    3.63  //FIXME here
    3.64    __ st_ptr(SP, TREG, in_bytes(JavaThread::last_Java_sp_offset()));
    3.65 -  // -2 because return address is already present and so is saved ebp
    3.66    __ move(AT, -(StackAlignmentInBytes));
    3.67    __ andr(SP, SP, AT);
    3.68  
    3.69    __ enter();
    3.70 +  // -2 because return address is already present and so is saved ebp
    3.71    __ addiu(SP, SP, -1 * (stack_size - 2*wordSize));
    3.72  
    3.73    // Frame is now completed as far a size and linkage.
    3.74 @@ -2102,13 +2097,13 @@
    3.75      // least significant 2 bits clear.
    3.76      // NOTE: the oopMark is in swap_reg %eax as the result of cmpxchg
    3.77  
    3.78 -    __ dsub(swap_reg, swap_reg,SP);
    3.79 -     __ move(AT, 3 - os::vm_page_size());
    3.80 +    __ dsub(swap_reg, swap_reg, SP);
    3.81 +    __ move(AT, 3 - os::vm_page_size());
    3.82      __ andr(swap_reg , swap_reg, AT);
    3.83      // Save the test result, for recursive case, the result is zero
    3.84      __ sd(swap_reg, lock_reg, mark_word_offset);
    3.85    //FIXME here, Why notEqual?
    3.86 -    __ bne(swap_reg,R0, slow_path_lock);
    3.87 +    __ bne(swap_reg, R0, slow_path_lock);
    3.88      __ delayed()->nop();
    3.89      // Slow path will re-enter here
    3.90      __ bind(lock_done);
    3.91 @@ -2125,7 +2120,7 @@
    3.92  
    3.93    // get JNIEnv* which is first argument to native
    3.94    if (!is_critical_native) {
    3.95 -  __ addi(A0, thread, in_bytes(JavaThread::jni_environment_offset()));
    3.96 +    __ addi(A0, thread, in_bytes(JavaThread::jni_environment_offset()));
    3.97    }
    3.98  
    3.99    // Example: Java_java_lang_ref_Finalizer_invokeFinalizeMethod(JNIEnv *env, jclass clazz, jobject ob)
   3.100 @@ -2168,18 +2163,16 @@
   3.101    //     VM thread changes sync state to synchronizing and suspends threads for GC.
   3.102    //     Thread A is resumed to finish this native method, but doesn't block here since it
   3.103    //     didn't see any synchronization is progress, and escapes.
   3.104 -  // __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native_trans);
   3.105 -  //__ sw(_thread_in_native_trans, thread, JavaThread::thread_state_offset());
   3.106 -  //   __ move(AT, (int)_thread_in_native_trans);
   3.107    __ addi(AT, R0, _thread_in_native_trans);
   3.108    __ sw(AT, thread, in_bytes(JavaThread::thread_state_offset()));
   3.109  
   3.110 +  //if(os::is_MP()) {}
   3.111 +
   3.112    Label after_transition;
   3.113  
   3.114    // check for safepoint operation in progress and/or pending suspend requests
   3.115 -  { Label Continue;
   3.116 -//FIXME here, which regiser should we use?
   3.117 -    //        SafepointSynchronize::_not_synchronized);
   3.118 +  {
   3.119 +    Label Continue;
   3.120      __ li(AT, SafepointSynchronize::address_of_state());
   3.121      __ lw(A0, AT, 0);
   3.122      __ addi(AT, A0, -SafepointSynchronize::_not_synchronized);
   3.123 @@ -2198,8 +2191,8 @@
   3.124      // by hand.
   3.125      //
   3.126      save_native_result(masm, ret_type, stack_slots);
   3.127 -    __ move (A0, thread);
   3.128 -    __ addi(SP,SP, -wordSize);
   3.129 +    __ move(A0, thread);
   3.130 +    __ addi(SP, SP, -wordSize);
   3.131      __ push(S2);
   3.132      __ move(AT, -(StackAlignmentInBytes));
   3.133      __ move(S2, SP);     // use S2 as a sender SP holder
   3.134 @@ -2311,7 +2304,7 @@
   3.135    // Unpack oop result
   3.136    if (ret_type == T_OBJECT || ret_type == T_ARRAY) {
   3.137      Label L;
   3.138 -    __ beq(V0, R0,L );
   3.139 +    __ beq(V0, R0, L);
   3.140      __ delayed()->nop();
   3.141      __ ld(V0, V0, 0);
   3.142      __ bind(L);
   3.143 @@ -2319,15 +2312,14 @@
   3.144    }
   3.145  
   3.146    if (!is_critical_native) {
   3.147 -  // reset handle block
   3.148 -  __ ld(AT, thread, in_bytes(JavaThread::active_handles_offset()));
   3.149 -  __ sw(R0, AT, JNIHandleBlock::top_offset_in_bytes());
   3.150 +    // reset handle block
   3.151 +    __ ld(AT, thread, in_bytes(JavaThread::active_handles_offset()));
   3.152 +    __ sw(R0, AT, JNIHandleBlock::top_offset_in_bytes());
   3.153    }
   3.154  
   3.155    if (!is_critical_native) {
   3.156      // Any exception pending?
   3.157      __ ld(AT, thread, in_bytes(Thread::pending_exception_offset()));
   3.158 -
   3.159      __ bne(AT, R0, exception_pending);
   3.160      __ delayed()->nop();
   3.161    }
   3.162 @@ -2340,7 +2332,7 @@
   3.163  #ifndef OPT_THREAD
   3.164    __ get_thread(TREG);
   3.165  #endif
   3.166 -  __ ld_ptr(SP, TREG, in_bytes(JavaThread::last_Java_sp_offset()));
   3.167 +  //__ ld_ptr(SP, TREG, in_bytes(JavaThread::last_Java_sp_offset()));
   3.168    __ leave();
   3.169  
   3.170    __ jr(RA);
   3.171 @@ -2471,8 +2463,8 @@
   3.172      __ empty_FPU_stack();
   3.173  
   3.174      // pop our frame
   3.175 -   //forward_exception_entry need return address on stack
   3.176 -          __ addiu(SP, FP, wordSize);
   3.177 +    //forward_exception_entry need return address on stack
   3.178 +    __ addiu(SP, FP, wordSize);
   3.179      __ ld(FP, SP, (-1) * wordSize);
   3.180  
   3.181      // and forward the exception
   3.182 @@ -3708,7 +3700,7 @@
   3.183  
   3.184    //CodeBuffer buffer(name, 1000, 512);
   3.185    //FIXME. aoqi. code_size
   3.186 -  CodeBuffer buffer(name, 20000, 2048);
   3.187 +  CodeBuffer buffer(name, 2000, 2048);
   3.188    MacroAssembler* masm  = new MacroAssembler(&buffer);
   3.189  
   3.190    int frame_size_words;
     4.1 --- a/src/cpu/mips/vm/stubGenerator_mips_64.cpp	Thu Nov 16 17:27:00 2017 +0800
     4.2 +++ b/src/cpu/mips/vm/stubGenerator_mips_64.cpp	Mon Nov 13 15:49:42 2017 +0800
     4.3 @@ -392,11 +392,11 @@
     4.4      // ignore them.  A potential result in registers can be ignored as
     4.5      // well.
     4.6  
     4.7 -#ifdef ASSERT
     4.8 -    // make sure this code is only executed if there is a pending exception
     4.9  #ifndef OPT_THREAD
    4.10      __ get_thread(thread);
    4.11  #endif
    4.12 +#ifdef ASSERT
    4.13 +    // make sure this code is only executed if there is a pending exception
    4.14      {
    4.15        Label L;
    4.16        __ ld(AT, thread, in_bytes(Thread::pending_exception_offset()));
    4.17 @@ -612,7 +612,7 @@
    4.18                 // exactly backwards!!
    4.19                 //__ xchgptr(c_rarg1, c_rarg0);
    4.20                 __ move(AT, A0);
    4.21 -               __ move(A0, A1); 
    4.22 +               __ move(A0, A1);
    4.23                 __ move(A1, AT);
    4.24               } else {
    4.25                 __ move(A1, count);
    4.26 @@ -659,7 +659,7 @@
    4.27                // exactly backwards!!
    4.28                //__ xchgptr(c_rarg1, c_rarg0);
    4.29                __ move(AT, A0);
    4.30 -              __ move(A0, A1); 
    4.31 +              __ move(A0, A1);
    4.32                __ move(A1, AT);
    4.33              } else {
    4.34                __ move(A1, count);
    4.35 @@ -694,7 +694,7 @@
    4.36            __ dsubu(end, end, start); // end --> cards count
    4.37  
    4.38            __ daddu(start, start, scratch);
    4.39 -          
    4.40 +
    4.41            __ bind(L_loop);
    4.42            if (UseLoongsonISA) {
    4.43              __ gssbx(R0, start, count, 0);
    4.44 @@ -1993,14 +1993,14 @@
    4.45      int frame_complete = __ pc() - start;
    4.46      // push java thread (becomes first argument of C function)
    4.47      __ sd(java_thread, SP, thread_off * wordSize);
    4.48 -    if (java_thread!=A0)
    4.49 +    if (java_thread != A0)
    4.50        __ move(A0, java_thread);
    4.51  
    4.52      // Set up last_Java_sp and last_Java_fp
    4.53      __ set_last_Java_frame(java_thread, SP, FP, NULL);
    4.54 -                // Align stack
    4.55 -                __ set64(AT, -(StackAlignmentInBytes));
    4.56 -                __ andr(SP, SP, AT);
    4.57 +    // Align stack
    4.58 +    __ set64(AT, -(StackAlignmentInBytes));
    4.59 +    __ andr(SP, SP, AT);
    4.60  
    4.61      __ relocate(relocInfo::internal_pc_type);
    4.62      {
    4.63 @@ -2051,8 +2051,11 @@
    4.64  #endif //ASSERT
    4.65      __ jmp(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
    4.66      __ delayed()->nop();
    4.67 -    RuntimeStub* stub = RuntimeStub::new_runtime_stub(name, &code,frame_complete,
    4.68 -                    framesize, oop_maps, false);
    4.69 +    RuntimeStub* stub = RuntimeStub::new_runtime_stub(name,
    4.70 +                                                      &code,
    4.71 +                                                      frame_complete,
    4.72 +                                                      framesize,
    4.73 +                                                      oop_maps, false);
    4.74      return stub->entry_point();
    4.75    }
    4.76  

mercurial