comparison src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @ 1783:d5d065957597

6953144: Tiered compilation Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation. Reviewed-by: kvn, never, phh, twisti
author iveresov
date Fri, 03 Sep 2010 17:51:07 -0700
parents e9ff18c4ace7
children 3a294e483abc
comparison
equal deleted inserted replaced
1782:f353275af40e 1783:d5d065957597
1623 } 1623 }
1624 1624
1625 1625
1626 void LIR_Assembler::return_op(LIR_Opr result) { 1626 void LIR_Assembler::return_op(LIR_Opr result) {
1627 // the poll may need a register so just pick one that isn't the return register 1627 // the poll may need a register so just pick one that isn't the return register
1628 #ifdef TIERED 1628 #if defined(TIERED) && !defined(_LP64)
1629 if (result->type_field() == LIR_OprDesc::long_type) { 1629 if (result->type_field() == LIR_OprDesc::long_type) {
1630 // Must move the result to G1 1630 // Must move the result to G1
1631 // Must leave proper result in O0,O1 and G1 (TIERED only) 1631 // Must leave proper result in O0,O1 and G1 (TIERED only)
1632 __ sllx(I0, 32, G1); // Shift bits into high G1 1632 __ sllx(I0, 32, G1); // Shift bits into high G1
1633 __ srl (I1, 0, I1); // Zero extend O1 (harmless?) 1633 __ srl (I1, 0, I1); // Zero extend O1 (harmless?)
1634 __ or3 (I1, G1, G1); // OR 64 bits into G1 1634 __ or3 (I1, G1, G1); // OR 64 bits into G1
1635 #ifdef ASSERT
1636 // mangle it so any problems will show up
1637 __ set(0xdeadbeef, I0);
1638 __ set(0xdeadbeef, I1);
1639 #endif
1635 } 1640 }
1636 #endif // TIERED 1641 #endif // TIERED
1637 __ set((intptr_t)os::get_polling_page(), L0); 1642 __ set((intptr_t)os::get_polling_page(), L0);
1638 __ relocate(relocInfo::poll_return_type); 1643 __ relocate(relocInfo::poll_return_type);
1639 __ ld_ptr(L0, 0, G0); 1644 __ ld_ptr(L0, 0, G0);
2422 } 2427 }
2423 __ bind(*op->stub()->continuation()); 2428 __ bind(*op->stub()->continuation());
2424 } 2429 }
2425 2430
2426 2431
2432 void LIR_Assembler::type_profile_helper(Register mdo, int mdo_offset_bias,
2433 ciMethodData *md, ciProfileData *data,
2434 Register recv, Register tmp1, Label* update_done) {
2435 uint i;
2436 for (i = 0; i < VirtualCallData::row_limit(); i++) {
2437 Label next_test;
2438 // See if the receiver is receiver[n].
2439 Address receiver_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) -
2440 mdo_offset_bias);
2441 __ ld_ptr(receiver_addr, tmp1);
2442 __ verify_oop(tmp1);
2443 __ cmp(recv, tmp1);
2444 __ brx(Assembler::notEqual, false, Assembler::pt, next_test);
2445 __ delayed()->nop();
2446 Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) -
2447 mdo_offset_bias);
2448 __ ld_ptr(data_addr, tmp1);
2449 __ add(tmp1, DataLayout::counter_increment, tmp1);
2450 __ st_ptr(tmp1, data_addr);
2451 __ ba(false, *update_done);
2452 __ delayed()->nop();
2453 __ bind(next_test);
2454 }
2455
2456 // Didn't find receiver; find next empty slot and fill it in
2457 for (i = 0; i < VirtualCallData::row_limit(); i++) {
2458 Label next_test;
2459 Address recv_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) -
2460 mdo_offset_bias);
2461 load(recv_addr, tmp1, T_OBJECT);
2462 __ br_notnull(tmp1, false, Assembler::pt, next_test);
2463 __ delayed()->nop();
2464 __ st_ptr(recv, recv_addr);
2465 __ set(DataLayout::counter_increment, tmp1);
2466 __ st_ptr(tmp1, mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) -
2467 mdo_offset_bias);
2468 __ ba(false, *update_done);
2469 __ delayed()->nop();
2470 __ bind(next_test);
2471 }
2472 }
2473
2474 void LIR_Assembler::emit_checkcast(LIR_OpTypeCheck *op) {
2475 assert(op->code() == lir_checkcast, "Invalid operation");
2476 // we always need a stub for the failure case.
2477 CodeStub* stub = op->stub();
2478 Register obj = op->object()->as_register();
2479 Register k_RInfo = op->tmp1()->as_register();
2480 Register klass_RInfo = op->tmp2()->as_register();
2481 Register dst = op->result_opr()->as_register();
2482 Register Rtmp1 = op->tmp3()->as_register();
2483 ciKlass* k = op->klass();
2484
2485
2486 if (obj == k_RInfo) {
2487 k_RInfo = klass_RInfo;
2488 klass_RInfo = obj;
2489 }
2490
2491 ciMethodData* md;
2492 ciProfileData* data;
2493 int mdo_offset_bias = 0;
2494 if (op->should_profile()) {
2495 ciMethod* method = op->profiled_method();
2496 assert(method != NULL, "Should have method");
2497 int bci = op->profiled_bci();
2498 md = method->method_data();
2499 if (md == NULL) {
2500 bailout("out of memory building methodDataOop");
2501 return;
2502 }
2503 data = md->bci_to_data(bci);
2504 assert(data != NULL, "need data for checkcast");
2505 assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for checkcast");
2506 if (!Assembler::is_simm13(md->byte_offset_of_slot(data, DataLayout::header_offset()) + data->size_in_bytes())) {
2507 // The offset is large so bias the mdo by the base of the slot so
2508 // that the ld can use simm13s to reference the slots of the data
2509 mdo_offset_bias = md->byte_offset_of_slot(data, DataLayout::header_offset());
2510 }
2511
2512 // We need two temporaries to perform this operation on SPARC,
2513 // so to keep things simple we perform a redundant test here
2514 Label profile_done;
2515 __ br_notnull(obj, false, Assembler::pn, profile_done);
2516 __ delayed()->nop();
2517 Register mdo = k_RInfo;
2518 Register data_val = Rtmp1;
2519 jobject2reg(md->constant_encoding(), mdo);
2520 if (mdo_offset_bias > 0) {
2521 __ set(mdo_offset_bias, data_val);
2522 __ add(mdo, data_val, mdo);
2523 }
2524 Address flags_addr(mdo, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias);
2525 __ ldub(flags_addr, data_val);
2526 __ or3(data_val, BitData::null_seen_byte_constant(), data_val);
2527 __ stb(data_val, flags_addr);
2528 __ bind(profile_done);
2529 }
2530 Label profile_cast_failure;
2531
2532 Label done, done_null;
2533 // Where to go in case of cast failure
2534 Label *failure_target = op->should_profile() ? &profile_cast_failure : stub->entry();
2535
2536 // patching may screw with our temporaries on sparc,
2537 // so let's do it before loading the class
2538 if (k->is_loaded()) {
2539 jobject2reg(k->constant_encoding(), k_RInfo);
2540 } else {
2541 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
2542 }
2543 assert(obj != k_RInfo, "must be different");
2544 __ br_null(obj, false, Assembler::pn, done_null);
2545 __ delayed()->nop();
2546
2547 // get object class
2548 // not a safepoint as obj null check happens earlier
2549 load(obj, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL);
2550 if (op->fast_check()) {
2551 assert_different_registers(klass_RInfo, k_RInfo);
2552 __ cmp(k_RInfo, klass_RInfo);
2553 __ brx(Assembler::notEqual, false, Assembler::pt, *failure_target);
2554 __ delayed()->nop();
2555 } else {
2556 bool need_slow_path = true;
2557 if (k->is_loaded()) {
2558 if (k->super_check_offset() != sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes())
2559 need_slow_path = false;
2560 // perform the fast part of the checking logic
2561 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, noreg,
2562 (need_slow_path ? &done : NULL),
2563 failure_target, NULL,
2564 RegisterOrConstant(k->super_check_offset()));
2565 } else {
2566 // perform the fast part of the checking logic
2567 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, O7, &done,
2568 failure_target, NULL);
2569 }
2570 if (need_slow_path) {
2571 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
2572 assert(klass_RInfo == G3 && k_RInfo == G1, "incorrect call setup");
2573 __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type);
2574 __ delayed()->nop();
2575 __ cmp(G3, 0);
2576 __ br(Assembler::equal, false, Assembler::pn, *failure_target);
2577 __ delayed()->nop();
2578 }
2579 }
2580 __ bind(done);
2581
2582 if (op->should_profile()) {
2583 Register mdo = klass_RInfo, recv = k_RInfo, tmp1 = Rtmp1;
2584 assert_different_registers(obj, mdo, recv, tmp1);
2585
2586 jobject2reg(md->constant_encoding(), mdo);
2587 if (mdo_offset_bias > 0) {
2588 __ set(mdo_offset_bias, tmp1);
2589 __ add(mdo, tmp1, mdo);
2590 }
2591 Label update_done;
2592 load(Address(obj, oopDesc::klass_offset_in_bytes()), recv, T_OBJECT);
2593 type_profile_helper(mdo, mdo_offset_bias, md, data, recv, tmp1, &update_done);
2594 // Jump over the failure case
2595 __ ba(false, update_done);
2596 __ delayed()->nop();
2597
2598
2599 // Cast failure case
2600 __ bind(profile_cast_failure);
2601 jobject2reg(md->constant_encoding(), mdo);
2602 if (mdo_offset_bias > 0) {
2603 __ set(mdo_offset_bias, tmp1);
2604 __ add(mdo, tmp1, mdo);
2605 }
2606 Address data_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias);
2607 __ ld_ptr(data_addr, tmp1);
2608 __ sub(tmp1, DataLayout::counter_increment, tmp1);
2609 __ st_ptr(tmp1, data_addr);
2610 __ ba(false, *stub->entry());
2611 __ delayed()->nop();
2612
2613 __ bind(update_done);
2614 }
2615
2616 __ bind(done_null);
2617 __ mov(obj, dst);
2618 }
2619
2620
2427 void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { 2621 void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
2428 LIR_Code code = op->code(); 2622 LIR_Code code = op->code();
2429 if (code == lir_store_check) { 2623 if (code == lir_store_check) {
2430 Register value = op->object()->as_register(); 2624 Register value = op->object()->as_register();
2431 Register array = op->array()->as_register(); 2625 Register array = op->array()->as_register();
2435 2629
2436 __ verify_oop(value); 2630 __ verify_oop(value);
2437 2631
2438 CodeStub* stub = op->stub(); 2632 CodeStub* stub = op->stub();
2439 Label done; 2633 Label done;
2440 __ cmp(value, 0); 2634 __ br_null(value, false, Assembler::pn, done);
2441 __ br(Assembler::equal, false, Assembler::pn, done);
2442 __ delayed()->nop(); 2635 __ delayed()->nop();
2443 load(array, oopDesc::klass_offset_in_bytes(), k_RInfo, T_OBJECT, op->info_for_exception()); 2636 load(array, oopDesc::klass_offset_in_bytes(), k_RInfo, T_OBJECT, op->info_for_exception());
2444 load(value, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL); 2637 load(value, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL);
2445 2638
2446 // get instance klass 2639 // get instance klass
2454 __ delayed()->nop(); 2647 __ delayed()->nop();
2455 __ cmp(G3, 0); 2648 __ cmp(G3, 0);
2456 __ br(Assembler::equal, false, Assembler::pn, *stub->entry()); 2649 __ br(Assembler::equal, false, Assembler::pn, *stub->entry());
2457 __ delayed()->nop(); 2650 __ delayed()->nop();
2458 __ bind(done); 2651 __ bind(done);
2459 } else if (op->code() == lir_checkcast) {
2460 // we always need a stub for the failure case.
2461 CodeStub* stub = op->stub();
2462 Register obj = op->object()->as_register();
2463 Register k_RInfo = op->tmp1()->as_register();
2464 Register klass_RInfo = op->tmp2()->as_register();
2465 Register dst = op->result_opr()->as_register();
2466 Register Rtmp1 = op->tmp3()->as_register();
2467 ciKlass* k = op->klass();
2468
2469 if (obj == k_RInfo) {
2470 k_RInfo = klass_RInfo;
2471 klass_RInfo = obj;
2472 }
2473 if (op->profiled_method() != NULL) {
2474 ciMethod* method = op->profiled_method();
2475 int bci = op->profiled_bci();
2476
2477 // We need two temporaries to perform this operation on SPARC,
2478 // so to keep things simple we perform a redundant test here
2479 Label profile_done;
2480 __ cmp(obj, 0);
2481 __ br(Assembler::notEqual, false, Assembler::pn, profile_done);
2482 __ delayed()->nop();
2483 // Object is null; update methodDataOop
2484 ciMethodData* md = method->method_data();
2485 if (md == NULL) {
2486 bailout("out of memory building methodDataOop");
2487 return;
2488 }
2489 ciProfileData* data = md->bci_to_data(bci);
2490 assert(data != NULL, "need data for checkcast");
2491 assert(data->is_BitData(), "need BitData for checkcast");
2492 Register mdo = k_RInfo;
2493 Register data_val = Rtmp1;
2494 jobject2reg(md->constant_encoding(), mdo);
2495
2496 int mdo_offset_bias = 0;
2497 if (!Assembler::is_simm13(md->byte_offset_of_slot(data, DataLayout::header_offset()) + data->size_in_bytes())) {
2498 // The offset is large so bias the mdo by the base of the slot so
2499 // that the ld can use simm13s to reference the slots of the data
2500 mdo_offset_bias = md->byte_offset_of_slot(data, DataLayout::header_offset());
2501 __ set(mdo_offset_bias, data_val);
2502 __ add(mdo, data_val, mdo);
2503 }
2504
2505
2506 Address flags_addr(mdo, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias);
2507 __ ldub(flags_addr, data_val);
2508 __ or3(data_val, BitData::null_seen_byte_constant(), data_val);
2509 __ stb(data_val, flags_addr);
2510 __ bind(profile_done);
2511 }
2512
2513 Label done;
2514 // patching may screw with our temporaries on sparc,
2515 // so let's do it before loading the class
2516 if (k->is_loaded()) {
2517 jobject2reg(k->constant_encoding(), k_RInfo);
2518 } else {
2519 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
2520 }
2521 assert(obj != k_RInfo, "must be different");
2522 __ cmp(obj, 0);
2523 __ br(Assembler::equal, false, Assembler::pn, done);
2524 __ delayed()->nop();
2525
2526 // get object class
2527 // not a safepoint as obj null check happens earlier
2528 load(obj, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL);
2529 if (op->fast_check()) {
2530 assert_different_registers(klass_RInfo, k_RInfo);
2531 __ cmp(k_RInfo, klass_RInfo);
2532 __ br(Assembler::notEqual, false, Assembler::pt, *stub->entry());
2533 __ delayed()->nop();
2534 __ bind(done);
2535 } else {
2536 bool need_slow_path = true;
2537 if (k->is_loaded()) {
2538 if (k->super_check_offset() != sizeof(oopDesc) + Klass::secondary_super_cache_offset_in_bytes())
2539 need_slow_path = false;
2540 // perform the fast part of the checking logic
2541 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, noreg,
2542 (need_slow_path ? &done : NULL),
2543 stub->entry(), NULL,
2544 RegisterOrConstant(k->super_check_offset()));
2545 } else {
2546 // perform the fast part of the checking logic
2547 __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, O7,
2548 &done, stub->entry(), NULL);
2549 }
2550 if (need_slow_path) {
2551 // call out-of-line instance of __ check_klass_subtype_slow_path(...):
2552 assert(klass_RInfo == G3 && k_RInfo == G1, "incorrect call setup");
2553 __ call(Runtime1::entry_for(Runtime1::slow_subtype_check_id), relocInfo::runtime_call_type);
2554 __ delayed()->nop();
2555 __ cmp(G3, 0);
2556 __ br(Assembler::equal, false, Assembler::pn, *stub->entry());
2557 __ delayed()->nop();
2558 }
2559 __ bind(done);
2560 }
2561 __ mov(obj, dst);
2562 } else if (code == lir_instanceof) { 2652 } else if (code == lir_instanceof) {
2563 Register obj = op->object()->as_register(); 2653 Register obj = op->object()->as_register();
2564 Register k_RInfo = op->tmp1()->as_register(); 2654 Register k_RInfo = op->tmp1()->as_register();
2565 Register klass_RInfo = op->tmp2()->as_register(); 2655 Register klass_RInfo = op->tmp2()->as_register();
2566 Register dst = op->result_opr()->as_register(); 2656 Register dst = op->result_opr()->as_register();
2578 jobject2reg(k->constant_encoding(), k_RInfo); 2668 jobject2reg(k->constant_encoding(), k_RInfo);
2579 } else { 2669 } else {
2580 jobject2reg_with_patching(k_RInfo, op->info_for_patch()); 2670 jobject2reg_with_patching(k_RInfo, op->info_for_patch());
2581 } 2671 }
2582 assert(obj != k_RInfo, "must be different"); 2672 assert(obj != k_RInfo, "must be different");
2583 __ cmp(obj, 0); 2673 __ br_null(obj, true, Assembler::pn, done);
2584 __ br(Assembler::equal, true, Assembler::pn, done);
2585 __ delayed()->set(0, dst); 2674 __ delayed()->set(0, dst);
2586 2675
2587 // get object class 2676 // get object class
2588 // not a safepoint as obj null check happens earlier 2677 // not a safepoint as obj null check happens earlier
2589 load(obj, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL); 2678 load(obj, oopDesc::klass_offset_in_bytes(), klass_RInfo, T_OBJECT, NULL);
2590 if (op->fast_check()) { 2679 if (op->fast_check()) {
2591 __ cmp(k_RInfo, klass_RInfo); 2680 __ cmp(k_RInfo, klass_RInfo);
2592 __ br(Assembler::equal, true, Assembler::pt, done); 2681 __ brx(Assembler::equal, true, Assembler::pt, done);
2593 __ delayed()->set(1, dst); 2682 __ delayed()->set(1, dst);
2594 __ set(0, dst); 2683 __ set(0, dst);
2595 __ bind(done); 2684 __ bind(done);
2596 } else { 2685 } else {
2597 bool need_slow_path = true; 2686 bool need_slow_path = true;
2774 return; 2863 return;
2775 } 2864 }
2776 ciProfileData* data = md->bci_to_data(bci); 2865 ciProfileData* data = md->bci_to_data(bci);
2777 assert(data->is_CounterData(), "need CounterData for calls"); 2866 assert(data->is_CounterData(), "need CounterData for calls");
2778 assert(op->mdo()->is_single_cpu(), "mdo must be allocated"); 2867 assert(op->mdo()->is_single_cpu(), "mdo must be allocated");
2868 Register mdo = op->mdo()->as_register();
2869 #ifdef _LP64
2870 assert(op->tmp1()->is_double_cpu(), "tmp1 must be allocated");
2871 Register tmp1 = op->tmp1()->as_register_lo();
2872 #else
2779 assert(op->tmp1()->is_single_cpu(), "tmp1 must be allocated"); 2873 assert(op->tmp1()->is_single_cpu(), "tmp1 must be allocated");
2780 Register mdo = op->mdo()->as_register();
2781 Register tmp1 = op->tmp1()->as_register(); 2874 Register tmp1 = op->tmp1()->as_register();
2875 #endif
2782 jobject2reg(md->constant_encoding(), mdo); 2876 jobject2reg(md->constant_encoding(), mdo);
2783 int mdo_offset_bias = 0; 2877 int mdo_offset_bias = 0;
2784 if (!Assembler::is_simm13(md->byte_offset_of_slot(data, CounterData::count_offset()) + 2878 if (!Assembler::is_simm13(md->byte_offset_of_slot(data, CounterData::count_offset()) +
2785 data->size_in_bytes())) { 2879 data->size_in_bytes())) {
2786 // The offset is large so bias the mdo by the base of the slot so 2880 // The offset is large so bias the mdo by the base of the slot so
2793 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias); 2887 Address counter_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias);
2794 Bytecodes::Code bc = method->java_code_at_bci(bci); 2888 Bytecodes::Code bc = method->java_code_at_bci(bci);
2795 // Perform additional virtual call profiling for invokevirtual and 2889 // Perform additional virtual call profiling for invokevirtual and
2796 // invokeinterface bytecodes 2890 // invokeinterface bytecodes
2797 if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) && 2891 if ((bc == Bytecodes::_invokevirtual || bc == Bytecodes::_invokeinterface) &&
2798 Tier1ProfileVirtualCalls) { 2892 C1ProfileVirtualCalls) {
2799 assert(op->recv()->is_single_cpu(), "recv must be allocated"); 2893 assert(op->recv()->is_single_cpu(), "recv must be allocated");
2800 Register recv = op->recv()->as_register(); 2894 Register recv = op->recv()->as_register();
2801 assert_different_registers(mdo, tmp1, recv); 2895 assert_different_registers(mdo, tmp1, recv);
2802 assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls"); 2896 assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
2803 ciKlass* known_klass = op->known_holder(); 2897 ciKlass* known_klass = op->known_holder();
2804 if (Tier1OptimizeVirtualCallProfiling && known_klass != NULL) { 2898 if (C1OptimizeVirtualCallProfiling && known_klass != NULL) {
2805 // We know the type that will be seen at this call site; we can 2899 // We know the type that will be seen at this call site; we can
2806 // statically update the methodDataOop rather than needing to do 2900 // statically update the methodDataOop rather than needing to do
2807 // dynamic tests on the receiver type 2901 // dynamic tests on the receiver type
2808 2902
2809 // NOTE: we should probably put a lock around this search to 2903 // NOTE: we should probably put a lock around this search to
2814 ciKlass* receiver = vc_data->receiver(i); 2908 ciKlass* receiver = vc_data->receiver(i);
2815 if (known_klass->equals(receiver)) { 2909 if (known_klass->equals(receiver)) {
2816 Address data_addr(mdo, md->byte_offset_of_slot(data, 2910 Address data_addr(mdo, md->byte_offset_of_slot(data,
2817 VirtualCallData::receiver_count_offset(i)) - 2911 VirtualCallData::receiver_count_offset(i)) -
2818 mdo_offset_bias); 2912 mdo_offset_bias);
2819 __ lduw(data_addr, tmp1); 2913 __ ld_ptr(data_addr, tmp1);
2820 __ add(tmp1, DataLayout::counter_increment, tmp1); 2914 __ add(tmp1, DataLayout::counter_increment, tmp1);
2821 __ stw(tmp1, data_addr); 2915 __ st_ptr(tmp1, data_addr);
2822 return; 2916 return;
2823 } 2917 }
2824 } 2918 }
2825 2919
2826 // Receiver type not found in profile data; select an empty slot 2920 // Receiver type not found in profile data; select an empty slot
2835 mdo_offset_bias); 2929 mdo_offset_bias);
2836 jobject2reg(known_klass->constant_encoding(), tmp1); 2930 jobject2reg(known_klass->constant_encoding(), tmp1);
2837 __ st_ptr(tmp1, recv_addr); 2931 __ st_ptr(tmp1, recv_addr);
2838 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) - 2932 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
2839 mdo_offset_bias); 2933 mdo_offset_bias);
2840 __ lduw(data_addr, tmp1); 2934 __ ld_ptr(data_addr, tmp1);
2841 __ add(tmp1, DataLayout::counter_increment, tmp1); 2935 __ add(tmp1, DataLayout::counter_increment, tmp1);
2842 __ stw(tmp1, data_addr); 2936 __ st_ptr(tmp1, data_addr);
2843 return; 2937 return;
2844 } 2938 }
2845 } 2939 }
2846 } else { 2940 } else {
2847 load(Address(recv, oopDesc::klass_offset_in_bytes()), recv, T_OBJECT); 2941 load(Address(recv, oopDesc::klass_offset_in_bytes()), recv, T_OBJECT);
2848 Label update_done; 2942 Label update_done;
2849 uint i; 2943 type_profile_helper(mdo, mdo_offset_bias, md, data, recv, tmp1, &update_done);
2850 for (i = 0; i < VirtualCallData::row_limit(); i++) {
2851 Label next_test;
2852 // See if the receiver is receiver[n].
2853 Address receiver_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) -
2854 mdo_offset_bias);
2855 __ ld_ptr(receiver_addr, tmp1);
2856 __ verify_oop(tmp1);
2857 __ cmp(recv, tmp1);
2858 __ brx(Assembler::notEqual, false, Assembler::pt, next_test);
2859 __ delayed()->nop();
2860 Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
2861 mdo_offset_bias);
2862 __ lduw(data_addr, tmp1);
2863 __ add(tmp1, DataLayout::counter_increment, tmp1);
2864 __ stw(tmp1, data_addr);
2865 __ br(Assembler::always, false, Assembler::pt, update_done);
2866 __ delayed()->nop();
2867 __ bind(next_test);
2868 }
2869
2870 // Didn't find receiver; find next empty slot and fill it in
2871 for (i = 0; i < VirtualCallData::row_limit(); i++) {
2872 Label next_test;
2873 Address recv_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) -
2874 mdo_offset_bias);
2875 load(recv_addr, tmp1, T_OBJECT);
2876 __ tst(tmp1);
2877 __ brx(Assembler::notEqual, false, Assembler::pt, next_test);
2878 __ delayed()->nop();
2879 __ st_ptr(recv, recv_addr);
2880 __ set(DataLayout::counter_increment, tmp1);
2881 __ st_ptr(tmp1, mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) -
2882 mdo_offset_bias);
2883 __ br(Assembler::always, false, Assembler::pt, update_done);
2884 __ delayed()->nop();
2885 __ bind(next_test);
2886 }
2887 // Receiver did not match any saved receiver and there is no empty row for it. 2944 // Receiver did not match any saved receiver and there is no empty row for it.
2888 // Increment total counter to indicate polymorphic case. 2945 // Increment total counter to indicate polymorphic case.
2889 __ lduw(counter_addr, tmp1); 2946 __ ld_ptr(counter_addr, tmp1);
2890 __ add(tmp1, DataLayout::counter_increment, tmp1); 2947 __ add(tmp1, DataLayout::counter_increment, tmp1);
2891 __ stw(tmp1, counter_addr); 2948 __ st_ptr(tmp1, counter_addr);
2892 2949
2893 __ bind(update_done); 2950 __ bind(update_done);
2894 } 2951 }
2895 } else { 2952 } else {
2896 // Static call 2953 // Static call
2897 __ lduw(counter_addr, tmp1); 2954 __ ld_ptr(counter_addr, tmp1);
2898 __ add(tmp1, DataLayout::counter_increment, tmp1); 2955 __ add(tmp1, DataLayout::counter_increment, tmp1);
2899 __ stw(tmp1, counter_addr); 2956 __ st_ptr(tmp1, counter_addr);
2900 } 2957 }
2901 } 2958 }
2902
2903 2959
2904 void LIR_Assembler::align_backward_branch_target() { 2960 void LIR_Assembler::align_backward_branch_target() {
2905 __ align(OptoLoopAlignment); 2961 __ align(OptoLoopAlignment);
2906 } 2962 }
2907 2963
3091 3147
3092 void LIR_Assembler::membar_release() { 3148 void LIR_Assembler::membar_release() {
3093 // no-op on TSO 3149 // no-op on TSO
3094 } 3150 }
3095 3151
3096 // Macro to Pack two sequential registers containing 32 bit values 3152 // Pack two sequential registers containing 32 bit values
3097 // into a single 64 bit register. 3153 // into a single 64 bit register.
3098 // rs and rs->successor() are packed into rd 3154 // src and src->successor() are packed into dst
3099 // rd and rs may be the same register. 3155 // src and dst may be the same register.
3100 // Note: rs and rs->successor() are destroyed. 3156 // Note: src is destroyed
3101 void LIR_Assembler::pack64( Register rs, Register rd ) { 3157 void LIR_Assembler::pack64(LIR_Opr src, LIR_Opr dst) {
3158 Register rs = src->as_register();
3159 Register rd = dst->as_register_lo();
3102 __ sllx(rs, 32, rs); 3160 __ sllx(rs, 32, rs);
3103 __ srl(rs->successor(), 0, rs->successor()); 3161 __ srl(rs->successor(), 0, rs->successor());
3104 __ or3(rs, rs->successor(), rd); 3162 __ or3(rs, rs->successor(), rd);
3105 } 3163 }
3106 3164
3107 // Macro to unpack a 64 bit value in a register into 3165 // Unpack a 64 bit value in a register into
3108 // two sequential registers. 3166 // two sequential registers.
3109 // rd is unpacked into rd and rd->successor() 3167 // src is unpacked into dst and dst->successor()
3110 void LIR_Assembler::unpack64( Register rd ) { 3168 void LIR_Assembler::unpack64(LIR_Opr src, LIR_Opr dst) {
3111 __ mov(rd, rd->successor()); 3169 Register rs = src->as_register_lo();
3112 __ srax(rd, 32, rd); 3170 Register rd = dst->as_register_hi();
3113 __ sra(rd->successor(), 0, rd->successor()); 3171 assert_different_registers(rs, rd, rd->successor());
3172 __ srlx(rs, 32, rd);
3173 __ srl (rs, 0, rd->successor());
3114 } 3174 }
3115 3175
3116 3176
3117 void LIR_Assembler::leal(LIR_Opr addr_opr, LIR_Opr dest) { 3177 void LIR_Assembler::leal(LIR_Opr addr_opr, LIR_Opr dest) {
3118 LIR_Address* addr = addr_opr->as_address_ptr(); 3178 LIR_Address* addr = addr_opr->as_address_ptr();
3119 assert(addr->index()->is_illegal() && addr->scale() == LIR_Address::times_1 && Assembler::is_simm13(addr->disp()), "can't handle complex addresses yet"); 3179 assert(addr->index()->is_illegal() && addr->scale() == LIR_Address::times_1 && Assembler::is_simm13(addr->disp()), "can't handle complex addresses yet");
3120 __ add(addr->base()->as_register(), addr->disp(), dest->as_register()); 3180
3181 __ add(addr->base()->as_pointer_register(), addr->disp(), dest->as_pointer_register());
3121 } 3182 }
3122 3183
3123 3184
3124 void LIR_Assembler::get_thread(LIR_Opr result_reg) { 3185 void LIR_Assembler::get_thread(LIR_Opr result_reg) {
3125 assert(result_reg->is_register(), "check"); 3186 assert(result_reg->is_register(), "check");
3186 inst->at(i - 1)->print(); 3247 inst->at(i - 1)->print();
3187 inst->at(i)->print(); 3248 inst->at(i)->print();
3188 tty->cr(); 3249 tty->cr();
3189 } 3250 }
3190 #endif 3251 #endif
3191 continue; 3252 } else {
3253 LIR_Op* delay_op = new LIR_OpDelay(new LIR_Op0(lir_nop), op->as_OpJavaCall()->info());
3254 inst->insert_before(i + 1, delay_op);
3255 i++;
3192 } 3256 }
3193 3257
3194 LIR_Op* delay_op = new LIR_OpDelay(new LIR_Op0(lir_nop), op->as_OpJavaCall()->info()); 3258 #if defined(TIERED) && !defined(_LP64)
3195 inst->insert_before(i + 1, delay_op); 3259 // fixup the return value from G1 to O0/O1 for long returns.
3260 // It's done here instead of in LIRGenerator because there's
3261 // such a mismatch between the single reg and double reg
3262 // calling convention.
3263 LIR_OpJavaCall* callop = op->as_OpJavaCall();
3264 if (callop->result_opr() == FrameMap::out_long_opr) {
3265 LIR_OpJavaCall* call;
3266 LIR_OprList* arguments = new LIR_OprList(callop->arguments()->length());
3267 for (int a = 0; a < arguments->length(); a++) {
3268 arguments[a] = callop->arguments()[a];
3269 }
3270 if (op->code() == lir_virtual_call) {
3271 call = new LIR_OpJavaCall(op->code(), callop->method(), callop->receiver(), FrameMap::g1_long_single_opr,
3272 callop->vtable_offset(), arguments, callop->info());
3273 } else {
3274 call = new LIR_OpJavaCall(op->code(), callop->method(), callop->receiver(), FrameMap::g1_long_single_opr,
3275 callop->addr(), arguments, callop->info());
3276 }
3277 inst->at_put(i - 1, call);
3278 inst->insert_before(i + 1, new LIR_Op1(lir_unpack64, FrameMap::g1_long_single_opr, callop->result_opr(),
3279 T_LONG, lir_patch_none, NULL));
3280 }
3281 #endif
3196 break; 3282 break;
3197 } 3283 }
3198 } 3284 }
3199 } 3285 }
3200 } 3286 }