Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 10802038: Add dependency to HLoadKeyed* instructions to prevent invalid hoisting (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nits Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 object()->PrintNameTo(stream); 1796 object()->PrintNameTo(stream);
1797 stream->Add("."); 1797 stream->Add(".");
1798 stream->Add(*String::cast(*name())->ToCString()); 1798 stream->Add(*String::cast(*name())->ToCString());
1799 } 1799 }
1800 1800
1801 1801
1802 void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) { 1802 void HLoadKeyedFastElement::PrintDataTo(StringStream* stream) {
1803 object()->PrintNameTo(stream); 1803 object()->PrintNameTo(stream);
1804 stream->Add("["); 1804 stream->Add("[");
1805 key()->PrintNameTo(stream); 1805 key()->PrintNameTo(stream);
1806 stream->Add("]"); 1806 stream->Add("] ");
1807 dependency()->PrintNameTo(stream);
1807 if (RequiresHoleCheck()) { 1808 if (RequiresHoleCheck()) {
1808 stream->Add(" check_hole"); 1809 stream->Add(" check_hole");
1809 } 1810 }
1810 } 1811 }
1811 1812
1812 1813
1813 bool HLoadKeyedFastElement::RequiresHoleCheck() { 1814 bool HLoadKeyedFastElement::RequiresHoleCheck() {
1814 if (IsFastPackedElementsKind(elements_kind())) { 1815 if (IsFastPackedElementsKind(elements_kind())) {
1815 return false; 1816 return false;
1816 } 1817 }
1817 1818
1818 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { 1819 for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
1819 HValue* use = it.value(); 1820 HValue* use = it.value();
1820 if (!use->IsChange()) return true; 1821 if (!use->IsChange()) return true;
1821 } 1822 }
1822 1823
1823 return false; 1824 return false;
1824 } 1825 }
1825 1826
1826 1827
1827 void HLoadKeyedFastDoubleElement::PrintDataTo(StringStream* stream) { 1828 void HLoadKeyedFastDoubleElement::PrintDataTo(StringStream* stream) {
1828 elements()->PrintNameTo(stream); 1829 elements()->PrintNameTo(stream);
1829 stream->Add("["); 1830 stream->Add("[");
1830 key()->PrintNameTo(stream); 1831 key()->PrintNameTo(stream);
1831 stream->Add("]"); 1832 stream->Add("] ");
1833 dependency()->PrintNameTo(stream);
1832 } 1834 }
1833 1835
1834 1836
1835 void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) { 1837 void HLoadKeyedGeneric::PrintDataTo(StringStream* stream) {
1836 object()->PrintNameTo(stream); 1838 object()->PrintNameTo(stream);
1837 stream->Add("["); 1839 stream->Add("[");
1838 key()->PrintNameTo(stream); 1840 key()->PrintNameTo(stream);
1839 stream->Add("]"); 1841 stream->Add("]");
1840 } 1842 }
1841 1843
1842 1844
1843 HValue* HLoadKeyedGeneric::Canonicalize() { 1845 HValue* HLoadKeyedGeneric::Canonicalize() {
1844 // Recognize generic keyed loads that use property name generated 1846 // Recognize generic keyed loads that use property name generated
1845 // by for-in statement as a key and rewrite them into fast property load 1847 // by for-in statement as a key and rewrite them into fast property load
1846 // by index. 1848 // by index.
1847 if (key()->IsLoadKeyedFastElement()) { 1849 if (key()->IsLoadKeyedFastElement()) {
1848 HLoadKeyedFastElement* key_load = HLoadKeyedFastElement::cast(key()); 1850 HLoadKeyedFastElement* key_load = HLoadKeyedFastElement::cast(key());
1849 if (key_load->object()->IsForInCacheArray()) { 1851 if (key_load->object()->IsForInCacheArray()) {
1850 HForInCacheArray* names_cache = 1852 HForInCacheArray* names_cache =
1851 HForInCacheArray::cast(key_load->object()); 1853 HForInCacheArray::cast(key_load->object());
1852 1854
1853 if (names_cache->enumerable() == object()) { 1855 if (names_cache->enumerable() == object()) {
1854 HForInCacheArray* index_cache = 1856 HForInCacheArray* index_cache =
1855 names_cache->index_cache(); 1857 names_cache->index_cache();
1856 HCheckMapValue* map_check = 1858 HCheckMapValue* map_check =
1857 new(block()->zone()) HCheckMapValue(object(), names_cache->map()); 1859 new(block()->zone()) HCheckMapValue(object(), names_cache->map());
1858 HInstruction* index = new(block()->zone()) HLoadKeyedFastElement( 1860 HInstruction* index = new(block()->zone()) HLoadKeyedFastElement(
1859 index_cache, 1861 index_cache,
1862 key_load->key(),
1860 key_load->key()); 1863 key_load->key());
1861 map_check->InsertBefore(this); 1864 map_check->InsertBefore(this);
1862 index->InsertBefore(this); 1865 index->InsertBefore(this);
1863 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex( 1866 HLoadFieldByIndex* load = new(block()->zone()) HLoadFieldByIndex(
1864 object(), index); 1867 object(), index);
1865 load->InsertBefore(this); 1868 load->InsertBefore(this);
1866 return load; 1869 return load;
1867 } 1870 }
1868 } 1871 }
1869 } 1872 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 case FAST_HOLEY_ELEMENTS: 1913 case FAST_HOLEY_ELEMENTS:
1911 case FAST_HOLEY_SMI_ELEMENTS: 1914 case FAST_HOLEY_SMI_ELEMENTS:
1912 case FAST_HOLEY_DOUBLE_ELEMENTS: 1915 case FAST_HOLEY_DOUBLE_ELEMENTS:
1913 case DICTIONARY_ELEMENTS: 1916 case DICTIONARY_ELEMENTS:
1914 case NON_STRICT_ARGUMENTS_ELEMENTS: 1917 case NON_STRICT_ARGUMENTS_ELEMENTS:
1915 UNREACHABLE(); 1918 UNREACHABLE();
1916 break; 1919 break;
1917 } 1920 }
1918 stream->Add("["); 1921 stream->Add("[");
1919 key()->PrintNameTo(stream); 1922 key()->PrintNameTo(stream);
1920 stream->Add("]"); 1923 stream->Add("] ");
1924 dependency()->PrintNameTo(stream);
1921 } 1925 }
1922 1926
1923 1927
1924 void HStoreNamedGeneric::PrintDataTo(StringStream* stream) { 1928 void HStoreNamedGeneric::PrintDataTo(StringStream* stream) {
1925 object()->PrintNameTo(stream); 1929 object()->PrintNameTo(stream);
1926 stream->Add("."); 1930 stream->Add(".");
1927 ASSERT(name()->IsString()); 1931 ASSERT(name()->IsString());
1928 stream->Add(*String::cast(*name())->ToCString()); 1932 stream->Add(*String::cast(*name())->ToCString());
1929 stream->Add(" = "); 1933 stream->Add(" = ");
1930 value()->PrintNameTo(stream); 1934 value()->PrintNameTo(stream);
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 2584
2581 2585
2582 void HCheckPrototypeMaps::Verify() { 2586 void HCheckPrototypeMaps::Verify() {
2583 HInstruction::Verify(); 2587 HInstruction::Verify();
2584 ASSERT(HasNoUses()); 2588 ASSERT(HasNoUses());
2585 } 2589 }
2586 2590
2587 #endif 2591 #endif
2588 2592
2589 } } // namespace v8::internal 2593 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698