author | stefank |
Tue, 23 Nov 2010 13:22:55 -0800 | |
changeset 7397 | 5b173b4ca846 |
parent 5547 | f4b087cbb361 |
child 8107 | 78e5bd944384 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
7397 | 2 |
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "runtime/stackValueCollection.hpp" |
|
27 |
#ifdef TARGET_ARCH_x86 |
|
28 |
# include "jniTypes_x86.hpp" |
|
29 |
#endif |
|
30 |
#ifdef TARGET_ARCH_sparc |
|
31 |
# include "jniTypes_sparc.hpp" |
|
32 |
#endif |
|
33 |
#ifdef TARGET_ARCH_zero |
|
34 |
# include "jniTypes_zero.hpp" |
|
35 |
#endif |
|
1 | 36 |
|
37 |
jint StackValueCollection::int_at(int slot) const { |
|
38 |
intptr_t val = at(slot)->get_int(); |
|
39 |
jint ival = *((jint*) (&val)); |
|
40 |
return ival; |
|
41 |
} |
|
42 |
||
43 |
jlong StackValueCollection::long_at(int slot) const { |
|
44 |
#ifdef _LP64 |
|
45 |
return at(slot+1)->get_int(); |
|
46 |
#else |
|
47 |
union { |
|
48 |
jlong jl; |
|
49 |
jint array[2]; |
|
50 |
} value; |
|
51 |
// Interpreter stack is reversed in memory: |
|
52 |
// low memory location is in higher java local slot. |
|
53 |
value.array[0] = at(slot+1)->get_int(); |
|
54 |
value.array[1] = at(slot )->get_int(); |
|
55 |
return value.jl; |
|
56 |
#endif |
|
57 |
} |
|
58 |
||
59 |
Handle StackValueCollection::obj_at(int slot) const { |
|
60 |
return at(slot)->get_obj(); |
|
61 |
} |
|
62 |
||
63 |
jfloat StackValueCollection::float_at(int slot) const { |
|
64 |
intptr_t res = at(slot)->get_int(); |
|
65 |
return *((jfloat*) (&res)); |
|
66 |
} |
|
67 |
||
68 |
jdouble StackValueCollection::double_at(int slot) const { |
|
69 |
#ifdef _LP64 |
|
70 |
intptr_t res = at(slot+1)->get_int(); |
|
71 |
return *((jdouble*) (&res)); |
|
72 |
#else |
|
73 |
union { |
|
74 |
jdouble jd; |
|
75 |
jint array[2]; |
|
76 |
} value; |
|
77 |
// Interpreter stack is reversed in memory: |
|
78 |
// low memory location is in higher java local slot. |
|
79 |
value.array[0] = at(slot+1)->get_int(); |
|
80 |
value.array[1] = at(slot )->get_int(); |
|
81 |
return value.jd; |
|
82 |
#endif |
|
83 |
} |
|
84 |
||
85 |
void StackValueCollection::set_int_at(int slot, jint value) { |
|
86 |
intptr_t val; |
|
87 |
*((jint*) (&val)) = value; |
|
88 |
at(slot)->set_int(val); |
|
89 |
} |
|
90 |
||
91 |
void StackValueCollection::set_long_at(int slot, jlong value) { |
|
92 |
#ifdef _LP64 |
|
93 |
at(slot+1)->set_int(value); |
|
94 |
#else |
|
95 |
union { |
|
96 |
jlong jl; |
|
97 |
jint array[2]; |
|
98 |
} x; |
|
99 |
// Interpreter stack is reversed in memory: |
|
100 |
// low memory location is in higher java local slot. |
|
101 |
x.jl = value; |
|
102 |
at(slot+1)->set_int(x.array[0]); |
|
103 |
at(slot+0)->set_int(x.array[1]); |
|
104 |
#endif |
|
105 |
} |
|
106 |
||
107 |
void StackValueCollection::set_obj_at(int slot, Handle value) { |
|
108 |
at(slot)->set_obj(value); |
|
109 |
} |
|
110 |
||
111 |
void StackValueCollection::set_float_at(int slot, jfloat value) { |
|
112 |
#ifdef _LP64 |
|
113 |
union { |
|
114 |
intptr_t jd; |
|
115 |
jint array[2]; |
|
116 |
} val; |
|
117 |
// Interpreter stores 32 bit floats in first half of 64 bit word. |
|
118 |
val.array[0] = *(jint*)(&value); |
|
119 |
val.array[1] = 0; |
|
120 |
at(slot)->set_int(val.jd); |
|
121 |
#else |
|
122 |
at(slot)->set_int(*(jint*)(&value)); |
|
123 |
#endif |
|
124 |
} |
|
125 |
||
126 |
void StackValueCollection::set_double_at(int slot, jdouble value) { |
|
127 |
#ifdef _LP64 |
|
128 |
at(slot+1)->set_int(*(intptr_t*)(&value)); |
|
129 |
#else |
|
130 |
union { |
|
131 |
jdouble jd; |
|
132 |
jint array[2]; |
|
133 |
} x; |
|
134 |
// Interpreter stack is reversed in memory: |
|
135 |
// low memory location is in higher java local slot. |
|
136 |
x.jd = value; |
|
137 |
at(slot+1)->set_int(x.array[0]); |
|
138 |
at(slot+0)->set_int(x.array[1]); |
|
139 |
#endif |
|
140 |
} |
|
141 |
||
142 |
#ifndef PRODUCT |
|
143 |
void StackValueCollection::print() { |
|
144 |
for(int index = 0; index < size(); index++) { |
|
145 |
tty->print("\t %2d ", index); |
|
146 |
at(index)->print_on(tty); |
|
147 |
if( at(index )->type() == T_INT && |
|
148 |
index+1 < size() && |
|
149 |
at(index+1)->type() == T_INT ) { |
|
150 |
tty->print(" " INT64_FORMAT " (long)", long_at(index)); |
|
151 |
tty->cr(); |
|
152 |
tty->print("\t %.15e (double)", double_at(index)); |
|
153 |
tty->print(" " PTR64_FORMAT " (longhex)", long_at(index)); |
|
154 |
} |
|
155 |
tty->cr(); |
|
156 |
} |
|
157 |
} |
|
158 |
#endif |