src/share/vm/runtime/stackValueCollection.cpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 1
2d8a650513c2
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "runtime/stackValueCollection.hpp"
aoqi@0 27 #ifdef TARGET_ARCH_x86
aoqi@0 28 # include "jniTypes_x86.hpp"
aoqi@0 29 #endif
aoqi@0 30 #ifdef TARGET_ARCH_sparc
aoqi@0 31 # include "jniTypes_sparc.hpp"
aoqi@0 32 #endif
aoqi@0 33 #ifdef TARGET_ARCH_zero
aoqi@0 34 # include "jniTypes_zero.hpp"
aoqi@0 35 #endif
aoqi@0 36 #ifdef TARGET_ARCH_arm
aoqi@0 37 # include "jniTypes_arm.hpp"
aoqi@0 38 #endif
aoqi@0 39 #ifdef TARGET_ARCH_ppc
aoqi@0 40 # include "jniTypes_ppc.hpp"
aoqi@0 41 #endif
aoqi@0 42
aoqi@0 43 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
aoqi@0 44
aoqi@0 45 jint StackValueCollection::int_at(int slot) const {
aoqi@0 46 intptr_t val = at(slot)->get_int();
aoqi@0 47 jint ival = *((jint*) (&val));
aoqi@0 48 return ival;
aoqi@0 49 }
aoqi@0 50
aoqi@0 51 jlong StackValueCollection::long_at(int slot) const {
aoqi@0 52 #ifdef _LP64
aoqi@0 53 return at(slot+1)->get_int();
aoqi@0 54 #else
aoqi@0 55 union {
aoqi@0 56 jlong jl;
aoqi@0 57 jint array[2];
aoqi@0 58 } value;
aoqi@0 59 // Interpreter stack is reversed in memory:
aoqi@0 60 // low memory location is in higher java local slot.
aoqi@0 61 value.array[0] = at(slot+1)->get_int();
aoqi@0 62 value.array[1] = at(slot )->get_int();
aoqi@0 63 return value.jl;
aoqi@0 64 #endif
aoqi@0 65 }
aoqi@0 66
aoqi@0 67 Handle StackValueCollection::obj_at(int slot) const {
aoqi@0 68 return at(slot)->get_obj();
aoqi@0 69 }
aoqi@0 70
aoqi@0 71 jfloat StackValueCollection::float_at(int slot) const {
aoqi@0 72 intptr_t res = at(slot)->get_int();
aoqi@0 73 return *((jfloat*) (&res));
aoqi@0 74 }
aoqi@0 75
aoqi@0 76 jdouble StackValueCollection::double_at(int slot) const {
aoqi@0 77 #ifdef _LP64
aoqi@0 78 intptr_t res = at(slot+1)->get_int();
aoqi@0 79 return *((jdouble*) (&res));
aoqi@0 80 #else
aoqi@0 81 union {
aoqi@0 82 jdouble jd;
aoqi@0 83 jint array[2];
aoqi@0 84 } value;
aoqi@0 85 // Interpreter stack is reversed in memory:
aoqi@0 86 // low memory location is in higher java local slot.
aoqi@0 87 value.array[0] = at(slot+1)->get_int();
aoqi@0 88 value.array[1] = at(slot )->get_int();
aoqi@0 89 return value.jd;
aoqi@0 90 #endif
aoqi@0 91 }
aoqi@0 92
aoqi@0 93 void StackValueCollection::set_int_at(int slot, jint value) {
aoqi@0 94 intptr_t val;
aoqi@0 95 *((jint*) (&val)) = value;
aoqi@0 96 at(slot)->set_int(val);
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 void StackValueCollection::set_long_at(int slot, jlong value) {
aoqi@0 100 #ifdef _LP64
aoqi@0 101 at(slot+1)->set_int(value);
aoqi@0 102 #else
aoqi@0 103 union {
aoqi@0 104 jlong jl;
aoqi@0 105 jint array[2];
aoqi@0 106 } x;
aoqi@0 107 // Interpreter stack is reversed in memory:
aoqi@0 108 // low memory location is in higher java local slot.
aoqi@0 109 x.jl = value;
aoqi@0 110 at(slot+1)->set_int(x.array[0]);
aoqi@0 111 at(slot+0)->set_int(x.array[1]);
aoqi@0 112 #endif
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 void StackValueCollection::set_obj_at(int slot, Handle value) {
aoqi@0 116 at(slot)->set_obj(value);
aoqi@0 117 }
aoqi@0 118
aoqi@0 119 void StackValueCollection::set_float_at(int slot, jfloat value) {
aoqi@0 120 #ifdef _LP64
aoqi@0 121 union {
aoqi@0 122 intptr_t jd;
aoqi@0 123 jint array[2];
aoqi@0 124 } val;
aoqi@0 125 // Interpreter stores 32 bit floats in first half of 64 bit word.
aoqi@0 126 val.array[0] = *(jint*)(&value);
aoqi@0 127 val.array[1] = 0;
aoqi@0 128 at(slot)->set_int(val.jd);
aoqi@0 129 #else
aoqi@0 130 at(slot)->set_int(*(jint*)(&value));
aoqi@0 131 #endif
aoqi@0 132 }
aoqi@0 133
aoqi@0 134 void StackValueCollection::set_double_at(int slot, jdouble value) {
aoqi@0 135 #ifdef _LP64
aoqi@0 136 at(slot+1)->set_int(*(intptr_t*)(&value));
aoqi@0 137 #else
aoqi@0 138 union {
aoqi@0 139 jdouble jd;
aoqi@0 140 jint array[2];
aoqi@0 141 } x;
aoqi@0 142 // Interpreter stack is reversed in memory:
aoqi@0 143 // low memory location is in higher java local slot.
aoqi@0 144 x.jd = value;
aoqi@0 145 at(slot+1)->set_int(x.array[0]);
aoqi@0 146 at(slot+0)->set_int(x.array[1]);
aoqi@0 147 #endif
aoqi@0 148 }
aoqi@0 149
aoqi@0 150 #ifndef PRODUCT
aoqi@0 151 void StackValueCollection::print() {
aoqi@0 152 for(int index = 0; index < size(); index++) {
aoqi@0 153 tty->print("\t %2d ", index);
aoqi@0 154 at(index)->print_on(tty);
aoqi@0 155 if( at(index )->type() == T_INT &&
aoqi@0 156 index+1 < size() &&
aoqi@0 157 at(index+1)->type() == T_INT ) {
aoqi@0 158 tty->print(" " INT64_FORMAT " (long)", long_at(index));
aoqi@0 159 tty->cr();
aoqi@0 160 tty->print("\t %.15e (double)", double_at(index));
aoqi@0 161 tty->print(" " PTR64_FORMAT " (longhex)", long_at(index));
aoqi@0 162 }
aoqi@0 163 tty->cr();
aoqi@0 164 }
aoqi@0 165 }
aoqi@0 166 #endif

mercurial