121 set(CellTypeState::bottom);
122 } else if (is_reference_type(type)) {
123 set(CellTypeState::ref);
124 } else {
125 assert(is_java_primitive(type), "");
126 set(CellTypeState::value);
127 if (is_double_word_type(type)) {
128 set(CellTypeState::value);
129 }
130 }
131 }
132
133 public:
134 ComputeCallStack(Symbol* signature) : SignatureIterator(signature) {};
135
136 // Compute methods
137 int compute_for_parameters(bool is_static, CellTypeState *effect) {
138 _idx = 0;
139 _effect = effect;
140
141 if (!is_static)
142 effect[_idx++] = CellTypeState::ref;
143
144 do_parameters_on(this);
145
146 return length();
147 };
148
149 int compute_for_returntype(CellTypeState *effect) {
150 _idx = 0;
151 _effect = effect;
152 do_type(return_type(), true);
153 set(CellTypeState::bottom); // Always terminate with a bottom state, so ppush works
154
155 return length();
156 }
157 };
158
159 //=========================================================================================
160 // ComputeEntryStack
161 //
162 // Specialization of SignatureIterator - in order to set up first stack frame
1579
1580 case Bytecodes::_lreturn: do_return_monitor_check();
1581 ppop(vvCTS);
1582 break;
1583
1584 case Bytecodes::_dreturn: do_return_monitor_check();
1585 ppop(vvCTS);
1586 break;
1587
1588 case Bytecodes::_if_acmpeq:
1589 case Bytecodes::_if_acmpne: ppop(rrCTS); break;
1590
1591 case Bytecodes::_jsr: do_jsr(itr->dest()); break;
1592 case Bytecodes::_jsr_w: do_jsr(itr->dest_w()); break;
1593
1594 case Bytecodes::_getstatic: do_field(true, true, itr->get_index_u2(), itr->bci(), itr->code()); break;
1595 case Bytecodes::_putstatic: do_field(false, true, itr->get_index_u2(), itr->bci(), itr->code()); break;
1596 case Bytecodes::_getfield: do_field(true, false, itr->get_index_u2(), itr->bci(), itr->code()); break;
1597 case Bytecodes::_putfield: do_field(false, false, itr->get_index_u2(), itr->bci(), itr->code()); break;
1598
1599 case Bytecodes::_invokevirtual:
1600 case Bytecodes::_invokespecial: do_method(false, false, itr->get_index_u2(), itr->bci(), itr->code()); break;
1601 case Bytecodes::_invokestatic: do_method(true, false, itr->get_index_u2(), itr->bci(), itr->code()); break;
1602 case Bytecodes::_invokedynamic: do_method(true, false, itr->get_index_u4(), itr->bci(), itr->code()); break;
1603 case Bytecodes::_invokeinterface: do_method(false, true, itr->get_index_u2(), itr->bci(), itr->code()); break;
1604 case Bytecodes::_newarray:
1605 case Bytecodes::_anewarray: pp_new_ref(vCTS, itr->bci()); break;
1606 case Bytecodes::_checkcast: do_checkcast(); break;
1607 case Bytecodes::_arraylength:
1608 case Bytecodes::_instanceof: pp(rCTS, vCTS); break;
1609 case Bytecodes::_monitorenter: do_monitorenter(itr->bci()); break;
1610 case Bytecodes::_monitorexit: do_monitorexit(itr->bci()); break;
1611
1612 case Bytecodes::_athrow: // handled by do_exception_edge() BUT ...
1613 // vlh(apple): do_exception_edge() does not get
1614 // called if method has no exception handlers
1615 if ((!_has_exceptions) && (_monitor_top > 0)) {
1616 _monitor_safe = false;
1617 }
1618 break;
1619
1620 case Bytecodes::_areturn: do_return_monitor_check();
1621 ppop1(refCTS);
1622 break;
1623 case Bytecodes::_ifnull:
1624 case Bytecodes::_ifnonnull: ppop1(refCTS); break;
1625 case Bytecodes::_multianewarray: do_multianewarray(*(itr->bcp()+3), itr->bci()); break;
1626
1627 case Bytecodes::_wide: fatal("Iterator should skip this bytecode"); break;
1628 case Bytecodes::_ret: break;
1629
1630 // Java opcodes
1631 case Bytecodes::_lookupswitch: ppop1(valCTS); break;
1632
1633 default:
1634 tty->print("unexpected opcode: %d\n", itr->code());
1635 ShouldNotReachHere();
1636 break;
1637 }
1638 }
1639
1640 void GenerateOopMap::check_type(CellTypeState expected, CellTypeState actual) {
1641 if (!expected.equal_kind(actual)) {
1642 verify_error("wrong type on stack (found: %c expected: %c)", actual.to_char(), expected.to_char());
1928 void GenerateOopMap::do_field(int is_get, int is_static, int idx, int bci, Bytecodes::Code bc) {
1929 // Dig up signature for field in constant pool
1930 ConstantPool* cp = method()->constants();
1931 int nameAndTypeIdx = cp->name_and_type_ref_index_at(idx, bc);
1932 int signatureIdx = cp->signature_ref_index_at(nameAndTypeIdx);
1933 Symbol* signature = cp->symbol_at(signatureIdx);
1934
1935 CellTypeState temp[4];
1936 CellTypeState *eff = signature_to_effect(signature, bci, temp);
1937
1938 CellTypeState in[4];
1939 CellTypeState *out;
1940 int i = 0;
1941
1942 if (is_get) {
1943 out = eff;
1944 } else {
1945 out = epsilonCTS;
1946 i = copy_cts(in, eff);
1947 }
1948 if (!is_static) in[i++] = CellTypeState::ref;
1949 in[i] = CellTypeState::bottom;
1950 assert(i<=3, "sanity check");
1951 pp(in, out);
1952 }
1953
1954 void GenerateOopMap::do_method(int is_static, int is_interface, int idx, int bci, Bytecodes::Code bc) {
1955 // Dig up signature for field in constant pool
1956 ConstantPool* cp = _method->constants();
1957 Symbol* signature = cp->signature_ref_at(idx, bc);
1958
1959 // Parse method signature
1960 CellTypeState out[4];
1961 CellTypeState in[MAXARGSIZE+1]; // Includes result
1962 ComputeCallStack cse(signature);
1963
1964 // Compute return type
1965 int res_length= cse.compute_for_returntype(out);
1966
1967 // Temporary hack.
1968 if (out[0].equal(CellTypeState::ref) && out[1].equal(CellTypeState::bottom)) {
1969 out[0] = CellTypeState::make_line_ref(bci);
1970 }
1971
1972 assert(res_length<=4, "max value should be vv");
1973
1974 // Compute arguments
|
121 set(CellTypeState::bottom);
122 } else if (is_reference_type(type)) {
123 set(CellTypeState::ref);
124 } else {
125 assert(is_java_primitive(type), "");
126 set(CellTypeState::value);
127 if (is_double_word_type(type)) {
128 set(CellTypeState::value);
129 }
130 }
131 }
132
133 public:
134 ComputeCallStack(Symbol* signature) : SignatureIterator(signature) {};
135
136 // Compute methods
137 int compute_for_parameters(bool is_static, CellTypeState *effect) {
138 _idx = 0;
139 _effect = effect;
140
141 if (!is_static) {
142 effect[_idx++] = CellTypeState::ref;
143 }
144
145 do_parameters_on(this);
146
147 return length();
148 };
149
150 int compute_for_returntype(CellTypeState *effect) {
151 _idx = 0;
152 _effect = effect;
153 do_type(return_type(), true);
154 set(CellTypeState::bottom); // Always terminate with a bottom state, so ppush works
155
156 return length();
157 }
158 };
159
160 //=========================================================================================
161 // ComputeEntryStack
162 //
163 // Specialization of SignatureIterator - in order to set up first stack frame
1580
1581 case Bytecodes::_lreturn: do_return_monitor_check();
1582 ppop(vvCTS);
1583 break;
1584
1585 case Bytecodes::_dreturn: do_return_monitor_check();
1586 ppop(vvCTS);
1587 break;
1588
1589 case Bytecodes::_if_acmpeq:
1590 case Bytecodes::_if_acmpne: ppop(rrCTS); break;
1591
1592 case Bytecodes::_jsr: do_jsr(itr->dest()); break;
1593 case Bytecodes::_jsr_w: do_jsr(itr->dest_w()); break;
1594
1595 case Bytecodes::_getstatic: do_field(true, true, itr->get_index_u2(), itr->bci(), itr->code()); break;
1596 case Bytecodes::_putstatic: do_field(false, true, itr->get_index_u2(), itr->bci(), itr->code()); break;
1597 case Bytecodes::_getfield: do_field(true, false, itr->get_index_u2(), itr->bci(), itr->code()); break;
1598 case Bytecodes::_putfield: do_field(false, false, itr->get_index_u2(), itr->bci(), itr->code()); break;
1599
1600 case Bytecodes::_invokeinterface:
1601 case Bytecodes::_invokevirtual:
1602 case Bytecodes::_invokespecial: do_method(false, itr->get_index_u2(), itr->bci(), itr->code()); break;
1603 case Bytecodes::_invokestatic: do_method(true , itr->get_index_u2(), itr->bci(), itr->code()); break;
1604 case Bytecodes::_invokedynamic: do_method(true , itr->get_index_u4(), itr->bci(), itr->code()); break;
1605 case Bytecodes::_newarray:
1606 case Bytecodes::_anewarray: pp_new_ref(vCTS, itr->bci()); break;
1607 case Bytecodes::_checkcast: do_checkcast(); break;
1608 case Bytecodes::_arraylength:
1609 case Bytecodes::_instanceof: pp(rCTS, vCTS); break;
1610 case Bytecodes::_monitorenter: do_monitorenter(itr->bci()); break;
1611 case Bytecodes::_monitorexit: do_monitorexit(itr->bci()); break;
1612
1613 case Bytecodes::_athrow: // handled by do_exception_edge() BUT ...
1614 // vlh(apple): do_exception_edge() does not get
1615 // called if method has no exception handlers
1616 if ((!_has_exceptions) && (_monitor_top > 0)) {
1617 _monitor_safe = false;
1618 }
1619 break;
1620
1621 case Bytecodes::_areturn: do_return_monitor_check();
1622 ppop1(refCTS);
1623 break;
1624
1625 case Bytecodes::_ifnull:
1626 case Bytecodes::_ifnonnull: ppop1(refCTS); break;
1627 case Bytecodes::_multianewarray: do_multianewarray(*(itr->bcp()+3), itr->bci()); break;
1628
1629 case Bytecodes::_wide: fatal("Iterator should skip this bytecode"); break;
1630 case Bytecodes::_ret: break;
1631
1632 // Java opcodes
1633 case Bytecodes::_lookupswitch: ppop1(valCTS); break;
1634
1635 default:
1636 tty->print("unexpected opcode: %d\n", itr->code());
1637 ShouldNotReachHere();
1638 break;
1639 }
1640 }
1641
1642 void GenerateOopMap::check_type(CellTypeState expected, CellTypeState actual) {
1643 if (!expected.equal_kind(actual)) {
1644 verify_error("wrong type on stack (found: %c expected: %c)", actual.to_char(), expected.to_char());
1930 void GenerateOopMap::do_field(int is_get, int is_static, int idx, int bci, Bytecodes::Code bc) {
1931 // Dig up signature for field in constant pool
1932 ConstantPool* cp = method()->constants();
1933 int nameAndTypeIdx = cp->name_and_type_ref_index_at(idx, bc);
1934 int signatureIdx = cp->signature_ref_index_at(nameAndTypeIdx);
1935 Symbol* signature = cp->symbol_at(signatureIdx);
1936
1937 CellTypeState temp[4];
1938 CellTypeState *eff = signature_to_effect(signature, bci, temp);
1939
1940 CellTypeState in[4];
1941 CellTypeState *out;
1942 int i = 0;
1943
1944 if (is_get) {
1945 out = eff;
1946 } else {
1947 out = epsilonCTS;
1948 i = copy_cts(in, eff);
1949 }
1950 if (!is_static) {
1951 in[i++] = CellTypeState::ref;
1952 }
1953 in[i] = CellTypeState::bottom;
1954 assert(i<=3, "sanity check");
1955 pp(in, out);
1956 }
1957
1958 void GenerateOopMap::do_method(int is_static, int idx, int bci, Bytecodes::Code bc) {
1959 // Dig up signature for field in constant pool
1960 ConstantPool* cp = _method->constants();
1961 Symbol* signature = cp->signature_ref_at(idx, bc);
1962
1963 // Parse method signature
1964 CellTypeState out[4];
1965 CellTypeState in[MAXARGSIZE+1]; // Includes result
1966 ComputeCallStack cse(signature);
1967
1968 // Compute return type
1969 int res_length= cse.compute_for_returntype(out);
1970
1971 // Temporary hack.
1972 if (out[0].equal(CellTypeState::ref) && out[1].equal(CellTypeState::bottom)) {
1973 out[0] = CellTypeState::make_line_ref(bci);
1974 }
1975
1976 assert(res_length<=4, "max value should be vv");
1977
1978 // Compute arguments
|