src/cpu/x86/vm/interpreter_x86_32.cpp

Thu, 07 Oct 2010 08:06:06 -0700

author
coleenp
date
Thu, 07 Oct 2010 08:06:06 -0700
changeset 2222
b6aedd1acdc0
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6983240: guarantee((Solaris::min_stack_allowed >= (StackYellowPages+StackRedPages...) wrong
Summary: min_stack_allowed is a compile time constant and Stack*Pages are settable
Reviewed-by: dholmes, kvn

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

mercurial