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 *
23 */
24
25 #include "ci/ciValueKlass.hpp"
26 #include "opto/addnode.hpp"
27 #include "opto/graphKit.hpp"
28 #include "opto/rootnode.hpp"
29 #include "opto/valuetypenode.hpp"
30 #include "opto/phaseX.hpp"
31
32 Node* ValueTypeNode::make(PhaseGVN& gvn, ciValueKlass* klass) {
33 // Create a new ValueTypeNode with uninitialized values and NULL oop
34 const TypeValueType* type = TypeValueType::make(klass);
35 return new ValueTypeNode(type, gvn.zerocon(T_VALUETYPE));
36 }
37
38 Node* ValueTypeNode::make(PhaseGVN& gvn, Node* mem, Node* oop) {
39 // Create and initialize a ValueTypeNode by loading all field
40 // values from a heap-allocated version and also save the oop.
41 const TypeValueTypePtr* vtptr = gvn.type(oop)->is_valuetypeptr();
42 ValueTypeNode* vt = new ValueTypeNode(vtptr->value_type(), oop);
43 vt->load_values(gvn, mem, vt->get_value_klass(), oop);
44 return gvn.transform(vt);
45 }
46
47 Node* ValueTypeNode::make(PhaseGVN& gvn, ciValueKlass* klass, Node* mem, ciInstanceKlass* holder, Node* obj, int field_offset) {
48 // Create and initialize a ValueTypeNode by loading all field
49 // values from a flattened value type field at 'field_offset' in 'obj'.
50 ValueTypeNode* vt = make(gvn, klass)->as_ValueType();
51 // The value type is flattened into the object without an oop header. Subtract the
52 // offset of the first field to account for the missing header when loading the values.
282 uint first_ind = (sfpt->req() - jvms->scloff());
283 SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type,
284 #ifdef ASSERT
285 NULL,
286 #endif
287 first_ind, nfields);
288 sobj->init_req(0, C->root());
289 // Iterate over the value type fields in order of increasing
290 // offset and add the field values to the safepoint.
291 for (uint j = 0; j < nfields; ++j) {
292 int offset = vk->nonstatic_field_at(j)->offset();
293 Node* value = get_field_value_by_offset(offset, true /* include flattened value type fields */);
294 sfpt->add_req(value);
295 }
296 jvms->set_endoff(sfpt->req());
297 int nb = sfpt->replace_edges_in_range(this, sobj, start, end);
298 --i; imax -= nb;
299 }
300 }
301 }
302 }
303
304 Node* ValueTypeNode::Ideal(PhaseGVN* phase, bool can_reshape) {
305 // No optimizations for now
306 return NULL;
307 }
308
309 #ifndef PRODUCT
310
311 void ValueTypeNode::dump_spec(outputStream* st) const {
312 TypeNode::dump_spec(st);
313 }
314
315 #endif
|
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 *
23 */
24
25 #include "ci/ciValueKlass.hpp"
26 #include "opto/addnode.hpp"
27 #include "opto/graphKit.hpp"
28 #include "opto/rootnode.hpp"
29 #include "opto/valuetypenode.hpp"
30 #include "opto/phaseX.hpp"
31
32 ValueTypeNode* ValueTypeNode::make(PhaseGVN& gvn, ciValueKlass* klass) {
33 // Create a new ValueTypeNode with uninitialized values and NULL oop
34 const TypeValueType* type = TypeValueType::make(klass);
35 return new ValueTypeNode(type, gvn.zerocon(T_VALUETYPE));
36 }
37
38 Node* ValueTypeNode::make(PhaseGVN& gvn, Node* mem, Node* oop) {
39 // Create and initialize a ValueTypeNode by loading all field
40 // values from a heap-allocated version and also save the oop.
41 const TypeValueTypePtr* vtptr = gvn.type(oop)->is_valuetypeptr();
42 ValueTypeNode* vt = new ValueTypeNode(vtptr->value_type(), oop);
43 vt->load_values(gvn, mem, vt->get_value_klass(), oop);
44 return gvn.transform(vt);
45 }
46
47 Node* ValueTypeNode::make(PhaseGVN& gvn, ciValueKlass* klass, Node* mem, ciInstanceKlass* holder, Node* obj, int field_offset) {
48 // Create and initialize a ValueTypeNode by loading all field
49 // values from a flattened value type field at 'field_offset' in 'obj'.
50 ValueTypeNode* vt = make(gvn, klass)->as_ValueType();
51 // The value type is flattened into the object without an oop header. Subtract the
52 // offset of the first field to account for the missing header when loading the values.
282 uint first_ind = (sfpt->req() - jvms->scloff());
283 SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type,
284 #ifdef ASSERT
285 NULL,
286 #endif
287 first_ind, nfields);
288 sobj->init_req(0, C->root());
289 // Iterate over the value type fields in order of increasing
290 // offset and add the field values to the safepoint.
291 for (uint j = 0; j < nfields; ++j) {
292 int offset = vk->nonstatic_field_at(j)->offset();
293 Node* value = get_field_value_by_offset(offset, true /* include flattened value type fields */);
294 sfpt->add_req(value);
295 }
296 jvms->set_endoff(sfpt->req());
297 int nb = sfpt->replace_edges_in_range(this, sobj, start, end);
298 --i; imax -= nb;
299 }
300 }
301 }
302 }
303
304 uint ValueTypeNode::set_arguments_for_java_call(CallJavaNode* call, int base_input, const GraphKit& kit, ciValueKlass* base_vk, int base_offset) {
305 ciValueKlass* vk = get_value_klass();
306 if (base_vk == NULL) {
307 base_vk = vk;
308 }
309 uint edges = 0;
310 for (uint i = 0; i < field_count(); i++) {
311 ciType* field_type = get_field_type(i);
312 int offset = base_offset + get_field_offset(i) - (base_offset > 0 ? vk->get_first_field_offset() : 0);
313 Node* arg = get_field_value(i);
314 if (field_type->is_valuetype()) {
315 ciValueKlass* embedded_vk = field_type->as_value_klass();
316 edges += arg->as_ValueType()->set_arguments_for_java_call(call, base_input, kit, base_vk, offset);
317 } else {
318 int j = 0; int extra = 0;
319 for (; j < base_vk->nof_nonstatic_fields(); j++) {
320 ciField* f = base_vk->nonstatic_field_at(j);
321 if (offset == f->offset()) {
322 assert(f->type() == field_type, "");
323 break;
324 }
325 BasicType bt = f->type()->basic_type();
326 if (bt == T_LONG || bt == T_DOUBLE) {
327 extra++;
328 }
329 }
330 call->init_req(base_input + j + extra, arg);
331 edges++;
332 BasicType bt = field_type->basic_type();
333 if (bt == T_LONG || bt == T_DOUBLE) {
334 call->init_req(base_input + j + extra + 1, kit.top());
335 edges++;
336 }
337 }
338 }
339 return edges;
340 }
341
342 Node* ValueTypeNode::Ideal(PhaseGVN* phase, bool can_reshape) {
343 // No optimizations for now
344 return NULL;
345 }
346
347 #ifndef PRODUCT
348
349 void ValueTypeNode::dump_spec(outputStream* st) const {
350 TypeNode::dump_spec(st);
351 }
352
353 #endif
|