0
|
1 /*
|
|
2 * Copyright 2005 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 // Simulates the FPU stack and maintains mapping [fpu-register -> stack offset]
|
|
26 // FPU registers are described as numbers from 0..nof_fpu_regs-1
|
|
27
|
|
28 class Compilation;
|
|
29
|
|
30 class FpuStackSim VALUE_OBJ_CLASS_SPEC {
|
|
31 private:
|
|
32 Compilation* _compilation;
|
|
33 int _stack_size;
|
|
34 int _regs[FrameMap::nof_fpu_regs];
|
|
35
|
|
36 int tos_index() const { return _stack_size - 1; }
|
|
37
|
|
38 int regs_at(int i) const;
|
|
39 void set_regs_at(int i, int val);
|
|
40 void dec_stack_size();
|
|
41 void inc_stack_size();
|
|
42
|
|
43 // unified bailout support
|
|
44 Compilation* compilation() const { return _compilation; }
|
|
45 void bailout(const char* msg) const { compilation()->bailout(msg); }
|
|
46 bool bailed_out() const { return compilation()->bailed_out(); }
|
|
47
|
|
48 public:
|
|
49 FpuStackSim(Compilation* compilation);
|
|
50 void pop ();
|
|
51 void pop (int rnr); // rnr must be on tos
|
|
52 void push(int rnr);
|
|
53 void swap(int offset); // exchange tos with tos + offset
|
|
54 int offset_from_tos(int rnr) const; // return the offset of the topmost instance of rnr from TOS
|
|
55 int get_slot(int tos_offset) const; // return the entry at the given offset from TOS
|
|
56 void set_slot(int tos_offset, int rnr); // set the entry at the given offset from TOS
|
|
57 void rename(int old_rnr, int new_rnr); // rename all instances of old_rnr to new_rnr
|
|
58 bool contains(int rnr); // debugging support only
|
|
59 bool is_empty();
|
|
60 bool slot_is_empty(int tos_offset);
|
|
61 int stack_size() const { return _stack_size; }
|
|
62 void clear();
|
|
63 intArray* write_state();
|
|
64 void read_state(intArray* fpu_stack_state);
|
|
65
|
|
66 void print() PRODUCT_RETURN;
|
|
67 };
|