< prev index next >

src/share/vm/opto/parse2.cpp

Print this page




  38 #include "opto/matcher.hpp"
  39 #include "opto/memnode.hpp"
  40 #include "opto/mulnode.hpp"
  41 #include "opto/opaquenode.hpp"
  42 #include "opto/parse.hpp"
  43 #include "opto/runtime.hpp"
  44 #include "opto/valuetypenode.hpp"
  45 #include "runtime/deoptimization.hpp"
  46 #include "runtime/sharedRuntime.hpp"
  47 
  48 #ifndef PRODUCT
  49 extern int explicit_null_checks_inserted,
  50            explicit_null_checks_elided;
  51 #endif
  52 
  53 //---------------------------------array_load----------------------------------
  54 void Parse::array_load(BasicType elem_type) {
  55   const Type* elem = Type::TOP;
  56   Node* adr = array_addressing(elem_type, 0, &elem);
  57   if (stopped())  return;     // guaranteed null or range check
  58   dec_sp(2);                  // Pop array and index









  59   const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
  60   Node* ld = make_load(control(), adr, elem, elem_type, adr_type, MemNode::unordered);
  61   push(ld);
  62 }
  63 
  64 
  65 //--------------------------------array_store----------------------------------
  66 void Parse::array_store(BasicType elem_type) {
  67   Node* adr = array_addressing(elem_type, 1);
  68   if (stopped())  return;     // guaranteed null or range check
  69   Node* val = pop();
  70   dec_sp(2);                  // Pop array and index
  71   const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
  72   store_to_memory(control(), adr, val, elem_type, adr_type, StoreNode::release_if_reference(elem_type));
  73 }
  74 
  75 
  76 //------------------------------array_addressing-------------------------------
  77 // Pull array and index from the stack.  Compute pointer-to-element.
  78 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {


1690     push( c );
1691     push( b );
1692     push( a );
1693     break;
1694 
1695   case Bytecodes::_arraylength: {
1696     // Must do null-check with value on expression stack
1697     Node *ary = null_check(peek(), T_ARRAY);
1698     // Compile-time detect of null-exception?
1699     if (stopped())  return;
1700     a = pop();
1701     push(load_array_length(a));
1702     break;
1703   }
1704 
1705   case Bytecodes::_baload: array_load(T_BYTE);   break;
1706   case Bytecodes::_caload: array_load(T_CHAR);   break;
1707   case Bytecodes::_iaload: array_load(T_INT);    break;
1708   case Bytecodes::_saload: array_load(T_SHORT);  break;
1709   case Bytecodes::_faload: array_load(T_FLOAT);  break;

1710   case Bytecodes::_aaload: array_load(T_OBJECT); break;
1711   case Bytecodes::_laload: {
1712     a = array_addressing(T_LONG, 0);
1713     if (stopped())  return;     // guaranteed null or range check
1714     dec_sp(2);                  // Pop array and index
1715     push_pair(make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS, MemNode::unordered));
1716     break;
1717   }
1718   case Bytecodes::_daload: {
1719     a = array_addressing(T_DOUBLE, 0);
1720     if (stopped())  return;     // guaranteed null or range check
1721     dec_sp(2);                  // Pop array and index
1722     push_pair(make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES, MemNode::unordered));
1723     break;
1724   }
1725   case Bytecodes::_bastore: array_store(T_BYTE);  break;
1726   case Bytecodes::_castore: array_store(T_CHAR);  break;
1727   case Bytecodes::_iastore: array_store(T_INT);   break;
1728   case Bytecodes::_sastore: array_store(T_SHORT); break;
1729   case Bytecodes::_fastore: array_store(T_FLOAT); break;
























1730   case Bytecodes::_aastore: {
1731     d = array_addressing(T_OBJECT, 1);
1732     if (stopped())  return;     // guaranteed null or range check
1733     array_store_check();
1734     c = pop();                  // Oop to store
1735     b = pop();                  // index (already used)
1736     a = pop();                  // the array itself
1737     const TypeOopPtr* elemtype  = _gvn.type(a)->is_aryptr()->elem()->make_oopptr();
1738     const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
1739     Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT,
1740                                      StoreNode::release_if_reference(T_OBJECT));
1741     break;
1742   }
1743   case Bytecodes::_lastore: {
1744     a = array_addressing(T_LONG, 2);
1745     if (stopped())  return;     // guaranteed null or range check
1746     c = pop_pair();
1747     dec_sp(2);                  // Pop array and index
1748     store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS, MemNode::unordered);
1749     break;


2336 
2337   case Bytecodes::_lookupswitch:
2338     do_lookupswitch();
2339     break;
2340 
2341   case Bytecodes::_invokestatic:
2342   case Bytecodes::_invokedynamic:
2343   case Bytecodes::_invokespecial:
2344   case Bytecodes::_invokevirtual:
2345   case Bytecodes::_invokedirect:
2346   case Bytecodes::_invokeinterface:
2347     do_call();
2348     break;
2349   case Bytecodes::_checkcast:
2350     do_checkcast();
2351     break;
2352   case Bytecodes::_instanceof:
2353     do_instanceof();
2354     break;
2355   case Bytecodes::_anewarray:
2356     do_anewarray();
2357     break;
2358   case Bytecodes::_newarray:
2359     do_newarray((BasicType)iter().get_index());
2360     break;
2361   case Bytecodes::_multianewarray:
2362     do_multianewarray();
2363     break;
2364   case Bytecodes::_new:
2365     do_new();
2366     break;
2367   case Bytecodes::_vnew:
2368     do_vnew();
2369     break;
2370 
2371   case Bytecodes::_jsr:
2372   case Bytecodes::_jsr_w:
2373     do_jsr();
2374     break;
2375 
2376   case Bytecodes::_ret:




  38 #include "opto/matcher.hpp"
  39 #include "opto/memnode.hpp"
  40 #include "opto/mulnode.hpp"
  41 #include "opto/opaquenode.hpp"
  42 #include "opto/parse.hpp"
  43 #include "opto/runtime.hpp"
  44 #include "opto/valuetypenode.hpp"
  45 #include "runtime/deoptimization.hpp"
  46 #include "runtime/sharedRuntime.hpp"
  47 
  48 #ifndef PRODUCT
  49 extern int explicit_null_checks_inserted,
  50            explicit_null_checks_elided;
  51 #endif
  52 
  53 //---------------------------------array_load----------------------------------
  54 void Parse::array_load(BasicType elem_type) {
  55   const Type* elem = Type::TOP;
  56   Node* adr = array_addressing(elem_type, 0, &elem);
  57   if (stopped())  return;     // guaranteed null or range check
  58   Node* idx   = pop();   // Get from stack without popping
  59   Node* ary   = pop();   // in case of exception
  60   //dec_sp(2);                  // Pop array and index
  61   const TypeAryPtr* arytype = _gvn.type(ary)->is_aryptr();
  62   if (arytype->klass()->is_value_array_klass()) {
  63     ciValueArrayKlass* vak = arytype->klass()->as_value_array_klass();
  64     Node* vt = ValueTypeNode::make(gvn(), vak->element_klass()->as_value_klass(), map()->memory(), ary, adr, vak);
  65     push(vt);
  66     return;
  67   }
  68   const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
  69   Node* ld = make_load(control(), adr, elem, elem_type, adr_type, MemNode::unordered);
  70   push(ld);
  71 }
  72 
  73 
  74 //--------------------------------array_store----------------------------------
  75 void Parse::array_store(BasicType elem_type) {
  76   Node* adr = array_addressing(elem_type, 1);
  77   if (stopped())  return;     // guaranteed null or range check
  78   Node* val = pop();
  79   dec_sp(2);                  // Pop array and index
  80   const TypeAryPtr* adr_type = TypeAryPtr::get_array_body_type(elem_type);
  81   store_to_memory(control(), adr, val, elem_type, adr_type, StoreNode::release_if_reference(elem_type));
  82 }
  83 
  84 
  85 //------------------------------array_addressing-------------------------------
  86 // Pull array and index from the stack.  Compute pointer-to-element.
  87 Node* Parse::array_addressing(BasicType type, int vals, const Type* *result2) {


1699     push( c );
1700     push( b );
1701     push( a );
1702     break;
1703 
1704   case Bytecodes::_arraylength: {
1705     // Must do null-check with value on expression stack
1706     Node *ary = null_check(peek(), T_ARRAY);
1707     // Compile-time detect of null-exception?
1708     if (stopped())  return;
1709     a = pop();
1710     push(load_array_length(a));
1711     break;
1712   }
1713 
1714   case Bytecodes::_baload: array_load(T_BYTE);   break;
1715   case Bytecodes::_caload: array_load(T_CHAR);   break;
1716   case Bytecodes::_iaload: array_load(T_INT);    break;
1717   case Bytecodes::_saload: array_load(T_SHORT);  break;
1718   case Bytecodes::_faload: array_load(T_FLOAT);  break;
1719   case Bytecodes::_vaload: array_load(T_VALUETYPE); break;
1720   case Bytecodes::_aaload: array_load(T_OBJECT); break;
1721   case Bytecodes::_laload: {
1722     a = array_addressing(T_LONG, 0);
1723     if (stopped())  return;     // guaranteed null or range check
1724     dec_sp(2);                  // Pop array and index
1725     push_pair(make_load(control(), a, TypeLong::LONG, T_LONG, TypeAryPtr::LONGS, MemNode::unordered));
1726     break;
1727   }
1728   case Bytecodes::_daload: {
1729     a = array_addressing(T_DOUBLE, 0);
1730     if (stopped())  return;     // guaranteed null or range check
1731     dec_sp(2);                  // Pop array and index
1732     push_pair(make_load(control(), a, Type::DOUBLE, T_DOUBLE, TypeAryPtr::DOUBLES, MemNode::unordered));
1733     break;
1734   }
1735   case Bytecodes::_bastore: array_store(T_BYTE);  break;
1736   case Bytecodes::_castore: array_store(T_CHAR);  break;
1737   case Bytecodes::_iastore: array_store(T_INT);   break;
1738   case Bytecodes::_sastore: array_store(T_SHORT); break;
1739   case Bytecodes::_fastore: array_store(T_FLOAT); break;
1740   case Bytecodes::_vastore: {
1741     d = array_addressing(T_OBJECT, 1);
1742     if (stopped())  return;     // guaranteed null or range check
1743     // TODO fix this
1744    // array_store_check();
1745     c = pop();                  // Oop to store
1746     b = pop();                  // index (already used)
1747     a = pop();                  // the array itself
1748     const TypeAryPtr* arytype = _gvn.type(a)->is_aryptr();
1749     const TypeOopPtr* elemtype = arytype->elem()->make_oopptr();
1750     const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
1751 
1752     if (elemtype->isa_valuetypeptr()) {
1753       if (elemtype->isa_valuetypeptr()->value_type()->value_klass()->flatten_array()) {
1754         c->as_ValueType()->store_values(this, a, d, arytype->klass()->as_value_array_klass());
1755         break;
1756       }
1757     }
1758 
1759     Node* oop = c->as_ValueType()->store_to_memory(this);
1760     Node* store = store_oop_to_array(control(), a, d, adr_type, oop, elemtype, T_OBJECT,
1761                                      StoreNode::release_if_reference(T_OBJECT));
1762     break;
1763   }
1764   case Bytecodes::_aastore: {
1765     d = array_addressing(T_OBJECT, 1);
1766     if (stopped())  return;     // guaranteed null or range check
1767     array_store_check();
1768     c = pop();                  // Oop to store
1769     b = pop();                  // index (already used)
1770     a = pop();                  // the array itself
1771     const TypeOopPtr* elemtype  = _gvn.type(a)->is_aryptr()->elem()->make_oopptr();
1772     const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
1773     Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT,
1774                                      StoreNode::release_if_reference(T_OBJECT));
1775     break;
1776   }
1777   case Bytecodes::_lastore: {
1778     a = array_addressing(T_LONG, 2);
1779     if (stopped())  return;     // guaranteed null or range check
1780     c = pop_pair();
1781     dec_sp(2);                  // Pop array and index
1782     store_to_memory(control(), a, c, T_LONG, TypeAryPtr::LONGS, MemNode::unordered);
1783     break;


2370 
2371   case Bytecodes::_lookupswitch:
2372     do_lookupswitch();
2373     break;
2374 
2375   case Bytecodes::_invokestatic:
2376   case Bytecodes::_invokedynamic:
2377   case Bytecodes::_invokespecial:
2378   case Bytecodes::_invokevirtual:
2379   case Bytecodes::_invokedirect:
2380   case Bytecodes::_invokeinterface:
2381     do_call();
2382     break;
2383   case Bytecodes::_checkcast:
2384     do_checkcast();
2385     break;
2386   case Bytecodes::_instanceof:
2387     do_instanceof();
2388     break;
2389   case Bytecodes::_anewarray:
2390     do_newarray();
2391     break;
2392   case Bytecodes::_newarray:
2393     do_newarray((BasicType)iter().get_index());
2394     break;
2395   case Bytecodes::_multianewarray:
2396     do_multianewarray();
2397     break;
2398   case Bytecodes::_new:
2399     do_new();
2400     break;
2401   case Bytecodes::_vnew:
2402     do_vnew();
2403     break;
2404 
2405   case Bytecodes::_jsr:
2406   case Bytecodes::_jsr_w:
2407     do_jsr();
2408     break;
2409 
2410   case Bytecodes::_ret:


< prev index next >