src/cpu/x86/vm/interpreter_x86_32.cpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 2552
638119ce7cfd
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

duke@435 1 /*
trims@1907 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "asm/assembler.hpp"
stefank@2314 27 #include "interpreter/bytecodeHistogram.hpp"
stefank@2314 28 #include "interpreter/interpreter.hpp"
stefank@2314 29 #include "interpreter/interpreterGenerator.hpp"
stefank@2314 30 #include "interpreter/interpreterRuntime.hpp"
stefank@2314 31 #include "interpreter/templateTable.hpp"
stefank@2314 32 #include "oops/arrayOop.hpp"
stefank@2314 33 #include "oops/methodDataOop.hpp"
stefank@2314 34 #include "oops/methodOop.hpp"
stefank@2314 35 #include "oops/oop.inline.hpp"
stefank@2314 36 #include "prims/jvmtiExport.hpp"
stefank@2314 37 #include "prims/jvmtiThreadState.hpp"
stefank@2314 38 #include "prims/methodHandles.hpp"
stefank@2314 39 #include "runtime/arguments.hpp"
stefank@2314 40 #include "runtime/deoptimization.hpp"
stefank@2314 41 #include "runtime/frame.inline.hpp"
stefank@2314 42 #include "runtime/sharedRuntime.hpp"
stefank@2314 43 #include "runtime/stubRoutines.hpp"
stefank@2314 44 #include "runtime/synchronizer.hpp"
stefank@2314 45 #include "runtime/timer.hpp"
stefank@2314 46 #include "runtime/vframeArray.hpp"
stefank@2314 47 #include "utilities/debug.hpp"
stefank@2314 48 #ifdef COMPILER1
stefank@2314 49 #include "c1/c1_Runtime1.hpp"
stefank@2314 50 #endif
duke@435 51
duke@435 52 #define __ _masm->
duke@435 53
duke@435 54 // Initialize the sentinel used to distinguish an interpreter return address.
duke@435 55 const int Interpreter::return_sentinel = 0xfeedbeed;
duke@435 56
duke@435 57 //------------------------------------------------------------------------------------------------------------------------
duke@435 58
duke@435 59 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
duke@435 60 address entry = __ pc();
duke@435 61 // rbx,: method
duke@435 62 // rcx: temporary
duke@435 63 // rdi: pointer to locals
duke@435 64 // rsp: end of copied parameters area
never@739 65 __ mov(rcx, rsp);
duke@435 66 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
duke@435 67 __ ret(0);
duke@435 68 return entry;
duke@435 69 }
duke@435 70
duke@435 71
duke@435 72 //
duke@435 73 // Various method entries (that c++ and asm interpreter agree upon)
duke@435 74 //------------------------------------------------------------------------------------------------------------------------
duke@435 75 //
duke@435 76 //
duke@435 77
duke@435 78 // Empty method, generate a very fast return.
duke@435 79
duke@435 80 address InterpreterGenerator::generate_empty_entry(void) {
duke@435 81
duke@435 82 // rbx,: methodOop
duke@435 83 // rcx: receiver (unused)
duke@435 84 // rsi: previous interpreter state (C++ interpreter) must preserve
duke@435 85 // rsi: sender sp must set sp to this value on return
duke@435 86
duke@435 87 if (!UseFastEmptyMethods) return NULL;
duke@435 88
duke@435 89 address entry_point = __ pc();
duke@435 90
duke@435 91 // If we need a safepoint check, generate full interpreter entry.
duke@435 92 Label slow_path;
duke@435 93 ExternalAddress state(SafepointSynchronize::address_of_state());
duke@435 94 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
duke@435 95 SafepointSynchronize::_not_synchronized);
duke@435 96 __ jcc(Assembler::notEqual, slow_path);
duke@435 97
duke@435 98 // do nothing for empty methods (do not even increment invocation counter)
duke@435 99 // Code: _return
duke@435 100 // _return
duke@435 101 // return w/o popping parameters
never@739 102 __ pop(rax);
never@739 103 __ mov(rsp, rsi);
duke@435 104 __ jmp(rax);
duke@435 105
duke@435 106 __ bind(slow_path);
duke@435 107 (void) generate_normal_entry(false);
duke@435 108 return entry_point;
duke@435 109 }
duke@435 110
duke@435 111 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
duke@435 112
duke@435 113 // rbx,: methodOop
duke@435 114 // rcx: scratrch
duke@435 115 // rsi: sender sp
duke@435 116
duke@435 117 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
duke@435 118
duke@435 119 address entry_point = __ pc();
duke@435 120
duke@435 121 // These don't need a safepoint check because they aren't virtually
duke@435 122 // callable. We won't enter these intrinsics from compiled code.
duke@435 123 // If in the future we added an intrinsic which was virtually callable
duke@435 124 // we'd have to worry about how to safepoint so that this code is used.
duke@435 125
duke@435 126 // mathematical functions inlined by compiler
duke@435 127 // (interpreter must provide identical implementation
duke@435 128 // in order to avoid monotonicity bugs when switching
duke@435 129 // from interpreter to compiler in the middle of some
duke@435 130 // computation)
duke@435 131 //
duke@435 132 // stack: [ ret adr ] <-- rsp
duke@435 133 // [ lo(arg) ]
duke@435 134 // [ hi(arg) ]
duke@435 135 //
duke@435 136
duke@435 137 // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
duke@435 138 // native methods. Interpreter::method_kind(...) does a check for
duke@435 139 // native methods first before checking for intrinsic methods and
duke@435 140 // thus will never select this entry point. Make sure it is not
duke@435 141 // called accidentally since the SharedRuntime entry points will
duke@435 142 // not work for JDK 1.2.
duke@435 143 //
duke@435 144 // We no longer need to check for JDK 1.2 since it's EOL'ed.
duke@435 145 // The following check existed in pre 1.6 implementation,
duke@435 146 // if (Universe::is_jdk12x_version()) {
duke@435 147 // __ should_not_reach_here();
duke@435 148 // }
duke@435 149 // Universe::is_jdk12x_version() always returns false since
duke@435 150 // the JDK version is not yet determined when this method is called.
duke@435 151 // This method is called during interpreter_init() whereas
duke@435 152 // JDK version is only determined when universe2_init() is called.
duke@435 153
duke@435 154 // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
duke@435 155 // java methods. Interpreter::method_kind(...) will select
duke@435 156 // this entry point for the corresponding methods in JDK 1.3.
duke@435 157 // get argument
twisti@1861 158 __ fld_d(Address(rsp, 1*wordSize));
duke@435 159 switch (kind) {
duke@435 160 case Interpreter::java_lang_math_sin :
duke@435 161 __ trigfunc('s');
duke@435 162 break;
duke@435 163 case Interpreter::java_lang_math_cos :
duke@435 164 __ trigfunc('c');
duke@435 165 break;
duke@435 166 case Interpreter::java_lang_math_tan :
duke@435 167 __ trigfunc('t');
duke@435 168 break;
duke@435 169 case Interpreter::java_lang_math_sqrt:
duke@435 170 __ fsqrt();
duke@435 171 break;
duke@435 172 case Interpreter::java_lang_math_abs:
duke@435 173 __ fabs();
duke@435 174 break;
duke@435 175 case Interpreter::java_lang_math_log:
duke@435 176 __ flog();
duke@435 177 // Store to stack to convert 80bit precision back to 64bits
duke@435 178 __ push_fTOS();
duke@435 179 __ pop_fTOS();
duke@435 180 break;
duke@435 181 case Interpreter::java_lang_math_log10:
duke@435 182 __ flog10();
duke@435 183 // Store to stack to convert 80bit precision back to 64bits
duke@435 184 __ push_fTOS();
duke@435 185 __ pop_fTOS();
duke@435 186 break;
duke@435 187 default :
duke@435 188 ShouldNotReachHere();
duke@435 189 }
duke@435 190
duke@435 191 // return double result in xmm0 for interpreter and compilers.
duke@435 192 if (UseSSE >= 2) {
never@739 193 __ subptr(rsp, 2*wordSize);
duke@435 194 __ fstp_d(Address(rsp, 0));
duke@435 195 __ movdbl(xmm0, Address(rsp, 0));
never@739 196 __ addptr(rsp, 2*wordSize);
duke@435 197 }
duke@435 198
duke@435 199 // done, result in FPU ST(0) or XMM0
never@739 200 __ pop(rdi); // get return address
never@739 201 __ mov(rsp, rsi); // set sp to sender sp
duke@435 202 __ jmp(rdi);
duke@435 203
duke@435 204 return entry_point;
duke@435 205 }
duke@435 206
duke@435 207
duke@435 208 // Abstract method entry
duke@435 209 // Attempt to execute abstract method. Throw exception
duke@435 210 address InterpreterGenerator::generate_abstract_entry(void) {
duke@435 211
duke@435 212 // rbx,: methodOop
duke@435 213 // rcx: receiver (unused)
duke@435 214 // rsi: previous interpreter state (C++ interpreter) must preserve
duke@435 215
duke@435 216 // rsi: sender SP
duke@435 217
duke@435 218 address entry_point = __ pc();
duke@435 219
duke@435 220 // abstract method entry
duke@435 221
jrose@1145 222 // pop return address, reset last_sp to NULL
jrose@1145 223 __ empty_expression_stack();
jrose@1145 224 __ restore_bcp(); // rsi must be correct for exception handler (was destroyed)
jrose@1145 225 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed)
jrose@1145 226
duke@435 227 // throw exception
duke@435 228 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
duke@435 229 // the call_VM checks for exception, so we should never return here.
duke@435 230 __ should_not_reach_here();
duke@435 231
duke@435 232 return entry_point;
duke@435 233 }
duke@435 234
jrose@1145 235
jrose@1145 236 // Method handle invoker
jrose@1145 237 // Dispatch a method of the form java.dyn.MethodHandles::invoke(...)
jrose@1145 238 address InterpreterGenerator::generate_method_handle_entry(void) {
jrose@1145 239 if (!EnableMethodHandles) {
jrose@1145 240 return generate_abstract_entry();
jrose@1145 241 }
jrose@1145 242
jrose@1145 243 address entry_point = MethodHandles::generate_method_handle_interpreter_entry(_masm);
jrose@1145 244
jrose@1145 245 return entry_point;
jrose@1145 246 }
jrose@1145 247
jrose@1145 248
duke@435 249 // This method tells the deoptimizer how big an interpreted frame must be:
duke@435 250 int AbstractInterpreter::size_activation(methodOop method,
duke@435 251 int tempcount,
duke@435 252 int popframe_extra_args,
duke@435 253 int moncount,
duke@435 254 int callee_param_count,
duke@435 255 int callee_locals,
duke@435 256 bool is_top_frame) {
duke@435 257 return layout_activation(method,
duke@435 258 tempcount,
duke@435 259 popframe_extra_args,
duke@435 260 moncount,
duke@435 261 callee_param_count,
duke@435 262 callee_locals,
duke@435 263 (frame*) NULL,
duke@435 264 (frame*) NULL,
duke@435 265 is_top_frame);
duke@435 266 }
duke@435 267
duke@435 268 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
duke@435 269
duke@435 270 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
duke@435 271 // the days we had adapter frames. When we deoptimize a situation where a
duke@435 272 // compiled caller calls a compiled caller will have registers it expects
duke@435 273 // to survive the call to the callee. If we deoptimize the callee the only
duke@435 274 // way we can restore these registers is to have the oldest interpreter
duke@435 275 // frame that we create restore these values. That is what this routine
duke@435 276 // will accomplish.
duke@435 277
duke@435 278 // At the moment we have modified c2 to not have any callee save registers
duke@435 279 // so this problem does not exist and this routine is just a place holder.
duke@435 280
duke@435 281 assert(f->is_interpreted_frame(), "must be interpreted");
duke@435 282 }

mercurial