src/cpu/x86/vm/interpreterRT_x86_32.cpp

Fri, 03 Sep 2010 17:51:07 -0700

author
iveresov
date
Fri, 03 Sep 2010 17:51:07 -0700
changeset 2138
d5d065957597
parent 2036
126ea7725993
child 2314
f95d63e2154a
permissions
-rw-r--r--

6953144: Tiered compilation
Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation.
Reviewed-by: kvn, never, phh, twisti

duke@435 1 /*
trims@1907 2 * Copyright (c) 1998, 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/_interpreterRT_x86_32.cpp.incl"
duke@435 27
duke@435 28
duke@435 29 #define __ _masm->
duke@435 30
duke@435 31
duke@435 32 // Implementation of SignatureHandlerGenerator
duke@435 33 void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {
duke@435 34 move(offset(), jni_offset() + 1);
duke@435 35 }
duke@435 36
bobv@2036 37 void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
bobv@2036 38 move(offset(), jni_offset() + 1);
bobv@2036 39 }
bobv@2036 40
duke@435 41 void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {
duke@435 42 move(offset(), jni_offset() + 2);
duke@435 43 move(offset() + 1, jni_offset() + 1);
duke@435 44 }
duke@435 45
duke@435 46 void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {
duke@435 47 box (offset(), jni_offset() + 1);
duke@435 48 }
duke@435 49
duke@435 50 void InterpreterRuntime::SignatureHandlerGenerator::move(int from_offset, int to_offset) {
duke@435 51 __ movl(temp(), Address(from(), Interpreter::local_offset_in_bytes(from_offset)));
duke@435 52 __ movl(Address(to(), to_offset * wordSize), temp());
duke@435 53 }
duke@435 54
duke@435 55
duke@435 56 void InterpreterRuntime::SignatureHandlerGenerator::box(int from_offset, int to_offset) {
never@739 57 __ lea(temp(), Address(from(), Interpreter::local_offset_in_bytes(from_offset)));
never@739 58 __ cmpptr(Address(from(), Interpreter::local_offset_in_bytes(from_offset)), (int32_t)NULL_WORD); // do not use temp() to avoid AGI
duke@435 59 Label L;
duke@435 60 __ jcc(Assembler::notZero, L);
xlu@947 61 __ movptr(temp(), NULL_WORD);
duke@435 62 __ bind(L);
never@739 63 __ movptr(Address(to(), to_offset * wordSize), temp());
duke@435 64 }
duke@435 65
duke@435 66
duke@435 67 void InterpreterRuntime::SignatureHandlerGenerator::generate( uint64_t fingerprint) {
duke@435 68 // generate code to handle arguments
duke@435 69 iterate(fingerprint);
duke@435 70 // return result handler
duke@435 71 __ lea(rax,
duke@435 72 ExternalAddress((address)Interpreter::result_handler(method()->result_type())));
duke@435 73 // return
duke@435 74 __ ret(0);
duke@435 75 __ flush();
duke@435 76 }
duke@435 77
duke@435 78
duke@435 79 Register InterpreterRuntime::SignatureHandlerGenerator::from() { return rdi; }
duke@435 80 Register InterpreterRuntime::SignatureHandlerGenerator::to() { return rsp; }
duke@435 81 Register InterpreterRuntime::SignatureHandlerGenerator::temp() { return rcx; }
duke@435 82
duke@435 83
duke@435 84 // Implementation of SignatureHandlerLibrary
duke@435 85
duke@435 86 void SignatureHandlerLibrary::pd_set_handler(address handler) {}
duke@435 87
duke@435 88 class SlowSignatureHandler: public NativeSignatureIterator {
duke@435 89 private:
duke@435 90 address _from;
duke@435 91 intptr_t* _to;
duke@435 92
duke@435 93 virtual void pass_int() {
duke@435 94 *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));
twisti@1861 95 _from -= Interpreter::stackElementSize;
duke@435 96 }
duke@435 97
bobv@2036 98 virtual void pass_float() {
bobv@2036 99 *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));
bobv@2036 100 _from -= Interpreter::stackElementSize;
bobv@2036 101 }
bobv@2036 102
duke@435 103 virtual void pass_long() {
duke@435 104 _to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1));
duke@435 105 _to[1] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(0));
duke@435 106 _to += 2;
twisti@1861 107 _from -= 2*Interpreter::stackElementSize;
duke@435 108 }
duke@435 109
duke@435 110 virtual void pass_object() {
duke@435 111 // pass address of from
duke@435 112 intptr_t from_addr = (intptr_t)(_from + Interpreter::local_offset_in_bytes(0));
xlu@968 113 *_to++ = (*(intptr_t*)from_addr == 0) ? NULL_WORD : from_addr;
twisti@1861 114 _from -= Interpreter::stackElementSize;
duke@435 115 }
duke@435 116
duke@435 117 public:
duke@435 118 SlowSignatureHandler(methodHandle method, address from, intptr_t* to) :
duke@435 119 NativeSignatureIterator(method) {
duke@435 120 _from = from;
duke@435 121 _to = to + (is_static() ? 2 : 1);
duke@435 122 }
duke@435 123 };
duke@435 124
duke@435 125 IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(JavaThread* thread, methodOopDesc* method, intptr_t* from, intptr_t* to))
duke@435 126 methodHandle m(thread, (methodOop)method);
duke@435 127 assert(m->is_native(), "sanity check");
duke@435 128 // handle arguments
duke@435 129 SlowSignatureHandler(m, (address)from, to + 1).iterate(UCONST64(-1));
duke@435 130 // return result handler
duke@435 131 return Interpreter::result_handler(m->result_type());
duke@435 132 IRT_END

mercurial