352 SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type, 353 #ifdef ASSERT 354 NULL, 355 #endif 356 first_ind, nfields); 357 sobj->init_req(0, C->root()); 358 // Iterate over the value type fields in order of increasing 359 // offset and add the field values to the safepoint. 360 for (uint j = 0; j < nfields; ++j) { 361 int offset = vk->nonstatic_field_at(j)->offset(); 362 Node* value = field_value_by_offset(offset, true /* include flattened value type fields */); 363 sfpt->add_req(value); 364 } 365 jvms->set_endoff(sfpt->req()); 366 int nb = sfpt->replace_edges_in_range(this, sobj, start, end); 367 --i; imax -= nb; 368 } 369 } 370 } 371 372 uint ValueTypeNode::set_arguments_for_java_call(CallJavaNode* call, int base_input, const GraphKit& kit, ciValueKlass* base_vk, int base_offset) { 373 ciValueKlass* vk = value_klass(); 374 if (base_vk == NULL) { 375 base_vk = vk; 376 } 377 uint edges = 0; 378 for (uint i = 0; i < field_count(); i++) { 379 ciType* f_type = field_type(i); 380 int offset = base_offset + field_offset(i) - (base_offset > 0 ? vk->first_field_offset() : 0); 381 Node* arg = field_value(i); 382 if (f_type->is_valuetype()) { 383 ciValueKlass* embedded_vk = f_type->as_value_klass(); 384 edges += arg->as_ValueType()->set_arguments_for_java_call(call, base_input, kit, base_vk, offset); 385 } else { 386 int j = 0; int extra = 0; 387 for (; j < base_vk->nof_nonstatic_fields(); j++) { 388 ciField* f = base_vk->nonstatic_field_at(j); 389 if (offset == f->offset()) { 390 assert(f->type() == f_type, "inconsistent field type"); 391 break; 392 } 393 BasicType bt = f->type()->basic_type(); 394 if (bt == T_LONG || bt == T_DOUBLE) { 395 extra++; 396 } 397 } 398 call->init_req(base_input + j + extra, arg); 399 edges++; 400 BasicType bt = f_type->basic_type(); 401 if (bt == T_LONG || bt == T_DOUBLE) { 402 call->init_req(base_input + j + extra + 1, kit.top()); 403 edges++; 404 } 405 } 406 } 407 return edges; 408 } 409 410 Node* ValueTypeNode::Ideal(PhaseGVN* phase, bool can_reshape) { 411 if (can_reshape) { 412 PhaseIterGVN* igvn = phase->is_IterGVN(); 413 const Type* oop_type = igvn->type(get_oop()); 414 if (oop_type->meet(TypePtr::NULL_PTR) != oop_type) { 415 // Value type is heap allocated, search for safepoint uses 416 for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) { 417 Node* out = fast_out(i); 418 if (out->is_SafePoint()) { 419 // Let SafePointNode::Ideal() take care of re-wiring the 420 // safepoint to the oop input instead of the value type node. 421 igvn->rehash_node_delayed(out); 422 } 423 } 424 } 425 } 426 427 return NULL; 428 } 429 430 #ifndef PRODUCT 431 432 void ValueTypeNode::dump_spec(outputStream* st) const { 433 TypeNode::dump_spec(st); 434 } 435 436 #endif | 352 SafePointScalarObjectNode* sobj = new SafePointScalarObjectNode(res_type, 353 #ifdef ASSERT 354 NULL, 355 #endif 356 first_ind, nfields); 357 sobj->init_req(0, C->root()); 358 // Iterate over the value type fields in order of increasing 359 // offset and add the field values to the safepoint. 360 for (uint j = 0; j < nfields; ++j) { 361 int offset = vk->nonstatic_field_at(j)->offset(); 362 Node* value = field_value_by_offset(offset, true /* include flattened value type fields */); 363 sfpt->add_req(value); 364 } 365 jvms->set_endoff(sfpt->req()); 366 int nb = sfpt->replace_edges_in_range(this, sobj, start, end); 367 --i; imax -= nb; 368 } 369 } 370 } 371 372 void ValueTypeNode::pass_klass(Node* n, uint pos, const GraphKit& kit) { 373 ciValueKlass* vk = value_klass(); 374 const TypeKlassPtr* tk = TypeKlassPtr::make(vk); 375 Node* arg = kit.makecon(tk); 376 n->init_req(pos, arg); 377 } 378 379 uint ValueTypeNode::pass_fields(Node* n, int base_input, const GraphKit& kit, ciValueKlass* base_vk, int base_offset) { 380 ciValueKlass* vk = value_klass(); 381 if (base_vk == NULL) { 382 base_vk = vk; 383 } 384 uint edges = 0; 385 for (uint i = 0; i < field_count(); i++) { 386 ciType* f_type = field_type(i); 387 int offset = base_offset + field_offset(i) - (base_offset > 0 ? vk->first_field_offset() : 0); 388 Node* arg = field_value(i); 389 if (f_type->is_valuetype()) { 390 ciValueKlass* embedded_vk = f_type->as_value_klass(); 391 edges += arg->as_ValueType()->pass_fields(n, base_input, kit, base_vk, offset); 392 } else { 393 int j = 0; int extra = 0; 394 for (; j < base_vk->nof_nonstatic_fields(); j++) { 395 ciField* f = base_vk->nonstatic_field_at(j); 396 if (offset == f->offset()) { 397 assert(f->type() == f_type, "inconsistent field type"); 398 break; 399 } 400 BasicType bt = f->type()->basic_type(); 401 if (bt == T_LONG || bt == T_DOUBLE) { 402 extra++; 403 } 404 } 405 n->init_req(base_input + j + extra, arg); 406 edges++; 407 BasicType bt = f_type->basic_type(); 408 if (bt == T_LONG || bt == T_DOUBLE) { 409 n->init_req(base_input + j + extra + 1, kit.top()); 410 edges++; 411 } 412 } 413 } 414 return edges; 415 } 416 417 Node* ValueTypeNode::Ideal(PhaseGVN* phase, bool can_reshape) { 418 if (can_reshape) { 419 PhaseIterGVN* igvn = phase->is_IterGVN(); 420 const Type* oop_type = igvn->type(get_oop()); 421 if (oop_type->meet(TypePtr::NULL_PTR) != oop_type) { 422 // Value type is heap allocated, search for safepoint uses 423 for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) { 424 Node* out = fast_out(i); 425 if (out->is_SafePoint()) { 426 // Let SafePointNode::Ideal() take care of re-wiring the 427 // safepoint to the oop input instead of the value type node. 428 igvn->rehash_node_delayed(out); 429 } 430 } 431 } 432 } 433 434 return NULL; 435 } 436 437 // When a call returns multiple values, it has several result 438 // projections, one per field. Replacing the result of the call by a 439 // value type node (after late inlining) requires that for each result 440 // projection, we find the corresponding value type field. 441 void ValueTypeNode::replace_call_results(Node* call, Compile* C) { 442 ciValueKlass* vk = value_klass(); 443 for (DUIterator_Fast imax, i = call->fast_outs(imax); i < imax; i++) { 444 ProjNode *pn = call->fast_out(i)->as_Proj(); 445 uint con = pn->_con; 446 if (con >= TypeFunc::Parms+1) { 447 uint field_nb = con - (TypeFunc::Parms+1); 448 int extra = 0; 449 for (uint j = 0; j < field_nb - extra; j++) { 450 ciField* f = vk->nonstatic_field_at(j); 451 BasicType bt = f->type()->basic_type(); 452 if (bt == T_LONG || bt == T_DOUBLE) { 453 extra++; 454 } 455 } 456 ciField* f = vk->nonstatic_field_at(field_nb - extra); 457 Node* field = field_value_by_offset(f->offset(), true); 458 459 C->gvn_replace_by(pn, field); 460 C->initial_gvn()->hash_delete(pn); 461 pn->set_req(0, C->top()); 462 --i; --imax; 463 } 464 } 465 } 466 467 468 #ifndef PRODUCT 469 470 void ValueTypeNode::dump_spec(outputStream* st) const { 471 TypeNode::dump_spec(st); 472 } 473 474 #endif |