comparison src/share/vm/opto/memnode.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 ab075d07f1ba
children a1980da045cc
comparison
equal deleted inserted replaced
333:7484fa4b8825 366:8261ee795323
1885 const TypeAryPtr *tap = tp->isa_aryptr(); 1885 const TypeAryPtr *tap = tp->isa_aryptr();
1886 if( !tap ) return _type; 1886 if( !tap ) return _type;
1887 return tap->size(); 1887 return tap->size();
1888 } 1888 }
1889 1889
1890 //-------------------------------Ideal---------------------------------------
1891 // Feed through the length in AllocateArray(...length...)._length.
1892 Node *LoadRangeNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1893 Node* p = MemNode::Ideal_common(phase, can_reshape);
1894 if (p) return (p == NodeSentinel) ? NULL : p;
1895
1896 // Take apart the address into an oop and and offset.
1897 // Return 'this' if we cannot.
1898 Node* adr = in(MemNode::Address);
1899 intptr_t offset = 0;
1900 Node* base = AddPNode::Ideal_base_and_offset(adr, phase, offset);
1901 if (base == NULL) return NULL;
1902 const TypeAryPtr* tary = phase->type(adr)->isa_aryptr();
1903 if (tary == NULL) return NULL;
1904
1905 // We can fetch the length directly through an AllocateArrayNode.
1906 // This works even if the length is not constant (clone or newArray).
1907 if (offset == arrayOopDesc::length_offset_in_bytes()) {
1908 AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(base, phase);
1909 if (alloc != NULL) {
1910 Node* allocated_length = alloc->Ideal_length();
1911 Node* len = alloc->make_ideal_length(tary, phase);
1912 if (allocated_length != len) {
1913 // New CastII improves on this.
1914 return len;
1915 }
1916 }
1917 }
1918
1919 return NULL;
1920 }
1921
1890 //------------------------------Identity--------------------------------------- 1922 //------------------------------Identity---------------------------------------
1891 // Feed through the length in AllocateArray(...length...)._length. 1923 // Feed through the length in AllocateArray(...length...)._length.
1892 Node* LoadRangeNode::Identity( PhaseTransform *phase ) { 1924 Node* LoadRangeNode::Identity( PhaseTransform *phase ) {
1893 Node* x = LoadINode::Identity(phase); 1925 Node* x = LoadINode::Identity(phase);
1894 if (x != this) return x; 1926 if (x != this) return x;
1903 if (tary == NULL) return this; 1935 if (tary == NULL) return this;
1904 1936
1905 // We can fetch the length directly through an AllocateArrayNode. 1937 // We can fetch the length directly through an AllocateArrayNode.
1906 // This works even if the length is not constant (clone or newArray). 1938 // This works even if the length is not constant (clone or newArray).
1907 if (offset == arrayOopDesc::length_offset_in_bytes()) { 1939 if (offset == arrayOopDesc::length_offset_in_bytes()) {
1908 Node* allocated_length = AllocateArrayNode::Ideal_length(base, phase); 1940 AllocateArrayNode* alloc = AllocateArrayNode::Ideal_array_allocation(base, phase);
1909 if (allocated_length != NULL) { 1941 if (alloc != NULL) {
1910 return allocated_length; 1942 Node* allocated_length = alloc->Ideal_length();
1943 // Do not allow make_ideal_length to allocate a CastII node.
1944 Node* len = alloc->make_ideal_length(tary, phase, false);
1945 if (allocated_length == len) {
1946 // Return allocated_length only if it would not be improved by a CastII.
1947 return allocated_length;
1948 }
1911 } 1949 }
1912 } 1950 }
1913 1951
1914 return this; 1952 return this;
1915 1953
1916 } 1954 }
1955
1917 //============================================================================= 1956 //=============================================================================
1918 //---------------------------StoreNode::make----------------------------------- 1957 //---------------------------StoreNode::make-----------------------------------
1919 // Polymorphic factory method: 1958 // Polymorphic factory method:
1920 StoreNode* StoreNode::make( PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, BasicType bt ) { 1959 StoreNode* StoreNode::make( PhaseGVN& gvn, Node* ctl, Node* mem, Node* adr, const TypePtr* adr_type, Node* val, BasicType bt ) {
1921 Compile* C = gvn.C; 1960 Compile* C = gvn.C;