2576 enum { no_int_result_path = 1,
2577 no_clear_result_path = 2,
2578 slow_result_path = 3
2579 };
2580
2581 // (a) Receiving thread must be the current thread.
2582 Node* rec_thr = argument(0);
2583 Node* tls_ptr = NULL;
2584 Node* cur_thr = generate_current_thread(tls_ptr);
2585 Node* cmp_thr = _gvn.transform( new (C, 3) CmpPNode(cur_thr, rec_thr) );
2586 Node* bol_thr = _gvn.transform( new (C, 2) BoolNode(cmp_thr, BoolTest::ne) );
2587
2588 bool known_current_thread = (_gvn.type(bol_thr) == TypeInt::ZERO);
2589 if (!known_current_thread)
2590 generate_slow_guard(bol_thr, slow_region);
2591
2592 // (b) Interrupt bit on TLS must be false.
2593 Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset()));
2594 Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS);
2595 p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::interrupted_offset()));
2596 Node* int_bit = make_load(NULL, p, TypeInt::BOOL, T_INT);
2597 Node* cmp_bit = _gvn.transform( new (C, 3) CmpINode(int_bit, intcon(0)) );
2598 Node* bol_bit = _gvn.transform( new (C, 2) BoolNode(cmp_bit, BoolTest::ne) );
2599
2600 IfNode* iff_bit = create_and_map_if(control(), bol_bit, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN);
2601
2602 // First fast path: if (!TLS._interrupted) return false;
2603 Node* false_bit = _gvn.transform( new (C, 1) IfFalseNode(iff_bit) );
2604 result_rgn->init_req(no_int_result_path, false_bit);
2605 result_val->init_req(no_int_result_path, intcon(0));
2606
2607 // drop through to next case
2608 set_control( _gvn.transform(new (C, 1) IfTrueNode(iff_bit)) );
2609
2610 // (c) Or, if interrupt bit is set and clear_int is false, use 2nd fast path.
2611 Node* clr_arg = argument(1);
2612 Node* cmp_arg = _gvn.transform( new (C, 3) CmpINode(clr_arg, intcon(0)) );
2613 Node* bol_arg = _gvn.transform( new (C, 2) BoolNode(cmp_arg, BoolTest::ne) );
2614 IfNode* iff_arg = create_and_map_if(control(), bol_arg, PROB_FAIR, COUNT_UNKNOWN);
2615
2616 // Second fast path: ... else if (!clear_int) return true;
|
2576 enum { no_int_result_path = 1,
2577 no_clear_result_path = 2,
2578 slow_result_path = 3
2579 };
2580
2581 // (a) Receiving thread must be the current thread.
2582 Node* rec_thr = argument(0);
2583 Node* tls_ptr = NULL;
2584 Node* cur_thr = generate_current_thread(tls_ptr);
2585 Node* cmp_thr = _gvn.transform( new (C, 3) CmpPNode(cur_thr, rec_thr) );
2586 Node* bol_thr = _gvn.transform( new (C, 2) BoolNode(cmp_thr, BoolTest::ne) );
2587
2588 bool known_current_thread = (_gvn.type(bol_thr) == TypeInt::ZERO);
2589 if (!known_current_thread)
2590 generate_slow_guard(bol_thr, slow_region);
2591
2592 // (b) Interrupt bit on TLS must be false.
2593 Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset()));
2594 Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS);
2595 p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::interrupted_offset()));
2596 // Set the control input on the field _interrupted read to prevent it to flow up.
2597 Node* int_bit = make_load(control(), p, TypeInt::BOOL, T_INT);
2598 Node* cmp_bit = _gvn.transform( new (C, 3) CmpINode(int_bit, intcon(0)) );
2599 Node* bol_bit = _gvn.transform( new (C, 2) BoolNode(cmp_bit, BoolTest::ne) );
2600
2601 IfNode* iff_bit = create_and_map_if(control(), bol_bit, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN);
2602
2603 // First fast path: if (!TLS._interrupted) return false;
2604 Node* false_bit = _gvn.transform( new (C, 1) IfFalseNode(iff_bit) );
2605 result_rgn->init_req(no_int_result_path, false_bit);
2606 result_val->init_req(no_int_result_path, intcon(0));
2607
2608 // drop through to next case
2609 set_control( _gvn.transform(new (C, 1) IfTrueNode(iff_bit)) );
2610
2611 // (c) Or, if interrupt bit is set and clear_int is false, use 2nd fast path.
2612 Node* clr_arg = argument(1);
2613 Node* cmp_arg = _gvn.transform( new (C, 3) CmpINode(clr_arg, intcon(0)) );
2614 Node* bol_arg = _gvn.transform( new (C, 2) BoolNode(cmp_arg, BoolTest::ne) );
2615 IfNode* iff_arg = create_and_map_if(control(), bol_arg, PROB_FAIR, COUNT_UNKNOWN);
2616
2617 // Second fast path: ... else if (!clear_int) return true;
|