annotate src/hotspot/share/opto/parse3.cpp @ 54048:744dc9c33676

8217417: Decorator name typo: C2_TIGHLY_COUPLED_ALLOC Summary: Fixed typo in decorator name, variables, and comments. Reviewed-by: tschatzl
author kbarrett
date Mon, 11 Mar 2019 02:05:07 -0400
parents ec4c3c287ca7
children 17f85a8780d5
rev   line source
duke@1 1 /*
stefank@49359 2 * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #include "precompiled.hpp"
stefank@7397 26 #include "compiler/compileLog.hpp"
stefank@7397 27 #include "interpreter/linkResolver.hpp"
stefank@49359 28 #include "memory/universe.hpp"
stefank@7397 29 #include "oops/objArrayKlass.hpp"
stefank@7397 30 #include "opto/addnode.hpp"
morris@23528 31 #include "opto/castnode.hpp"
stefank@7397 32 #include "opto/memnode.hpp"
stefank@7397 33 #include "opto/parse.hpp"
stefank@7397 34 #include "opto/rootnode.hpp"
stefank@7397 35 #include "opto/runtime.hpp"
stefank@7397 36 #include "opto/subnode.hpp"
stefank@7397 37 #include "runtime/deoptimization.hpp"
stefank@7397 38 #include "runtime/handles.inline.hpp"
duke@1 39
duke@1 40 //=============================================================================
duke@1 41 // Helper methods for _get* and _put* bytecodes
duke@1 42 //=============================================================================
duke@1 43 bool Parse::static_field_ok_in_clinit(ciField *field, ciMethod *method) {
duke@1 44 // Could be the field_holder's <clinit> method, or <clinit> for a subklass.
duke@1 45 // Better to check now than to Deoptimize as soon as we execute
duke@1 46 assert( field->is_static(), "Only check if field is static");
duke@1 47 // is_being_initialized() is too generous. It allows access to statics
duke@1 48 // by threads that are not running the <clinit> before the <clinit> finishes.
duke@1 49 // return field->holder()->is_being_initialized();
duke@1 50
duke@1 51 // The following restriction is correct but conservative.
duke@1 52 // It is also desirable to allow compilation of methods called from <clinit>
duke@1 53 // but this generated code will need to be made safe for execution by
duke@1 54 // other threads, or the transition from interpreted to compiled code would
duke@1 55 // need to be guarded.
duke@1 56 ciInstanceKlass *field_holder = field->holder();
duke@1 57
duke@1 58 if (method->holder()->is_subclass_of(field_holder)) {
vlivanov@53632 59 if (method->is_static_initializer()) {
vlivanov@53632 60 // OK to access static fields inside initializer
vlivanov@53632 61 return true;
vlivanov@53632 62 } else if (method->is_object_initializer()) {
vlivanov@53632 63 // It's also OK to access static fields inside a constructor,
vlivanov@53632 64 // because any thread calling the constructor must first have
vlivanov@53632 65 // synchronized on the class by executing a '_new' bytecode.
vlivanov@53632 66 return true;
duke@1 67 }
duke@1 68 }
vlivanov@53632 69 if (C->is_compiling_clinit_for(field_holder)) {
vlivanov@53632 70 return true; // access in the context of static initializer
vlivanov@53632 71 }
vlivanov@53632 72 return false;
duke@1 73 }
duke@1 74
duke@1 75
duke@1 76 void Parse::do_field_access(bool is_get, bool is_field) {
duke@1 77 bool will_link;
duke@1 78 ciField* field = iter().get_field(will_link);
duke@1 79 assert(will_link, "getfield: typeflow responsibility");
duke@1 80
duke@1 81 ciInstanceKlass* field_holder = field->holder();
duke@1 82
duke@1 83 if (is_field == field->is_static()) {
duke@1 84 // Interpreter will throw java_lang_IncompatibleClassChangeError
duke@1 85 // Check this before allowing <clinit> methods to access static fields
duke@1 86 uncommon_trap(Deoptimization::Reason_unhandled,
duke@1 87 Deoptimization::Action_none);
duke@1 88 return;
duke@1 89 }
duke@1 90
duke@1 91 if (!is_field && !field_holder->is_initialized()) {
duke@1 92 if (!static_field_ok_in_clinit(field, method())) {
duke@1 93 uncommon_trap(Deoptimization::Reason_uninitialized,
duke@1 94 Deoptimization::Action_reinterpret,
duke@1 95 NULL, "!static_field_ok_in_clinit");
duke@1 96 return;
duke@1 97 }
duke@1 98 }
duke@1 99
twisti@10510 100 // Deoptimize on putfield writes to call site target field.
twisti@10265 101 if (!is_get && field->is_call_site_target()) {
twisti@10265 102 uncommon_trap(Deoptimization::Reason_unhandled,
twisti@10265 103 Deoptimization::Action_reinterpret,
twisti@10510 104 NULL, "put to call site target field");
twisti@10265 105 return;
twisti@10265 106 }
twisti@10265 107
zmajo@39421 108 assert(field->will_link(method(), bc()), "getfield: typeflow responsibility");
duke@1 109
duke@1 110 // Note: We do not check for an unloaded field type here any more.
duke@1 111
duke@1 112 // Generate code for the object pointer.
duke@1 113 Node* obj;
duke@1 114 if (is_field) {
duke@1 115 int obj_depth = is_get ? 0 : field->type()->size();
twisti@14621 116 obj = null_check(peek(obj_depth));
duke@1 117 // Compile-time detect of null-exception?
duke@1 118 if (stopped()) return;
duke@1 119
never@8725 120 #ifdef ASSERT
duke@1 121 const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
duke@1 122 assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
never@8725 123 #endif
duke@1 124
duke@1 125 if (is_get) {
twisti@14621 126 (void) pop(); // pop receiver before getting
never@8725 127 do_get_xxx(obj, field, is_field);
duke@1 128 } else {
never@8725 129 do_put_xxx(obj, field, is_field);
twisti@14621 130 (void) pop(); // pop receiver after putting
duke@1 131 }
duke@1 132 } else {
never@8725 133 const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
never@8725 134 obj = _gvn.makecon(tip);
duke@1 135 if (is_get) {
never@8725 136 do_get_xxx(obj, field, is_field);
duke@1 137 } else {
never@8725 138 do_put_xxx(obj, field, is_field);
duke@1 139 }
duke@1 140 }
duke@1 141 }
duke@1 142
duke@1 143
never@8725 144 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
roland@44996 145 BasicType bt = field->layout_type();
roland@44996 146
duke@1 147 // Does this field have a constant value? If so, just push the value.
roland@44996 148 if (field->is_constant() &&
roland@44996 149 // Keep consistent with types found by ciTypeFlow: for an
roland@44996 150 // unloaded field type, ciTypeFlow::StateVector::do_getstatic()
roland@44996 151 // speculates the field is null. The code in the rest of this
roland@44996 152 // method does the same. We must not bypass it and use a non
roland@44996 153 // null constant here.
roland@44996 154 (bt != T_OBJECT || field->type()->is_loaded())) {
vlivanov@19770 155 // final or stable field
vlivanov@38030 156 Node* con = make_constant_from_field(field, obj);
vlivanov@38030 157 if (con != NULL) {
vlivanov@38030 158 push_node(field->layout_type(), con);
vlivanov@31857 159 return;
twisti@4567 160 }
twisti@4567 161 }
duke@1 162
duke@1 163 ciType* field_klass = field->type();
duke@1 164 bool is_vol = field->is_volatile();
duke@1 165
duke@1 166 // Compute address and memory type.
duke@1 167 int offset = field->offset_in_bytes();
duke@1 168 const TypePtr* adr_type = C->alias_type(field)->adr_type();
duke@1 169 Node *adr = basic_plus_adr(obj, obj, offset);
duke@1 170
duke@1 171 // Build the resultant type of the load
duke@1 172 const Type *type;
duke@1 173
duke@1 174 bool must_assert_null = false;
duke@1 175
eosterlund@50180 176 DecoratorSet decorators = IN_HEAP;
eosterlund@50180 177 decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
eosterlund@50180 178
eosterlund@50180 179 bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
eosterlund@50180 180
eosterlund@50180 181 if (is_obj) {
duke@1 182 if (!field->type()->is_loaded()) {
duke@1 183 type = TypeInstPtr::BOTTOM;
duke@1 184 must_assert_null = true;
vlivanov@38030 185 } else if (field->is_static_constant()) {
duke@1 186 // This can happen if the constant oop is non-perm.
duke@1 187 ciObject* con = field->constant_value().as_object();
duke@1 188 // Do not "join" in the previous type; it doesn't add value,
duke@1 189 // and may yield a vacuous result if the field is of interface type.
vlivanov@38030 190 if (con->is_null_object()) {
vlivanov@38030 191 type = TypePtr::NULL_PTR;
vlivanov@38030 192 } else {
vlivanov@38030 193 type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
vlivanov@38030 194 }
duke@1 195 assert(type != NULL, "field singleton type must be consistent");
duke@1 196 } else {
duke@1 197 type = TypeOopPtr::make_from_klass(field_klass->as_klass());
duke@1 198 }
duke@1 199 } else {
duke@1 200 type = Type::get_const_basic_type(bt);
duke@1 201 }
eosterlund@50180 202
eosterlund@50180 203 Node* ld = access_load_at(obj, adr, adr_type, type, bt, decorators);
duke@1 204
duke@1 205 // Adjust Java stack
duke@1 206 if (type2size[bt] == 1)
duke@1 207 push(ld);
duke@1 208 else
duke@1 209 push_pair(ld);
duke@1 210
duke@1 211 if (must_assert_null) {
duke@1 212 // Do not take a trap here. It's possible that the program
duke@1 213 // will never load the field's class, and will happily see
duke@1 214 // null values in this field forever. Don't stumble into a
duke@1 215 // trap for such a program, or we might get a long series
duke@1 216 // of useless recompilations. (Or, we might load a class
duke@1 217 // which should not be loaded.) If we ever see a non-null
duke@1 218 // value, we will then trap and recompile. (The trap will
duke@1 219 // not need to mention the class index, since the class will
duke@1 220 // already have been loaded if we ever see a non-null value.)
duke@1 221 // uncommon_trap(iter().get_field_signature_index());
duke@1 222 if (PrintOpto && (Verbose || WizardMode)) {
duke@1 223 method()->print_name(); tty->print_cr(" asserting nullness of field at bci: %d", bci());
duke@1 224 }
duke@1 225 if (C->log() != NULL) {
duke@1 226 C->log()->elem("assert_null reason='field' klass='%d'",
duke@1 227 C->log()->identify(field->type()));
duke@1 228 }
duke@1 229 // If there is going to be a trap, put it at the next bytecode:
duke@1 230 set_bci(iter().next_bci());
twisti@14621 231 null_assert(peek());
duke@1 232 set_bci(iter().cur_bci()); // put it back
duke@1 233 }
duke@1 234 }
duke@1 235
never@8725 236 void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
duke@1 237 bool is_vol = field->is_volatile();
duke@1 238
duke@1 239 // Compute address and memory type.
duke@1 240 int offset = field->offset_in_bytes();
duke@1 241 const TypePtr* adr_type = C->alias_type(field)->adr_type();
duke@1 242 Node* adr = basic_plus_adr(obj, obj, offset);
duke@1 243 BasicType bt = field->layout_type();
duke@1 244 // Value to be stored
duke@1 245 Node* val = type2size[bt] == 1 ? pop() : pop_pair();
duke@1 246
eosterlund@50180 247 DecoratorSet decorators = IN_HEAP;
eosterlund@50180 248 decorators |= is_vol ? MO_SEQ_CST : MO_UNORDERED;
eosterlund@50180 249
eosterlund@50180 250 bool is_obj = bt == T_OBJECT || bt == T_ARRAY;
goetz@22845 251
duke@1 252 // Store the value.
eosterlund@50180 253 const Type* field_type;
eosterlund@50180 254 if (!field->type()->is_loaded()) {
eosterlund@50180 255 field_type = TypeInstPtr::BOTTOM;
eosterlund@50180 256 } else {
eosterlund@50180 257 if (is_obj) {
eosterlund@50180 258 field_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
duke@1 259 } else {
eosterlund@50180 260 field_type = Type::BOTTOM;
duke@1 261 }
duke@1 262 }
roland@51880 263 access_store_at(obj, adr, adr_type, val, field_type, bt, decorators);
duke@1 264
eosterlund@50180 265 if (is_field) {
goetz@22868 266 // Remember we wrote a volatile field.
goetz@22868 267 // For not multiple copy atomic cpu (ppc64) a barrier should be issued
goetz@22868 268 // in constructors which have such stores. See do_exits() in parse1.cpp.
eosterlund@50180 269 if (is_vol) {
goetz@22868 270 set_wrote_volatile(true);
goetz@22868 271 }
eosterlund@50180 272 set_wrote_fields(true);
duke@1 273
eosterlund@50180 274 // If the field is final, the rules of Java say we are in <init> or <clinit>.
eosterlund@50180 275 // Note the presence of writes to final non-static fields, so that we
eosterlund@50180 276 // can insert a memory barrier later on to keep the writes from floating
eosterlund@50180 277 // out of the constructor.
eosterlund@50180 278 // Any method can write a @Stable field; insert memory barriers after those also.
shade@23190 279 if (field->is_final()) {
eosterlund@50180 280 set_wrote_final(true);
eosterlund@50180 281 if (AllocateNode::Ideal_allocation(obj, &_gvn) != NULL) {
eosterlund@50180 282 // Preserve allocation ptr to create precedent edge to it in membar
eosterlund@50180 283 // generated on exit from constructor.
eosterlund@50180 284 // Can't bind stable with its allocation, only record allocation for final field.
eosterlund@50180 285 set_alloc_with_final(obj);
eosterlund@50180 286 }
shade@23190 287 }
shade@23190 288 if (field->is_stable()) {
eosterlund@50180 289 set_wrote_stable(true);
kvn@17383 290 }
duke@1 291 }
duke@1 292 }
duke@1 293
duke@1 294 //=============================================================================
duke@1 295 void Parse::do_anewarray() {
duke@1 296 bool will_link;
duke@1 297 ciKlass* klass = iter().get_klass(will_link);
duke@1 298
duke@1 299 // Uncommon Trap when class that array contains is not loaded
duke@1 300 // we need the loaded class for the rest of graph; do not
duke@1 301 // initialize the container class (see Java spec)!!!
duke@1 302 assert(will_link, "anewarray: typeflow responsibility");
duke@1 303
duke@1 304 ciObjArrayKlass* array_klass = ciObjArrayKlass::make(klass);
duke@1 305 // Check that array_klass object is loaded
duke@1 306 if (!array_klass->is_loaded()) {
duke@1 307 // Generate uncommon_trap for unloaded array_class
duke@1 308 uncommon_trap(Deoptimization::Reason_unloaded,
duke@1 309 Deoptimization::Action_reinterpret,
duke@1 310 array_klass);
duke@1 311 return;
duke@1 312 }
duke@1 313
duke@1 314 kill_dead_locals();
duke@1 315
duke@1 316 const TypeKlassPtr* array_klass_type = TypeKlassPtr::make(array_klass);
duke@1 317 Node* count_val = pop();
cfang@2574 318 Node* obj = new_array(makecon(array_klass_type), count_val, 1);
duke@1 319 push(obj);
duke@1 320 }
duke@1 321
duke@1 322
duke@1 323 void Parse::do_newarray(BasicType elem_type) {
duke@1 324 kill_dead_locals();
duke@1 325
duke@1 326 Node* count_val = pop();
duke@1 327 const TypeKlassPtr* array_klass = TypeKlassPtr::make(ciTypeArrayKlass::make(elem_type));
cfang@2574 328 Node* obj = new_array(makecon(array_klass), count_val, 1);
duke@1 329 // Push resultant oop onto stack
duke@1 330 push(obj);
duke@1 331 }
duke@1 332
duke@1 333 // Expand simple expressions like new int[3][5] and new Object[2][nonConLen].
duke@1 334 // Also handle the degenerate 1-dimensional case of anewarray.
cfang@2574 335 Node* Parse::expand_multianewarray(ciArrayKlass* array_klass, Node* *lengths, int ndimensions, int nargs) {
duke@1 336 Node* length = lengths[0];
duke@1 337 assert(length != NULL, "");
cfang@2574 338 Node* array = new_array(makecon(TypeKlassPtr::make(array_klass)), length, nargs);
duke@1 339 if (ndimensions > 1) {
duke@1 340 jint length_con = find_int_con(length, -1);
duke@1 341 guarantee(length_con >= 0, "non-constant multianewarray");
duke@1 342 ciArrayKlass* array_klass_1 = array_klass->as_obj_array_klass()->element_klass()->as_array_klass();
duke@1 343 const TypePtr* adr_type = TypeAryPtr::OOPS;
never@3180 344 const TypeOopPtr* elemtype = _gvn.type(array)->is_aryptr()->elem()->make_oopptr();
duke@1 345 const intptr_t header = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
duke@1 346 for (jint i = 0; i < length_con; i++) {
cfang@2574 347 Node* elem = expand_multianewarray(array_klass_1, &lengths[1], ndimensions-1, nargs);
coleenp@360 348 intptr_t offset = header + ((intptr_t)i << LogBytesPerHeapOop);
duke@1 349 Node* eaddr = basic_plus_adr(array, offset);
roland@51880 350 access_store_at(array, eaddr, adr_type, elem, elemtype, T_OBJECT, IN_HEAP | IS_ARRAY);
duke@1 351 }
duke@1 352 }
duke@1 353 return array;
duke@1 354 }
duke@1 355
duke@1 356 void Parse::do_multianewarray() {
duke@1 357 int ndimensions = iter().get_dimensions();
duke@1 358
duke@1 359 // the m-dimensional array
duke@1 360 bool will_link;
duke@1 361 ciArrayKlass* array_klass = iter().get_klass(will_link)->as_array_klass();
duke@1 362 assert(will_link, "multianewarray: typeflow responsibility");
duke@1 363
duke@1 364 // Note: Array classes are always initialized; no is_initialized check.
duke@1 365
duke@1 366 kill_dead_locals();
duke@1 367
duke@1 368 // get the lengths from the stack (first dimension is on top)
iveresov@10028 369 Node** length = NEW_RESOURCE_ARRAY(Node*, ndimensions + 1);
duke@1 370 length[ndimensions] = NULL; // terminating null for make_runtime_call
duke@1 371 int j;
duke@1 372 for (j = ndimensions-1; j >= 0 ; j--) length[j] = pop();
duke@1 373
duke@1 374 // The original expression was of this form: new T[length0][length1]...
duke@1 375 // It is often the case that the lengths are small (except the last).
duke@1 376 // If that happens, use the fast 1-d creator a constant number of times.
coleenp@47765 377 const int expand_limit = MIN2((int)MultiArrayExpandLimit, 100);
coleenp@47765 378 int expand_count = 1; // count of allocations in the expansion
coleenp@47765 379 int expand_fanout = 1; // running total fanout
duke@1 380 for (j = 0; j < ndimensions-1; j++) {
coleenp@47765 381 int dim_con = find_int_con(length[j], -1);
duke@1 382 expand_fanout *= dim_con;
duke@1 383 expand_count += expand_fanout; // count the level-J sub-arrays
rasbold@353 384 if (dim_con <= 0
duke@1 385 || dim_con > expand_limit
duke@1 386 || expand_count > expand_limit) {
duke@1 387 expand_count = 0;
duke@1 388 break;
duke@1 389 }
duke@1 390 }
duke@1 391
duke@1 392 // Can use multianewarray instead of [a]newarray if only one dimension,
duke@1 393 // or if all non-final dimensions are small constants.
kvn@4893 394 if (ndimensions == 1 || (1 <= expand_count && expand_count <= expand_limit)) {
kvn@4893 395 Node* obj = NULL;
kvn@4893 396 // Set the original stack and the reexecute bit for the interpreter
kvn@4893 397 // to reexecute the multianewarray bytecode if deoptimization happens.
kvn@4893 398 // Do it unconditionally even for one dimension multianewarray.
kvn@4893 399 // Note: the reexecute bit will be set in GraphKit::add_safepoint_edges()
kvn@4893 400 // when AllocateArray node for newarray is created.
kvn@4893 401 { PreserveReexecuteState preexecs(this);
twisti@14621 402 inc_sp(ndimensions);
kvn@4893 403 // Pass 0 as nargs since uncommon trap code does not need to restore stack.
kvn@4893 404 obj = expand_multianewarray(array_klass, &length[0], ndimensions, 0);
kvn@4893 405 } //original reexecute and sp are set back here
duke@1 406 push(obj);
duke@1 407 return;
duke@1 408 }
duke@1 409
duke@1 410 address fun = NULL;
duke@1 411 switch (ndimensions) {
iveresov@10028 412 case 1: ShouldNotReachHere(); break;
duke@1 413 case 2: fun = OptoRuntime::multianewarray2_Java(); break;
duke@1 414 case 3: fun = OptoRuntime::multianewarray3_Java(); break;
duke@1 415 case 4: fun = OptoRuntime::multianewarray4_Java(); break;
duke@1 416 case 5: fun = OptoRuntime::multianewarray5_Java(); break;
duke@1 417 };
iveresov@10028 418 Node* c = NULL;
duke@1 419
iveresov@10028 420 if (fun != NULL) {
iveresov@10028 421 c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
iveresov@10028 422 OptoRuntime::multianewarray_Type(ndimensions),
iveresov@10028 423 fun, NULL, TypeRawPtr::BOTTOM,
iveresov@10028 424 makecon(TypeKlassPtr::make(array_klass)),
iveresov@10028 425 length[0], length[1], length[2],
drchase@15480 426 (ndimensions > 2) ? length[3] : NULL,
drchase@15480 427 (ndimensions > 3) ? length[4] : NULL);
iveresov@10028 428 } else {
iveresov@10028 429 // Create a java array for dimension sizes
iveresov@10028 430 Node* dims = NULL;
iveresov@10028 431 { PreserveReexecuteState preexecs(this);
twisti@14621 432 inc_sp(ndimensions);
iveresov@10028 433 Node* dims_array_klass = makecon(TypeKlassPtr::make(ciArrayKlass::make(ciType::make(T_INT))));
iveresov@10028 434 dims = new_array(dims_array_klass, intcon(ndimensions), 0);
iveresov@10028 435
iveresov@10028 436 // Fill-in it with values
iveresov@10028 437 for (j = 0; j < ndimensions; j++) {
iveresov@10028 438 Node *dims_elem = array_element_address(dims, intcon(j), T_INT);
goetz@22845 439 store_to_memory(control(), dims_elem, length[j], T_INT, TypeAryPtr::INTS, MemNode::unordered);
iveresov@10028 440 }
iveresov@10028 441 }
iveresov@10028 442
iveresov@10028 443 c = make_runtime_call(RC_NO_LEAF | RC_NO_IO,
iveresov@10028 444 OptoRuntime::multianewarrayN_Type(),
iveresov@10028 445 OptoRuntime::multianewarrayN_Java(), NULL, TypeRawPtr::BOTTOM,
iveresov@10028 446 makecon(TypeKlassPtr::make(array_klass)),
iveresov@10028 447 dims);
iveresov@10028 448 }
kvn@14835 449 make_slow_call_ex(c, env()->Throwable_klass(), false);
iveresov@10028 450
thartmann@24923 451 Node* res = _gvn.transform(new ProjNode(c, TypeFunc::Parms));
duke@1 452
duke@1 453 const Type* type = TypeOopPtr::make_from_klass_raw(array_klass);
duke@1 454
duke@1 455 // Improve the type: We know it's not null, exact, and of a given length.
duke@1 456 type = type->is_ptr()->cast_to_ptr_type(TypePtr::NotNull);
duke@1 457 type = type->is_aryptr()->cast_to_exactness(true);
duke@1 458
duke@1 459 const TypeInt* ltype = _gvn.find_int_type(length[0]);
duke@1 460 if (ltype != NULL)
duke@1 461 type = type->is_aryptr()->cast_to_size(ltype);
duke@1 462
iveresov@10028 463 // We cannot sharpen the nested sub-arrays, since the top level is mutable.
duke@1 464
thartmann@24923 465 Node* cast = _gvn.transform( new CheckCastPPNode(control(), res, type) );
duke@1 466 push(cast);
duke@1 467
duke@1 468 // Possible improvements:
duke@1 469 // - Make a fast path for small multi-arrays. (W/ implicit init. loops.)
duke@1 470 // - Issue CastII against length[*] values, to TypeInt::POS.
duke@1 471 }