Mercurial > hg > truffle
diff src/share/vm/opto/callnode.cpp @ 366:8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
Summary: insert CastII nodes to narrow type of load_array_length() node
Reviewed-by: never, kvn
author | rasbold |
---|---|
date | Wed, 17 Sep 2008 08:29:17 -0700 |
parents | cecd8eb4e0ca |
children | a1980da045cc |
line wrap: on
line diff
--- a/src/share/vm/opto/callnode.cpp Mon Sep 15 09:58:26 2008 -0700 +++ b/src/share/vm/opto/callnode.cpp Wed Sep 17 08:29:17 2008 -0700 @@ -1034,6 +1034,39 @@ //============================================================================= uint AllocateArrayNode::size_of() const { return sizeof(*this); } +// Retrieve the length from the AllocateArrayNode. Narrow the type with a +// CastII, if appropriate. If we are not allowed to create new nodes, and +// a CastII is appropriate, return NULL. +Node *AllocateArrayNode::make_ideal_length(const TypeOopPtr* oop_type, PhaseTransform *phase, bool allow_new_nodes) { + Node *length = in(AllocateNode::ALength); + assert(length != NULL, "length is not null"); + + const TypeInt* length_type = phase->find_int_type(length); + const TypeAryPtr* ary_type = oop_type->isa_aryptr(); + + if (ary_type != NULL && length_type != NULL) { + const TypeInt* narrow_length_type = ary_type->narrow_size_type(length_type); + if (narrow_length_type != length_type) { + // Assert one of: + // - the narrow_length is 0 + // - the narrow_length is not wider than length + assert(narrow_length_type == TypeInt::ZERO || + (narrow_length_type->_hi <= length_type->_hi && + narrow_length_type->_lo >= length_type->_lo), + "narrow type must be narrower than length type"); + + // Return NULL if new nodes are not allowed + if (!allow_new_nodes) return NULL; + // Create a cast which is control dependent on the initialization to + // propagate the fact that the array length must be positive. + length = new (phase->C, 2) CastIINode(length, narrow_length_type); + length->set_req(0, initialization()->proj_out(0)); + } + } + + return length; +} + //============================================================================= uint LockNode::size_of() const { return sizeof(*this); }