src/share/vm/opto/parse3.cpp

changeset 3002
263247c478c5
parent 2658
c7f3d0b4570f
child 3050
fdb992d83a87
     1.1 --- a/src/share/vm/opto/parse3.cpp	Fri Jul 08 09:38:48 2011 -0700
     1.2 +++ b/src/share/vm/opto/parse3.cpp	Fri Jul 08 15:33:03 2011 -0700
     1.3 @@ -417,17 +417,10 @@
     1.4  
     1.5    // Note:  Array classes are always initialized; no is_initialized check.
     1.6  
     1.7 -  enum { MAX_DIMENSION = 5 };
     1.8 -  if (ndimensions > MAX_DIMENSION || ndimensions <= 0) {
     1.9 -    uncommon_trap(Deoptimization::Reason_unhandled,
    1.10 -                  Deoptimization::Action_none);
    1.11 -    return;
    1.12 -  }
    1.13 -
    1.14    kill_dead_locals();
    1.15  
    1.16    // get the lengths from the stack (first dimension is on top)
    1.17 -  Node* length[MAX_DIMENSION+1];
    1.18 +  Node** length = NEW_RESOURCE_ARRAY(Node*, ndimensions + 1);
    1.19    length[ndimensions] = NULL;  // terminating null for make_runtime_call
    1.20    int j;
    1.21    for (j = ndimensions-1; j >= 0 ; j--) length[j] = pop();
    1.22 @@ -470,20 +463,43 @@
    1.23  
    1.24    address fun = NULL;
    1.25    switch (ndimensions) {
    1.26 -  //case 1: Actually, there is no case 1.  It's handled by new_array.
    1.27 +  case 1: ShouldNotReachHere(); break;
    1.28    case 2: fun = OptoRuntime::multianewarray2_Java(); break;
    1.29    case 3: fun = OptoRuntime::multianewarray3_Java(); break;
    1.30    case 4: fun = OptoRuntime::multianewarray4_Java(); break;
    1.31    case 5: fun = OptoRuntime::multianewarray5_Java(); break;
    1.32 -  default: ShouldNotReachHere();
    1.33    };
    1.34 +  Node* c = NULL;
    1.35  
    1.36 -  Node* c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
    1.37 -                              OptoRuntime::multianewarray_Type(ndimensions),
    1.38 -                              fun, NULL, TypeRawPtr::BOTTOM,
    1.39 -                              makecon(TypeKlassPtr::make(array_klass)),
    1.40 -                              length[0], length[1], length[2],
    1.41 -                              length[3], length[4]);
    1.42 +  if (fun != NULL) {
    1.43 +    c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
    1.44 +                          OptoRuntime::multianewarray_Type(ndimensions),
    1.45 +                          fun, NULL, TypeRawPtr::BOTTOM,
    1.46 +                          makecon(TypeKlassPtr::make(array_klass)),
    1.47 +                          length[0], length[1], length[2],
    1.48 +                          length[3], length[4]);
    1.49 +  } else {
    1.50 +    // Create a java array for dimension sizes
    1.51 +    Node* dims = NULL;
    1.52 +    { PreserveReexecuteState preexecs(this);
    1.53 +      _sp += ndimensions;
    1.54 +      Node* dims_array_klass = makecon(TypeKlassPtr::make(ciArrayKlass::make(ciType::make(T_INT))));
    1.55 +      dims = new_array(dims_array_klass, intcon(ndimensions), 0);
    1.56 +
    1.57 +      // Fill-in it with values
    1.58 +      for (j = 0; j < ndimensions; j++) {
    1.59 +        Node *dims_elem = array_element_address(dims, intcon(j), T_INT);
    1.60 +        store_to_memory(control(), dims_elem, length[j], T_INT, TypeAryPtr::INTS);
    1.61 +      }
    1.62 +    }
    1.63 +
    1.64 +    c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
    1.65 +                          OptoRuntime::multianewarrayN_Type(),
    1.66 +                          OptoRuntime::multianewarrayN_Java(), NULL, TypeRawPtr::BOTTOM,
    1.67 +                          makecon(TypeKlassPtr::make(array_klass)),
    1.68 +                          dims);
    1.69 +  }
    1.70 +
    1.71    Node* res = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms));
    1.72  
    1.73    const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
    1.74 @@ -496,7 +512,7 @@
    1.75    if (ltype != NULL)
    1.76      type = type->is_aryptr()->cast_to_size(ltype);
    1.77  
    1.78 -  // We cannot sharpen the nested sub-arrays, since the top level is mutable.
    1.79 +    // We cannot sharpen the nested sub-arrays, since the top level is mutable.
    1.80  
    1.81    Node* cast = _gvn.transform( new (C, 2) CheckCastPPNode(control(), res, type) );
    1.82    push(cast);

mercurial