src/share/vm/runtime/stackValueCollection.cpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 2508
b92c45f2bc75
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

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

mercurial