33 #include "opto/divnode.hpp"
34 #include "opto/idealGraphPrinter.hpp"
35 #include "opto/matcher.hpp"
36 #include "opto/memnode.hpp"
37 #include "opto/mulnode.hpp"
38 #include "opto/parse.hpp"
39 #include "opto/runtime.hpp"
40 #include "runtime/deoptimization.hpp"
41 #include "runtime/sharedRuntime.hpp"
42
43 extern int explicit_null_checks_inserted,
44 explicit_null_checks_elided;
45
46 //---------------------------------array_load----------------------------------
47 void Parse::array_load(BasicType elem_type) {
48 const Type* elem = Type::TOP;
49 Node* adr = array_addressing(elem_type, 0, &elem);
50 if (stopped()) return; // guaranteed null or range check
51 dec_sp(2); // Pop array and index
52 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
53 Node* ld = make_load(control(), adr, elem, elem_type, adr_type);
54 push(ld);
55 }
56
57
58 //--------------------------------array_store----------------------------------
59 void Parse::array_store(BasicType elem_type) {
60 Node* adr = array_addressing(elem_type, 1);
61 if (stopped()) return; // guaranteed null or range check
62 Node* val = pop();
63 dec_sp(2); // Pop array and index
64 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
65 store_to_memory(control(), adr, val, elem_type, adr_type);
66 }
67
68
69 //------------------------------array_addressing-------------------------------
70 // Pull array and index from the stack. Compute pointer-to-element.
71 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {
72 Node *idx = peek(0+vals); // Get from stack without popping
73 Node *ary = peek(1+vals); // in case of exception
74
75 // Null check the array base, with correct stack contents
76 ary = null_check(ary, T_ARRAY);
77 // Compile-time detect of null-exception?
78 if (stopped()) return top();
79
80 const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr();
81 const TypeInt* sizetype = arytype->size();
82 const Type* elemtype = arytype->elem();
83
84 if (UseUniqueSubclasses && result2 != NULL) {
85 const Type* el = elemtype->make_ptr();
1703 case Bytecodes::_arraylength: {
1704 // Must do null-check with value on expression stack
1705 Node *ary = null_check(peek(), T_ARRAY);
1706 // Compile-time detect of null-exception?
1707 if (stopped()) return;
1708 a = pop();
1709 push(load_array_length(a));
1710 break;
1711 }
1712
1713 case Bytecodes::_baload: array_load(T_BYTE); break;
1714 case Bytecodes::_caload: array_load(T_CHAR); break;
1715 case Bytecodes::_iaload: array_load(T_INT); break;
1716 case Bytecodes::_saload: array_load(T_SHORT); break;
1717 case Bytecodes::_faload: array_load(T_FLOAT); break;
1718 case Bytecodes::_aaload: array_load(T_OBJECT); break;
1719 case Bytecodes::_laload: {
1720 a = array_addressing(T_LONG, 0);
1721 if (stopped()) return; // guaranteed null or range check
1722 dec_sp(2); // Pop array and index
1723 push_pair(make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS));
1724 break;
1725 }
1726 case Bytecodes::_daload: {
1727 a = array_addressing(T_DOUBLE, 0);
1728 if (stopped()) return; // guaranteed null or range check
1729 dec_sp(2); // Pop array and index
1730 push_pair(make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES));
1731 break;
1732 }
1733 case Bytecodes::_bastore: array_store(T_BYTE); break;
1734 case Bytecodes::_castore: array_store(T_CHAR); break;
1735 case Bytecodes::_iastore: array_store(T_INT); break;
1736 case Bytecodes::_sastore: array_store(T_SHORT); break;
1737 case Bytecodes::_fastore: array_store(T_FLOAT); break;
1738 case Bytecodes::_aastore: {
1739 d = array_addressing(T_OBJECT, 1);
1740 if (stopped()) return; // guaranteed null or range check
1741 array_store_check();
1742 c = pop(); // Oop to store
1743 b = pop(); // index (already used)
1744 a = pop(); // the array itself
1745 const TypeOopPtr* elemtype = _gvn.type(a)->is_aryptr()->elem()->make_oopptr();
1746 const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
1747 Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT);
1748 break;
1749 }
1750 case Bytecodes::_lastore: {
1751 a = array_addressing(T_LONG, 2);
1752 if (stopped()) return; // guaranteed null or range check
1753 c = pop_pair();
1754 dec_sp(2); // Pop array and index
1755 store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS);
1756 break;
1757 }
1758 case Bytecodes::_dastore: {
1759 a = array_addressing(T_DOUBLE, 2);
1760 if (stopped()) return; // guaranteed null or range check
1761 c = pop_pair();
1762 dec_sp(2); // Pop array and index
1763 c = dstore_rounding(c);
1764 store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES);
1765 break;
1766 }
1767 case Bytecodes::_getfield:
1768 do_getfield();
1769 break;
1770
1771 case Bytecodes::_getstatic:
1772 do_getstatic();
1773 break;
1774
1775 case Bytecodes::_putfield:
1776 do_putfield();
1777 break;
1778
1779 case Bytecodes::_putstatic:
1780 do_putstatic();
1781 break;
1782
1783 case Bytecodes::_irem:
1784 do_irem();
|
33 #include "opto/divnode.hpp"
34 #include "opto/idealGraphPrinter.hpp"
35 #include "opto/matcher.hpp"
36 #include "opto/memnode.hpp"
37 #include "opto/mulnode.hpp"
38 #include "opto/parse.hpp"
39 #include "opto/runtime.hpp"
40 #include "runtime/deoptimization.hpp"
41 #include "runtime/sharedRuntime.hpp"
42
43 extern int explicit_null_checks_inserted,
44 explicit_null_checks_elided;
45
46 //---------------------------------array_load----------------------------------
47 void Parse::array_load(BasicType elem_type) {
48 const Type* elem = Type::TOP;
49 Node* adr = array_addressing(elem_type, 0, &elem);
50 if (stopped()) return; // guaranteed null or range check
51 dec_sp(2); // Pop array and index
52 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
53 Node* ld = make_load(control(), adr, elem, elem_type, adr_type, false, LoadNode::unordered);
54 push(ld);
55 }
56
57
58 //--------------------------------array_store----------------------------------
59 void Parse::array_store(BasicType elem_type) {
60 Node* adr = array_addressing(elem_type, 1);
61 if (stopped()) return; // guaranteed null or range check
62 Node* val = pop();
63 dec_sp(2); // Pop array and index
64 const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
65 store_to_memory(control(), adr, val, elem_type, adr_type, false, StoreNode::release_if_reference(elem_type));
66 }
67
68
69 //------------------------------array_addressing-------------------------------
70 // Pull array and index from the stack. Compute pointer-to-element.
71 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {
72 Node *idx = peek(0+vals); // Get from stack without popping
73 Node *ary = peek(1+vals); // in case of exception
74
75 // Null check the array base, with correct stack contents
76 ary = null_check(ary, T_ARRAY);
77 // Compile-time detect of null-exception?
78 if (stopped()) return top();
79
80 const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr();
81 const TypeInt* sizetype = arytype->size();
82 const Type* elemtype = arytype->elem();
83
84 if (UseUniqueSubclasses && result2 != NULL) {
85 const Type* el = elemtype->make_ptr();
1703 case Bytecodes::_arraylength: {
1704 // Must do null-check with value on expression stack
1705 Node *ary = null_check(peek(), T_ARRAY);
1706 // Compile-time detect of null-exception?
1707 if (stopped()) return;
1708 a = pop();
1709 push(load_array_length(a));
1710 break;
1711 }
1712
1713 case Bytecodes::_baload: array_load(T_BYTE); break;
1714 case Bytecodes::_caload: array_load(T_CHAR); break;
1715 case Bytecodes::_iaload: array_load(T_INT); break;
1716 case Bytecodes::_saload: array_load(T_SHORT); break;
1717 case Bytecodes::_faload: array_load(T_FLOAT); break;
1718 case Bytecodes::_aaload: array_load(T_OBJECT); break;
1719 case Bytecodes::_laload: {
1720 a = array_addressing(T_LONG, 0);
1721 if (stopped()) return; // guaranteed null or range check
1722 dec_sp(2); // Pop array and index
1723 push_pair(make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS, false, LoadNode::unordered));
1724 break;
1725 }
1726 case Bytecodes::_daload: {
1727 a = array_addressing(T_DOUBLE, 0);
1728 if (stopped()) return; // guaranteed null or range check
1729 dec_sp(2); // Pop array and index
1730 push_pair(make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES, false, LoadNode::unordered));
1731 break;
1732 }
1733 case Bytecodes::_bastore: array_store(T_BYTE); break;
1734 case Bytecodes::_castore: array_store(T_CHAR); break;
1735 case Bytecodes::_iastore: array_store(T_INT); break;
1736 case Bytecodes::_sastore: array_store(T_SHORT); break;
1737 case Bytecodes::_fastore: array_store(T_FLOAT); break;
1738 case Bytecodes::_aastore: {
1739 d = array_addressing(T_OBJECT, 1);
1740 if (stopped()) return; // guaranteed null or range check
1741 array_store_check();
1742 c = pop(); // Oop to store
1743 b = pop(); // index (already used)
1744 a = pop(); // the array itself
1745 const TypeOopPtr* elemtype = _gvn.type(a)->is_aryptr()->elem()->make_oopptr();
1746 const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
1747 Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT, StoreNode::release);
1748 break;
1749 }
1750 case Bytecodes::_lastore: {
1751 a = array_addressing(T_LONG, 2);
1752 if (stopped()) return; // guaranteed null or range check
1753 c = pop_pair();
1754 dec_sp(2); // Pop array and index
1755 store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS, false, StoreNode::unordered);
1756 break;
1757 }
1758 case Bytecodes::_dastore: {
1759 a = array_addressing(T_DOUBLE, 2);
1760 if (stopped()) return; // guaranteed null or range check
1761 c = pop_pair();
1762 dec_sp(2); // Pop array and index
1763 c = dstore_rounding(c);
1764 store_to_memory(control(), a, c, T_DOUBLE, TypeAryPtr::DOUBLES, false, StoreNode::unordered);
1765 break;
1766 }
1767 case Bytecodes::_getfield:
1768 do_getfield();
1769 break;
1770
1771 case Bytecodes::_getstatic:
1772 do_getstatic();
1773 break;
1774
1775 case Bytecodes::_putfield:
1776 do_putfield();
1777 break;
1778
1779 case Bytecodes::_putstatic:
1780 do_putstatic();
1781 break;
1782
1783 case Bytecodes::_irem:
1784 do_irem();
|