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