[Interpreter] Optimize method entry point and TemplateTable::branch(...)

Tue, 26 Sep 2017 15:22:25 +0800

author
fujie
date
Tue, 26 Sep 2017 15:22:25 +0800
changeset 6895
34448c1bea2d
parent 6894
c3f0dbba118a
child 6896
ada5000bdb38

[Interpreter] Optimize method entry point and TemplateTable::branch(...)

src/cpu/mips/vm/templateInterpreter_mips_64.cpp file | annotate | diff | comparison | revisions
src/cpu/mips/vm/templateTable_mips_64.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/mips/vm/templateInterpreter_mips_64.cpp	Tue Sep 26 11:18:59 2017 +0800
     1.2 +++ b/src/cpu/mips/vm/templateInterpreter_mips_64.cpp	Tue Sep 26 15:22:25 2017 +0800
     1.3 @@ -314,7 +314,7 @@
     1.4          Label* profile_method,
     1.5          Label* profile_method_continue) {
     1.6    Label done;
     1.7 -  const Address invocation_counter(FSR, in_bytes(MethodCounters::invocation_counter_offset())  //Fu:20130814  Wang:Rmethod --> FSR
     1.8 +  const Address invocation_counter(FSR, in_bytes(MethodCounters::invocation_counter_offset())
     1.9        + in_bytes(InvocationCounter::counter_offset()));
    1.10    const Address backedge_counter  (FSR, in_bytes(MethodCounters::backedge_counter_offset())
    1.11        + in_bytes(InvocationCounter::counter_offset()));
    1.12 @@ -339,9 +339,14 @@
    1.13  
    1.14    if (ProfileInterpreter && profile_method != NULL) {
    1.15      // Test to see if we should create a method data oop
    1.16 -    __ li(AT, (long)&InvocationCounter::InterpreterProfileLimit);
    1.17 -    __ lw(AT, AT, 0);
    1.18 -    __ slt(AT, T3, AT);
    1.19 +    if (Assembler::is_simm16(InvocationCounter::InterpreterProfileLimit)) {
    1.20 +      __ slti(AT, T3, InvocationCounter::InterpreterProfileLimit);
    1.21 +    } else {
    1.22 +      __ li(AT, (long)&InvocationCounter::InterpreterProfileLimit);
    1.23 +      __ lw(AT, AT, 0);
    1.24 +      __ slt(AT, T3, AT);
    1.25 +    }
    1.26 +
    1.27      __ bne(AT, R0, *profile_method_continue);
    1.28      __ delayed()->nop();
    1.29  
    1.30 @@ -349,9 +354,15 @@
    1.31      __ test_method_data_pointer(FSR, *profile_method);
    1.32    }
    1.33  
    1.34 -  __ li(AT, (long)&InvocationCounter::InterpreterInvocationLimit);
    1.35 -  __ lw(AT, AT, 0);
    1.36 -  __ slt(AT, T3, AT);
    1.37 +  if (Assembler::is_simm16(CompileThreshold)) {
    1.38 +    __ srl(AT, T3, InvocationCounter::count_shift);
    1.39 +    __ slti(AT, AT, CompileThreshold);
    1.40 +  } else {
    1.41 +    __ li(AT, (long)&InvocationCounter::InterpreterInvocationLimit);
    1.42 +    __ lw(AT, AT, 0);
    1.43 +    __ slt(AT, T3, AT);
    1.44 +  }
    1.45 +
    1.46    __ beq(AT, R0, *overflow);
    1.47    __ delayed()->nop();
    1.48    __ bind(done);
    1.49 @@ -1415,19 +1426,9 @@
    1.50    // Rmethod: Method*
    1.51    // Rsender: sender 's sp
    1.52    address entry_point = __ pc();
    1.53 -  /*
    1.54 -#ifndef CORE
    1.55 -  // check if compiled code exists
    1.56 -  Label run_compiled_code;
    1.57 -  if (!CompileTheWorld) {
    1.58 -  check_for_compiled_code(run_compiled_code);
    1.59 -  }
    1.60 -#endif
    1.61 -   */
    1.62 -#ifndef CORE
    1.63 +
    1.64    const Address invocation_counter(Rmethod,
    1.65        in_bytes(MethodCounters::invocation_counter_offset() + InvocationCounter::counter_offset()));
    1.66 -#endif
    1.67  
    1.68    // get parameter size (always needed)
    1.69    __ ld(T3, Rmethod, in_bytes(Method::const_offset()));  //T3 --> Rmethod._constMethod
    1.70 @@ -1462,18 +1463,18 @@
    1.71      Label exit, loop;
    1.72      __ beq(T2, R0, exit);
    1.73      __ delayed()->nop();
    1.74 +
    1.75      __ bind(loop);
    1.76      __ sd(R0, SP, -1 * wordSize);     // initialize local variables
    1.77      __ daddiu(T2, T2, -1);               // until everything initialized
    1.78      __ bne(T2, R0, loop);
    1.79      __ delayed();
    1.80 +
    1.81      __ daddiu(SP, SP, (-1) * wordSize); //fill delay slot
    1.82 +
    1.83      __ bind(exit);
    1.84    }
    1.85  
    1.86 -#ifndef CORE
    1.87 -  if (inc_counter) __ lw(T3, invocation_counter);  // (pre-)fetch invocation count
    1.88 -#endif
    1.89    //
    1.90    // [ local var m-1  ] <--- sp
    1.91    //   ...
    1.92 @@ -1633,7 +1634,6 @@
    1.93  
    1.94    __ dispatch_next(vtos);
    1.95  
    1.96 -#ifndef CORE
    1.97    // invocation counter overflow
    1.98    if (inc_counter) {
    1.99      if (ProfileInterpreter) {
   1.100 @@ -1651,7 +1651,6 @@
   1.101      generate_counter_overflow(&continue_after_compile);
   1.102    }
   1.103  
   1.104 -#endif
   1.105    return entry_point;
   1.106  }
   1.107  
     2.1 --- a/src/cpu/mips/vm/templateTable_mips_64.cpp	Tue Sep 26 11:18:59 2017 +0800
     2.2 +++ b/src/cpu/mips/vm/templateTable_mips_64.cpp	Tue Sep 26 15:22:25 2017 +0800
     2.3 @@ -1847,8 +1847,10 @@
     2.4  
     2.5    // Load up T4 with the branch displacement
     2.6    if (!is_wide) {
     2.7 -    __ get_2_byte_integer_at_bcp(A7, AT, 1);
     2.8 -    __ hswap(A7);
     2.9 +    __ lb(A7, BCP, 1);
    2.10 +    __ lbu(AT, BCP, 2);
    2.11 +    __ dsll(A7, A7, 8); 
    2.12 +    __ orr(A7, A7, AT);
    2.13    } else {
    2.14      __ get_4_byte_integer_at_bcp(A7, AT, 1);
    2.15      __ swap(A7);
    2.16 @@ -1934,12 +1936,15 @@
    2.17  
    2.18      if (ProfileInterpreter) {
    2.19        // Test to see if we should create a method data oop
    2.20 -      //__ lui(AT, Assembler::split_high(int(&InvocationCounter::InterpreterProfileLimit)));
    2.21 -      //__ lw(AT, AT, Assembler::split_low(int(&InvocationCounter::InterpreterProfileLimit)));
    2.22        // T1 : backedge counter & invocation counter
    2.23 -      __ li(AT, (long)&InvocationCounter::InterpreterProfileLimit);
    2.24 -      __ lw(AT, AT, 0);
    2.25 -      __ slt(AT, T1, AT);
    2.26 +      if (Assembler::is_simm16(InvocationCounter::InterpreterProfileLimit)) {
    2.27 +        __ slti(AT, T1, InvocationCounter::InterpreterProfileLimit);
    2.28 +      } else {
    2.29 +        __ li(AT, (long)&InvocationCounter::InterpreterProfileLimit);
    2.30 +        __ lw(AT, AT, 0);
    2.31 +        __ slt(AT, T1, AT);
    2.32 +      }
    2.33 +
    2.34        __ bne(AT, R0, dispatch);
    2.35        __ delayed()->nop();
    2.36  
    2.37 @@ -1947,11 +1952,14 @@
    2.38        __ test_method_data_pointer(T1, profile_method);
    2.39  
    2.40        if (UseOnStackReplacement) {
    2.41 -        // check for overflow against ebx which is the MDO taken count
    2.42 -        __ li(AT, (long)&InvocationCounter::InterpreterBackwardBranchLimit);
    2.43 -        __ lw(AT, AT, 0);
    2.44 -        // the value Rnext Is get from the beginning profile_taken_branch
    2.45 -        __ slt(AT, T2, AT);
    2.46 +        if (Assembler::is_simm16(InvocationCounter::InterpreterBackwardBranchLimit)) {
    2.47 +          __ slti(AT, T2, InvocationCounter::InterpreterBackwardBranchLimit);
    2.48 +        } else {
    2.49 +          __ li(AT, (long)&InvocationCounter::InterpreterBackwardBranchLimit);
    2.50 +          __ lw(AT, AT, 0);
    2.51 +          __ slt(AT, T2, AT);
    2.52 +        }
    2.53 +
    2.54          __ bne(AT, R0, dispatch);
    2.55          __ delayed()->nop();
    2.56  

mercurial