hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp
author coleenp
Tue, 22 Dec 2015 11:11:29 -0500
changeset 35214 d86005e0b4c2
parent 34651 07b1cc0f6040
child 35232 76aed99c0ddd
permissions -rw-r--r--
8074457: Remove the non-Zero CPP Interpreter Summary: Remove cppInterpreter assembly files and reorganize InterpreterGenerator includes Reviewed-by: goetz, bdelsart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
34651
07b1cc0f6040 8144534: Refactor templateInterpreter and templateInterpreterGenerator functions
coleenp
parents: 33465
diff changeset
     2
 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5419
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 13728
diff changeset
    26
#include "asm/macroAssembler.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "interpreter/bytecodeHistogram.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "interpreter/interpreterRuntime.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 23203
diff changeset
    30
#include "interpreter/interp_masm.hpp"
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
    31
#include "interpreter/templateInterpreterGenerator.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "interpreter/templateTable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "oops/arrayOop.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    34
#include "oops/methodData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    35
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "prims/jvmtiThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "prims/methodHandles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "runtime/arguments.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    41
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    42
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    43
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    44
#include "runtime/synchronizer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    45
#include "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    46
#include "runtime/vframeArray.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    47
#include "utilities/debug.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    48
#ifdef COMPILER1
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    49
#include "c1/c1_Runtime1.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    50
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
#define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // rbx,: method
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // rcx: temporary
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // rdi: pointer to locals
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // rsp: end of copied parameters area
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    62
  __ mov(rcx, rsp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 34651
diff changeset
    69
address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    71
  // rbx,: Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // rcx: scratrch
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // rsi: sender sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // These don't need a safepoint check because they aren't virtually
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // callable. We won't enter these intrinsics from compiled code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // If in the future we added an intrinsic which was virtually callable
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // we'd have to worry about how to safepoint so that this code is used.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // mathematical functions inlined by compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // (interpreter must provide identical implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // in order to avoid monotonicity bugs when switching
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // from interpreter to compiler in the middle of some
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // computation)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // stack: [ ret adr ] <-- rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  //        [ lo(arg) ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  //        [ hi(arg) ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  //       native methods. Interpreter::method_kind(...) does a check for
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  //       native methods first before checking for intrinsic methods and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  //       thus will never select this entry point. Make sure it is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  //       called accidentally since the SharedRuntime entry points will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  //       not work for JDK 1.2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  // We no longer need to check for JDK 1.2 since it's EOL'ed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // The following check existed in pre 1.6 implementation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  //    if (Universe::is_jdk12x_version()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  //      __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // Universe::is_jdk12x_version() always returns false since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // the JDK version is not yet determined when this method is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // This method is called during interpreter_init() whereas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // JDK version is only determined when universe2_init() is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  //       java methods.  Interpreter::method_kind(...) will select
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  //       this entry point for the corresponding methods in JDK 1.3.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // get argument
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 2534
diff changeset
   116
  __ fld_d(Address(rsp, 1*wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    case Interpreter::java_lang_math_sin :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
        __ trigfunc('s');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    case Interpreter::java_lang_math_cos :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
        __ trigfunc('c');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    case Interpreter::java_lang_math_tan :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
        __ trigfunc('t');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    case Interpreter::java_lang_math_sqrt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
        __ fsqrt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    case Interpreter::java_lang_math_abs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
        __ fabs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    case Interpreter::java_lang_math_log:
33465
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   134
        __ subptr(rsp, 2 * wordSize);
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   135
        __ fstp_d(Address(rsp, 0));
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   136
        if (VM_Version::supports_sse2()) {
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   137
          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog())));
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   138
        }
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   139
        else {
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   140
          __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog)));
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   141
        }
6063f28a6efb 8139575: Update for x86 log in the math lib
iveresov
parents: 33089
diff changeset
   142
        __ addptr(rsp, 2 * wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    case Interpreter::java_lang_math_log10:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
        __ flog10();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
        // Store to stack to convert 80bit precision back to 64bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
        __ push_fTOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
        __ pop_fTOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
        break;
12739
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   150
    case Interpreter::java_lang_math_pow:
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   151
      __ fld_d(Address(rsp, 3*wordSize)); // second argument
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   152
      __ pow_with_fallback(0);
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   153
      // Store to stack to convert 80bit precision back to 64bits
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   154
      __ push_fTOS();
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   155
      __ pop_fTOS();
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   156
      break;
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   157
    case Interpreter::java_lang_math_exp:
33089
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   158
      __ subptr(rsp, 2*wordSize);
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   159
      __ fstp_d(Address(rsp, 0));
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   160
      if (VM_Version::supports_sse2()) {
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   161
        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp())));
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   162
      } else {
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   163
        __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp)));
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   164
      }
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   165
      __ addptr(rsp, 2*wordSize);
f4e956ed8b43 8132207: update for x86 exp in the math lib
iveresov
parents: 25950
diff changeset
   166
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    default                              :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // return double result in xmm0 for interpreter and compilers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  if (UseSSE >= 2) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   173
    __ subptr(rsp, 2*wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    __ fstp_d(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    __ movdbl(xmm0, Address(rsp, 0));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   176
    __ addptr(rsp, 2*wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // done, result in FPU ST(0) or XMM0
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   180
  __ pop(rdi);                               // get return address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   181
  __ mov(rsp, rsi);                          // set sp to sender sp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  __ jmp(rdi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
}