src/share/vm/opto/parse3.cpp

Wed, 09 Dec 2009 16:40:45 -0800

author
kvn
date
Wed, 09 Dec 2009 16:40:45 -0800
changeset 1535
f96a1a986f7b
parent 1424
148e5441d916
child 1573
dd57230ba8fe
permissions
-rw-r--r--

6895383: JCK test throws NPE for method compiled with Escape Analysis
Summary: Add missing checks for MemBar nodes in EA.
Reviewed-by: never

duke@435 1 /*
xdono@1279 2 * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
duke@435 26 #include "incls/_parse3.cpp.incl"
duke@435 27
duke@435 28 //=============================================================================
duke@435 29 // Helper methods for _get* and _put* bytecodes
duke@435 30 //=============================================================================
duke@435 31 bool Parse::static_field_ok_in_clinit(ciField *field, ciMethod *method) {
duke@435 32 // Could be the field_holder's <clinit> method, or <clinit> for a subklass.
duke@435 33 // Better to check now than to Deoptimize as soon as we execute
duke@435 34 assert( field->is_static(), "Only check if field is static");
duke@435 35 // is_being_initialized() is too generous. It allows access to statics
duke@435 36 // by threads that are not running the <clinit> before the <clinit> finishes.
duke@435 37 // return field->holder()->is_being_initialized();
duke@435 38
duke@435 39 // The following restriction is correct but conservative.
duke@435 40 // It is also desirable to allow compilation of methods called from <clinit>
duke@435 41 // but this generated code will need to be made safe for execution by
duke@435 42 // other threads, or the transition from interpreted to compiled code would
duke@435 43 // need to be guarded.
duke@435 44 ciInstanceKlass *field_holder = field->holder();
duke@435 45
duke@435 46 bool access_OK = false;
duke@435 47 if (method->holder()->is_subclass_of(field_holder)) {
duke@435 48 if (method->is_static()) {
duke@435 49 if (method->name() == ciSymbol::class_initializer_name()) {
duke@435 50 // OK to access static fields inside initializer
duke@435 51 access_OK = true;
duke@435 52 }
duke@435 53 } else {
duke@435 54 if (method->name() == ciSymbol::object_initializer_name()) {
duke@435 55 // It's also OK to access static fields inside a constructor,
duke@435 56 // because any thread calling the constructor must first have
duke@435 57 // synchronized on the class by executing a '_new' bytecode.
duke@435 58 access_OK = true;
duke@435 59 }
duke@435 60 }
duke@435 61 }
duke@435 62
duke@435 63 return access_OK;
duke@435 64
duke@435 65 }
duke@435 66
duke@435 67
duke@435 68 void Parse::do_field_access(bool is_get, bool is_field) {
duke@435 69 bool will_link;
duke@435 70 ciField* field = iter().get_field(will_link);
duke@435 71 assert(will_link, "getfield: typeflow responsibility");
duke@435 72
duke@435 73 ciInstanceKlass* field_holder = field->holder();
duke@435 74
duke@435 75 if (is_field == field->is_static()) {
duke@435 76 // Interpreter will throw java_lang_IncompatibleClassChangeError
duke@435 77 // Check this before allowing <clinit> methods to access static fields
duke@435 78 uncommon_trap(Deoptimization::Reason_unhandled,
duke@435 79 Deoptimization::Action_none);
duke@435 80 return;
duke@435 81 }
duke@435 82
duke@435 83 if (!is_field && !field_holder->is_initialized()) {
duke@435 84 if (!static_field_ok_in_clinit(field, method())) {
duke@435 85 uncommon_trap(Deoptimization::Reason_uninitialized,
duke@435 86 Deoptimization::Action_reinterpret,
duke@435 87 NULL, "!static_field_ok_in_clinit");
duke@435 88 return;
duke@435 89 }
duke@435 90 }
duke@435 91
duke@435 92 assert(field->will_link(method()->holder(), bc()), "getfield: typeflow responsibility");
duke@435 93
duke@435 94 // Note: We do not check for an unloaded field type here any more.
duke@435 95
duke@435 96 // Generate code for the object pointer.
duke@435 97 Node* obj;
duke@435 98 if (is_field) {
duke@435 99 int obj_depth = is_get ? 0 : field->type()->size();
duke@435 100 obj = do_null_check(peek(obj_depth), T_OBJECT);
duke@435 101 // Compile-time detect of null-exception?
duke@435 102 if (stopped()) return;
duke@435 103
duke@435 104 const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
duke@435 105 assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
duke@435 106
duke@435 107 if (is_get) {
duke@435 108 --_sp; // pop receiver before getting
duke@435 109 do_get_xxx(tjp, obj, field, is_field);
duke@435 110 } else {
duke@435 111 do_put_xxx(tjp, obj, field, is_field);
duke@435 112 --_sp; // pop receiver after putting
duke@435 113 }
duke@435 114 } else {
duke@435 115 const TypeKlassPtr* tkp = TypeKlassPtr::make(field_holder);
duke@435 116 obj = _gvn.makecon(tkp);
duke@435 117 if (is_get) {
duke@435 118 do_get_xxx(tkp, obj, field, is_field);
duke@435 119 } else {
duke@435 120 do_put_xxx(tkp, obj, field, is_field);
duke@435 121 }
duke@435 122 }
duke@435 123 }
duke@435 124
duke@435 125
duke@435 126 void Parse::do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
duke@435 127 // Does this field have a constant value? If so, just push the value.
duke@435 128 if (field->is_constant() && push_constant(field->constant_value())) return;
duke@435 129
duke@435 130 ciType* field_klass = field->type();
duke@435 131 bool is_vol = field->is_volatile();
duke@435 132
duke@435 133 // Compute address and memory type.
duke@435 134 int offset = field->offset_in_bytes();
duke@435 135 const TypePtr* adr_type = C->alias_type(field)->adr_type();
duke@435 136 Node *adr = basic_plus_adr(obj, obj, offset);
duke@435 137 BasicType bt = field->layout_type();
duke@435 138
duke@435 139 // Build the resultant type of the load
duke@435 140 const Type *type;
duke@435 141
duke@435 142 bool must_assert_null = false;
duke@435 143
duke@435 144 if( bt == T_OBJECT ) {
duke@435 145 if (!field->type()->is_loaded()) {
duke@435 146 type = TypeInstPtr::BOTTOM;
duke@435 147 must_assert_null = true;
duke@435 148 } else if (field->is_constant()) {
duke@435 149 // This can happen if the constant oop is non-perm.
duke@435 150 ciObject* con = field->constant_value().as_object();
duke@435 151 // Do not "join" in the previous type; it doesn't add value,
duke@435 152 // and may yield a vacuous result if the field is of interface type.
duke@435 153 type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
duke@435 154 assert(type != NULL, "field singleton type must be consistent");
duke@435 155 } else {
duke@435 156 type = TypeOopPtr::make_from_klass(field_klass->as_klass());
duke@435 157 }
duke@435 158 } else {
duke@435 159 type = Type::get_const_basic_type(bt);
duke@435 160 }
duke@435 161 // Build the load.
duke@435 162 Node* ld = make_load(NULL, adr, type, bt, adr_type, is_vol);
duke@435 163
duke@435 164 // Adjust Java stack
duke@435 165 if (type2size[bt] == 1)
duke@435 166 push(ld);
duke@435 167 else
duke@435 168 push_pair(ld);
duke@435 169
duke@435 170 if (must_assert_null) {
duke@435 171 // Do not take a trap here. It's possible that the program
duke@435 172 // will never load the field's class, and will happily see
duke@435 173 // null values in this field forever. Don't stumble into a
duke@435 174 // trap for such a program, or we might get a long series
duke@435 175 // of useless recompilations. (Or, we might load a class
duke@435 176 // which should not be loaded.) If we ever see a non-null
duke@435 177 // value, we will then trap and recompile. (The trap will
duke@435 178 // not need to mention the class index, since the class will
duke@435 179 // already have been loaded if we ever see a non-null value.)
duke@435 180 // uncommon_trap(iter().get_field_signature_index());
duke@435 181 #ifndef PRODUCT
duke@435 182 if (PrintOpto && (Verbose || WizardMode)) {
duke@435 183 method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
duke@435 184 }
duke@435 185 #endif
duke@435 186 if (C->log() != NULL) {
duke@435 187 C->log()->elem("assert_null reason='field' klass='%d'",
duke@435 188 C->log()->identify(field->type()));
duke@435 189 }
duke@435 190 // If there is going to be a trap, put it at the next bytecode:
duke@435 191 set_bci(iter().next_bci());
duke@435 192 do_null_assert(peek(), T_OBJECT);
duke@435 193 set_bci(iter().cur_bci()); // put it back
duke@435 194 }
duke@435 195
duke@435 196 // If reference is volatile, prevent following memory ops from
duke@435 197 // floating up past the volatile read. Also prevents commoning
duke@435 198 // another volatile read.
duke@435 199 if (field->is_volatile()) {
duke@435 200 // Memory barrier includes bogus read of value to force load BEFORE membar
duke@435 201 insert_mem_bar(Op_MemBarAcquire, ld);
duke@435 202 }
duke@435 203 }
duke@435 204
duke@435 205 void Parse::do_put_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
duke@435 206 bool is_vol = field->is_volatile();
duke@435 207 // If reference is volatile, prevent following memory ops from
duke@435 208 // floating down past the volatile write. Also prevents commoning
duke@435 209 // another volatile read.
duke@435 210 if (is_vol) insert_mem_bar(Op_MemBarRelease);
duke@435 211
duke@435 212 // Compute address and memory type.
duke@435 213 int offset = field->offset_in_bytes();
duke@435 214 const TypePtr* adr_type = C->alias_type(field)->adr_type();
duke@435 215 Node* adr = basic_plus_adr(obj, obj, offset);
duke@435 216 BasicType bt = field->layout_type();
duke@435 217 // Value to be stored
duke@435 218 Node* val = type2size[bt] == 1 ? pop() : pop_pair();
duke@435 219 // Round doubles before storing
duke@435 220 if (bt == T_DOUBLE) val = dstore_rounding(val);
duke@435 221
duke@435 222 // Store the value.
duke@435 223 Node* store;
duke@435 224 if (bt == T_OBJECT) {
never@1260 225 const TypeOopPtr* field_type;
duke@435 226 if (!field->type()->is_loaded()) {
duke@435 227 field_type = TypeInstPtr::BOTTOM;
duke@435 228 } else {
duke@435 229 field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
duke@435 230 }
duke@435 231 store = store_oop_to_object( control(), obj, adr, adr_type, val, field_type, bt);
duke@435 232 } else {
duke@435 233 store = store_to_memory( control(), adr, val, bt, adr_type, is_vol );
duke@435 234 }
duke@435 235
duke@435 236 // If reference is volatile, prevent following volatiles ops from
duke@435 237 // floating up before the volatile write.
duke@435 238 if (is_vol) {
duke@435 239 // First place the specific membar for THIS volatile index. This first
duke@435 240 // membar is dependent on the store, keeping any other membars generated
duke@435 241 // below from floating up past the store.
duke@435 242 int adr_idx = C->get_alias_index(adr_type);
kvn@1535 243 insert_mem_bar_volatile(Op_MemBarVolatile, adr_idx, store);
duke@435 244
duke@435 245 // Now place a membar for AliasIdxBot for the unknown yet-to-be-parsed
duke@435 246 // volatile alias indices. Skip this if the membar is redundant.
duke@435 247 if (adr_idx != Compile::AliasIdxBot) {
kvn@1535 248 insert_mem_bar_volatile(Op_MemBarVolatile, Compile::AliasIdxBot, store);
duke@435 249 }
duke@435 250
duke@435 251 // Finally, place alias-index-specific membars for each volatile index
duke@435 252 // that isn't the adr_idx membar. Typically there's only 1 or 2.
duke@435 253 for( int i = Compile::AliasIdxRaw; i < C->num_alias_types(); i++ ) {
duke@435 254 if (i != adr_idx && C->alias_type(i)->is_volatile()) {
kvn@1535 255 insert_mem_bar_volatile(Op_MemBarVolatile, i, store);
duke@435 256 }
duke@435 257 }
duke@435 258 }
duke@435 259
duke@435 260 // If the field is final, the rules of Java say we are in <init> or <clinit>.
duke@435 261 // Note the presence of writes to final non-static fields, so that we
duke@435 262 // can insert a memory barrier later on to keep the writes from floating
duke@435 263 // out of the constructor.
duke@435 264 if (is_field && field->is_final()) {
duke@435 265 set_wrote_final(true);
duke@435 266 }
duke@435 267 }
duke@435 268
duke@435 269
jrose@1424 270 bool Parse::push_constant(ciConstant constant, bool require_constant) {
duke@435 271 switch (constant.basic_type()) {
duke@435 272 case T_BOOLEAN: push( intcon(constant.as_boolean()) ); break;
duke@435 273 case T_INT: push( intcon(constant.as_int()) ); break;
duke@435 274 case T_CHAR: push( intcon(constant.as_char()) ); break;
duke@435 275 case T_BYTE: push( intcon(constant.as_byte()) ); break;
duke@435 276 case T_SHORT: push( intcon(constant.as_short()) ); break;
duke@435 277 case T_FLOAT: push( makecon(TypeF::make(constant.as_float())) ); break;
duke@435 278 case T_DOUBLE: push_pair( makecon(TypeD::make(constant.as_double())) ); break;
duke@435 279 case T_LONG: push_pair( longcon(constant.as_long()) ); break;
duke@435 280 case T_ARRAY:
duke@435 281 case T_OBJECT: {
jrose@1424 282 // cases:
jrose@1424 283 // can_be_constant = (oop not scavengable || ScavengeRootsInCode != 0)
jrose@1424 284 // should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2)
jrose@1424 285 // An oop is not scavengable if it is in the perm gen.
duke@435 286 ciObject* oop_constant = constant.as_object();
duke@435 287 if (oop_constant->is_null_object()) {
duke@435 288 push( zerocon(T_OBJECT) );
duke@435 289 break;
jrose@1424 290 } else if (require_constant || oop_constant->should_be_constant()) {
jrose@1424 291 push( makecon(TypeOopPtr::make_from_constant(oop_constant, require_constant)) );
duke@435 292 break;
duke@435 293 } else {
duke@435 294 // we cannot inline the oop, but we can use it later to narrow a type
duke@435 295 return false;
duke@435 296 }
duke@435 297 }
duke@435 298 case T_ILLEGAL: {
duke@435 299 // Invalid ciConstant returned due to OutOfMemoryError in the CI
duke@435 300 assert(C->env()->failing(), "otherwise should not see this");
duke@435 301 // These always occur because of object types; we are going to
duke@435 302 // bail out anyway, so make the stack depths match up
duke@435 303 push( zerocon(T_OBJECT) );
duke@435 304 return false;
duke@435 305 }
duke@435 306 default:
duke@435 307 ShouldNotReachHere();
duke@435 308 return false;
duke@435 309 }
duke@435 310
duke@435 311 // success
duke@435 312 return true;
duke@435 313 }
duke@435 314
duke@435 315
duke@435 316
duke@435 317 //=============================================================================
duke@435 318 void Parse::do_anewarray() {
duke@435 319 bool will_link;
duke@435 320 ciKlass* klass = iter().get_klass(will_link);
duke@435 321
duke@435 322 // Uncommon Trap when class that array contains is not loaded
duke@435 323 // we need the loaded class for the rest of graph; do not
duke@435 324 // initialize the container class (see Java spec)!!!
duke@435 325 assert(will_link, "anewarray: typeflow responsibility");
duke@435 326
duke@435 327 ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
duke@435 328 // Check that array_klass object is loaded
duke@435 329 if (!array_klass->is_loaded()) {
duke@435 330 // Generate uncommon_trap for unloaded array_class
duke@435 331 uncommon_trap(Deoptimization::Reason_unloaded,
duke@435 332 Deoptimization::Action_reinterpret,
duke@435 333 array_klass);
duke@435 334 return;
duke@435 335 }
duke@435 336
duke@435 337 kill_dead_locals();
duke@435 338
duke@435 339 const TypeKlassPtr* array_klass_type = TypeKlassPtr::make(array_klass);
duke@435 340 Node* count_val = pop();
cfang@1165 341 Node* obj = new_array(makecon(array_klass_type), count_val, 1);
duke@435 342 push(obj);
duke@435 343 }
duke@435 344
duke@435 345
duke@435 346 void Parse::do_newarray(BasicType elem_type) {
duke@435 347 kill_dead_locals();
duke@435 348
duke@435 349 Node* count_val = pop();
duke@435 350 const TypeKlassPtr* array_klass = TypeKlassPtr::make(ciTypeArrayKlass::make(elem_type));
cfang@1165 351 Node* obj = new_array(makecon(array_klass), count_val, 1);
duke@435 352 // Push resultant oop onto stack
duke@435 353 push(obj);
duke@435 354 }
duke@435 355
duke@435 356 // Expand simple expressions like new int[3][5] and new Object[2][nonConLen].
duke@435 357 // Also handle the degenerate 1-dimensional case of anewarray.
cfang@1165 358 Node* Parse::expand_multianewarray(ciArrayKlass* array_klass, Node* *lengths, int ndimensions, int nargs) {
duke@435 359 Node* length = lengths[0];
duke@435 360 assert(length != NULL, "");
cfang@1165 361 Node* array = new_array(makecon(TypeKlassPtr::make(array_klass)), length, nargs);
duke@435 362 if (ndimensions > 1) {
duke@435 363 jint length_con = find_int_con(length, -1);
duke@435 364 guarantee(length_con >= 0, "non-constant multianewarray");
duke@435 365 ciArrayKlass* array_klass_1 = array_klass->as_obj_array_klass()->element_klass()->as_array_klass();
duke@435 366 const TypePtr* adr_type = TypeAryPtr::OOPS;
never@1262 367 const TypeOopPtr* elemtype = _gvn.type(array)->is_aryptr()->elem()->make_oopptr();
duke@435 368 const intptr_t header = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
duke@435 369 for (jint i = 0; i < length_con; i++) {
cfang@1165 370 Node* elem = expand_multianewarray(array_klass_1, &lengths[1], ndimensions-1, nargs);
coleenp@548 371 intptr_t offset = header + ((intptr_t)i << LogBytesPerHeapOop);
duke@435 372 Node* eaddr = basic_plus_adr(array, offset);
duke@435 373 store_oop_to_array(control(), array, eaddr, adr_type, elem, elemtype, T_OBJECT);
duke@435 374 }
duke@435 375 }
duke@435 376 return array;
duke@435 377 }
duke@435 378
duke@435 379 void Parse::do_multianewarray() {
duke@435 380 int ndimensions = iter().get_dimensions();
duke@435 381
duke@435 382 // the m-dimensional array
duke@435 383 bool will_link;
duke@435 384 ciArrayKlass* array_klass = iter().get_klass(will_link)->as_array_klass();
duke@435 385 assert(will_link, "multianewarray: typeflow responsibility");
duke@435 386
duke@435 387 // Note: Array classes are always initialized; no is_initialized check.
duke@435 388
duke@435 389 enum { MAX_DIMENSION = 5 };
duke@435 390 if (ndimensions > MAX_DIMENSION || ndimensions <= 0) {
duke@435 391 uncommon_trap(Deoptimization::Reason_unhandled,
duke@435 392 Deoptimization::Action_none);
duke@435 393 return;
duke@435 394 }
duke@435 395
duke@435 396 kill_dead_locals();
duke@435 397
duke@435 398 // get the lengths from the stack (first dimension is on top)
duke@435 399 Node* length[MAX_DIMENSION+1];
duke@435 400 length[ndimensions] = NULL; // terminating null for make_runtime_call
duke@435 401 int j;
duke@435 402 for (j = ndimensions-1; j >= 0 ; j--) length[j] = pop();
duke@435 403
duke@435 404 // The original expression was of this form: new T[length0][length1]...
duke@435 405 // It is often the case that the lengths are small (except the last).
duke@435 406 // If that happens, use the fast 1-d creator a constant number of times.
duke@435 407 const jint expand_limit = MIN2((juint)MultiArrayExpandLimit, (juint)100);
duke@435 408 jint expand_count = 1; // count of allocations in the expansion
duke@435 409 jint expand_fanout = 1; // running total fanout
duke@435 410 for (j = 0; j < ndimensions-1; j++) {
duke@435 411 jint dim_con = find_int_con(length[j], -1);
duke@435 412 expand_fanout *= dim_con;
duke@435 413 expand_count += expand_fanout; // count the level-J sub-arrays
rasbold@541 414 if (dim_con <= 0
duke@435 415 || dim_con > expand_limit
duke@435 416 || expand_count > expand_limit) {
duke@435 417 expand_count = 0;
duke@435 418 break;
duke@435 419 }
duke@435 420 }
duke@435 421
duke@435 422 // Can use multianewarray instead of [a]newarray if only one dimension,
duke@435 423 // or if all non-final dimensions are small constants.
duke@435 424 if (expand_count == 1 || (1 <= expand_count && expand_count <= expand_limit)) {
cfang@1165 425 Node* obj = expand_multianewarray(array_klass, &length[0], ndimensions, ndimensions);
duke@435 426 push(obj);
duke@435 427 return;
duke@435 428 }
duke@435 429
duke@435 430 address fun = NULL;
duke@435 431 switch (ndimensions) {
duke@435 432 //case 1: Actually, there is no case 1. It's handled by new_array.
duke@435 433 case 2: fun = OptoRuntime::multianewarray2_Java(); break;
duke@435 434 case 3: fun = OptoRuntime::multianewarray3_Java(); break;
duke@435 435 case 4: fun = OptoRuntime::multianewarray4_Java(); break;
duke@435 436 case 5: fun = OptoRuntime::multianewarray5_Java(); break;
duke@435 437 default: ShouldNotReachHere();
duke@435 438 };
duke@435 439
duke@435 440 Node* c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
duke@435 441 OptoRuntime::multianewarray_Type(ndimensions),
duke@435 442 fun, NULL, TypeRawPtr::BOTTOM,
duke@435 443 makecon(TypeKlassPtr::make(array_klass)),
duke@435 444 length[0], length[1], length[2],
duke@435 445 length[3], length[4]);
duke@435 446 Node* res = _gvn.transform(new (C, 1) ProjNode(c, TypeFunc::Parms));
duke@435 447
duke@435 448 const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
duke@435 449
duke@435 450 // Improve the type: We know it's not null, exact, and of a given length.
duke@435 451 type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
duke@435 452 type = type->is_aryptr()->cast_to_exactness(true);
duke@435 453
duke@435 454 const TypeInt* ltype = _gvn.find_int_type(length[0]);
duke@435 455 if (ltype != NULL)
duke@435 456 type = type->is_aryptr()->cast_to_size(ltype);
duke@435 457
duke@435 458 // We cannot sharpen the nested sub-arrays, since the top level is mutable.
duke@435 459
duke@435 460 Node* cast = _gvn.transform( new (C, 2) CheckCastPPNode(control(), res, type) );
duke@435 461 push(cast);
duke@435 462
duke@435 463 // Possible improvements:
duke@435 464 // - Make a fast path for small multi-arrays. (W/ implicit init. loops.)
duke@435 465 // - Issue CastII against length[*] values, to TypeInt::POS.
duke@435 466 }

mercurial