| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1615 : new(zone) Range(); | 1615 : new(zone) Range(); |
| 1616 result->Shl(c->Integer32Value()); | 1616 result->Shl(c->Integer32Value()); |
| 1617 result->set_can_be_minus_zero(false); | 1617 result->set_can_be_minus_zero(false); |
| 1618 return result; | 1618 return result; |
| 1619 } | 1619 } |
| 1620 } | 1620 } |
| 1621 return HValue::InferRange(zone); | 1621 return HValue::InferRange(zone); |
| 1622 } | 1622 } |
| 1623 | 1623 |
| 1624 | 1624 |
| 1625 Range* HLoadKeyedSpecializedArrayElement::InferRange(Zone* zone) { | 1625 Range* HLoadKeyed::InferRange(Zone* zone) { |
| 1626 switch (elements_kind()) { | 1626 switch (elements_kind()) { |
| 1627 case EXTERNAL_PIXEL_ELEMENTS: | 1627 case EXTERNAL_PIXEL_ELEMENTS: |
| 1628 return new(zone) Range(0, 255); | 1628 return new(zone) Range(0, 255); |
| 1629 case EXTERNAL_BYTE_ELEMENTS: | 1629 case EXTERNAL_BYTE_ELEMENTS: |
| 1630 return new(zone) Range(-128, 127); | 1630 return new(zone) Range(-128, 127); |
| 1631 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 1631 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 1632 return new(zone) Range(0, 255); | 1632 return new(zone) Range(0, 255); |
| 1633 case EXTERNAL_SHORT_ELEMENTS: | 1633 case EXTERNAL_SHORT_ELEMENTS: |
| 1634 return new(zone) Range(-32768, 32767); | 1634 return new(zone) Range(-32768, 32767); |
| 1635 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 1635 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 } | 1842 } |
| 1843 | 1843 |
| 1844 | 1844 |
| 1845 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) { | 1845 void HLoadNamedGeneric::PrintDataTo(StringStream* stream) { |
| 1846 object()->PrintNameTo(stream); | 1846 object()->PrintNameTo(stream); |
| 1847 stream->Add("."); | 1847 stream->Add("."); |
| 1848 stream->Add(*String::cast(*name())->ToCString()); | 1848 stream->Add(*String::cast(*name())->ToCString()); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 | 1851 |
| 1852 void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) { | 1852 void HLoadKeyed::PrintDataTo(StringStream* stream) { |
| 1853 object()->PrintNameTo(stream); | 1853 if (!is_external()) { |
| 1854 elements()->PrintNameTo(stream); |
| 1855 } else { |
| 1856 ASSERT(elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && |
| 1857 elements_kind() <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND); |
| 1858 elements()->PrintNameTo(stream); |
| 1859 stream->Add("."); |
| 1860 stream->Add(ElementsKindToString(elements_kind())); |
| 1861 } |
| 1862 |
| 1854 stream->Add("["); | 1863 stream->Add("["); |
| 1855 key()->PrintNameTo(stream); | 1864 key()->PrintNameTo(stream); |
| 1856 stream->Add("] "); | 1865 stream->Add("] "); |
| 1857 dependency()->PrintNameTo(stream); | 1866 dependency()->PrintNameTo(stream); |
| 1858 if (RequiresHoleCheck()) { | 1867 if (RequiresHoleCheck()) { |
| 1859 stream->Add(" check_hole"); | 1868 stream->Add(" check_hole"); |
| 1860 } | 1869 } |
| 1861 } | 1870 } |
| 1862 | 1871 |
| 1863 | 1872 |
| 1864 bool HLoadKeyedFastElement::RequiresHoleCheck() const { | 1873 bool HLoadKeyed::RequiresHoleCheck() const { |
| 1865 if (IsFastPackedElementsKind(elements_kind())) { | 1874 if (IsFastPackedElementsKind(elements_kind())) { |
| 1866 return false; | 1875 return false; |
| 1867 } | 1876 } |
| 1868 | 1877 |
| 1878 if (IsFastDoubleElementsKind(elements_kind())) { |
| 1879 return true; |
| 1880 } |
| 1881 |
| 1869 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 1882 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| 1870 HValue* use = it.value(); | 1883 HValue* use = it.value(); |
| 1871 if (!use->IsChange()) return true; | 1884 if (!use->IsChange()) { |
| 1885 return true; |
| 1886 } |
| 1872 } | 1887 } |
| 1873 | 1888 |
| 1874 return false; | 1889 return false; |
| 1875 } | 1890 } |
| 1876 | 1891 |
| 1877 | 1892 |
| 1878 void HLoadKeyedFastDoubleElement::PrintDataTo(StringStream* stream) { | |
| 1879 elements()->PrintNameTo(stream); | |
| 1880 stream->Add("["); | |
| 1881 key()->PrintNameTo(stream); | |
| 1882 stream->Add("] "); | |
| 1883 dependency()->PrintNameTo(stream); | |
| 1884 } | |
| 1885 | |
| 1886 | |
| 1887 void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) { | 1893 void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) { |
| 1888 object()->PrintNameTo(stream); | 1894 object()->PrintNameTo(stream); |
| 1889 stream->Add("["); | 1895 stream->Add("["); |
| 1890 key()->PrintNameTo(stream); | 1896 key()->PrintNameTo(stream); |
| 1891 stream->Add("]"); | 1897 stream->Add("]"); |
| 1892 } | 1898 } |
| 1893 | 1899 |
| 1894 | 1900 |
| 1895 HValue* HLoadKeyedGeneric::Canonicalize() { | 1901 HValue* HLoadKeyedGeneric::Canonicalize() { |
| 1896 // Recognize generic keyed loads that use property name generated | 1902 // Recognize generic keyed loads that use property name generated |
| 1897 // by for-in statement as a key and rewrite them into fast property load | 1903 // by for-in statement as a key and rewrite them into fast property load |
| 1898 // by index. | 1904 // by index. |
| 1899 if (key()->IsLoadKeyedFastElement()) { | 1905 if (key()->IsLoadKeyed()) { |
| 1900 HLoadKeyedFastElement* key_load = HLoadKeyedFastElement::cast(key()); | 1906 HLoadKeyed* key_load = HLoadKeyed::cast(key()); |
| 1901 if (key_load->object()->IsForInCacheArray()) { | 1907 if (key_load->elements()->IsForInCacheArray()) { |
| 1902 HForInCacheArray* names_cache = | 1908 HForInCacheArray* names_cache = |
| 1903 HForInCacheArray::cast(key_load->object()); | 1909 HForInCacheArray::cast(key_load->elements()); |
| 1904 | 1910 |
| 1905 if (names_cache->enumerable() == object()) { | 1911 if (names_cache->enumerable() == object()) { |
| 1906 HForInCacheArray* index_cache = | 1912 HForInCacheArray* index_cache = |
| 1907 names_cache->index_cache(); | 1913 names_cache->index_cache(); |
| 1908 HCheckMapValue* map_check = | 1914 HCheckMapValue* map_check = |
| 1909 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); | 1915 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); |
| 1910 HInstruction* index = new(block()->zone()) HLoadKeyedFastElement( | 1916 HInstruction* index = new(block()->zone()) HLoadKeyed( |
| 1911 index_cache, | 1917 index_cache, |
| 1912 key_load->key(), | 1918 key_load->key(), |
| 1913 key_load->key()); | 1919 key_load->key(), |
| 1920 key_load->elements_kind()); |
| 1914 map_check->InsertBefore(this); | 1921 map_check->InsertBefore(this); |
| 1915 index->InsertBefore(this); | 1922 index->InsertBefore(this); |
| 1916 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( | 1923 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( |
| 1917 object(), index); | 1924 object(), index); |
| 1918 load->InsertBefore(this); | 1925 load->InsertBefore(this); |
| 1919 return load; | 1926 return load; |
| 1920 } | 1927 } |
| 1921 } | 1928 } |
| 1922 } | 1929 } |
| 1923 | 1930 |
| 1924 return this; | 1931 return this; |
| 1925 } | 1932 } |
| 1926 | 1933 |
| 1927 | 1934 |
| 1928 void HLoadKeyedSpecializedArrayElement::PrintDataTo( | |
| 1929 StringStream* stream) { | |
| 1930 external_pointer()->PrintNameTo(stream); | |
| 1931 stream->Add("."); | |
| 1932 switch (elements_kind()) { | |
| 1933 case EXTERNAL_BYTE_ELEMENTS: | |
| 1934 stream->Add("byte"); | |
| 1935 break; | |
| 1936 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | |
| 1937 stream->Add("u_byte"); | |
| 1938 break; | |
| 1939 case EXTERNAL_SHORT_ELEMENTS: | |
| 1940 stream->Add("short"); | |
| 1941 break; | |
| 1942 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
| 1943 stream->Add("u_short"); | |
| 1944 break; | |
| 1945 case EXTERNAL_INT_ELEMENTS: | |
| 1946 stream->Add("int"); | |
| 1947 break; | |
| 1948 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
| 1949 stream->Add("u_int"); | |
| 1950 break; | |
| 1951 case EXTERNAL_FLOAT_ELEMENTS: | |
| 1952 stream->Add("float"); | |
| 1953 break; | |
| 1954 case EXTERNAL_DOUBLE_ELEMENTS: | |
| 1955 stream->Add("double"); | |
| 1956 break; | |
| 1957 case EXTERNAL_PIXEL_ELEMENTS: | |
| 1958 stream->Add("pixel"); | |
| 1959 break; | |
| 1960 case FAST_ELEMENTS: | |
| 1961 case FAST_SMI_ELEMENTS: | |
| 1962 case FAST_DOUBLE_ELEMENTS: | |
| 1963 case FAST_HOLEY_ELEMENTS: | |
| 1964 case FAST_HOLEY_SMI_ELEMENTS: | |
| 1965 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
| 1966 case DICTIONARY_ELEMENTS: | |
| 1967 case NON_STRICT_ARGUMENTS_ELEMENTS: | |
| 1968 UNREACHABLE(); | |
| 1969 break; | |
| 1970 } | |
| 1971 stream->Add("["); | |
| 1972 key()->PrintNameTo(stream); | |
| 1973 stream->Add("] "); | |
| 1974 dependency()->PrintNameTo(stream); | |
| 1975 } | |
| 1976 | |
| 1977 | |
| 1978 void HStoreNamedGeneric::PrintDataTo(StringStream* stream) { | 1935 void HStoreNamedGeneric::PrintDataTo(StringStream* stream) { |
| 1979 object()->PrintNameTo(stream); | 1936 object()->PrintNameTo(stream); |
| 1980 stream->Add("."); | 1937 stream->Add("."); |
| 1981 ASSERT(name()->IsString()); | 1938 ASSERT(name()->IsString()); |
| 1982 stream->Add(*String::cast(*name())->ToCString()); | 1939 stream->Add(*String::cast(*name())->ToCString()); |
| 1983 stream->Add(" = "); | 1940 stream->Add(" = "); |
| 1984 value()->PrintNameTo(stream); | 1941 value()->PrintNameTo(stream); |
| 1985 } | 1942 } |
| 1986 | 1943 |
| 1987 | 1944 |
| 1988 void HStoreNamedField::PrintDataTo(StringStream* stream) { | 1945 void HStoreNamedField::PrintDataTo(StringStream* stream) { |
| 1989 object()->PrintNameTo(stream); | 1946 object()->PrintNameTo(stream); |
| 1990 stream->Add("."); | 1947 stream->Add("."); |
| 1991 stream->Add(*String::cast(*name())->ToCString()); | 1948 stream->Add(*String::cast(*name())->ToCString()); |
| 1992 stream->Add(" = "); | 1949 stream->Add(" = "); |
| 1993 value()->PrintNameTo(stream); | 1950 value()->PrintNameTo(stream); |
| 1994 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); | 1951 stream->Add(" @%d%s", offset(), is_in_object() ? "[in-object]" : ""); |
| 1995 if (NeedsWriteBarrier()) { | 1952 if (NeedsWriteBarrier()) { |
| 1996 stream->Add(" (write-barrier)"); | 1953 stream->Add(" (write-barrier)"); |
| 1997 } | 1954 } |
| 1998 if (!transition().is_null()) { | 1955 if (!transition().is_null()) { |
| 1999 stream->Add(" (transition map %p)", *transition()); | 1956 stream->Add(" (transition map %p)", *transition()); |
| 2000 } | 1957 } |
| 2001 } | 1958 } |
| 2002 | 1959 |
| 2003 | 1960 |
| 2004 void HStoreKeyedFastElement::PrintDataTo(StringStream* stream) { | 1961 void HStoreKeyed::PrintDataTo(StringStream* stream) { |
| 2005 object()->PrintNameTo(stream); | 1962 if (!is_external()) { |
| 1963 elements()->PrintNameTo(stream); |
| 1964 } else { |
| 1965 elements()->PrintNameTo(stream); |
| 1966 stream->Add("."); |
| 1967 stream->Add(ElementsKindToString(elements_kind())); |
| 1968 ASSERT(elements_kind() >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && |
| 1969 elements_kind() <= LAST_EXTERNAL_ARRAY_ELEMENTS_KIND); |
| 1970 } |
| 1971 |
| 2006 stream->Add("["); | 1972 stream->Add("["); |
| 2007 key()->PrintNameTo(stream); | 1973 key()->PrintNameTo(stream); |
| 2008 stream->Add("] = "); | 1974 stream->Add("] = "); |
| 2009 value()->PrintNameTo(stream); | |
| 2010 } | |
| 2011 | |
| 2012 | |
| 2013 void HStoreKeyedFastDoubleElement::PrintDataTo(StringStream* stream) { | |
| 2014 elements()->PrintNameTo(stream); | |
| 2015 stream->Add("["); | |
| 2016 key()->PrintNameTo(stream); | |
| 2017 stream->Add("] = "); | |
| 2018 value()->PrintNameTo(stream); | 1975 value()->PrintNameTo(stream); |
| 2019 } | 1976 } |
| 2020 | 1977 |
| 2021 | 1978 |
| 2022 void HStoreKeyedGeneric::PrintDataTo(StringStream* stream) { | 1979 void HStoreKeyedGeneric::PrintDataTo(StringStream* stream) { |
| 2023 object()->PrintNameTo(stream); | 1980 object()->PrintNameTo(stream); |
| 2024 stream->Add("["); | 1981 stream->Add("["); |
| 2025 key()->PrintNameTo(stream); | 1982 key()->PrintNameTo(stream); |
| 2026 stream->Add("] = "); | 1983 stream->Add("] = "); |
| 2027 value()->PrintNameTo(stream); | 1984 value()->PrintNameTo(stream); |
| 2028 } | 1985 } |
| 2029 | 1986 |
| 2030 | 1987 |
| 2031 void HStoreKeyedSpecializedArrayElement::PrintDataTo( | |
| 2032 StringStream* stream) { | |
| 2033 external_pointer()->PrintNameTo(stream); | |
| 2034 stream->Add("."); | |
| 2035 switch (elements_kind()) { | |
| 2036 case EXTERNAL_BYTE_ELEMENTS: | |
| 2037 stream->Add("byte"); | |
| 2038 break; | |
| 2039 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | |
| 2040 stream->Add("u_byte"); | |
| 2041 break; | |
| 2042 case EXTERNAL_SHORT_ELEMENTS: | |
| 2043 stream->Add("short"); | |
| 2044 break; | |
| 2045 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
| 2046 stream->Add("u_short"); | |
| 2047 break; | |
| 2048 case EXTERNAL_INT_ELEMENTS: | |
| 2049 stream->Add("int"); | |
| 2050 break; | |
| 2051 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
| 2052 stream->Add("u_int"); | |
| 2053 break; | |
| 2054 case EXTERNAL_FLOAT_ELEMENTS: | |
| 2055 stream->Add("float"); | |
| 2056 break; | |
| 2057 case EXTERNAL_DOUBLE_ELEMENTS: | |
| 2058 stream->Add("double"); | |
| 2059 break; | |
| 2060 case EXTERNAL_PIXEL_ELEMENTS: | |
| 2061 stream->Add("pixel"); | |
| 2062 break; | |
| 2063 case FAST_SMI_ELEMENTS: | |
| 2064 case FAST_ELEMENTS: | |
| 2065 case FAST_DOUBLE_ELEMENTS: | |
| 2066 case FAST_HOLEY_SMI_ELEMENTS: | |
| 2067 case FAST_HOLEY_ELEMENTS: | |
| 2068 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
| 2069 case DICTIONARY_ELEMENTS: | |
| 2070 case NON_STRICT_ARGUMENTS_ELEMENTS: | |
| 2071 UNREACHABLE(); | |
| 2072 break; | |
| 2073 } | |
| 2074 stream->Add("["); | |
| 2075 key()->PrintNameTo(stream); | |
| 2076 stream->Add("] = "); | |
| 2077 value()->PrintNameTo(stream); | |
| 2078 } | |
| 2079 | |
| 2080 | |
| 2081 void HTransitionElementsKind::PrintDataTo(StringStream* stream) { | 1988 void HTransitionElementsKind::PrintDataTo(StringStream* stream) { |
| 2082 object()->PrintNameTo(stream); | 1989 object()->PrintNameTo(stream); |
| 2083 ElementsKind from_kind = original_map()->elements_kind(); | 1990 ElementsKind from_kind = original_map()->elements_kind(); |
| 2084 ElementsKind to_kind = transitioned_map()->elements_kind(); | 1991 ElementsKind to_kind = transitioned_map()->elements_kind(); |
| 2085 stream->Add(" %p [%s] -> %p [%s]", | 1992 stream->Add(" %p [%s] -> %p [%s]", |
| 2086 *original_map(), | 1993 *original_map(), |
| 2087 ElementsAccessor::ForKind(from_kind)->name(), | 1994 ElementsAccessor::ForKind(from_kind)->name(), |
| 2088 *transitioned_map(), | 1995 *transitioned_map(), |
| 2089 ElementsAccessor::ForKind(to_kind)->name()); | 1996 ElementsAccessor::ForKind(to_kind)->name()); |
| 2090 } | 1997 } |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 visited->Add(id()); | 2268 visited->Add(id()); |
| 2362 // Propagate to the left argument. If the left argument cannot be -0, then | 2269 // Propagate to the left argument. If the left argument cannot be -0, then |
| 2363 // the result of the sub operation cannot be either. | 2270 // the result of the sub operation cannot be either. |
| 2364 if (range() == NULL || range()->CanBeMinusZero()) { | 2271 if (range() == NULL || range()->CanBeMinusZero()) { |
| 2365 return left(); | 2272 return left(); |
| 2366 } | 2273 } |
| 2367 return NULL; | 2274 return NULL; |
| 2368 } | 2275 } |
| 2369 | 2276 |
| 2370 | 2277 |
| 2371 bool HStoreKeyedFastDoubleElement::NeedsCanonicalization() { | 2278 bool HStoreKeyed::NeedsCanonicalization() { |
| 2372 // If value was loaded from unboxed double backing store or | 2279 // If value is an integer or comes from the result of a keyed load |
| 2373 // converted from an integer then we don't have to canonicalize it. | 2280 // then it will be a non-hole value: no need for canonicalization. |
| 2374 if (value()->IsLoadKeyedFastDoubleElement() || | 2281 if (value()->IsLoadKeyed() || |
| 2375 (value()->IsChange() && HChange::cast(value())->from().IsInteger32())) { | 2282 (value()->IsChange() && HChange::cast(value())->from().IsInteger32())) { |
| 2376 return false; | 2283 return false; |
| 2377 } | 2284 } |
| 2378 return true; | 2285 return true; |
| 2379 } | 2286 } |
| 2380 | 2287 |
| 2381 | 2288 |
| 2382 #define H_CONSTANT_INT32(val) \ | 2289 #define H_CONSTANT_INT32(val) \ |
| 2383 new(zone) HConstant(FACTORY->NewNumberFromInt(val, TENURED), \ | 2290 new(zone) HConstant(FACTORY->NewNumberFromInt(val, TENURED), \ |
| 2384 Representation::Integer32()) | 2291 Representation::Integer32()) |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2634 | 2541 |
| 2635 | 2542 |
| 2636 void HCheckPrototypeMaps::Verify() { | 2543 void HCheckPrototypeMaps::Verify() { |
| 2637 HInstruction::Verify(); | 2544 HInstruction::Verify(); |
| 2638 ASSERT(HasNoUses()); | 2545 ASSERT(HasNoUses()); |
| 2639 } | 2546 } |
| 2640 | 2547 |
| 2641 #endif | 2548 #endif |
| 2642 | 2549 |
| 2643 } } // namespace v8::internal | 2550 } } // namespace v8::internal |
| OLD | NEW |