--- a/hotspot/src/share/vm/opto/library_call.cpp Mon Dec 17 11:00:22 2012 -0800
+++ b/hotspot/src/share/vm/opto/library_call.cpp Tue Dec 18 06:52:00 2012 -0800
@@ -2952,14 +2952,23 @@
// We only go to the fast case code if we pass two guards.
// Paths which do not pass are accumulated in the slow_region.
+
+ enum {
+ no_int_result_path = 1, // t == Thread.current() && !TLS._osthread._interrupted
+ no_clear_result_path = 2, // t == Thread.current() && TLS._osthread._interrupted && !clear_int
+ slow_result_path = 3, // slow path: t.isInterrupted(clear_int)
+ PATH_LIMIT
+ };
+
+ // Ensure that it's not possible to move the load of TLS._osthread._interrupted flag
+ // out of the function.
+ insert_mem_bar(Op_MemBarCPUOrder);
+
+ RegionNode* result_rgn = new (C) RegionNode(PATH_LIMIT);
+ PhiNode* result_val = new (C) PhiNode(result_rgn, TypeInt::BOOL);
+
RegionNode* slow_region = new (C) RegionNode(1);
record_for_igvn(slow_region);
- RegionNode* result_rgn = new (C) RegionNode(1+3); // fast1, fast2, slow
- PhiNode* result_val = new (C) PhiNode(result_rgn, TypeInt::BOOL);
- enum { no_int_result_path = 1,
- no_clear_result_path = 2,
- slow_result_path = 3
- };
// (a) Receiving thread must be the current thread.
Node* rec_thr = argument(0);
@@ -2968,14 +2977,13 @@
Node* cmp_thr = _gvn.transform( new (C) CmpPNode(cur_thr, rec_thr) );
Node* bol_thr = _gvn.transform( new (C) BoolNode(cmp_thr, BoolTest::ne) );
- bool known_current_thread = (_gvn.type(bol_thr) == TypeInt::ZERO);
- if (!known_current_thread)
- generate_slow_guard(bol_thr, slow_region);
+ generate_slow_guard(bol_thr, slow_region);
// (b) Interrupt bit on TLS must be false.
Node* p = basic_plus_adr(top()/*!oop*/, tls_ptr, in_bytes(JavaThread::osthread_offset()));
Node* osthread = make_load(NULL, p, TypeRawPtr::NOTNULL, T_ADDRESS);
p = basic_plus_adr(top()/*!oop*/, osthread, in_bytes(OSThread::interrupted_offset()));
+
// Set the control input on the field _interrupted read to prevent it floating up.
Node* int_bit = make_load(control(), p, TypeInt::BOOL, T_INT);
Node* cmp_bit = _gvn.transform( new (C) CmpINode(int_bit, intcon(0)) );
@@ -3020,22 +3028,20 @@
Node* slow_val = set_results_for_java_call(slow_call);
// this->control() comes from set_results_for_java_call
- // If we know that the result of the slow call will be true, tell the optimizer!
- if (known_current_thread) slow_val = intcon(1);
-
Node* fast_io = slow_call->in(TypeFunc::I_O);
Node* fast_mem = slow_call->in(TypeFunc::Memory);
+
// These two phis are pre-filled with copies of of the fast IO and Memory
- Node* io_phi = PhiNode::make(result_rgn, fast_io, Type::ABIO);
- Node* mem_phi = PhiNode::make(result_rgn, fast_mem, Type::MEMORY, TypePtr::BOTTOM);
+ PhiNode* result_mem = PhiNode::make(result_rgn, fast_mem, Type::MEMORY, TypePtr::BOTTOM);
+ PhiNode* result_io = PhiNode::make(result_rgn, fast_io, Type::ABIO);
result_rgn->init_req(slow_result_path, control());
- io_phi ->init_req(slow_result_path, i_o());
- mem_phi ->init_req(slow_result_path, reset_memory());
+ result_io ->init_req(slow_result_path, i_o());
+ result_mem->init_req(slow_result_path, reset_memory());
result_val->init_req(slow_result_path, slow_val);
- set_all_memory( _gvn.transform(mem_phi) );
- set_i_o( _gvn.transform(io_phi) );
+ set_all_memory(_gvn.transform(result_mem));
+ set_i_o( _gvn.transform(result_io));
}
C->set_has_split_ifs(true); // Has chance for split-if optimization