64 // aligned. This would be even uglier if monitor size wasn't modulo what the stack |
64 // aligned. This would be even uglier if monitor size wasn't modulo what the stack |
65 // needs to be aligned for). We are given that the sp (fp) is already aligned by |
65 // needs to be aligned for). We are given that the sp (fp) is already aligned by |
66 // the caller so we must ensure that it is properly aligned for our callee. |
66 // the caller so we must ensure that it is properly aligned for our callee. |
67 // |
67 // |
68 const int rounded_vm_local_words = |
68 const int rounded_vm_local_words = |
69 round_to(frame::interpreter_frame_vm_local_words,WordsPerLong); |
69 align_up((int)frame::interpreter_frame_vm_local_words,WordsPerLong); |
70 // callee_locals and max_stack are counts, not the size in frame. |
70 // callee_locals and max_stack are counts, not the size in frame. |
71 const int locals_size = |
71 const int locals_size = |
72 round_to(callee_extra_locals * Interpreter::stackElementWords, WordsPerLong); |
72 align_up(callee_extra_locals * Interpreter::stackElementWords, WordsPerLong); |
73 const int max_stack_words = max_stack * Interpreter::stackElementWords; |
73 const int max_stack_words = max_stack * Interpreter::stackElementWords; |
74 return (round_to((max_stack_words |
74 return (align_up((max_stack_words |
75 + rounded_vm_local_words |
75 + rounded_vm_local_words |
76 + frame::memory_parameter_word_sp_offset), WordsPerLong) |
76 + frame::memory_parameter_word_sp_offset), WordsPerLong) |
77 // already rounded |
77 // already rounded |
78 + locals_size + monitor_size); |
78 + locals_size + monitor_size); |
79 } |
79 } |
80 |
80 |
81 // How much stack a method top interpreter activation needs in words. |
81 // How much stack a method top interpreter activation needs in words. |
82 int AbstractInterpreter::size_top_interpreter_activation(Method* method) { |
82 int AbstractInterpreter::size_top_interpreter_activation(Method* method) { |
83 |
83 |
84 // See call_stub code |
84 // See call_stub code |
85 int call_stub_size = round_to(7 + frame::memory_parameter_word_sp_offset, |
85 int call_stub_size = align_up(7 + frame::memory_parameter_word_sp_offset, |
86 WordsPerLong); // 7 + register save area |
86 WordsPerLong); // 7 + register save area |
87 |
87 |
88 // Save space for one monitor to get into the interpreted method in case |
88 // Save space for one monitor to get into the interpreted method in case |
89 // the method is synchronized |
89 // the method is synchronized |
90 int monitor_size = method->is_synchronized() ? |
90 int monitor_size = method->is_synchronized() ? |
103 // Note: This calculation must exactly parallel the frame setup |
103 // Note: This calculation must exactly parallel the frame setup |
104 // in TemplateInterpreterGenerator::generate_fixed_frame. |
104 // in TemplateInterpreterGenerator::generate_fixed_frame. |
105 |
105 |
106 int monitor_size = monitors * frame::interpreter_frame_monitor_size(); |
106 int monitor_size = monitors * frame::interpreter_frame_monitor_size(); |
107 |
107 |
108 assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align"); |
108 assert(is_aligned(monitor_size, WordsPerLong), "must align"); |
109 |
109 |
110 // |
110 // |
111 // Note: if you look closely this appears to be doing something much different |
111 // Note: if you look closely this appears to be doing something much different |
112 // than generate_fixed_frame. What is happening is this. On sparc we have to do |
112 // than generate_fixed_frame. What is happening is this. On sparc we have to do |
113 // this dance with interpreter_sp_adjustment because the window save area would |
113 // this dance with interpreter_sp_adjustment because the window save area would |
129 // this code aware of what the interactions are when that initial caller fram was an osr or |
129 // this code aware of what the interactions are when that initial caller fram was an osr or |
130 // other adapter frame. deoptimization is complicated enough and hard enough to debug that |
130 // other adapter frame. deoptimization is complicated enough and hard enough to debug that |
131 // there is no sense in messing working code. |
131 // there is no sense in messing working code. |
132 // |
132 // |
133 |
133 |
134 int rounded_cls = round_to((callee_locals - callee_params), WordsPerLong); |
134 int rounded_cls = align_up((callee_locals - callee_params), WordsPerLong); |
135 assert(rounded_cls == round_to(rounded_cls, WordsPerLong), "must align"); |
135 assert(is_aligned(rounded_cls, WordsPerLong), "must align"); |
136 |
136 |
137 int raw_frame_size = size_activation_helper(rounded_cls, max_stack, monitor_size); |
137 int raw_frame_size = size_activation_helper(rounded_cls, max_stack, monitor_size); |
138 |
138 |
139 return raw_frame_size; |
139 return raw_frame_size; |
140 } |
140 } |
164 |
164 |
165 // The skeleton frame must already look like an interpreter frame |
165 // The skeleton frame must already look like an interpreter frame |
166 // even if not fully filled out. |
166 // even if not fully filled out. |
167 assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame"); |
167 assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame"); |
168 |
168 |
169 int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong); |
169 int rounded_vm_local_words = align_up((int)frame::interpreter_frame_vm_local_words,WordsPerLong); |
170 int monitor_size = moncount * frame::interpreter_frame_monitor_size(); |
170 int monitor_size = moncount * frame::interpreter_frame_monitor_size(); |
171 assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align"); |
171 assert(is_aligned(monitor_size, WordsPerLong), "must align"); |
172 |
172 |
173 intptr_t* fp = interpreter_frame->fp(); |
173 intptr_t* fp = interpreter_frame->fp(); |
174 |
174 |
175 JavaThread* thread = JavaThread::current(); |
175 JavaThread* thread = JavaThread::current(); |
176 RegisterMap map(thread, false); |
176 RegisterMap map(thread, false); |
196 // Note that this computation means we replace size_of_parameters() values from the caller |
196 // Note that this computation means we replace size_of_parameters() values from the caller |
197 // interpreter frame's expression stack with our argument locals |
197 // interpreter frame's expression stack with our argument locals |
198 int parm_words = caller_actual_parameters * Interpreter::stackElementWords; |
198 int parm_words = caller_actual_parameters * Interpreter::stackElementWords; |
199 locals = Lesp_ptr + parm_words; |
199 locals = Lesp_ptr + parm_words; |
200 int delta = local_words - parm_words; |
200 int delta = local_words - parm_words; |
201 int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0; |
201 int computed_sp_adjustment = (delta > 0) ? align_up(delta, WordsPerLong) : 0; |
202 *interpreter_frame->register_addr(I5_savedSP) = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS; |
202 *interpreter_frame->register_addr(I5_savedSP) = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS; |
203 if (!is_bottom_frame) { |
203 if (!is_bottom_frame) { |
204 // Llast_SP is set below for the current frame to SP (with the |
204 // Llast_SP is set below for the current frame to SP (with the |
205 // extra space for the callee's locals). Here we adjust |
205 // extra space for the callee's locals). Here we adjust |
206 // Llast_SP for the caller's frame, removing the extra space |
206 // Llast_SP for the caller's frame, removing the extra space |