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