24
25 #include "precompiled.hpp"
26 #include "c1/c1_FrameMap.hpp"
27 #include "c1/c1_LIR.hpp"
28 #include "code/vmreg.inline.hpp"
29 #include "runtime/sharedRuntime.hpp"
30 #include "utilities/align.hpp"
31
32 //-----------------------------------------------------
33
34 // Convert method signature into an array of BasicTypes for the arguments
35 BasicTypeArray* FrameMap::signature_type_array_for(const ciMethod* method) {
36 ciSignature* sig = method->signature();
37 BasicTypeList* sta = new BasicTypeList(method->arg_size());
38 // add receiver, if any
39 if (!method->is_static()) sta->append(T_OBJECT);
40 // add remaining arguments
41 for (int i = 0; i < sig->count(); i++) {
42 ciType* type = sig->type_at(i);
43 BasicType t = type->basic_type();
44 if (t == T_ARRAY) {
45 t = T_OBJECT;
46 }
47 sta->append(t);
48 }
49 // done
50 return sta;
51 }
52
53
54 CallingConvention* FrameMap::java_calling_convention(const BasicTypeArray* signature, bool outgoing) {
55 // compute the size of the arguments first. The signature array
56 // that java_calling_convention takes includes a T_VOID after double
57 // work items but our signatures do not.
58 int i;
59 int sizeargs = 0;
60 for (i = 0; i < signature->length(); i++) {
61 sizeargs += type2size[signature->at(i)];
62 }
63
64 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
166
167 _argcount = method->arg_size();
168 _argument_locations = new intArray(_argcount, _argcount, -1);
169 _incoming_arguments = java_calling_convention(signature_type_array_for(method), false);
170 _oop_map_arg_count = _incoming_arguments->reserved_stack_slots();
171
172 int java_index = 0;
173 for (int i = 0; i < _incoming_arguments->length(); i++) {
174 LIR_Opr opr = _incoming_arguments->at(i);
175 if (opr->is_address()) {
176 LIR_Address* address = opr->as_address_ptr();
177 _argument_locations->at_put(java_index, address->disp());
178 _incoming_arguments->args()->at_put(i, LIR_OprFact::stack(java_index, as_BasicType(as_ValueType(address->type()))));
179 }
180 java_index += type2size[opr->type()];
181 }
182
183 }
184
185
186 bool FrameMap::finalize_frame(int nof_slots) {
187 assert(nof_slots >= 0, "must be positive");
188 assert(_num_spills == -1, "can only be set once");
189 _num_spills = nof_slots;
190 assert(_framesize == -1, "should only be calculated once");
191 _framesize = align_up(in_bytes(sp_offset_for_monitor_base(0)) +
192 _num_monitors * (int)sizeof(BasicObjectLock) +
193 (int)sizeof(intptr_t) + // offset of deopt orig pc
194 frame_pad_in_bytes,
195 StackAlignmentInBytes) / 4;
196 int java_index = 0;
197 for (int i = 0; i < _incoming_arguments->length(); i++) {
198 LIR_Opr opr = _incoming_arguments->at(i);
199 if (opr->is_stack()) {
200 _argument_locations->at_put(java_index, in_bytes(framesize_in_bytes()) +
201 _argument_locations->at(java_index));
202 }
203 java_index += type2size[opr->type()];
204 }
205 // make sure it's expressible on the platform
206 return validate_frame();
207 }
208
209 VMReg FrameMap::sp_offset2vmreg(ByteSize offset) const {
210 int offset_in_bytes = in_bytes(offset);
211 assert(offset_in_bytes % 4 == 0, "must be multiple of 4 bytes");
212 assert(offset_in_bytes / 4 < framesize() + oop_map_arg_count(), "out of range");
213 return VMRegImpl::stack2reg(offset_in_bytes / 4);
|
24
25 #include "precompiled.hpp"
26 #include "c1/c1_FrameMap.hpp"
27 #include "c1/c1_LIR.hpp"
28 #include "code/vmreg.inline.hpp"
29 #include "runtime/sharedRuntime.hpp"
30 #include "utilities/align.hpp"
31
32 //-----------------------------------------------------
33
34 // Convert method signature into an array of BasicTypes for the arguments
35 BasicTypeArray* FrameMap::signature_type_array_for(const ciMethod* method) {
36 ciSignature* sig = method->signature();
37 BasicTypeList* sta = new BasicTypeList(method->arg_size());
38 // add receiver, if any
39 if (!method->is_static()) sta->append(T_OBJECT);
40 // add remaining arguments
41 for (int i = 0; i < sig->count(); i++) {
42 ciType* type = sig->type_at(i);
43 BasicType t = type->basic_type();
44 if (t == T_ARRAY || t == T_PRIMITIVE_OBJECT) {
45 t = T_OBJECT;
46 }
47 sta->append(t);
48 }
49 // done
50 return sta;
51 }
52
53
54 CallingConvention* FrameMap::java_calling_convention(const BasicTypeArray* signature, bool outgoing) {
55 // compute the size of the arguments first. The signature array
56 // that java_calling_convention takes includes a T_VOID after double
57 // work items but our signatures do not.
58 int i;
59 int sizeargs = 0;
60 for (i = 0; i < signature->length(); i++) {
61 sizeargs += type2size[signature->at(i)];
62 }
63
64 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
166
167 _argcount = method->arg_size();
168 _argument_locations = new intArray(_argcount, _argcount, -1);
169 _incoming_arguments = java_calling_convention(signature_type_array_for(method), false);
170 _oop_map_arg_count = _incoming_arguments->reserved_stack_slots();
171
172 int java_index = 0;
173 for (int i = 0; i < _incoming_arguments->length(); i++) {
174 LIR_Opr opr = _incoming_arguments->at(i);
175 if (opr->is_address()) {
176 LIR_Address* address = opr->as_address_ptr();
177 _argument_locations->at_put(java_index, address->disp());
178 _incoming_arguments->args()->at_put(i, LIR_OprFact::stack(java_index, as_BasicType(as_ValueType(address->type()))));
179 }
180 java_index += type2size[opr->type()];
181 }
182
183 }
184
185
186 bool FrameMap::finalize_frame(int nof_slots, bool needs_stack_repair) {
187 assert(nof_slots >= 0, "must be positive");
188 assert(_num_spills == -1, "can only be set once");
189 _num_spills = nof_slots;
190 assert(_framesize == -1, "should only be calculated once");
191 _framesize = align_up(in_bytes(sp_offset_for_monitor_base(0)) +
192 _num_monitors * (int)sizeof(BasicObjectLock) +
193 (int)sizeof(intptr_t) + // offset of deopt orig pc
194 (needs_stack_repair ? (int)sizeof(intptr_t) : 0) + // stack increment value
195 frame_pad_in_bytes,
196 StackAlignmentInBytes) / 4;
197 int java_index = 0;
198 for (int i = 0; i < _incoming_arguments->length(); i++) {
199 LIR_Opr opr = _incoming_arguments->at(i);
200 if (opr->is_stack()) {
201 _argument_locations->at_put(java_index, in_bytes(framesize_in_bytes()) +
202 _argument_locations->at(java_index));
203 }
204 java_index += type2size[opr->type()];
205 }
206 // make sure it's expressible on the platform
207 return validate_frame();
208 }
209
210 VMReg FrameMap::sp_offset2vmreg(ByteSize offset) const {
211 int offset_in_bytes = in_bytes(offset);
212 assert(offset_in_bytes % 4 == 0, "must be multiple of 4 bytes");
213 assert(offset_in_bytes / 4 < framesize() + oop_map_arg_count(), "out of range");
214 return VMRegImpl::stack2reg(offset_in_bytes / 4);
|