annotate src/cpu/x86/vm/frame_x86.hpp @ 71:3d62cb85208d

6662967: Optimize I2D conversion on new x86 Summary: Use CVTDQ2PS and CVTDQ2PD for integer values conversions to float and double values on new AMD cpu. Reviewed-by: sgoldman, never
author kvn
date Wed, 19 Mar 2008 15:33:25 -0700
parents a61af66fc99e
children 18a389214829
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // A frame represents a physical stack frame (an activation). Frames can be
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // C or Java frames, and the Java frames can be interpreted or compiled.
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // In contrast, vframes represent source-level activations, so that one physical frame
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // can correspond to multiple source level frames because of inlining.
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // A frame is comprised of {pc, fp, sp}
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // ------------------------------ Asm interpreter ----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // Layout of asm interpreter frame:
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // [expression stack ] * <- sp
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // [monitors ] \
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // ... | monitor block size
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // [monitors ] /
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // [monitor block size ]
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // [byte code index/pointr] = bcx() bcx_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // [pointer to locals ] = locals() locals_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // [constant pool cache ] = cache() cache_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // [methodData ] = mdp() mdx_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // [methodOop ] = method() method_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // [last sp ] = last_sp() last_sp_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // [old stack pointer ] (sender_sp) sender_sp_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // [old frame pointer ] <- fp = link()
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // [return pc ]
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // [oop temp ] (only for native calls)
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // [locals and parameters ]
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // <- sender sp
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // ------------------------------ Asm interpreter ----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // ------------------------------ C++ interpreter ----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
52 //
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Layout of C++ interpreter frame: (While executing in BytecodeInterpreter::run)
a61af66fc99e Initial load
duke
parents:
diff changeset
54 //
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // <- SP (current esp/rsp)
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // [local variables ] BytecodeInterpreter::run local variables
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // ... BytecodeInterpreter::run local variables
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // [local variables ] BytecodeInterpreter::run local variables
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // [old frame pointer ] fp [ BytecodeInterpreter::run's ebp/rbp ]
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // [return pc ] (return to frame manager)
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // [interpreter_state* ] (arg to BytecodeInterpreter::run) --------------
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // [expression stack ] <- last_Java_sp |
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // [... ] * <- interpreter_state.stack |
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // [expression stack ] * <- interpreter_state.stack_base |
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // [monitors ] \ |
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // ... | monitor block size |
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // [monitors ] / <- interpreter_state.monitor_base |
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // [struct interpretState ] <-----------------------------------------|
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // [return pc ] (return to callee of frame manager [1]
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // [locals and parameters ]
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // <- sender sp
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // [1] When the c++ interpreter calls a new method it returns to the frame
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // manager which allocates a new frame on the stack. In that case there
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // is no real callee of this newly allocated frame. The frame manager is
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // aware of the additional frame(s) and will pop them as nested calls
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // complete. Howevers tTo make it look good in the debugger the frame
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // manager actually installs a dummy pc pointing to RecursiveInterpreterActivation
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // with a fake interpreter_state* parameter to make it easy to debug
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // nested calls.
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Note that contrary to the layout for the assembly interpreter the
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // expression stack allocated for the C++ interpreter is full sized.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // However this is not as bad as it seems as the interpreter frame_manager
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // will truncate the unused space on succesive method calls.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // ------------------------------ C++ interpreter ----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
90 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 pc_return_offset = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // All frames
a61af66fc99e Initial load
duke
parents:
diff changeset
93 link_offset = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return_addr_offset = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // non-interpreter frames
a61af66fc99e Initial load
duke
parents:
diff changeset
96 sender_sp_offset = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 #ifndef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // Interpreter frames
a61af66fc99e Initial load
duke
parents:
diff changeset
101 interpreter_frame_result_handler_offset = 3, // for native calls only
a61af66fc99e Initial load
duke
parents:
diff changeset
102 interpreter_frame_oop_temp_offset = 2, // for native calls only
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 interpreter_frame_sender_sp_offset = -1,
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // outgoing sp before a call to an invoked method
a61af66fc99e Initial load
duke
parents:
diff changeset
106 interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
107 interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
108 interpreter_frame_mdx_offset = interpreter_frame_method_offset - 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
109 interpreter_frame_cache_offset = interpreter_frame_mdx_offset - 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
110 interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
111 interpreter_frame_bcx_offset = interpreter_frame_locals_offset - 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
112 interpreter_frame_initial_sp_offset = interpreter_frame_bcx_offset - 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 interpreter_frame_monitor_block_top_offset = interpreter_frame_initial_sp_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
115 interpreter_frame_monitor_block_bottom_offset = interpreter_frame_initial_sp_offset,
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 #endif // CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Entry frames
a61af66fc99e Initial load
duke
parents:
diff changeset
120 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
121 #ifdef _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
122 entry_frame_after_call_words = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
123 entry_frame_call_wrapper_offset = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 arg_reg_save_area_bytes = 32, // Register argument save area
a61af66fc99e Initial load
duke
parents:
diff changeset
126 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
127 entry_frame_after_call_words = 13,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 entry_frame_call_wrapper_offset = -6,
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 arg_reg_save_area_bytes = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
131 #endif // _WIN64
a61af66fc99e Initial load
duke
parents:
diff changeset
132 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
133 entry_frame_call_wrapper_offset = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
134 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Native frames
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 native_frame_initial_param_offset = 2
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 };
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 intptr_t ptr_at(int offset) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 return *ptr_at_addr(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 void ptr_at_put(int offset, intptr_t value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 *ptr_at_addr(offset) = value;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // an additional field beyond _sp and _pc:
a61af66fc99e Initial load
duke
parents:
diff changeset
152 intptr_t* _fp; // frame pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // The interpreter and adapters will extend the frame of the caller.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // Since oopMaps are based on the sp of the caller before extension
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // we need to know that value. However in order to compute the address
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // of the return address we need the real "raw" sp. Since sparc already
a61af66fc99e Initial load
duke
parents:
diff changeset
157 // uses sp() to mean "raw" sp and unextended_sp() to mean the caller's
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // original sp we use that convention.
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 intptr_t* _unextended_sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 intptr_t* ptr_at_addr(int offset) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 return (intptr_t*) addr_at(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Constructors
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 frame(intptr_t* sp, intptr_t* fp, address pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 frame(intptr_t* sp, intptr_t* fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // accessors for the instance variables
a61af66fc99e Initial load
duke
parents:
diff changeset
176 intptr_t* fp() const { return _fp; }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 inline address* sender_pc_addr() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // return address of param, zero origin index.
a61af66fc99e Initial load
duke
parents:
diff changeset
181 inline address* native_param_addr(int idx) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // expression stack tos if we are nested in a java call
a61af66fc99e Initial load
duke
parents:
diff changeset
184 intptr_t* interpreter_frame_last_sp() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 #ifndef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // deoptimization support
a61af66fc99e Initial load
duke
parents:
diff changeset
188 void interpreter_frame_set_last_sp(intptr_t* sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
189 #endif // CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 #ifdef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
192 inline interpreterState get_interpreterState() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 #endif // CC_INTERP