1 /*
2 * Copyright (c) 2005, 2010, 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 *
152 return stack_size() == 0;
153 }
154
155
156 bool FpuStackSim::slot_is_empty(int tos_offset) {
157 return (regs_at(tos_index() - tos_offset) == EMPTY);
158 }
159
160
161 void FpuStackSim::clear() {
162 if (TraceFPUStack) { tty->print("FPU-clear"); print(); tty->cr(); }
163 for (int i = tos_index(); i >= 0; i--) {
164 set_regs_at(i, EMPTY);
165 }
166 _stack_size = 0;
167 }
168
169
170 intArray* FpuStackSim::write_state() {
171 intArray* res = new intArray(1 + FrameMap::nof_fpu_regs);
172 (*res)[0] = stack_size();
173 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
174 (*res)[1 + i] = regs_at(i);
175 }
176 return res;
177 }
178
179
180 void FpuStackSim::read_state(intArray* fpu_stack_state) {
181 _stack_size = (*fpu_stack_state)[0];
182 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
183 set_regs_at(i, (*fpu_stack_state)[1 + i]);
184 }
185 }
186
187
188 #ifndef PRODUCT
189 void FpuStackSim::print() {
190 tty->print(" N=%d[", stack_size());\
191 for (int i = 0; i < stack_size(); i++) {
192 int reg = regs_at(i);
193 if (reg != EMPTY) {
194 tty->print("%d", reg);
195 } else {
196 tty->print("_");
197 }
198 };
199 tty->print(" ]");
200 }
201 #endif
|
1 /*
2 * Copyright (c) 2005, 2016, 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 *
152 return stack_size() == 0;
153 }
154
155
156 bool FpuStackSim::slot_is_empty(int tos_offset) {
157 return (regs_at(tos_index() - tos_offset) == EMPTY);
158 }
159
160
161 void FpuStackSim::clear() {
162 if (TraceFPUStack) { tty->print("FPU-clear"); print(); tty->cr(); }
163 for (int i = tos_index(); i >= 0; i--) {
164 set_regs_at(i, EMPTY);
165 }
166 _stack_size = 0;
167 }
168
169
170 intArray* FpuStackSim::write_state() {
171 intArray* res = new intArray(1 + FrameMap::nof_fpu_regs);
172 res->append(stack_size());
173 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
174 res->append(regs_at(i));
175 }
176 return res;
177 }
178
179
180 void FpuStackSim::read_state(intArray* fpu_stack_state) {
181 _stack_size = fpu_stack_state->at(0);
182 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
183 set_regs_at(i, fpu_stack_state->at(1 + i));
184 }
185 }
186
187
188 #ifndef PRODUCT
189 void FpuStackSim::print() {
190 tty->print(" N=%d[", stack_size());\
191 for (int i = 0; i < stack_size(); i++) {
192 int reg = regs_at(i);
193 if (reg != EMPTY) {
194 tty->print("%d", reg);
195 } else {
196 tty->print("_");
197 }
198 };
199 tty->print(" ]");
200 }
201 #endif
|