duke@435: /* trims@2708: * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "runtime/stackValueCollection.hpp" stefank@2314: #ifdef TARGET_ARCH_x86 stefank@2314: # include "jniTypes_x86.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_ARCH_sparc stefank@2314: # include "jniTypes_sparc.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_ARCH_zero stefank@2314: # include "jniTypes_zero.hpp" stefank@2314: #endif bobv@2508: #ifdef TARGET_ARCH_arm bobv@2508: # include "jniTypes_arm.hpp" bobv@2508: #endif bobv@2508: #ifdef TARGET_ARCH_ppc bobv@2508: # include "jniTypes_ppc.hpp" bobv@2508: #endif duke@435: duke@435: jint StackValueCollection::int_at(int slot) const { duke@435: intptr_t val = at(slot)->get_int(); duke@435: jint ival = *((jint*) (&val)); duke@435: return ival; duke@435: } duke@435: duke@435: jlong StackValueCollection::long_at(int slot) const { duke@435: #ifdef _LP64 duke@435: return at(slot+1)->get_int(); duke@435: #else duke@435: union { duke@435: jlong jl; duke@435: jint array[2]; duke@435: } value; duke@435: // Interpreter stack is reversed in memory: duke@435: // low memory location is in higher java local slot. duke@435: value.array[0] = at(slot+1)->get_int(); duke@435: value.array[1] = at(slot )->get_int(); duke@435: return value.jl; duke@435: #endif duke@435: } duke@435: duke@435: Handle StackValueCollection::obj_at(int slot) const { duke@435: return at(slot)->get_obj(); duke@435: } duke@435: duke@435: jfloat StackValueCollection::float_at(int slot) const { duke@435: intptr_t res = at(slot)->get_int(); duke@435: return *((jfloat*) (&res)); duke@435: } duke@435: duke@435: jdouble StackValueCollection::double_at(int slot) const { duke@435: #ifdef _LP64 duke@435: intptr_t res = at(slot+1)->get_int(); duke@435: return *((jdouble*) (&res)); duke@435: #else duke@435: union { duke@435: jdouble jd; duke@435: jint array[2]; duke@435: } value; duke@435: // Interpreter stack is reversed in memory: duke@435: // low memory location is in higher java local slot. duke@435: value.array[0] = at(slot+1)->get_int(); duke@435: value.array[1] = at(slot )->get_int(); duke@435: return value.jd; duke@435: #endif duke@435: } duke@435: duke@435: void StackValueCollection::set_int_at(int slot, jint value) { duke@435: intptr_t val; duke@435: *((jint*) (&val)) = value; duke@435: at(slot)->set_int(val); duke@435: } duke@435: duke@435: void StackValueCollection::set_long_at(int slot, jlong value) { duke@435: #ifdef _LP64 duke@435: at(slot+1)->set_int(value); duke@435: #else duke@435: union { duke@435: jlong jl; duke@435: jint array[2]; duke@435: } x; duke@435: // Interpreter stack is reversed in memory: duke@435: // low memory location is in higher java local slot. duke@435: x.jl = value; duke@435: at(slot+1)->set_int(x.array[0]); duke@435: at(slot+0)->set_int(x.array[1]); duke@435: #endif duke@435: } duke@435: duke@435: void StackValueCollection::set_obj_at(int slot, Handle value) { duke@435: at(slot)->set_obj(value); duke@435: } duke@435: duke@435: void StackValueCollection::set_float_at(int slot, jfloat value) { duke@435: #ifdef _LP64 duke@435: union { duke@435: intptr_t jd; duke@435: jint array[2]; duke@435: } val; duke@435: // Interpreter stores 32 bit floats in first half of 64 bit word. duke@435: val.array[0] = *(jint*)(&value); duke@435: val.array[1] = 0; duke@435: at(slot)->set_int(val.jd); duke@435: #else duke@435: at(slot)->set_int(*(jint*)(&value)); duke@435: #endif duke@435: } duke@435: duke@435: void StackValueCollection::set_double_at(int slot, jdouble value) { duke@435: #ifdef _LP64 duke@435: at(slot+1)->set_int(*(intptr_t*)(&value)); duke@435: #else duke@435: union { duke@435: jdouble jd; duke@435: jint array[2]; duke@435: } x; duke@435: // Interpreter stack is reversed in memory: duke@435: // low memory location is in higher java local slot. duke@435: x.jd = value; duke@435: at(slot+1)->set_int(x.array[0]); duke@435: at(slot+0)->set_int(x.array[1]); duke@435: #endif duke@435: } duke@435: duke@435: #ifndef PRODUCT duke@435: void StackValueCollection::print() { duke@435: for(int index = 0; index < size(); index++) { duke@435: tty->print("\t %2d ", index); duke@435: at(index)->print_on(tty); duke@435: if( at(index )->type() == T_INT && duke@435: index+1 < size() && duke@435: at(index+1)->type() == T_INT ) { duke@435: tty->print(" " INT64_FORMAT " (long)", long_at(index)); duke@435: tty->cr(); duke@435: tty->print("\t %.15e (double)", double_at(index)); duke@435: tty->print(" " PTR64_FORMAT " (longhex)", long_at(index)); duke@435: } duke@435: tty->cr(); duke@435: } duke@435: } duke@435: #endif