862
863 void ShenandoahBarrierC2Support::test_gc_state(Node*& ctrl, Node* raw_mem, Node*& test_fail_ctrl,
864 PhaseIdealLoop* phase, int flags) {
865 PhaseIterGVN& igvn = phase->igvn();
866 Node* old_ctrl = ctrl;
867
868 Node* thread = new ThreadLocalNode();
869 Node* gc_state_offset = igvn.MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
870 Node* gc_state_addr = new AddPNode(phase->C->top(), thread, gc_state_offset);
871 Node* gc_state = new LoadBNode(old_ctrl, raw_mem, gc_state_addr,
872 DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(NULL),
873 TypeInt::BYTE, MemNode::unordered);
874 Node* gc_state_and = new AndINode(gc_state, igvn.intcon(flags));
875 Node* gc_state_cmp = new CmpINode(gc_state_and, igvn.zerocon(T_INT));
876 Node* gc_state_bool = new BoolNode(gc_state_cmp, BoolTest::ne);
877
878 IfNode* gc_state_iff = new IfNode(old_ctrl, gc_state_bool, PROB_UNLIKELY(0.999), COUNT_UNKNOWN);
879 ctrl = new IfTrueNode(gc_state_iff);
880 test_fail_ctrl = new IfFalseNode(gc_state_iff);
881
882 IdealLoopTree* loop = phase->get_loop(ctrl);
883 phase->register_control(gc_state_iff, loop, old_ctrl);
884 phase->register_control(ctrl, loop, gc_state_iff);
885 phase->register_control(test_fail_ctrl, loop, gc_state_iff);
886
887 phase->register_new_node(thread, old_ctrl);
888 phase->register_new_node(gc_state_addr, old_ctrl);
889 phase->register_new_node(gc_state, old_ctrl);
890 phase->register_new_node(gc_state_and, old_ctrl);
891 phase->register_new_node(gc_state_cmp, old_ctrl);
892 phase->register_new_node(gc_state_bool, old_ctrl);
893
894 phase->set_ctrl(gc_state_offset, phase->C->root());
895
896 assert(is_gc_state_test(gc_state_iff, flags), "Should match the shape");
897 }
898
899 void ShenandoahBarrierC2Support::test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase) {
900 Node* old_ctrl = ctrl;
901 PhaseIterGVN& igvn = phase->igvn();
902
|
862
863 void ShenandoahBarrierC2Support::test_gc_state(Node*& ctrl, Node* raw_mem, Node*& test_fail_ctrl,
864 PhaseIdealLoop* phase, int flags) {
865 PhaseIterGVN& igvn = phase->igvn();
866 Node* old_ctrl = ctrl;
867
868 Node* thread = new ThreadLocalNode();
869 Node* gc_state_offset = igvn.MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset()));
870 Node* gc_state_addr = new AddPNode(phase->C->top(), thread, gc_state_offset);
871 Node* gc_state = new LoadBNode(old_ctrl, raw_mem, gc_state_addr,
872 DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(NULL),
873 TypeInt::BYTE, MemNode::unordered);
874 Node* gc_state_and = new AndINode(gc_state, igvn.intcon(flags));
875 Node* gc_state_cmp = new CmpINode(gc_state_and, igvn.zerocon(T_INT));
876 Node* gc_state_bool = new BoolNode(gc_state_cmp, BoolTest::ne);
877
878 IfNode* gc_state_iff = new IfNode(old_ctrl, gc_state_bool, PROB_UNLIKELY(0.999), COUNT_UNKNOWN);
879 ctrl = new IfTrueNode(gc_state_iff);
880 test_fail_ctrl = new IfFalseNode(gc_state_iff);
881
882 IdealLoopTree* loop = phase->get_loop(old_ctrl);
883 phase->register_control(gc_state_iff, loop, old_ctrl);
884 phase->register_control(ctrl, loop, gc_state_iff);
885 phase->register_control(test_fail_ctrl, loop, gc_state_iff);
886
887 phase->register_new_node(thread, old_ctrl);
888 phase->register_new_node(gc_state_addr, old_ctrl);
889 phase->register_new_node(gc_state, old_ctrl);
890 phase->register_new_node(gc_state_and, old_ctrl);
891 phase->register_new_node(gc_state_cmp, old_ctrl);
892 phase->register_new_node(gc_state_bool, old_ctrl);
893
894 phase->set_ctrl(gc_state_offset, phase->C->root());
895
896 assert(is_gc_state_test(gc_state_iff, flags), "Should match the shape");
897 }
898
899 void ShenandoahBarrierC2Support::test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase) {
900 Node* old_ctrl = ctrl;
901 PhaseIterGVN& igvn = phase->igvn();
902
|