hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp
author roland
Tue, 15 May 2012 10:10:23 +0200
changeset 12739 09f26b73ae66
parent 9636 363ca5579aff
child 13391 30245956af37
permissions -rw-r--r--
7133857: exp() and pow() should use the x87 ISA on x86 Summary: use x87 instructions to implement exp() and pow() in interpreter/c1/c2. Reviewed-by: kvn, never, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
8315
1503f9d7681f 7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122
twisti
parents: 7397
diff changeset
     2
 * Copyright (c) 1997, 2011, 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"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "asm/assembler.hpp"
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/interpreterGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "interpreter/interpreterRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "interpreter/templateTable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "oops/arrayOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "oops/methodDataOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "oops/methodOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    35
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    36
#include "prims/jvmtiExport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    37
#include "prims/jvmtiThreadState.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    38
#include "prims/methodHandles.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    39
#include "runtime/arguments.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    40
#include "runtime/deoptimization.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
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
// Various method entries (that c++ and asm interpreter agree upon)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
// Empty method, generate a very fast return.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
address InterpreterGenerator::generate_empty_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  // rbx,: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // rcx: receiver (unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // rsi: previous interpreter state (C++ interpreter) must preserve
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // rsi: sender sp must set sp to this value on return
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  if (!UseFastEmptyMethods) return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // If we need a safepoint check, generate full interpreter entry.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  Label slow_path;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  ExternalAddress state(SafepointSynchronize::address_of_state());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
           SafepointSynchronize::_not_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  __ jcc(Assembler::notEqual, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // do nothing for empty methods (do not even increment invocation counter)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // Code: _return
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // _return
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  // return w/o popping parameters
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    99
  __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   100
  __ mov(rsp, rsi);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  __ jmp(rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  __ bind(slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  (void) generate_normal_entry(false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // rbx,: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  // rcx: scratrch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // rsi: sender sp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // These don't need a safepoint check because they aren't virtually
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // callable. We won't enter these intrinsics from compiled code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // If in the future we added an intrinsic which was virtually callable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // we'd have to worry about how to safepoint so that this code is used.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // mathematical functions inlined by compiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // (interpreter must provide identical implementation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // in order to avoid monotonicity bugs when switching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // from interpreter to compiler in the middle of some
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // computation)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // stack: [ ret adr ] <-- rsp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  //        [ lo(arg) ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  //        [ hi(arg) ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  //       native methods. Interpreter::method_kind(...) does a check for
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  //       native methods first before checking for intrinsic methods and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  //       thus will never select this entry point. Make sure it is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  //       called accidentally since the SharedRuntime entry points will
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  //       not work for JDK 1.2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // We no longer need to check for JDK 1.2 since it's EOL'ed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // The following check existed in pre 1.6 implementation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  //    if (Universe::is_jdk12x_version()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  //      __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  //    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // Universe::is_jdk12x_version() always returns false since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // the JDK version is not yet determined when this method is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // This method is called during interpreter_init() whereas
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // JDK version is only determined when universe2_init() is called.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  //       java methods.  Interpreter::method_kind(...) will select
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  //       this entry point for the corresponding methods in JDK 1.3.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // get argument
5419
f2e8cc8c12ea 6943304: remove tagged stack interpreter
twisti
parents: 2534
diff changeset
   155
  __ fld_d(Address(rsp, 1*wordSize));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  switch (kind) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    case Interpreter::java_lang_math_sin :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        __ trigfunc('s');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    case Interpreter::java_lang_math_cos :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
        __ trigfunc('c');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    case Interpreter::java_lang_math_tan :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
        __ trigfunc('t');
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    case Interpreter::java_lang_math_sqrt:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
        __ fsqrt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    case Interpreter::java_lang_math_abs:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
        __ fabs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    case Interpreter::java_lang_math_log:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
        __ flog();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
        // Store to stack to convert 80bit precision back to 64bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
        __ push_fTOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
        __ pop_fTOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    case Interpreter::java_lang_math_log10:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
        __ flog10();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
        // Store to stack to convert 80bit precision back to 64bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
        __ push_fTOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
        __ pop_fTOS();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
        break;
12739
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   184
    case Interpreter::java_lang_math_pow:
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   185
      __ 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
   186
      __ pow_with_fallback(0);
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   187
      // 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
   188
      __ push_fTOS();
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   189
      __ pop_fTOS();
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   190
      break;
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   191
    case Interpreter::java_lang_math_exp:
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   192
      __ exp_with_fallback(0);
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   193
      // 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
   194
      __ push_fTOS();
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   195
      __ pop_fTOS();
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 9636
diff changeset
   196
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    default                              :
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
        ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  // return double result in xmm0 for interpreter and compilers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  if (UseSSE >= 2) {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   203
    __ subptr(rsp, 2*wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    __ fstp_d(Address(rsp, 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    __ movdbl(xmm0, Address(rsp, 0));
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   206
    __ addptr(rsp, 2*wordSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  // done, result in FPU ST(0) or XMM0
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   210
  __ pop(rdi);                               // get return address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   211
  __ mov(rsp, rsi);                          // set sp to sender sp
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  __ jmp(rdi);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
// Abstract method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
// Attempt to execute abstract method. Throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
address InterpreterGenerator::generate_abstract_entry(void) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  // rbx,: methodOop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // rcx: receiver (unused)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // rsi: previous interpreter state (C++ interpreter) must preserve
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // rsi: sender SP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  address entry_point = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  // abstract method entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   232
  //  pop return address, reset last_sp to NULL
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   233
  __ empty_expression_stack();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   234
  __ restore_bcp();      // rsi must be correct for exception handler   (was destroyed)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   235
  __ restore_locals();   // make sure locals pointer is correct as well (was destroyed)
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   236
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  // throw exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // the call_VM checks for exception, so we should never return here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  return entry_point;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   245
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   246
// Method handle invoker
8676
9098d4e927e1 7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents: 8315
diff changeset
   247
// Dispatch a method of the form java.lang.invoke.MethodHandles::invoke(...)
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   248
address InterpreterGenerator::generate_method_handle_entry(void) {
8883
5569135acca3 6817525: turn on method handle functionality by default for JSR 292
twisti
parents: 8676
diff changeset
   249
  if (!EnableInvokeDynamic) {
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   250
    return generate_abstract_entry();
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   251
  }
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   252
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   253
  address entry_point = MethodHandles::generate_method_handle_interpreter_entry(_masm);
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   254
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   255
  return entry_point;
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   256
}
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1217
diff changeset
   257
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // the days we had adapter frames. When we deoptimize a situation where a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  // compiled caller calls a compiled caller will have registers it expects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  // to survive the call to the callee. If we deoptimize the callee the only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  // way we can restore these registers is to have the oldest interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  // frame that we create restore these values. That is what this routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  // will accomplish.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  // At the moment we have modified c2 to not have any callee save registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  // so this problem does not exist and this routine is just a place holder.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  assert(f->is_interpreted_frame(), "must be interpreted");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
}