src/share/vm/runtime/stackValueCollection.cpp

Tue, 05 Nov 2013 17:38:04 -0800

author
kvn
date
Tue, 05 Nov 2013 17:38:04 -0800
changeset 6472
2b8e28fdf503
parent 2708
1d1603768966
child 6680
78bbf4d43a14
permissions
-rw-r--r--

Merge

duke@435 1 /*
trims@2708 2 * Copyright (c) 2001, 2011, 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
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "runtime/stackValueCollection.hpp"
stefank@2314 27 #ifdef TARGET_ARCH_x86
stefank@2314 28 # include "jniTypes_x86.hpp"
stefank@2314 29 #endif
stefank@2314 30 #ifdef TARGET_ARCH_sparc
stefank@2314 31 # include "jniTypes_sparc.hpp"
stefank@2314 32 #endif
stefank@2314 33 #ifdef TARGET_ARCH_zero
stefank@2314 34 # include "jniTypes_zero.hpp"
stefank@2314 35 #endif
bobv@2508 36 #ifdef TARGET_ARCH_arm
bobv@2508 37 # include "jniTypes_arm.hpp"
bobv@2508 38 #endif
bobv@2508 39 #ifdef TARGET_ARCH_ppc
bobv@2508 40 # include "jniTypes_ppc.hpp"
bobv@2508 41 #endif
duke@435 42
duke@435 43 jint StackValueCollection::int_at(int slot) const {
duke@435 44 intptr_t val = at(slot)->get_int();
duke@435 45 jint ival = *((jint*) (&val));
duke@435 46 return ival;
duke@435 47 }
duke@435 48
duke@435 49 jlong StackValueCollection::long_at(int slot) const {
duke@435 50 #ifdef _LP64
duke@435 51 return at(slot+1)->get_int();
duke@435 52 #else
duke@435 53 union {
duke@435 54 jlong jl;
duke@435 55 jint array[2];
duke@435 56 } value;
duke@435 57 // Interpreter stack is reversed in memory:
duke@435 58 // low memory location is in higher java local slot.
duke@435 59 value.array[0] = at(slot+1)->get_int();
duke@435 60 value.array[1] = at(slot )->get_int();
duke@435 61 return value.jl;
duke@435 62 #endif
duke@435 63 }
duke@435 64
duke@435 65 Handle StackValueCollection::obj_at(int slot) const {
duke@435 66 return at(slot)->get_obj();
duke@435 67 }
duke@435 68
duke@435 69 jfloat StackValueCollection::float_at(int slot) const {
duke@435 70 intptr_t res = at(slot)->get_int();
duke@435 71 return *((jfloat*) (&res));
duke@435 72 }
duke@435 73
duke@435 74 jdouble StackValueCollection::double_at(int slot) const {
duke@435 75 #ifdef _LP64
duke@435 76 intptr_t res = at(slot+1)->get_int();
duke@435 77 return *((jdouble*) (&res));
duke@435 78 #else
duke@435 79 union {
duke@435 80 jdouble jd;
duke@435 81 jint array[2];
duke@435 82 } value;
duke@435 83 // Interpreter stack is reversed in memory:
duke@435 84 // low memory location is in higher java local slot.
duke@435 85 value.array[0] = at(slot+1)->get_int();
duke@435 86 value.array[1] = at(slot )->get_int();
duke@435 87 return value.jd;
duke@435 88 #endif
duke@435 89 }
duke@435 90
duke@435 91 void StackValueCollection::set_int_at(int slot, jint value) {
duke@435 92 intptr_t val;
duke@435 93 *((jint*) (&val)) = value;
duke@435 94 at(slot)->set_int(val);
duke@435 95 }
duke@435 96
duke@435 97 void StackValueCollection::set_long_at(int slot, jlong value) {
duke@435 98 #ifdef _LP64
duke@435 99 at(slot+1)->set_int(value);
duke@435 100 #else
duke@435 101 union {
duke@435 102 jlong jl;
duke@435 103 jint array[2];
duke@435 104 } x;
duke@435 105 // Interpreter stack is reversed in memory:
duke@435 106 // low memory location is in higher java local slot.
duke@435 107 x.jl = value;
duke@435 108 at(slot+1)->set_int(x.array[0]);
duke@435 109 at(slot+0)->set_int(x.array[1]);
duke@435 110 #endif
duke@435 111 }
duke@435 112
duke@435 113 void StackValueCollection::set_obj_at(int slot, Handle value) {
duke@435 114 at(slot)->set_obj(value);
duke@435 115 }
duke@435 116
duke@435 117 void StackValueCollection::set_float_at(int slot, jfloat value) {
duke@435 118 #ifdef _LP64
duke@435 119 union {
duke@435 120 intptr_t jd;
duke@435 121 jint array[2];
duke@435 122 } val;
duke@435 123 // Interpreter stores 32 bit floats in first half of 64 bit word.
duke@435 124 val.array[0] = *(jint*)(&value);
duke@435 125 val.array[1] = 0;
duke@435 126 at(slot)->set_int(val.jd);
duke@435 127 #else
duke@435 128 at(slot)->set_int(*(jint*)(&value));
duke@435 129 #endif
duke@435 130 }
duke@435 131
duke@435 132 void StackValueCollection::set_double_at(int slot, jdouble value) {
duke@435 133 #ifdef _LP64
duke@435 134 at(slot+1)->set_int(*(intptr_t*)(&value));
duke@435 135 #else
duke@435 136 union {
duke@435 137 jdouble jd;
duke@435 138 jint array[2];
duke@435 139 } x;
duke@435 140 // Interpreter stack is reversed in memory:
duke@435 141 // low memory location is in higher java local slot.
duke@435 142 x.jd = value;
duke@435 143 at(slot+1)->set_int(x.array[0]);
duke@435 144 at(slot+0)->set_int(x.array[1]);
duke@435 145 #endif
duke@435 146 }
duke@435 147
duke@435 148 #ifndef PRODUCT
duke@435 149 void StackValueCollection::print() {
duke@435 150 for(int index = 0; index < size(); index++) {
duke@435 151 tty->print("\t %2d ", index);
duke@435 152 at(index)->print_on(tty);
duke@435 153 if( at(index )->type() == T_INT &&
duke@435 154 index+1 < size() &&
duke@435 155 at(index+1)->type() == T_INT ) {
duke@435 156 tty->print(" " INT64_FORMAT " (long)", long_at(index));
duke@435 157 tty->cr();
duke@435 158 tty->print("\t %.15e (double)", double_at(index));
duke@435 159 tty->print(" " PTR64_FORMAT " (longhex)", long_at(index));
duke@435 160 }
duke@435 161 tty->cr();
duke@435 162 }
duke@435 163 }
duke@435 164 #endif

mercurial