annotate src/cpu/x86/vm/interpreter_x86_32.cpp @ 3602:da91efe96a93

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