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

Side by Side Diff: src/compiler/ast-graph-builder.cc

Issue 1002713002: [turbofan] Introduce builders for property access. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/ast-graph-builder.h" 5 #include "src/compiler/ast-graph-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/compiler/ast-loop-assignment-analyzer.h" 8 #include "src/compiler/ast-loop-assignment-analyzer.h"
9 #include "src/compiler/control-builders.h" 9 #include "src/compiler/control-builders.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1549 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1550 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 1550 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
1551 // Fall through. 1551 // Fall through.
1552 case ObjectLiteral::Property::COMPUTED: { 1552 case ObjectLiteral::Property::COMPUTED: {
1553 // It is safe to use [[Put]] here because the boilerplate already 1553 // It is safe to use [[Put]] here because the boilerplate already
1554 // contains computed properties with an uninitialized value. 1554 // contains computed properties with an uninitialized value.
1555 if (key->value()->IsInternalizedString()) { 1555 if (key->value()->IsInternalizedString()) {
1556 if (property->emit_store()) { 1556 if (property->emit_store()) {
1557 VisitForValue(property->value()); 1557 VisitForValue(property->value());
1558 Node* value = environment()->Pop(); 1558 Node* value = environment()->Pop();
1559 Unique<Name> name = MakeUnique(key->AsPropertyName()); 1559 Handle<Name> name = key->AsPropertyName();
1560 Node* store = 1560 Node* store = BuildNamedStore(literal, name, value);
1561 NewNode(javascript()->StoreNamed(language_mode(), name),
1562 literal, value);
1563 PrepareFrameState(store, key->id()); 1561 PrepareFrameState(store, key->id());
1564 BuildSetHomeObject(value, literal, property->value()); 1562 BuildSetHomeObject(value, literal, property->value());
1565 } else { 1563 } else {
1566 VisitForEffect(property->value()); 1564 VisitForEffect(property->value());
1567 } 1565 }
1568 break; 1566 break;
1569 } 1567 }
1570 environment()->Push(literal); // Duplicate receiver. 1568 environment()->Push(literal); // Duplicate receiver.
1571 VisitForValue(property->key()); 1569 VisitForValue(property->key());
1572 VisitForValue(property->value()); 1570 VisitForValue(property->value());
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 1722
1725 // Create nodes to evaluate all the non-constant subexpressions and to store 1723 // Create nodes to evaluate all the non-constant subexpressions and to store
1726 // them into the newly cloned array. 1724 // them into the newly cloned array.
1727 for (int i = 0; i < expr->values()->length(); i++) { 1725 for (int i = 0; i < expr->values()->length(); i++) {
1728 Expression* subexpr = expr->values()->at(i); 1726 Expression* subexpr = expr->values()->at(i);
1729 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1727 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1730 1728
1731 VisitForValue(subexpr); 1729 VisitForValue(subexpr);
1732 Node* value = environment()->Pop(); 1730 Node* value = environment()->Pop();
1733 Node* index = jsgraph()->Constant(i); 1731 Node* index = jsgraph()->Constant(i);
1734 Node* store = NewNode(javascript()->StoreProperty(language_mode()), literal, 1732 Node* store = BuildKeyedStore(literal, index, value);
1735 index, value);
1736 PrepareFrameState(store, expr->GetIdForElement(i)); 1733 PrepareFrameState(store, expr->GetIdForElement(i));
1737 } 1734 }
1738 1735
1739 environment()->Pop(); // Array literal index. 1736 environment()->Pop(); // Array literal index.
1740 ast_context()->ProduceValue(environment()->Pop()); 1737 ast_context()->ProduceValue(environment()->Pop());
1741 } 1738 }
1742 1739
1743 1740
1744 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value, 1741 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
1745 BailoutId bailout_id) { 1742 BailoutId bailout_id) {
1746 DCHECK(expr->IsValidReferenceExpression()); 1743 DCHECK(expr->IsValidReferenceExpression());
1747 1744
1748 // Left-hand side can only be a property, a global or a variable slot. 1745 // Left-hand side can only be a property, a global or a variable slot.
1749 Property* property = expr->AsProperty(); 1746 Property* property = expr->AsProperty();
1750 LhsKind assign_type = DetermineLhsKind(expr); 1747 LhsKind assign_type = DetermineLhsKind(expr);
1751 1748
1752 // Evaluate LHS expression and store the value. 1749 // Evaluate LHS expression and store the value.
1753 switch (assign_type) { 1750 switch (assign_type) {
1754 case VARIABLE: { 1751 case VARIABLE: {
1755 Variable* var = expr->AsVariableProxy()->var(); 1752 Variable* var = expr->AsVariableProxy()->var();
1756 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id); 1753 BuildVariableAssignment(var, value, Token::ASSIGN, bailout_id);
1757 break; 1754 break;
1758 } 1755 }
1759 case NAMED_PROPERTY: { 1756 case NAMED_PROPERTY: {
1760 environment()->Push(value); 1757 environment()->Push(value);
1761 VisitForValue(property->obj()); 1758 VisitForValue(property->obj());
1762 Node* object = environment()->Pop(); 1759 Node* object = environment()->Pop();
1763 value = environment()->Pop(); 1760 value = environment()->Pop();
1764 Unique<Name> name = 1761 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
1765 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 1762 Node* store = BuildNamedStore(object, name, value);
1766 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
1767 object, value);
1768 PrepareFrameState(store, bailout_id); 1763 PrepareFrameState(store, bailout_id);
1769 break; 1764 break;
1770 } 1765 }
1771 case KEYED_PROPERTY: { 1766 case KEYED_PROPERTY: {
1772 environment()->Push(value); 1767 environment()->Push(value);
1773 VisitForValue(property->obj()); 1768 VisitForValue(property->obj());
1774 VisitForValue(property->key()); 1769 VisitForValue(property->key());
1775 Node* key = environment()->Pop(); 1770 Node* key = environment()->Pop();
1776 Node* object = environment()->Pop(); 1771 Node* object = environment()->Pop();
1777 value = environment()->Pop(); 1772 value = environment()->Pop();
1778 Node* store = NewNode(javascript()->StoreProperty(language_mode()), 1773 Node* store = BuildKeyedStore(object, key, value);
1779 object, key, value);
1780 PrepareFrameState(store, bailout_id); 1774 PrepareFrameState(store, bailout_id);
1781 break; 1775 break;
1782 } 1776 }
1783 } 1777 }
1784 } 1778 }
1785 1779
1786 1780
1787 void AstGraphBuilder::VisitAssignment(Assignment* expr) { 1781 void AstGraphBuilder::VisitAssignment(Assignment* expr) {
1788 DCHECK(expr->target()->IsValidReferenceExpression()); 1782 DCHECK(expr->target()->IsValidReferenceExpression());
1789 1783
(...skipping 23 matching lines...) Expand all
1813 switch (assign_type) { 1807 switch (assign_type) {
1814 case VARIABLE: { 1808 case VARIABLE: {
1815 VariableProxy* proxy = expr->target()->AsVariableProxy(); 1809 VariableProxy* proxy = expr->target()->AsVariableProxy();
1816 VectorSlotPair pair = 1810 VectorSlotPair pair =
1817 CreateVectorSlotPair(proxy->VariableFeedbackSlot()); 1811 CreateVectorSlotPair(proxy->VariableFeedbackSlot());
1818 old_value = BuildVariableLoad(proxy->var(), expr->target()->id(), pair); 1812 old_value = BuildVariableLoad(proxy->var(), expr->target()->id(), pair);
1819 break; 1813 break;
1820 } 1814 }
1821 case NAMED_PROPERTY: { 1815 case NAMED_PROPERTY: {
1822 Node* object = environment()->Top(); 1816 Node* object = environment()->Top();
1823 Unique<Name> name = 1817 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
1824 MakeUnique(property->key()->AsLiteral()->AsPropertyName());
1825 VectorSlotPair pair = 1818 VectorSlotPair pair =
1826 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 1819 CreateVectorSlotPair(property->PropertyFeedbackSlot());
1827 old_value = NewNode(javascript()->LoadNamed(name, pair), object); 1820 old_value = BuildNamedLoad(object, name, pair);
1828 PrepareFrameState(old_value, property->LoadId(), 1821 PrepareFrameState(old_value, property->LoadId(),
1829 OutputFrameStateCombine::Push()); 1822 OutputFrameStateCombine::Push());
1830 break; 1823 break;
1831 } 1824 }
1832 case KEYED_PROPERTY: { 1825 case KEYED_PROPERTY: {
1833 Node* key = environment()->Top(); 1826 Node* key = environment()->Top();
1834 Node* object = environment()->Peek(1); 1827 Node* object = environment()->Peek(1);
1835 VectorSlotPair pair = 1828 VectorSlotPair pair =
1836 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 1829 CreateVectorSlotPair(property->PropertyFeedbackSlot());
1837 old_value = NewNode(javascript()->LoadProperty(pair), object, key); 1830 old_value = BuildKeyedLoad(object, key, pair);
1838 PrepareFrameState(old_value, property->LoadId(), 1831 PrepareFrameState(old_value, property->LoadId(),
1839 OutputFrameStateCombine::Push()); 1832 OutputFrameStateCombine::Push());
1840 break; 1833 break;
1841 } 1834 }
1842 } 1835 }
1843 environment()->Push(old_value); 1836 environment()->Push(old_value);
1844 VisitForValue(expr->value()); 1837 VisitForValue(expr->value());
1845 Node* frame_state_before = environment()->Checkpoint(expr->value()->id()); 1838 Node* frame_state_before = environment()->Checkpoint(expr->value()->id());
1846 Node* right = environment()->Pop(); 1839 Node* right = environment()->Pop();
1847 Node* left = environment()->Pop(); 1840 Node* left = environment()->Pop();
(...skipping 10 matching lines...) Expand all
1858 Node* value = environment()->Pop(); 1851 Node* value = environment()->Pop();
1859 switch (assign_type) { 1852 switch (assign_type) {
1860 case VARIABLE: { 1853 case VARIABLE: {
1861 Variable* variable = expr->target()->AsVariableProxy()->var(); 1854 Variable* variable = expr->target()->AsVariableProxy()->var();
1862 BuildVariableAssignment(variable, value, expr->op(), expr->id(), 1855 BuildVariableAssignment(variable, value, expr->op(), expr->id(),
1863 ast_context()->GetStateCombine()); 1856 ast_context()->GetStateCombine());
1864 break; 1857 break;
1865 } 1858 }
1866 case NAMED_PROPERTY: { 1859 case NAMED_PROPERTY: {
1867 Node* object = environment()->Pop(); 1860 Node* object = environment()->Pop();
1868 Unique<Name> name = 1861 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
1869 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 1862 Node* store = BuildNamedStore(object, name, value);
1870 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
1871 object, value);
1872 PrepareFrameState(store, expr->id(), ast_context()->GetStateCombine()); 1863 PrepareFrameState(store, expr->id(), ast_context()->GetStateCombine());
1873 break; 1864 break;
1874 } 1865 }
1875 case KEYED_PROPERTY: { 1866 case KEYED_PROPERTY: {
1876 Node* key = environment()->Pop(); 1867 Node* key = environment()->Pop();
1877 Node* object = environment()->Pop(); 1868 Node* object = environment()->Pop();
1878 Node* store = NewNode(javascript()->StoreProperty(language_mode()), 1869 Node* store = BuildKeyedStore(object, key, value);
1879 object, key, value);
1880 PrepareFrameState(store, expr->id(), ast_context()->GetStateCombine()); 1870 PrepareFrameState(store, expr->id(), ast_context()->GetStateCombine());
1881 break; 1871 break;
1882 } 1872 }
1883 } 1873 }
1884 1874
1885 ast_context()->ProduceValue(value); 1875 ast_context()->ProduceValue(value);
1886 } 1876 }
1887 1877
1888 1878
1889 void AstGraphBuilder::VisitYield(Yield* expr) { 1879 void AstGraphBuilder::VisitYield(Yield* expr) {
(...skipping 10 matching lines...) Expand all
1900 ast_context()->ProduceValue(value); 1890 ast_context()->ProduceValue(value);
1901 } 1891 }
1902 1892
1903 1893
1904 void AstGraphBuilder::VisitProperty(Property* expr) { 1894 void AstGraphBuilder::VisitProperty(Property* expr) {
1905 Node* value; 1895 Node* value;
1906 VectorSlotPair pair = CreateVectorSlotPair(expr->PropertyFeedbackSlot()); 1896 VectorSlotPair pair = CreateVectorSlotPair(expr->PropertyFeedbackSlot());
1907 if (expr->key()->IsPropertyName()) { 1897 if (expr->key()->IsPropertyName()) {
1908 VisitForValue(expr->obj()); 1898 VisitForValue(expr->obj());
1909 Node* object = environment()->Pop(); 1899 Node* object = environment()->Pop();
1910 Unique<Name> name = MakeUnique(expr->key()->AsLiteral()->AsPropertyName()); 1900 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName();
1911 value = NewNode(javascript()->LoadNamed(name, pair), object); 1901 value = BuildNamedLoad(object, name, pair);
1912 } else { 1902 } else {
1913 VisitForValue(expr->obj()); 1903 VisitForValue(expr->obj());
1914 VisitForValue(expr->key()); 1904 VisitForValue(expr->key());
1915 Node* key = environment()->Pop(); 1905 Node* key = environment()->Pop();
1916 Node* object = environment()->Pop(); 1906 Node* object = environment()->Pop();
1917 value = NewNode(javascript()->LoadProperty(pair), object, key); 1907 value = BuildKeyedLoad(object, key, pair);
1918 } 1908 }
1919 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 1909 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
1920 ast_context()->ProduceValue(value); 1910 ast_context()->ProduceValue(value);
1921 } 1911 }
1922 1912
1923 1913
1924 void AstGraphBuilder::VisitCall(Call* expr) { 1914 void AstGraphBuilder::VisitCall(Call* expr) {
1925 Expression* callee = expr->expression(); 1915 Expression* callee = expr->expression();
1926 Call::CallType call_type = expr->GetCallType(isolate()); 1916 Call::CallType call_type = expr->GetCallType(isolate());
1927 1917
(...skipping 26 matching lines...) Expand all
1954 OutputFrameStateCombine::Push(2)); 1944 OutputFrameStateCombine::Push(2));
1955 break; 1945 break;
1956 } 1946 }
1957 case Call::PROPERTY_CALL: { 1947 case Call::PROPERTY_CALL: {
1958 Property* property = callee->AsProperty(); 1948 Property* property = callee->AsProperty();
1959 VisitForValue(property->obj()); 1949 VisitForValue(property->obj());
1960 Node* object = environment()->Top(); 1950 Node* object = environment()->Top();
1961 VectorSlotPair pair = 1951 VectorSlotPair pair =
1962 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 1952 CreateVectorSlotPair(property->PropertyFeedbackSlot());
1963 if (property->key()->IsPropertyName()) { 1953 if (property->key()->IsPropertyName()) {
1964 Unique<Name> name = 1954 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
1965 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 1955 callee_value = BuildNamedLoad(object, name, pair);
1966 callee_value = NewNode(javascript()->LoadNamed(name, pair), object);
1967 } else { 1956 } else {
1968 VisitForValue(property->key()); 1957 VisitForValue(property->key());
1969 Node* key = environment()->Pop(); 1958 Node* key = environment()->Pop();
1970 callee_value = NewNode(javascript()->LoadProperty(pair), object, key); 1959 callee_value = BuildKeyedLoad(object, key, pair);
1971 } 1960 }
1972 PrepareFrameState(callee_value, property->LoadId(), 1961 PrepareFrameState(callee_value, property->LoadId(),
1973 OutputFrameStateCombine::Push()); 1962 OutputFrameStateCombine::Push());
1974 receiver_value = environment()->Pop(); 1963 receiver_value = environment()->Pop();
1975 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an 1964 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an
1976 // object for sloppy callees. This could also be modeled explicitly here, 1965 // object for sloppy callees. This could also be modeled explicitly here,
1977 // thereby obsoleting the need for a flag to the call operator. 1966 // thereby obsoleting the need for a flag to the call operator.
1978 flags = CALL_AS_METHOD; 1967 flags = CALL_AS_METHOD;
1979 break; 1968 break;
1980 } 1969 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 } 2044 }
2056 2045
2057 2046
2058 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { 2047 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
2059 Handle<String> name = expr->name(); 2048 Handle<String> name = expr->name();
2060 2049
2061 // The callee and the receiver both have to be pushed onto the operand stack 2050 // The callee and the receiver both have to be pushed onto the operand stack
2062 // before arguments are being evaluated. 2051 // before arguments are being evaluated.
2063 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; 2052 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS;
2064 Node* receiver_value = BuildLoadBuiltinsObject(); 2053 Node* receiver_value = BuildLoadBuiltinsObject();
2065 Unique<String> unique = MakeUnique(name);
2066 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot()); 2054 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot());
2067 Node* callee_value = 2055 Node* callee_value = BuildNamedLoad(receiver_value, name, pair);
2068 NewNode(javascript()->LoadNamed(unique, pair), receiver_value);
2069 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft 2056 // TODO(jarin): Find/create a bailout id to deoptimize to (crankshaft
2070 // refuses to optimize functions with jsruntime calls). 2057 // refuses to optimize functions with jsruntime calls).
2071 PrepareFrameState(callee_value, BailoutId::None(), 2058 PrepareFrameState(callee_value, BailoutId::None(),
2072 OutputFrameStateCombine::Push()); 2059 OutputFrameStateCombine::Push());
2073 environment()->Push(callee_value); 2060 environment()->Push(callee_value);
2074 environment()->Push(receiver_value); 2061 environment()->Push(receiver_value);
2075 2062
2076 // Evaluate all arguments to the JS runtime call. 2063 // Evaluate all arguments to the JS runtime call.
2077 ZoneList<Expression*>* args = expr->arguments(); 2064 ZoneList<Expression*>* args = expr->arguments();
2078 VisitForValues(args); 2065 VisitForValues(args);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2143 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 2130 VariableProxy* proxy = expr->expression()->AsVariableProxy();
2144 VectorSlotPair pair = CreateVectorSlotPair(proxy->VariableFeedbackSlot()); 2131 VectorSlotPair pair = CreateVectorSlotPair(proxy->VariableFeedbackSlot());
2145 old_value = 2132 old_value =
2146 BuildVariableLoad(proxy->var(), expr->expression()->id(), pair); 2133 BuildVariableLoad(proxy->var(), expr->expression()->id(), pair);
2147 stack_depth = 0; 2134 stack_depth = 0;
2148 break; 2135 break;
2149 } 2136 }
2150 case NAMED_PROPERTY: { 2137 case NAMED_PROPERTY: {
2151 VisitForValue(property->obj()); 2138 VisitForValue(property->obj());
2152 Node* object = environment()->Top(); 2139 Node* object = environment()->Top();
2153 Unique<Name> name = 2140 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2154 MakeUnique(property->key()->AsLiteral()->AsPropertyName());
2155 VectorSlotPair pair = 2141 VectorSlotPair pair =
2156 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 2142 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2157 old_value = NewNode(javascript()->LoadNamed(name, pair), object); 2143 old_value = BuildNamedLoad(object, name, pair);
2158 PrepareFrameState(old_value, property->LoadId(), 2144 PrepareFrameState(old_value, property->LoadId(),
2159 OutputFrameStateCombine::Push()); 2145 OutputFrameStateCombine::Push());
2160 stack_depth = 1; 2146 stack_depth = 1;
2161 break; 2147 break;
2162 } 2148 }
2163 case KEYED_PROPERTY: { 2149 case KEYED_PROPERTY: {
2164 VisitForValue(property->obj()); 2150 VisitForValue(property->obj());
2165 VisitForValue(property->key()); 2151 VisitForValue(property->key());
2166 Node* key = environment()->Top(); 2152 Node* key = environment()->Top();
2167 Node* object = environment()->Peek(1); 2153 Node* object = environment()->Peek(1);
2168 VectorSlotPair pair = 2154 VectorSlotPair pair =
2169 CreateVectorSlotPair(property->PropertyFeedbackSlot()); 2155 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2170 old_value = NewNode(javascript()->LoadProperty(pair), object, key); 2156 old_value = BuildKeyedLoad(object, key, pair);
2171 PrepareFrameState(old_value, property->LoadId(), 2157 PrepareFrameState(old_value, property->LoadId(),
2172 OutputFrameStateCombine::Push()); 2158 OutputFrameStateCombine::Push());
2173 stack_depth = 2; 2159 stack_depth = 2;
2174 break; 2160 break;
2175 } 2161 }
2176 } 2162 }
2177 2163
2178 // Convert old value into a number. 2164 // Convert old value into a number.
2179 old_value = NewNode(javascript()->ToNumber(), old_value); 2165 old_value = NewNode(javascript()->ToNumber(), old_value);
2180 PrepareFrameState(old_value, expr->ToNumberId(), 2166 PrepareFrameState(old_value, expr->ToNumberId(),
(...skipping 16 matching lines...) Expand all
2197 case VARIABLE: { 2183 case VARIABLE: {
2198 Variable* variable = expr->expression()->AsVariableProxy()->var(); 2184 Variable* variable = expr->expression()->AsVariableProxy()->var();
2199 environment()->Push(value); 2185 environment()->Push(value);
2200 BuildVariableAssignment(variable, value, expr->op(), 2186 BuildVariableAssignment(variable, value, expr->op(),
2201 expr->AssignmentId()); 2187 expr->AssignmentId());
2202 environment()->Pop(); 2188 environment()->Pop();
2203 break; 2189 break;
2204 } 2190 }
2205 case NAMED_PROPERTY: { 2191 case NAMED_PROPERTY: {
2206 Node* object = environment()->Pop(); 2192 Node* object = environment()->Pop();
2207 Unique<Name> name = 2193 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2208 MakeUnique(property->key()->AsLiteral()->AsPropertyName()); 2194 Node* store = BuildNamedStore(object, name, value);
2209 Node* store = NewNode(javascript()->StoreNamed(language_mode(), name),
2210 object, value);
2211 environment()->Push(value); 2195 environment()->Push(value);
2212 PrepareFrameState(store, expr->AssignmentId()); 2196 PrepareFrameState(store, expr->AssignmentId());
2213 environment()->Pop(); 2197 environment()->Pop();
2214 break; 2198 break;
2215 } 2199 }
2216 case KEYED_PROPERTY: { 2200 case KEYED_PROPERTY: {
2217 Node* key = environment()->Pop(); 2201 Node* key = environment()->Pop();
2218 Node* object = environment()->Pop(); 2202 Node* object = environment()->Pop();
2219 Node* store = NewNode(javascript()->StoreProperty(language_mode()), 2203 Node* store = BuildKeyedStore(object, key, value);
2220 object, key, value);
2221 environment()->Push(value); 2204 environment()->Push(value);
2222 PrepareFrameState(store, expr->AssignmentId()); 2205 PrepareFrameState(store, expr->AssignmentId());
2223 environment()->Pop(); 2206 environment()->Pop();
2224 break; 2207 break;
2225 } 2208 }
2226 } 2209 }
2227 2210
2228 // Restore old value for postfix expressions. 2211 // Restore old value for postfix expressions.
2229 if (is_postfix) value = environment()->Pop(); 2212 if (is_postfix) value = environment()->Pop();
2230 2213
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2614 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable, 2597 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
2615 BailoutId bailout_id, 2598 BailoutId bailout_id,
2616 const VectorSlotPair& feedback, 2599 const VectorSlotPair& feedback,
2617 ContextualMode contextual_mode) { 2600 ContextualMode contextual_mode) {
2618 Node* the_hole = jsgraph()->TheHoleConstant(); 2601 Node* the_hole = jsgraph()->TheHoleConstant();
2619 VariableMode mode = variable->mode(); 2602 VariableMode mode = variable->mode();
2620 switch (variable->location()) { 2603 switch (variable->location()) {
2621 case Variable::UNALLOCATED: { 2604 case Variable::UNALLOCATED: {
2622 // Global var, const, or let variable. 2605 // Global var, const, or let variable.
2623 Node* global = BuildLoadGlobalObject(); 2606 Node* global = BuildLoadGlobalObject();
2624 Unique<Name> name = MakeUnique(variable->name()); 2607 Handle<Name> name = variable->name();
2625 const Operator* op = 2608 Node* node = BuildNamedLoad(global, name, feedback, contextual_mode);
2626 javascript()->LoadNamed(name, feedback, contextual_mode);
2627 Node* node = NewNode(op, global);
2628 PrepareFrameState(node, bailout_id, OutputFrameStateCombine::Push()); 2609 PrepareFrameState(node, bailout_id, OutputFrameStateCombine::Push());
2629 return node; 2610 return node;
2630 } 2611 }
2631 case Variable::PARAMETER: 2612 case Variable::PARAMETER:
2632 case Variable::LOCAL: { 2613 case Variable::LOCAL: {
2633 // Local var, const, or let variable. 2614 // Local var, const, or let variable.
2634 Node* value = environment()->Lookup(variable); 2615 Node* value = environment()->Lookup(variable);
2635 if (mode == CONST_LEGACY) { 2616 if (mode == CONST_LEGACY) {
2636 // Perform check for uninitialized legacy const variables. 2617 // Perform check for uninitialized legacy const variables.
2637 if (value->op() == the_hole->op()) { 2618 if (value->op() == the_hole->op()) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2723 2704
2724 Node* AstGraphBuilder::BuildVariableAssignment( 2705 Node* AstGraphBuilder::BuildVariableAssignment(
2725 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id, 2706 Variable* variable, Node* value, Token::Value op, BailoutId bailout_id,
2726 OutputFrameStateCombine combine) { 2707 OutputFrameStateCombine combine) {
2727 Node* the_hole = jsgraph()->TheHoleConstant(); 2708 Node* the_hole = jsgraph()->TheHoleConstant();
2728 VariableMode mode = variable->mode(); 2709 VariableMode mode = variable->mode();
2729 switch (variable->location()) { 2710 switch (variable->location()) {
2730 case Variable::UNALLOCATED: { 2711 case Variable::UNALLOCATED: {
2731 // Global var, const, or let variable. 2712 // Global var, const, or let variable.
2732 Node* global = BuildLoadGlobalObject(); 2713 Node* global = BuildLoadGlobalObject();
2733 Unique<Name> name = MakeUnique(variable->name()); 2714 Handle<Name> name = variable->name();
2734 const Operator* op = javascript()->StoreNamed(language_mode(), name); 2715 Node* store = BuildNamedStore(global, name, value);
2735 Node* store = NewNode(op, global, value);
2736 PrepareFrameState(store, bailout_id, combine); 2716 PrepareFrameState(store, bailout_id, combine);
2737 return store; 2717 return store;
2738 } 2718 }
2739 case Variable::PARAMETER: 2719 case Variable::PARAMETER:
2740 case Variable::LOCAL: 2720 case Variable::LOCAL:
2741 // Local var, const, or let variable. 2721 // Local var, const, or let variable.
2742 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { 2722 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
2743 // Perform an initialization check for legacy const variables. 2723 // Perform an initialization check for legacy const variables.
2744 Node* current = environment()->Lookup(variable); 2724 Node* current = environment()->Lookup(variable);
2745 if (current->op() != the_hole->op()) { 2725 if (current->op() != the_hole->op()) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2821 Node* store = NewNode(op, value, current_context(), name, language); 2801 Node* store = NewNode(op, value, current_context(), name, language);
2822 PrepareFrameState(store, bailout_id, combine); 2802 PrepareFrameState(store, bailout_id, combine);
2823 return store; 2803 return store;
2824 } 2804 }
2825 } 2805 }
2826 UNREACHABLE(); 2806 UNREACHABLE();
2827 return NULL; 2807 return NULL;
2828 } 2808 }
2829 2809
2830 2810
2811 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
2812 const VectorSlotPair& feedback) {
2813 const Operator* op = javascript()->LoadProperty(feedback);
2814 return NewNode(op, object, key);
2815 }
2816
2817
2818 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
2819 const VectorSlotPair& feedback,
2820 ContextualMode mode) {
2821 const Operator* op =
2822 javascript()->LoadNamed(MakeUnique(name), feedback, mode);
2823 return NewNode(op, object);
2824 }
2825
2826
2827 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value) {
2828 const Operator* op = javascript()->StoreProperty(language_mode());
2829 return NewNode(op, object, key, value);
2830 }
2831
2832
2833 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name,
2834 Node* value) {
2835 const Operator* op =
2836 javascript()->StoreNamed(language_mode(), MakeUnique(name));
2837 return NewNode(op, object, value);
2838 }
2839
2840
2831 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) { 2841 Node* AstGraphBuilder::BuildLoadObjectField(Node* object, int offset) {
2832 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object, 2842 return NewNode(jsgraph()->machine()->Load(kMachAnyTagged), object,
2833 jsgraph()->IntPtrConstant(offset - kHeapObjectTag)); 2843 jsgraph()->IntPtrConstant(offset - kHeapObjectTag));
2834 } 2844 }
2835 2845
2836 2846
2837 Node* AstGraphBuilder::BuildLoadBuiltinsObject() { 2847 Node* AstGraphBuilder::BuildLoadBuiltinsObject() {
2838 Node* global = BuildLoadGlobalObject(); 2848 Node* global = BuildLoadGlobalObject();
2839 Node* builtins = 2849 Node* builtins =
2840 BuildLoadObjectField(global, JSGlobalObject::kBuiltinsOffset); 2850 BuildLoadObjectField(global, JSGlobalObject::kBuiltinsOffset);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2905 // into a JSOperatorReducer. 2915 // into a JSOperatorReducer.
2906 Node* name = NewNode(javascript()->ToName(), input); 2916 Node* name = NewNode(javascript()->ToName(), input);
2907 PrepareFrameState(name, bailout_id); 2917 PrepareFrameState(name, bailout_id);
2908 return name; 2918 return name;
2909 } 2919 }
2910 2920
2911 2921
2912 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object, 2922 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object,
2913 Expression* expr) { 2923 Expression* expr) {
2914 if (!FunctionLiteral::NeedsHomeObject(expr)) return value; 2924 if (!FunctionLiteral::NeedsHomeObject(expr)) return value;
2915 Unique<Name> name = MakeUnique(isolate()->factory()->home_object_symbol()); 2925 Handle<Name> name = isolate()->factory()->home_object_symbol();
2916 const Operator* op = javascript()->StoreNamed(language_mode(), name); 2926 Node* store = BuildNamedStore(value, name, home_object);
2917 Node* store = NewNode(op, value, home_object);
2918 PrepareFrameState(store, BailoutId::None()); 2927 PrepareFrameState(store, BailoutId::None());
2919 return store; 2928 return store;
2920 } 2929 }
2921 2930
2922 2931
2923 Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) { 2932 Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) {
2924 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1); 2933 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1);
2925 Node* call = NewNode(op, exception); 2934 Node* call = NewNode(op, exception);
2926 PrepareFrameState(call, bailout_id); 2935 PrepareFrameState(call, bailout_id);
2927 return call; 2936 return call;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3329 // Phi does not exist yet, introduce one. 3338 // Phi does not exist yet, introduce one.
3330 value = NewPhi(inputs, value, control); 3339 value = NewPhi(inputs, value, control);
3331 value->ReplaceInput(inputs - 1, other); 3340 value->ReplaceInput(inputs - 1, other);
3332 } 3341 }
3333 return value; 3342 return value;
3334 } 3343 }
3335 3344
3336 } // namespace compiler 3345 } // namespace compiler
3337 } // namespace internal 3346 } // namespace internal
3338 } // namespace v8 3347 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698