src/cpu/x86/vm/interpreter_x86_32.cpp

Sat, 29 Sep 2012 06:40:00 -0400

author
coleenp
date
Sat, 29 Sep 2012 06:40:00 -0400
changeset 4142
d8ce2825b193
parent 4037
da91efe96a93
child 4318
cd3d6a6b95d9
permissions
-rw-r--r--

8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
Summary: Capitalize these metadata types (and objArrayKlass)
Reviewed-by: stefank, twisti, kvn

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 1997, 2012, 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"
coleenp@4037 33 #include "oops/methodData.hpp"
coleenp@4037 34 #include "oops/method.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 //------------------------------------------------------------------------------------------------------------------------
duke@435 55
duke@435 56 address AbstractInterpreterGenerator::generate_slow_signature_handler() {
duke@435 57 address entry = __ pc();
duke@435 58 // rbx,: method
duke@435 59 // rcx: temporary
duke@435 60 // rdi: pointer to locals
duke@435 61 // rsp: end of copied parameters area
never@739 62 __ mov(rcx, rsp);
duke@435 63 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), rbx, rdi, rcx);
duke@435 64 __ ret(0);
duke@435 65 return entry;
duke@435 66 }
duke@435 67
duke@435 68
duke@435 69 //
duke@435 70 // Various method entries (that c++ and asm interpreter agree upon)
duke@435 71 //------------------------------------------------------------------------------------------------------------------------
duke@435 72 //
duke@435 73 //
duke@435 74
duke@435 75 // Empty method, generate a very fast return.
duke@435 76
duke@435 77 address InterpreterGenerator::generate_empty_entry(void) {
duke@435 78
coleenp@4037 79 // rbx,: Method*
duke@435 80 // rcx: receiver (unused)
duke@435 81 // rsi: previous interpreter state (C++ interpreter) must preserve
duke@435 82 // rsi: sender sp must set sp to this value on return
duke@435 83
duke@435 84 if (!UseFastEmptyMethods) return NULL;
duke@435 85
duke@435 86 address entry_point = __ pc();
duke@435 87
duke@435 88 // If we need a safepoint check, generate full interpreter entry.
duke@435 89 Label slow_path;
duke@435 90 ExternalAddress state(SafepointSynchronize::address_of_state());
duke@435 91 __ cmp32(ExternalAddress(SafepointSynchronize::address_of_state()),
duke@435 92 SafepointSynchronize::_not_synchronized);
duke@435 93 __ jcc(Assembler::notEqual, slow_path);
duke@435 94
duke@435 95 // do nothing for empty methods (do not even increment invocation counter)
duke@435 96 // Code: _return
duke@435 97 // _return
duke@435 98 // return w/o popping parameters
never@739 99 __ pop(rax);
never@739 100 __ mov(rsp, rsi);
duke@435 101 __ jmp(rax);
duke@435 102
duke@435 103 __ bind(slow_path);
duke@435 104 (void) generate_normal_entry(false);
duke@435 105 return entry_point;
duke@435 106 }
duke@435 107
duke@435 108 address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {
duke@435 109
coleenp@4037 110 // rbx,: Method*
duke@435 111 // rcx: scratrch
duke@435 112 // rsi: sender sp
duke@435 113
duke@435 114 if (!InlineIntrinsics) return NULL; // Generate a vanilla entry
duke@435 115
duke@435 116 address entry_point = __ pc();
duke@435 117
duke@435 118 // These don't need a safepoint check because they aren't virtually
duke@435 119 // callable. We won't enter these intrinsics from compiled code.
duke@435 120 // If in the future we added an intrinsic which was virtually callable
duke@435 121 // we'd have to worry about how to safepoint so that this code is used.
duke@435 122
duke@435 123 // mathematical functions inlined by compiler
duke@435 124 // (interpreter must provide identical implementation
duke@435 125 // in order to avoid monotonicity bugs when switching
duke@435 126 // from interpreter to compiler in the middle of some
duke@435 127 // computation)
duke@435 128 //
duke@435 129 // stack: [ ret adr ] <-- rsp
duke@435 130 // [ lo(arg) ]
duke@435 131 // [ hi(arg) ]
duke@435 132 //
duke@435 133
duke@435 134 // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
duke@435 135 // native methods. Interpreter::method_kind(...) does a check for
duke@435 136 // native methods first before checking for intrinsic methods and
duke@435 137 // thus will never select this entry point. Make sure it is not
duke@435 138 // called accidentally since the SharedRuntime entry points will
duke@435 139 // not work for JDK 1.2.
duke@435 140 //
duke@435 141 // We no longer need to check for JDK 1.2 since it's EOL'ed.
duke@435 142 // The following check existed in pre 1.6 implementation,
duke@435 143 // if (Universe::is_jdk12x_version()) {
duke@435 144 // __ should_not_reach_here();
duke@435 145 // }
duke@435 146 // Universe::is_jdk12x_version() always returns false since
duke@435 147 // the JDK version is not yet determined when this method is called.
duke@435 148 // This method is called during interpreter_init() whereas
duke@435 149 // JDK version is only determined when universe2_init() is called.
duke@435 150
duke@435 151 // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
duke@435 152 // java methods. Interpreter::method_kind(...) will select
duke@435 153 // this entry point for the corresponding methods in JDK 1.3.
duke@435 154 // get argument
twisti@1861 155 __ fld_d(Address(rsp, 1*wordSize));
duke@435 156 switch (kind) {
duke@435 157 case Interpreter::java_lang_math_sin :
duke@435 158 __ trigfunc('s');
duke@435 159 break;
duke@435 160 case Interpreter::java_lang_math_cos :
duke@435 161 __ trigfunc('c');
duke@435 162 break;
duke@435 163 case Interpreter::java_lang_math_tan :
duke@435 164 __ trigfunc('t');
duke@435 165 break;
duke@435 166 case Interpreter::java_lang_math_sqrt:
duke@435 167 __ fsqrt();
duke@435 168 break;
duke@435 169 case Interpreter::java_lang_math_abs:
duke@435 170 __ fabs();
duke@435 171 break;
duke@435 172 case Interpreter::java_lang_math_log:
duke@435 173 __ flog();
duke@435 174 // Store to stack to convert 80bit precision back to 64bits
duke@435 175 __ push_fTOS();
duke@435 176 __ pop_fTOS();
duke@435 177 break;
duke@435 178 case Interpreter::java_lang_math_log10:
duke@435 179 __ flog10();
duke@435 180 // Store to stack to convert 80bit precision back to 64bits
duke@435 181 __ push_fTOS();
duke@435 182 __ pop_fTOS();
duke@435 183 break;
roland@3787 184 case Interpreter::java_lang_math_pow:
roland@3787 185 __ fld_d(Address(rsp, 3*wordSize)); // second argument
roland@3787 186 __ pow_with_fallback(0);
roland@3787 187 // Store to stack to convert 80bit precision back to 64bits
roland@3787 188 __ push_fTOS();
roland@3787 189 __ pop_fTOS();
roland@3787 190 break;
roland@3787 191 case Interpreter::java_lang_math_exp:
roland@3787 192 __ exp_with_fallback(0);
roland@3787 193 // Store to stack to convert 80bit precision back to 64bits
roland@3787 194 __ push_fTOS();
roland@3787 195 __ pop_fTOS();
roland@3787 196 break;
duke@435 197 default :
duke@435 198 ShouldNotReachHere();
duke@435 199 }
duke@435 200
duke@435 201 // return double result in xmm0 for interpreter and compilers.
duke@435 202 if (UseSSE >= 2) {
never@739 203 __ subptr(rsp, 2*wordSize);
duke@435 204 __ fstp_d(Address(rsp, 0));
duke@435 205 __ movdbl(xmm0, Address(rsp, 0));
never@739 206 __ addptr(rsp, 2*wordSize);
duke@435 207 }
duke@435 208
duke@435 209 // done, result in FPU ST(0) or XMM0
never@739 210 __ pop(rdi); // get return address
never@739 211 __ mov(rsp, rsi); // set sp to sender sp
duke@435 212 __ jmp(rdi);
duke@435 213
duke@435 214 return entry_point;
duke@435 215 }
duke@435 216
duke@435 217
duke@435 218 // Abstract method entry
duke@435 219 // Attempt to execute abstract method. Throw exception
duke@435 220 address InterpreterGenerator::generate_abstract_entry(void) {
duke@435 221
coleenp@4037 222 // rbx,: Method*
duke@435 223 // rcx: receiver (unused)
duke@435 224 // rsi: previous interpreter state (C++ interpreter) must preserve
duke@435 225
duke@435 226 // rsi: sender SP
duke@435 227
duke@435 228 address entry_point = __ pc();
duke@435 229
duke@435 230 // abstract method entry
duke@435 231
jrose@1145 232 // pop return address, reset last_sp to NULL
jrose@1145 233 __ empty_expression_stack();
jrose@1145 234 __ restore_bcp(); // rsi must be correct for exception handler (was destroyed)
jrose@1145 235 __ restore_locals(); // make sure locals pointer is correct as well (was destroyed)
jrose@1145 236
duke@435 237 // throw exception
duke@435 238 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
duke@435 239 // the call_VM checks for exception, so we should never return here.
duke@435 240 __ should_not_reach_here();
duke@435 241
duke@435 242 return entry_point;
duke@435 243 }
duke@435 244
jrose@1145 245
duke@435 246 void Deoptimization::unwind_callee_save_values(frame* f, vframeArray* vframe_array) {
duke@435 247
duke@435 248 // This code is sort of the equivalent of C2IAdapter::setup_stack_frame back in
duke@435 249 // the days we had adapter frames. When we deoptimize a situation where a
duke@435 250 // compiled caller calls a compiled caller will have registers it expects
duke@435 251 // to survive the call to the callee. If we deoptimize the callee the only
duke@435 252 // way we can restore these registers is to have the oldest interpreter
duke@435 253 // frame that we create restore these values. That is what this routine
duke@435 254 // will accomplish.
duke@435 255
duke@435 256 // At the moment we have modified c2 to not have any callee save registers
duke@435 257 // so this problem does not exist and this routine is just a place holder.
duke@435 258
duke@435 259 assert(f->is_interpreted_frame(), "must be interpreted");
duke@435 260 }

mercurial