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

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

Issue 1198983002: [turbofan] Revive the VectorSlotPair and also put feedback on JSCallFunction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Try to address compilation error. Created 5 years, 6 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') | src/compiler/js-operator.h » ('j') | 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/js-type-feedback.h" 10 #include "src/compiler/js-type-feedback.h"
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 PrepareFrameState(value, stmt->FilterId(), 1358 PrepareFrameState(value, stmt->FilterId(),
1359 OutputFrameStateCombine::Push()); 1359 OutputFrameStateCombine::Push());
1360 IfBuilder test_value(this); 1360 IfBuilder test_value(this);
1361 Node* test_value_cond = NewNode(javascript()->StrictEqual(), value, 1361 Node* test_value_cond = NewNode(javascript()->StrictEqual(), value,
1362 jsgraph()->UndefinedConstant()); 1362 jsgraph()->UndefinedConstant());
1363 test_value.If(test_value_cond, BranchHint::kFalse); 1363 test_value.If(test_value_cond, BranchHint::kFalse);
1364 test_value.Then(); 1364 test_value.Then();
1365 test_value.Else(); 1365 test_value.Else();
1366 { 1366 {
1367 // Bind value and do loop body. 1367 // Bind value and do loop body.
1368 ResolvedFeedbackSlot slot = 1368 VectorSlotPair feedback =
1369 ResolveFeedbackSlot(stmt->EachFeedbackSlot()); 1369 CreateVectorSlotPair(stmt->EachFeedbackSlot());
1370 VisitForInAssignment(stmt->each(), value, slot, stmt->AssignmentId()); 1370 VisitForInAssignment(stmt->each(), value, feedback,
1371 stmt->AssignmentId());
1371 VisitIterationBody(stmt, &for_loop); 1372 VisitIterationBody(stmt, &for_loop);
1372 } 1373 }
1373 test_value.End(); 1374 test_value.End();
1374 index = environment()->Peek(0); 1375 index = environment()->Peek(0);
1375 for_loop.EndBody(); 1376 for_loop.EndBody();
1376 1377
1377 // Increment counter and continue. 1378 // Increment counter and continue.
1378 index = NewNode(javascript()->ForInStep(), index); 1379 index = NewNode(javascript()->ForInStep(), index);
1379 environment()->Poke(0, index); 1380 environment()->Poke(0, index);
1380 } 1381 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 if (property->is_static() && property->is_computed_name()) { 1605 if (property->is_static() && property->is_computed_name()) {
1605 Node* check = BuildThrowIfStaticPrototype(environment()->Pop(), 1606 Node* check = BuildThrowIfStaticPrototype(environment()->Pop(),
1606 expr->GetIdForProperty(i)); 1607 expr->GetIdForProperty(i));
1607 environment()->Push(check); 1608 environment()->Push(check);
1608 } 1609 }
1609 1610
1610 VisitForValue(property->value()); 1611 VisitForValue(property->value());
1611 Node* value = environment()->Pop(); 1612 Node* value = environment()->Pop();
1612 Node* key = environment()->Pop(); 1613 Node* key = environment()->Pop();
1613 Node* receiver = environment()->Pop(); 1614 Node* receiver = environment()->Pop();
1614 ResolvedFeedbackSlot slot = ResolveFeedbackSlot( 1615 VectorSlotPair feedback = CreateVectorSlotPair(
1615 expr->SlotForHomeObject(property->value(), &store_slot_index)); 1616 expr->SlotForHomeObject(property->value(), &store_slot_index));
1616 BuildSetHomeObject(value, receiver, property->value(), slot); 1617 BuildSetHomeObject(value, receiver, property->value(), feedback);
1617 1618
1618 switch (property->kind()) { 1619 switch (property->kind()) {
1619 case ObjectLiteral::Property::CONSTANT: 1620 case ObjectLiteral::Property::CONSTANT:
1620 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 1621 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1621 case ObjectLiteral::Property::PROTOTYPE: 1622 case ObjectLiteral::Property::PROTOTYPE:
1622 UNREACHABLE(); 1623 UNREACHABLE();
1623 case ObjectLiteral::Property::COMPUTED: { 1624 case ObjectLiteral::Property::COMPUTED: {
1624 const Operator* op = 1625 const Operator* op =
1625 javascript()->CallRuntime(Runtime::kDefineClassMethod, 3); 1626 javascript()->CallRuntime(Runtime::kDefineClassMethod, 3);
1626 NewNode(op, receiver, key, value); 1627 NewNode(op, receiver, key, value);
(...skipping 19 matching lines...) Expand all
1646 // Transform both the class literal and the prototype to fast properties. 1647 // Transform both the class literal and the prototype to fast properties.
1647 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties, 1); 1648 const Operator* op = javascript()->CallRuntime(Runtime::kToFastProperties, 1);
1648 NewNode(op, environment()->Pop()); // prototype 1649 NewNode(op, environment()->Pop()); // prototype
1649 NewNode(op, environment()->Pop()); // literal 1650 NewNode(op, environment()->Pop()); // literal
1650 1651
1651 // Assign to class variable. 1652 // Assign to class variable.
1652 if (expr->scope() != NULL) { 1653 if (expr->scope() != NULL) {
1653 DCHECK_NOT_NULL(expr->class_variable_proxy()); 1654 DCHECK_NOT_NULL(expr->class_variable_proxy());
1654 Variable* var = expr->class_variable_proxy()->var(); 1655 Variable* var = expr->class_variable_proxy()->var();
1655 FrameStateBeforeAndAfter states(this, BailoutId::None()); 1656 FrameStateBeforeAndAfter states(this, BailoutId::None());
1656 ResolvedFeedbackSlot slot = ResolveFeedbackSlot( 1657 VectorSlotPair feedback = CreateVectorSlotPair(
1657 FLAG_vector_stores ? expr->GetNthSlot(store_slot_index++) 1658 FLAG_vector_stores ? expr->GetNthSlot(store_slot_index++)
1658 : FeedbackVectorICSlot::Invalid()); 1659 : FeedbackVectorICSlot::Invalid());
1659 BuildVariableAssignment(var, literal, Token::INIT_CONST, slot, 1660 BuildVariableAssignment(var, literal, Token::INIT_CONST, feedback,
1660 BailoutId::None(), states); 1661 BailoutId::None(), states);
1661 } 1662 }
1662 1663
1663 ast_context()->ProduceValue(literal); 1664 ast_context()->ProduceValue(literal);
1664 } 1665 }
1665 1666
1666 1667
1667 void AstGraphBuilder::VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) { 1668 void AstGraphBuilder::VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) {
1668 UNREACHABLE(); 1669 UNREACHABLE();
1669 } 1670 }
1670 1671
1671 1672
1672 void AstGraphBuilder::VisitConditional(Conditional* expr) { 1673 void AstGraphBuilder::VisitConditional(Conditional* expr) {
1673 IfBuilder compare_if(this); 1674 IfBuilder compare_if(this);
1674 VisitForTest(expr->condition()); 1675 VisitForTest(expr->condition());
1675 Node* condition = environment()->Pop(); 1676 Node* condition = environment()->Pop();
1676 compare_if.If(condition); 1677 compare_if.If(condition);
1677 compare_if.Then(); 1678 compare_if.Then();
1678 Visit(expr->then_expression()); 1679 Visit(expr->then_expression());
1679 compare_if.Else(); 1680 compare_if.Else();
1680 Visit(expr->else_expression()); 1681 Visit(expr->else_expression());
1681 compare_if.End(); 1682 compare_if.End();
1682 ast_context()->ReplaceValue(); 1683 ast_context()->ReplaceValue();
1683 } 1684 }
1684 1685
1685 1686
1686 void AstGraphBuilder::VisitVariableProxy(VariableProxy* expr) { 1687 void AstGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
1687 ResolvedFeedbackSlot slot = ResolveFeedbackSlot(expr->VariableFeedbackSlot()); 1688 VectorSlotPair pair = CreateVectorSlotPair(expr->VariableFeedbackSlot());
1688 FrameStateBeforeAndAfter states(this, BeforeId(expr)); 1689 FrameStateBeforeAndAfter states(this, BeforeId(expr));
1689 Node* value = BuildVariableLoad(expr->var(), expr->id(), states, slot, 1690 Node* value = BuildVariableLoad(expr->var(), expr->id(), states, pair,
1690 ast_context()->GetStateCombine()); 1691 ast_context()->GetStateCombine());
1691 ast_context()->ProduceValue(value); 1692 ast_context()->ProduceValue(value);
1692 } 1693 }
1693 1694
1694 1695
1695 void AstGraphBuilder::VisitLiteral(Literal* expr) { 1696 void AstGraphBuilder::VisitLiteral(Literal* expr) {
1696 Node* value = jsgraph()->Constant(expr->value()); 1697 Node* value = jsgraph()->Constant(expr->value());
1697 ast_context()->ProduceValue(value); 1698 ast_context()->ProduceValue(value);
1698 } 1699 }
1699 1700
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 // Fall through. 1752 // Fall through.
1752 case ObjectLiteral::Property::COMPUTED: { 1753 case ObjectLiteral::Property::COMPUTED: {
1753 // It is safe to use [[Put]] here because the boilerplate already 1754 // It is safe to use [[Put]] here because the boilerplate already
1754 // contains computed properties with an uninitialized value. 1755 // contains computed properties with an uninitialized value.
1755 if (key->value()->IsInternalizedString()) { 1756 if (key->value()->IsInternalizedString()) {
1756 if (property->emit_store()) { 1757 if (property->emit_store()) {
1757 VisitForValue(property->value()); 1758 VisitForValue(property->value());
1758 FrameStateBeforeAndAfter states(this, property->value()->id()); 1759 FrameStateBeforeAndAfter states(this, property->value()->id());
1759 Node* value = environment()->Pop(); 1760 Node* value = environment()->Pop();
1760 Handle<Name> name = key->AsPropertyName(); 1761 Handle<Name> name = key->AsPropertyName();
1761 ResolvedFeedbackSlot slot = 1762 VectorSlotPair feedback =
1762 FLAG_vector_stores 1763 FLAG_vector_stores
1763 ? ResolveFeedbackSlot(expr->GetNthSlot(store_slot_index++)) 1764 ? CreateVectorSlotPair(expr->GetNthSlot(store_slot_index++))
1764 : ResolvedFeedbackSlot(); 1765 : VectorSlotPair();
1765 Node* store = BuildNamedStore(literal, name, value, slot, 1766 Node* store = BuildNamedStore(literal, name, value, feedback,
1766 TypeFeedbackId::None()); 1767 TypeFeedbackId::None());
1767 states.AddToNode(store, key->id(), 1768 states.AddToNode(store, key->id(),
1768 OutputFrameStateCombine::Ignore()); 1769 OutputFrameStateCombine::Ignore());
1769 ResolvedFeedbackSlot home_slot = ResolveFeedbackSlot( 1770 VectorSlotPair home_feedback = CreateVectorSlotPair(
1770 expr->SlotForHomeObject(property->value(), &store_slot_index)); 1771 expr->SlotForHomeObject(property->value(), &store_slot_index));
1771 BuildSetHomeObject(value, literal, property->value(), home_slot); 1772 BuildSetHomeObject(value, literal, property->value(),
1773 home_feedback);
1772 } else { 1774 } else {
1773 VisitForEffect(property->value()); 1775 VisitForEffect(property->value());
1774 } 1776 }
1775 break; 1777 break;
1776 } 1778 }
1777 environment()->Push(literal); // Duplicate receiver. 1779 environment()->Push(literal); // Duplicate receiver.
1778 VisitForValue(property->key()); 1780 VisitForValue(property->key());
1779 VisitForValue(property->value()); 1781 VisitForValue(property->value());
1780 Node* value = environment()->Pop(); 1782 Node* value = environment()->Pop();
1781 Node* key = environment()->Pop(); 1783 Node* key = environment()->Pop();
1782 Node* receiver = environment()->Pop(); 1784 Node* receiver = environment()->Pop();
1783 if (property->emit_store()) { 1785 if (property->emit_store()) {
1784 Node* language = jsgraph()->Constant(SLOPPY); 1786 Node* language = jsgraph()->Constant(SLOPPY);
1785 const Operator* op = 1787 const Operator* op =
1786 javascript()->CallRuntime(Runtime::kSetProperty, 4); 1788 javascript()->CallRuntime(Runtime::kSetProperty, 4);
1787 Node* set_property = NewNode(op, receiver, key, value, language); 1789 Node* set_property = NewNode(op, receiver, key, value, language);
1788 // SetProperty should not lazy deopt on an object literal. 1790 // SetProperty should not lazy deopt on an object literal.
1789 PrepareFrameState(set_property, BailoutId::None()); 1791 PrepareFrameState(set_property, BailoutId::None());
1790 ResolvedFeedbackSlot home_slot = ResolveFeedbackSlot( 1792 VectorSlotPair home_feedback = CreateVectorSlotPair(
1791 expr->SlotForHomeObject(property->value(), &store_slot_index)); 1793 expr->SlotForHomeObject(property->value(), &store_slot_index));
1792 BuildSetHomeObject(value, receiver, property->value(), home_slot); 1794 BuildSetHomeObject(value, receiver, property->value(), home_feedback);
1793 } 1795 }
1794 break; 1796 break;
1795 } 1797 }
1796 case ObjectLiteral::Property::PROTOTYPE: { 1798 case ObjectLiteral::Property::PROTOTYPE: {
1797 environment()->Push(literal); // Duplicate receiver. 1799 environment()->Push(literal); // Duplicate receiver.
1798 VisitForValue(property->value()); 1800 VisitForValue(property->value());
1799 Node* value = environment()->Pop(); 1801 Node* value = environment()->Pop();
1800 Node* receiver = environment()->Pop(); 1802 Node* receiver = environment()->Pop();
1801 DCHECK(property->emit_store()); 1803 DCHECK(property->emit_store());
1802 const Operator* op = 1804 const Operator* op =
(...skipping 15 matching lines...) Expand all
1818 break; 1820 break;
1819 } 1821 }
1820 } 1822 }
1821 1823
1822 // Create nodes to define accessors, using only a single call to the runtime 1824 // Create nodes to define accessors, using only a single call to the runtime
1823 // for each pair of corresponding getters and setters. 1825 // for each pair of corresponding getters and setters.
1824 for (AccessorTable::Iterator it = accessor_table.begin(); 1826 for (AccessorTable::Iterator it = accessor_table.begin();
1825 it != accessor_table.end(); ++it) { 1827 it != accessor_table.end(); ++it) {
1826 VisitForValue(it->first); 1828 VisitForValue(it->first);
1827 VisitForValueOrNull(it->second->getter); 1829 VisitForValueOrNull(it->second->getter);
1828 ResolvedFeedbackSlot slot_getter = ResolveFeedbackSlot( 1830 VectorSlotPair feedback_getter = CreateVectorSlotPair(
1829 expr->SlotForHomeObject(it->second->getter, &store_slot_index)); 1831 expr->SlotForHomeObject(it->second->getter, &store_slot_index));
1830 BuildSetHomeObject(environment()->Top(), literal, it->second->getter, 1832 BuildSetHomeObject(environment()->Top(), literal, it->second->getter,
1831 slot_getter); 1833 feedback_getter);
1832 VisitForValueOrNull(it->second->setter); 1834 VisitForValueOrNull(it->second->setter);
1833 ResolvedFeedbackSlot slot_setter = ResolveFeedbackSlot( 1835 VectorSlotPair feedback_setter = CreateVectorSlotPair(
1834 expr->SlotForHomeObject(it->second->getter, &store_slot_index)); 1836 expr->SlotForHomeObject(it->second->getter, &store_slot_index));
1835 BuildSetHomeObject(environment()->Top(), literal, it->second->setter, 1837 BuildSetHomeObject(environment()->Top(), literal, it->second->setter,
1836 slot_setter); 1838 feedback_setter);
1837 Node* setter = environment()->Pop(); 1839 Node* setter = environment()->Pop();
1838 Node* getter = environment()->Pop(); 1840 Node* getter = environment()->Pop();
1839 Node* name = environment()->Pop(); 1841 Node* name = environment()->Pop();
1840 Node* attr = jsgraph()->Constant(NONE); 1842 Node* attr = jsgraph()->Constant(NONE);
1841 const Operator* op = 1843 const Operator* op =
1842 javascript()->CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5); 1844 javascript()->CallRuntime(Runtime::kDefineAccessorPropertyUnchecked, 5);
1843 Node* call = NewNode(op, literal, name, getter, setter, attr); 1845 Node* call = NewNode(op, literal, name, getter, setter, attr);
1844 // This should not lazy deopt on a new literal. 1846 // This should not lazy deopt on a new literal.
1845 PrepareFrameState(call, BailoutId::None()); 1847 PrepareFrameState(call, BailoutId::None());
1846 } 1848 }
(...skipping 24 matching lines...) Expand all
1871 1873
1872 environment()->Push(literal); // Duplicate receiver. 1874 environment()->Push(literal); // Duplicate receiver.
1873 VisitForValue(property->key()); 1875 VisitForValue(property->key());
1874 Node* name = BuildToName(environment()->Pop(), 1876 Node* name = BuildToName(environment()->Pop(),
1875 expr->GetIdForProperty(property_index)); 1877 expr->GetIdForProperty(property_index));
1876 environment()->Push(name); 1878 environment()->Push(name);
1877 VisitForValue(property->value()); 1879 VisitForValue(property->value());
1878 Node* value = environment()->Pop(); 1880 Node* value = environment()->Pop();
1879 Node* key = environment()->Pop(); 1881 Node* key = environment()->Pop();
1880 Node* receiver = environment()->Pop(); 1882 Node* receiver = environment()->Pop();
1881 ResolvedFeedbackSlot slot = ResolveFeedbackSlot( 1883 VectorSlotPair feedback = CreateVectorSlotPair(
1882 expr->SlotForHomeObject(property->value(), &store_slot_index)); 1884 expr->SlotForHomeObject(property->value(), &store_slot_index));
1883 BuildSetHomeObject(value, receiver, property->value(), slot); 1885 BuildSetHomeObject(value, receiver, property->value(), feedback);
1884 switch (property->kind()) { 1886 switch (property->kind()) {
1885 case ObjectLiteral::Property::CONSTANT: 1887 case ObjectLiteral::Property::CONSTANT:
1886 case ObjectLiteral::Property::COMPUTED: 1888 case ObjectLiteral::Property::COMPUTED:
1887 case ObjectLiteral::Property::MATERIALIZED_LITERAL: { 1889 case ObjectLiteral::Property::MATERIALIZED_LITERAL: {
1888 Node* attr = jsgraph()->Constant(NONE); 1890 Node* attr = jsgraph()->Constant(NONE);
1889 const Operator* op = 1891 const Operator* op =
1890 javascript()->CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4); 1892 javascript()->CallRuntime(Runtime::kDefineDataPropertyUnchecked, 4);
1891 Node* call = NewNode(op, receiver, key, value, attr); 1893 Node* call = NewNode(op, receiver, key, value, attr);
1892 PrepareFrameState(call, BailoutId::None()); 1894 PrepareFrameState(call, BailoutId::None());
1893 break; 1895 break;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 for (; array_index < expr->values()->length(); array_index++) { 1957 for (; array_index < expr->values()->length(); array_index++) {
1956 Expression* subexpr = expr->values()->at(array_index); 1958 Expression* subexpr = expr->values()->at(array_index);
1957 if (subexpr->IsSpread()) break; 1959 if (subexpr->IsSpread()) break;
1958 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; 1960 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue;
1959 1961
1960 VisitForValue(subexpr); 1962 VisitForValue(subexpr);
1961 { 1963 {
1962 FrameStateBeforeAndAfter states(this, subexpr->id()); 1964 FrameStateBeforeAndAfter states(this, subexpr->id());
1963 Node* value = environment()->Pop(); 1965 Node* value = environment()->Pop();
1964 Node* index = jsgraph()->Constant(array_index); 1966 Node* index = jsgraph()->Constant(array_index);
1965 Node* store = 1967 Node* store = BuildKeyedStore(literal, index, value, VectorSlotPair(),
1966 BuildKeyedStore(literal, index, value, ResolvedFeedbackSlot(), 1968 TypeFeedbackId::None());
1967 TypeFeedbackId::None());
1968 states.AddToNode(store, expr->GetIdForElement(array_index), 1969 states.AddToNode(store, expr->GetIdForElement(array_index),
1969 OutputFrameStateCombine::Ignore()); 1970 OutputFrameStateCombine::Ignore());
1970 } 1971 }
1971 } 1972 }
1972 1973
1973 // In case the array literal contains spread expressions it has two parts. The 1974 // In case the array literal contains spread expressions it has two parts. The
1974 // first part is the "static" array which has a literal index is handled 1975 // first part is the "static" array which has a literal index is handled
1975 // above. The second part is the part after the first spread expression 1976 // above. The second part is the part after the first spread expression
1976 // (inclusive) and these elements gets appended to the array. Note that the 1977 // (inclusive) and these elements gets appended to the array. Note that the
1977 // number elements an iterable produces is unknown ahead of time. 1978 // number elements an iterable produces is unknown ahead of time.
(...skipping 23 matching lines...) Expand all
2001 2002
2002 PrepareFrameState(result, expr->GetIdForElement(array_index)); 2003 PrepareFrameState(result, expr->GetIdForElement(array_index));
2003 environment()->Push(result); 2004 environment()->Push(result);
2004 } 2005 }
2005 2006
2006 ast_context()->ProduceValue(environment()->Pop()); 2007 ast_context()->ProduceValue(environment()->Pop());
2007 } 2008 }
2008 2009
2009 2010
2010 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value, 2011 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value,
2011 const ResolvedFeedbackSlot& slot, 2012 const VectorSlotPair& feedback,
2012 BailoutId bailout_id) { 2013 BailoutId bailout_id) {
2013 DCHECK(expr->IsValidReferenceExpression()); 2014 DCHECK(expr->IsValidReferenceExpression());
2014 2015
2015 // Left-hand side can only be a property, a global or a variable slot. 2016 // Left-hand side can only be a property, a global or a variable slot.
2016 Property* property = expr->AsProperty(); 2017 Property* property = expr->AsProperty();
2017 LhsKind assign_type = Property::GetAssignType(property); 2018 LhsKind assign_type = Property::GetAssignType(property);
2018 2019
2019 // Evaluate LHS expression and store the value. 2020 // Evaluate LHS expression and store the value.
2020 switch (assign_type) { 2021 switch (assign_type) {
2021 case VARIABLE: { 2022 case VARIABLE: {
2022 Variable* var = expr->AsVariableProxy()->var(); 2023 Variable* var = expr->AsVariableProxy()->var();
2023 FrameStateBeforeAndAfter states(this, BailoutId::None()); 2024 FrameStateBeforeAndAfter states(this, BailoutId::None());
2024 BuildVariableAssignment(var, value, Token::ASSIGN, slot, bailout_id, 2025 BuildVariableAssignment(var, value, Token::ASSIGN, feedback, bailout_id,
2025 states); 2026 states);
2026 break; 2027 break;
2027 } 2028 }
2028 case NAMED_PROPERTY: { 2029 case NAMED_PROPERTY: {
2029 environment()->Push(value); 2030 environment()->Push(value);
2030 VisitForValue(property->obj()); 2031 VisitForValue(property->obj());
2031 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2032 FrameStateBeforeAndAfter states(this, property->obj()->id());
2032 Node* object = environment()->Pop(); 2033 Node* object = environment()->Pop();
2033 value = environment()->Pop(); 2034 value = environment()->Pop();
2034 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2035 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2035 Node* store = 2036 Node* store = BuildNamedStore(object, name, value, feedback,
2036 BuildNamedStore(object, name, value, slot, TypeFeedbackId::None()); 2037 TypeFeedbackId::None());
2037 states.AddToNode(store, bailout_id, OutputFrameStateCombine::Ignore()); 2038 states.AddToNode(store, bailout_id, OutputFrameStateCombine::Ignore());
2038 break; 2039 break;
2039 } 2040 }
2040 case KEYED_PROPERTY: { 2041 case KEYED_PROPERTY: {
2041 environment()->Push(value); 2042 environment()->Push(value);
2042 VisitForValue(property->obj()); 2043 VisitForValue(property->obj());
2043 VisitForValue(property->key()); 2044 VisitForValue(property->key());
2044 FrameStateBeforeAndAfter states(this, property->key()->id()); 2045 FrameStateBeforeAndAfter states(this, property->key()->id());
2045 Node* key = environment()->Pop(); 2046 Node* key = environment()->Pop();
2046 Node* object = environment()->Pop(); 2047 Node* object = environment()->Pop();
2047 value = environment()->Pop(); 2048 value = environment()->Pop();
2048 Node* store = 2049 Node* store =
2049 BuildKeyedStore(object, key, value, slot, TypeFeedbackId::None()); 2050 BuildKeyedStore(object, key, value, feedback, TypeFeedbackId::None());
2050 states.AddToNode(store, bailout_id, OutputFrameStateCombine::Ignore()); 2051 states.AddToNode(store, bailout_id, OutputFrameStateCombine::Ignore());
2051 break; 2052 break;
2052 } 2053 }
2053 case NAMED_SUPER_PROPERTY: { 2054 case NAMED_SUPER_PROPERTY: {
2054 environment()->Push(value); 2055 environment()->Push(value);
2055 VisitForValue(property->obj()->AsSuperPropertyReference()->this_var()); 2056 VisitForValue(property->obj()->AsSuperPropertyReference()->this_var());
2056 VisitForValue(property->obj()->AsSuperPropertyReference()->home_object()); 2057 VisitForValue(property->obj()->AsSuperPropertyReference()->home_object());
2057 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2058 FrameStateBeforeAndAfter states(this, property->obj()->id());
2058 Node* home_object = environment()->Pop(); 2059 Node* home_object = environment()->Pop();
2059 Node* receiver = environment()->Pop(); 2060 Node* receiver = environment()->Pop();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 } 2122 }
2122 2123
2123 BailoutId before_store_id = BailoutId::None(); 2124 BailoutId before_store_id = BailoutId::None();
2124 // Evaluate the value and potentially handle compound assignments by loading 2125 // Evaluate the value and potentially handle compound assignments by loading
2125 // the left-hand side value and performing a binary operation. 2126 // the left-hand side value and performing a binary operation.
2126 if (expr->is_compound()) { 2127 if (expr->is_compound()) {
2127 Node* old_value = NULL; 2128 Node* old_value = NULL;
2128 switch (assign_type) { 2129 switch (assign_type) {
2129 case VARIABLE: { 2130 case VARIABLE: {
2130 VariableProxy* proxy = expr->target()->AsVariableProxy(); 2131 VariableProxy* proxy = expr->target()->AsVariableProxy();
2131 ResolvedFeedbackSlot slot = 2132 VectorSlotPair pair =
2132 ResolveFeedbackSlot(proxy->VariableFeedbackSlot()); 2133 CreateVectorSlotPair(proxy->VariableFeedbackSlot());
2133 FrameStateBeforeAndAfter states(this, BeforeId(proxy)); 2134 FrameStateBeforeAndAfter states(this, BeforeId(proxy));
2134 old_value = 2135 old_value =
2135 BuildVariableLoad(proxy->var(), expr->target()->id(), states, slot, 2136 BuildVariableLoad(proxy->var(), expr->target()->id(), states, pair,
2136 OutputFrameStateCombine::Push()); 2137 OutputFrameStateCombine::Push());
2137 break; 2138 break;
2138 } 2139 }
2139 case NAMED_PROPERTY: { 2140 case NAMED_PROPERTY: {
2140 Node* object = environment()->Top(); 2141 Node* object = environment()->Top();
2141 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2142 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2142 ResolvedFeedbackSlot slot = 2143 VectorSlotPair pair =
2143 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2144 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2144 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2145 FrameStateBeforeAndAfter states(this, property->obj()->id());
2145 old_value = BuildNamedLoad(object, name, slot); 2146 old_value = BuildNamedLoad(object, name, pair);
2146 states.AddToNode(old_value, property->LoadId(), 2147 states.AddToNode(old_value, property->LoadId(),
2147 OutputFrameStateCombine::Push()); 2148 OutputFrameStateCombine::Push());
2148 break; 2149 break;
2149 } 2150 }
2150 case KEYED_PROPERTY: { 2151 case KEYED_PROPERTY: {
2151 Node* key = environment()->Top(); 2152 Node* key = environment()->Top();
2152 Node* object = environment()->Peek(1); 2153 Node* object = environment()->Peek(1);
2153 ResolvedFeedbackSlot slot = 2154 VectorSlotPair pair =
2154 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2155 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2155 FrameStateBeforeAndAfter states(this, property->key()->id()); 2156 FrameStateBeforeAndAfter states(this, property->key()->id());
2156 old_value = BuildKeyedLoad(object, key, slot); 2157 old_value = BuildKeyedLoad(object, key, pair);
2157 states.AddToNode(old_value, property->LoadId(), 2158 states.AddToNode(old_value, property->LoadId(),
2158 OutputFrameStateCombine::Push()); 2159 OutputFrameStateCombine::Push());
2159 break; 2160 break;
2160 } 2161 }
2161 case NAMED_SUPER_PROPERTY: { 2162 case NAMED_SUPER_PROPERTY: {
2162 Node* home_object = environment()->Top(); 2163 Node* home_object = environment()->Top();
2163 Node* receiver = environment()->Peek(1); 2164 Node* receiver = environment()->Peek(1);
2164 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2165 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2165 ResolvedFeedbackSlot slot = 2166 VectorSlotPair pair =
2166 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2167 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2167 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2168 FrameStateBeforeAndAfter states(this, property->obj()->id());
2168 old_value = BuildNamedSuperLoad(receiver, home_object, name, slot); 2169 old_value = BuildNamedSuperLoad(receiver, home_object, name, pair);
2169 states.AddToNode(old_value, property->LoadId(), 2170 states.AddToNode(old_value, property->LoadId(),
2170 OutputFrameStateCombine::Push()); 2171 OutputFrameStateCombine::Push());
2171 break; 2172 break;
2172 } 2173 }
2173 case KEYED_SUPER_PROPERTY: { 2174 case KEYED_SUPER_PROPERTY: {
2174 Node* key = environment()->Top(); 2175 Node* key = environment()->Top();
2175 Node* home_object = environment()->Peek(1); 2176 Node* home_object = environment()->Peek(1);
2176 Node* receiver = environment()->Peek(2); 2177 Node* receiver = environment()->Peek(2);
2177 ResolvedFeedbackSlot slot = 2178 VectorSlotPair pair =
2178 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2179 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2179 FrameStateBeforeAndAfter states(this, property->key()->id()); 2180 FrameStateBeforeAndAfter states(this, property->key()->id());
2180 old_value = BuildKeyedSuperLoad(receiver, home_object, key, slot); 2181 old_value = BuildKeyedSuperLoad(receiver, home_object, key, pair);
2181 states.AddToNode(old_value, property->LoadId(), 2182 states.AddToNode(old_value, property->LoadId(),
2182 OutputFrameStateCombine::Push()); 2183 OutputFrameStateCombine::Push());
2183 break; 2184 break;
2184 } 2185 }
2185 } 2186 }
2186 environment()->Push(old_value); 2187 environment()->Push(old_value);
2187 VisitForValue(expr->value()); 2188 VisitForValue(expr->value());
2188 Node* value; 2189 Node* value;
2189 { 2190 {
2190 FrameStateBeforeAndAfter states(this, expr->value()->id()); 2191 FrameStateBeforeAndAfter states(this, expr->value()->id());
(...skipping 10 matching lines...) Expand all
2201 } else { 2202 } else {
2202 VisitForValue(expr->value()); 2203 VisitForValue(expr->value());
2203 if (needs_frame_state_before) { 2204 if (needs_frame_state_before) {
2204 before_store_id = expr->value()->id(); 2205 before_store_id = expr->value()->id();
2205 } 2206 }
2206 } 2207 }
2207 2208
2208 FrameStateBeforeAndAfter store_states(this, before_store_id); 2209 FrameStateBeforeAndAfter store_states(this, before_store_id);
2209 // Store the value. 2210 // Store the value.
2210 Node* value = environment()->Pop(); 2211 Node* value = environment()->Pop();
2211 ResolvedFeedbackSlot slot = ResolveFeedbackSlot(expr->AssignmentSlot()); 2212 VectorSlotPair feedback = CreateVectorSlotPair(expr->AssignmentSlot());
2212 switch (assign_type) { 2213 switch (assign_type) {
2213 case VARIABLE: { 2214 case VARIABLE: {
2214 Variable* variable = expr->target()->AsVariableProxy()->var(); 2215 Variable* variable = expr->target()->AsVariableProxy()->var();
2215 BuildVariableAssignment(variable, value, expr->op(), slot, expr->id(), 2216 BuildVariableAssignment(variable, value, expr->op(), feedback, expr->id(),
2216 store_states, ast_context()->GetStateCombine()); 2217 store_states, ast_context()->GetStateCombine());
2217 break; 2218 break;
2218 } 2219 }
2219 case NAMED_PROPERTY: { 2220 case NAMED_PROPERTY: {
2220 Node* object = environment()->Pop(); 2221 Node* object = environment()->Pop();
2221 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2222 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2222 Node* store = BuildNamedStore(object, name, value, slot, 2223 Node* store = BuildNamedStore(object, name, value, feedback,
2223 expr->AssignmentFeedbackId()); 2224 expr->AssignmentFeedbackId());
2224 store_states.AddToNode(store, expr->id(), 2225 store_states.AddToNode(store, expr->id(),
2225 ast_context()->GetStateCombine()); 2226 ast_context()->GetStateCombine());
2226 break; 2227 break;
2227 } 2228 }
2228 case KEYED_PROPERTY: { 2229 case KEYED_PROPERTY: {
2229 Node* key = environment()->Pop(); 2230 Node* key = environment()->Pop();
2230 Node* object = environment()->Pop(); 2231 Node* object = environment()->Pop();
2231 Node* store = BuildKeyedStore(object, key, value, slot, 2232 Node* store = BuildKeyedStore(object, key, value, feedback,
2232 expr->AssignmentFeedbackId()); 2233 expr->AssignmentFeedbackId());
2233 store_states.AddToNode(store, expr->id(), 2234 store_states.AddToNode(store, expr->id(),
2234 ast_context()->GetStateCombine()); 2235 ast_context()->GetStateCombine());
2235 break; 2236 break;
2236 } 2237 }
2237 case NAMED_SUPER_PROPERTY: { 2238 case NAMED_SUPER_PROPERTY: {
2238 Node* home_object = environment()->Pop(); 2239 Node* home_object = environment()->Pop();
2239 Node* receiver = environment()->Pop(); 2240 Node* receiver = environment()->Pop();
2240 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2241 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2241 Node* store = BuildNamedSuperStore(receiver, home_object, name, value, 2242 Node* store = BuildNamedSuperStore(receiver, home_object, name, value,
(...skipping 29 matching lines...) Expand all
2271 VisitForValue(expr->exception()); 2272 VisitForValue(expr->exception());
2272 Node* exception = environment()->Pop(); 2273 Node* exception = environment()->Pop();
2273 Node* value = BuildThrowError(exception, expr->id()); 2274 Node* value = BuildThrowError(exception, expr->id());
2274 ast_context()->ProduceValue(value); 2275 ast_context()->ProduceValue(value);
2275 } 2276 }
2276 2277
2277 2278
2278 void AstGraphBuilder::VisitProperty(Property* expr) { 2279 void AstGraphBuilder::VisitProperty(Property* expr) {
2279 Node* value = nullptr; 2280 Node* value = nullptr;
2280 LhsKind property_kind = Property::GetAssignType(expr); 2281 LhsKind property_kind = Property::GetAssignType(expr);
2281 ResolvedFeedbackSlot slot = ResolveFeedbackSlot(expr->PropertyFeedbackSlot()); 2282 VectorSlotPair pair = CreateVectorSlotPair(expr->PropertyFeedbackSlot());
2282 switch (property_kind) { 2283 switch (property_kind) {
2283 case VARIABLE: 2284 case VARIABLE:
2284 UNREACHABLE(); 2285 UNREACHABLE();
2285 break; 2286 break;
2286 case NAMED_PROPERTY: { 2287 case NAMED_PROPERTY: {
2287 VisitForValue(expr->obj()); 2288 VisitForValue(expr->obj());
2288 FrameStateBeforeAndAfter states(this, expr->obj()->id()); 2289 FrameStateBeforeAndAfter states(this, expr->obj()->id());
2289 Node* object = environment()->Pop(); 2290 Node* object = environment()->Pop();
2290 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName(); 2291 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName();
2291 value = BuildNamedLoad(object, name, slot); 2292 value = BuildNamedLoad(object, name, pair);
2292 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine()); 2293 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine());
2293 break; 2294 break;
2294 } 2295 }
2295 case KEYED_PROPERTY: { 2296 case KEYED_PROPERTY: {
2296 VisitForValue(expr->obj()); 2297 VisitForValue(expr->obj());
2297 VisitForValue(expr->key()); 2298 VisitForValue(expr->key());
2298 FrameStateBeforeAndAfter states(this, expr->key()->id()); 2299 FrameStateBeforeAndAfter states(this, expr->key()->id());
2299 Node* key = environment()->Pop(); 2300 Node* key = environment()->Pop();
2300 Node* object = environment()->Pop(); 2301 Node* object = environment()->Pop();
2301 value = BuildKeyedLoad(object, key, slot); 2302 value = BuildKeyedLoad(object, key, pair);
2302 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine()); 2303 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine());
2303 break; 2304 break;
2304 } 2305 }
2305 case NAMED_SUPER_PROPERTY: { 2306 case NAMED_SUPER_PROPERTY: {
2306 VisitForValue(expr->obj()->AsSuperPropertyReference()->this_var()); 2307 VisitForValue(expr->obj()->AsSuperPropertyReference()->this_var());
2307 VisitForValue(expr->obj()->AsSuperPropertyReference()->home_object()); 2308 VisitForValue(expr->obj()->AsSuperPropertyReference()->home_object());
2308 FrameStateBeforeAndAfter states(this, expr->obj()->id()); 2309 FrameStateBeforeAndAfter states(this, expr->obj()->id());
2309 Node* home_object = environment()->Pop(); 2310 Node* home_object = environment()->Pop();
2310 Node* receiver = environment()->Pop(); 2311 Node* receiver = environment()->Pop();
2311 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName(); 2312 Handle<Name> name = expr->key()->AsLiteral()->AsPropertyName();
2312 value = BuildNamedSuperLoad(receiver, home_object, name, slot); 2313 value = BuildNamedSuperLoad(receiver, home_object, name, pair);
2313 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine()); 2314 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine());
2314 break; 2315 break;
2315 } 2316 }
2316 case KEYED_SUPER_PROPERTY: { 2317 case KEYED_SUPER_PROPERTY: {
2317 VisitForValue(expr->obj()->AsSuperPropertyReference()->this_var()); 2318 VisitForValue(expr->obj()->AsSuperPropertyReference()->this_var());
2318 VisitForValue(expr->obj()->AsSuperPropertyReference()->home_object()); 2319 VisitForValue(expr->obj()->AsSuperPropertyReference()->home_object());
2319 VisitForValue(expr->key()); 2320 VisitForValue(expr->key());
2320 FrameStateBeforeAndAfter states(this, expr->key()->id()); 2321 FrameStateBeforeAndAfter states(this, expr->key()->id());
2321 Node* key = environment()->Pop(); 2322 Node* key = environment()->Pop();
2322 Node* home_object = environment()->Pop(); 2323 Node* home_object = environment()->Pop();
2323 Node* receiver = environment()->Pop(); 2324 Node* receiver = environment()->Pop();
2324 value = BuildKeyedSuperLoad(receiver, home_object, key, slot); 2325 value = BuildKeyedSuperLoad(receiver, home_object, key, pair);
2325 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine()); 2326 states.AddToNode(value, expr->id(), ast_context()->GetStateCombine());
2326 break; 2327 break;
2327 } 2328 }
2328 } 2329 }
2329 ast_context()->ProduceValue(value); 2330 ast_context()->ProduceValue(value);
2330 } 2331 }
2331 2332
2332 2333
2333 void AstGraphBuilder::VisitCall(Call* expr) { 2334 void AstGraphBuilder::VisitCall(Call* expr) {
2334 Expression* callee = expr->expression(); 2335 Expression* callee = expr->expression();
2335 Call::CallType call_type = expr->GetCallType(isolate()); 2336 Call::CallType call_type = expr->GetCallType(isolate());
2336 2337
2337 // Prepare the callee and the receiver to the function call. This depends on 2338 // Prepare the callee and the receiver to the function call. This depends on
2338 // the semantics of the underlying call type. 2339 // the semantics of the underlying call type.
2339 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; 2340 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS;
2340 Node* receiver_value = NULL; 2341 Node* receiver_value = NULL;
2341 Node* callee_value = NULL; 2342 Node* callee_value = NULL;
2342 bool possibly_eval = false; 2343 bool possibly_eval = false;
2343 switch (call_type) { 2344 switch (call_type) {
2344 case Call::GLOBAL_CALL: { 2345 case Call::GLOBAL_CALL: {
2345 VariableProxy* proxy = callee->AsVariableProxy(); 2346 VariableProxy* proxy = callee->AsVariableProxy();
2346 ResolvedFeedbackSlot slot = 2347 VectorSlotPair pair = CreateVectorSlotPair(proxy->VariableFeedbackSlot());
2347 ResolveFeedbackSlot(proxy->VariableFeedbackSlot());
2348 FrameStateBeforeAndAfter states(this, BeforeId(proxy)); 2348 FrameStateBeforeAndAfter states(this, BeforeId(proxy));
2349 callee_value = 2349 callee_value =
2350 BuildVariableLoad(proxy->var(), expr->expression()->id(), states, 2350 BuildVariableLoad(proxy->var(), expr->expression()->id(), states,
2351 slot, OutputFrameStateCombine::Push()); 2351 pair, OutputFrameStateCombine::Push());
2352 receiver_value = jsgraph()->UndefinedConstant(); 2352 receiver_value = jsgraph()->UndefinedConstant();
2353 break; 2353 break;
2354 } 2354 }
2355 case Call::LOOKUP_SLOT_CALL: { 2355 case Call::LOOKUP_SLOT_CALL: {
2356 Variable* variable = callee->AsVariableProxy()->var(); 2356 Variable* variable = callee->AsVariableProxy()->var();
2357 DCHECK(variable->location() == Variable::LOOKUP); 2357 DCHECK(variable->location() == Variable::LOOKUP);
2358 Node* name = jsgraph()->Constant(variable->name()); 2358 Node* name = jsgraph()->Constant(variable->name());
2359 const Operator* op = 2359 const Operator* op =
2360 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2); 2360 javascript()->CallRuntime(Runtime::kLoadLookupSlot, 2);
2361 Node* pair = NewNode(op, current_context(), name); 2361 Node* pair = NewNode(op, current_context(), name);
2362 callee_value = NewNode(common()->Projection(0), pair); 2362 callee_value = NewNode(common()->Projection(0), pair);
2363 receiver_value = NewNode(common()->Projection(1), pair); 2363 receiver_value = NewNode(common()->Projection(1), pair);
2364 2364
2365 PrepareFrameState(pair, expr->EvalOrLookupId(), 2365 PrepareFrameState(pair, expr->EvalOrLookupId(),
2366 OutputFrameStateCombine::Push(2)); 2366 OutputFrameStateCombine::Push(2));
2367 break; 2367 break;
2368 } 2368 }
2369 case Call::PROPERTY_CALL: { 2369 case Call::PROPERTY_CALL: {
2370 Property* property = callee->AsProperty(); 2370 Property* property = callee->AsProperty();
2371 ResolvedFeedbackSlot slot = 2371 VectorSlotPair pair =
2372 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2372 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2373 if (!property->IsSuperAccess()) { 2373 if (!property->IsSuperAccess()) {
2374 VisitForValue(property->obj()); 2374 VisitForValue(property->obj());
2375 Node* object = environment()->Top(); 2375 Node* object = environment()->Top();
2376 2376
2377 if (property->key()->IsPropertyName()) { 2377 if (property->key()->IsPropertyName()) {
2378 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2378 FrameStateBeforeAndAfter states(this, property->obj()->id());
2379 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2379 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2380 callee_value = BuildNamedLoad(object, name, slot); 2380 callee_value = BuildNamedLoad(object, name, pair);
2381 states.AddToNode(callee_value, property->LoadId(), 2381 states.AddToNode(callee_value, property->LoadId(),
2382 OutputFrameStateCombine::Push()); 2382 OutputFrameStateCombine::Push());
2383 } else { 2383 } else {
2384 VisitForValue(property->key()); 2384 VisitForValue(property->key());
2385 FrameStateBeforeAndAfter states(this, property->key()->id()); 2385 FrameStateBeforeAndAfter states(this, property->key()->id());
2386 Node* key = environment()->Pop(); 2386 Node* key = environment()->Pop();
2387 callee_value = BuildKeyedLoad(object, key, slot); 2387 callee_value = BuildKeyedLoad(object, key, pair);
2388 states.AddToNode(callee_value, property->LoadId(), 2388 states.AddToNode(callee_value, property->LoadId(),
2389 OutputFrameStateCombine::Push()); 2389 OutputFrameStateCombine::Push());
2390 } 2390 }
2391 receiver_value = environment()->Pop(); 2391 receiver_value = environment()->Pop();
2392 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an 2392 // Note that a PROPERTY_CALL requires the receiver to be wrapped into an
2393 // object for sloppy callees. This could also be modeled explicitly 2393 // object for sloppy callees. This could also be modeled explicitly
2394 // here, 2394 // here,
2395 // thereby obsoleting the need for a flag to the call operator. 2395 // thereby obsoleting the need for a flag to the call operator.
2396 flags = CALL_AS_METHOD; 2396 flags = CALL_AS_METHOD;
2397 2397
2398 } else { 2398 } else {
2399 VisitForValue(property->obj()->AsSuperPropertyReference()->this_var()); 2399 VisitForValue(property->obj()->AsSuperPropertyReference()->this_var());
2400 VisitForValue( 2400 VisitForValue(
2401 property->obj()->AsSuperPropertyReference()->home_object()); 2401 property->obj()->AsSuperPropertyReference()->home_object());
2402 Node* home_object = environment()->Pop(); 2402 Node* home_object = environment()->Pop();
2403 receiver_value = environment()->Pop(); 2403 receiver_value = environment()->Pop();
2404 if (property->key()->IsPropertyName()) { 2404 if (property->key()->IsPropertyName()) {
2405 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2405 FrameStateBeforeAndAfter states(this, property->obj()->id());
2406 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2406 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2407 callee_value = 2407 callee_value =
2408 BuildNamedSuperLoad(receiver_value, home_object, name, slot); 2408 BuildNamedSuperLoad(receiver_value, home_object, name, pair);
2409 states.AddToNode(callee_value, property->LoadId(), 2409 states.AddToNode(callee_value, property->LoadId(),
2410 OutputFrameStateCombine::Push()); 2410 OutputFrameStateCombine::Push());
2411 2411
2412 } else { 2412 } else {
2413 VisitForValue(property->key()); 2413 VisitForValue(property->key());
2414 FrameStateBeforeAndAfter states(this, property->key()->id()); 2414 FrameStateBeforeAndAfter states(this, property->key()->id());
2415 Node* key = environment()->Pop(); 2415 Node* key = environment()->Pop();
2416 callee_value = 2416 callee_value =
2417 BuildKeyedSuperLoad(receiver_value, home_object, key, slot); 2417 BuildKeyedSuperLoad(receiver_value, home_object, key, pair);
2418 states.AddToNode(callee_value, property->LoadId(), 2418 states.AddToNode(callee_value, property->LoadId(),
2419 OutputFrameStateCombine::Push()); 2419 OutputFrameStateCombine::Push());
2420 } 2420 }
2421 } 2421 }
2422 2422
2423 break; 2423 break;
2424 } 2424 }
2425 case Call::SUPER_CALL: 2425 case Call::SUPER_CALL:
2426 // TODO(dslomov): Implement super calls. 2426 // TODO(dslomov): Implement super calls.
2427 callee_value = jsgraph()->UndefinedConstant(); 2427 callee_value = jsgraph()->UndefinedConstant();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 Node* new_callee = 2466 Node* new_callee =
2467 NewNode(op, callee, source, function, language, position); 2467 NewNode(op, callee, source, function, language, position);
2468 PrepareFrameState(new_callee, expr->EvalOrLookupId(), 2468 PrepareFrameState(new_callee, expr->EvalOrLookupId(),
2469 OutputFrameStateCombine::PokeAt(arg_count + 1)); 2469 OutputFrameStateCombine::PokeAt(arg_count + 1));
2470 2470
2471 // Patch callee on the environment. 2471 // Patch callee on the environment.
2472 environment()->Poke(arg_count + 1, new_callee); 2472 environment()->Poke(arg_count + 1, new_callee);
2473 } 2473 }
2474 2474
2475 // Create node to perform the function call. 2475 // Create node to perform the function call.
2476 const Operator* call = 2476 VectorSlotPair feedback = CreateVectorSlotPair(expr->CallFeedbackICSlot());
2477 javascript()->CallFunction(args->length() + 2, flags, language_mode()); 2477 const Operator* call = javascript()->CallFunction(args->length() + 2, flags,
2478 language_mode(), feedback);
2478 Node* value = ProcessArguments(call, args->length() + 2); 2479 Node* value = ProcessArguments(call, args->length() + 2);
2479 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2480 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2480 ast_context()->ProduceValue(value); 2481 ast_context()->ProduceValue(value);
2481 } 2482 }
2482 2483
2483 2484
2484 void AstGraphBuilder::VisitCallNew(CallNew* expr) { 2485 void AstGraphBuilder::VisitCallNew(CallNew* expr) {
2485 VisitForValue(expr->expression()); 2486 VisitForValue(expr->expression());
2486 2487
2487 // Evaluate all arguments to the construct call. 2488 // Evaluate all arguments to the construct call.
2488 ZoneList<Expression*>* args = expr->arguments(); 2489 ZoneList<Expression*>* args = expr->arguments();
2489 VisitForValues(args); 2490 VisitForValues(args);
2490 2491
2491 // Create node to perform the construct call. 2492 // Create node to perform the construct call.
2492 const Operator* call = javascript()->CallConstruct(args->length() + 1); 2493 const Operator* call = javascript()->CallConstruct(args->length() + 1);
2493 Node* value = ProcessArguments(call, args->length() + 1); 2494 Node* value = ProcessArguments(call, args->length() + 1);
2494 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine()); 2495 PrepareFrameState(value, expr->id(), ast_context()->GetStateCombine());
2495 ast_context()->ProduceValue(value); 2496 ast_context()->ProduceValue(value);
2496 } 2497 }
2497 2498
2498 2499
2499 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) { 2500 void AstGraphBuilder::VisitCallJSRuntime(CallRuntime* expr) {
2500 Handle<String> name = expr->name(); 2501 Handle<String> name = expr->name();
2501 2502
2502 // The callee and the receiver both have to be pushed onto the operand stack 2503 // The callee and the receiver both have to be pushed onto the operand stack
2503 // before arguments are being evaluated. 2504 // before arguments are being evaluated.
2504 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS; 2505 CallFunctionFlags flags = NO_CALL_FUNCTION_FLAGS;
2505 Node* receiver_value = BuildLoadBuiltinsObject(); 2506 Node* receiver_value = BuildLoadBuiltinsObject();
2506 ResolvedFeedbackSlot slot = 2507 VectorSlotPair pair = CreateVectorSlotPair(expr->CallRuntimeFeedbackSlot());
2507 ResolveFeedbackSlot(expr->CallRuntimeFeedbackSlot());
2508 // TODO(jarin): bailout ids for runtime calls. 2508 // TODO(jarin): bailout ids for runtime calls.
2509 FrameStateBeforeAndAfter states(this, BailoutId::None()); 2509 FrameStateBeforeAndAfter states(this, BailoutId::None());
2510 Node* callee_value = BuildNamedLoad(receiver_value, name, slot); 2510 Node* callee_value = BuildNamedLoad(receiver_value, name, pair);
2511 states.AddToNode(callee_value, BailoutId::None(), 2511 states.AddToNode(callee_value, BailoutId::None(),
2512 OutputFrameStateCombine::Push()); 2512 OutputFrameStateCombine::Push());
2513 environment()->Push(callee_value); 2513 environment()->Push(callee_value);
2514 environment()->Push(receiver_value); 2514 environment()->Push(receiver_value);
2515 2515
2516 // Evaluate all arguments to the JS runtime call. 2516 // Evaluate all arguments to the JS runtime call.
2517 ZoneList<Expression*>* args = expr->arguments(); 2517 ZoneList<Expression*>* args = expr->arguments();
2518 VisitForValues(args); 2518 VisitForValues(args);
2519 2519
2520 // Create node to perform the JS runtime call. 2520 // Create node to perform the JS runtime call.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 // Reserve space for result of postfix operation. 2578 // Reserve space for result of postfix operation.
2579 bool is_postfix = expr->is_postfix() && !ast_context()->IsEffect(); 2579 bool is_postfix = expr->is_postfix() && !ast_context()->IsEffect();
2580 if (is_postfix) environment()->Push(jsgraph()->UndefinedConstant()); 2580 if (is_postfix) environment()->Push(jsgraph()->UndefinedConstant());
2581 2581
2582 // Evaluate LHS expression and get old value. 2582 // Evaluate LHS expression and get old value.
2583 Node* old_value = NULL; 2583 Node* old_value = NULL;
2584 int stack_depth = -1; 2584 int stack_depth = -1;
2585 switch (assign_type) { 2585 switch (assign_type) {
2586 case VARIABLE: { 2586 case VARIABLE: {
2587 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 2587 VariableProxy* proxy = expr->expression()->AsVariableProxy();
2588 ResolvedFeedbackSlot slot = 2588 VectorSlotPair pair = CreateVectorSlotPair(proxy->VariableFeedbackSlot());
2589 ResolveFeedbackSlot(proxy->VariableFeedbackSlot());
2590 FrameStateBeforeAndAfter states(this, BeforeId(proxy)); 2589 FrameStateBeforeAndAfter states(this, BeforeId(proxy));
2591 old_value = 2590 old_value =
2592 BuildVariableLoad(proxy->var(), expr->expression()->id(), states, 2591 BuildVariableLoad(proxy->var(), expr->expression()->id(), states,
2593 slot, OutputFrameStateCombine::Push()); 2592 pair, OutputFrameStateCombine::Push());
2594 stack_depth = 0; 2593 stack_depth = 0;
2595 break; 2594 break;
2596 } 2595 }
2597 case NAMED_PROPERTY: { 2596 case NAMED_PROPERTY: {
2598 VisitForValue(property->obj()); 2597 VisitForValue(property->obj());
2599 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2598 FrameStateBeforeAndAfter states(this, property->obj()->id());
2600 Node* object = environment()->Top(); 2599 Node* object = environment()->Top();
2601 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2600 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2602 ResolvedFeedbackSlot slot = 2601 VectorSlotPair pair =
2603 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2602 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2604 old_value = BuildNamedLoad(object, name, slot); 2603 old_value = BuildNamedLoad(object, name, pair);
2605 states.AddToNode(old_value, property->LoadId(), 2604 states.AddToNode(old_value, property->LoadId(),
2606 OutputFrameStateCombine::Push()); 2605 OutputFrameStateCombine::Push());
2607 stack_depth = 1; 2606 stack_depth = 1;
2608 break; 2607 break;
2609 } 2608 }
2610 case KEYED_PROPERTY: { 2609 case KEYED_PROPERTY: {
2611 VisitForValue(property->obj()); 2610 VisitForValue(property->obj());
2612 VisitForValue(property->key()); 2611 VisitForValue(property->key());
2613 FrameStateBeforeAndAfter states(this, property->key()->id()); 2612 FrameStateBeforeAndAfter states(this, property->key()->id());
2614 Node* key = environment()->Top(); 2613 Node* key = environment()->Top();
2615 Node* object = environment()->Peek(1); 2614 Node* object = environment()->Peek(1);
2616 ResolvedFeedbackSlot slot = 2615 VectorSlotPair pair =
2617 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2616 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2618 old_value = BuildKeyedLoad(object, key, slot); 2617 old_value = BuildKeyedLoad(object, key, pair);
2619 states.AddToNode(old_value, property->LoadId(), 2618 states.AddToNode(old_value, property->LoadId(),
2620 OutputFrameStateCombine::Push()); 2619 OutputFrameStateCombine::Push());
2621 stack_depth = 2; 2620 stack_depth = 2;
2622 break; 2621 break;
2623 } 2622 }
2624 case NAMED_SUPER_PROPERTY: { 2623 case NAMED_SUPER_PROPERTY: {
2625 VisitForValue(property->obj()->AsSuperPropertyReference()->this_var()); 2624 VisitForValue(property->obj()->AsSuperPropertyReference()->this_var());
2626 VisitForValue(property->obj()->AsSuperPropertyReference()->home_object()); 2625 VisitForValue(property->obj()->AsSuperPropertyReference()->home_object());
2627 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2626 FrameStateBeforeAndAfter states(this, property->obj()->id());
2628 Node* home_object = environment()->Top(); 2627 Node* home_object = environment()->Top();
2629 Node* receiver = environment()->Peek(1); 2628 Node* receiver = environment()->Peek(1);
2630 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2629 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2631 ResolvedFeedbackSlot slot = 2630 VectorSlotPair pair =
2632 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2631 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2633 old_value = BuildNamedSuperLoad(receiver, home_object, name, slot); 2632 old_value = BuildNamedSuperLoad(receiver, home_object, name, pair);
2634 states.AddToNode(old_value, property->LoadId(), 2633 states.AddToNode(old_value, property->LoadId(),
2635 OutputFrameStateCombine::Push()); 2634 OutputFrameStateCombine::Push());
2636 stack_depth = 2; 2635 stack_depth = 2;
2637 break; 2636 break;
2638 } 2637 }
2639 case KEYED_SUPER_PROPERTY: { 2638 case KEYED_SUPER_PROPERTY: {
2640 VisitForValue(property->obj()->AsSuperPropertyReference()->this_var()); 2639 VisitForValue(property->obj()->AsSuperPropertyReference()->this_var());
2641 VisitForValue(property->obj()->AsSuperPropertyReference()->home_object()); 2640 VisitForValue(property->obj()->AsSuperPropertyReference()->home_object());
2642 VisitForValue(property->key()); 2641 VisitForValue(property->key());
2643 FrameStateBeforeAndAfter states(this, property->obj()->id()); 2642 FrameStateBeforeAndAfter states(this, property->obj()->id());
2644 Node* key = environment()->Top(); 2643 Node* key = environment()->Top();
2645 Node* home_object = environment()->Peek(1); 2644 Node* home_object = environment()->Peek(1);
2646 Node* receiver = environment()->Peek(2); 2645 Node* receiver = environment()->Peek(2);
2647 ResolvedFeedbackSlot slot = 2646 VectorSlotPair pair =
2648 ResolveFeedbackSlot(property->PropertyFeedbackSlot()); 2647 CreateVectorSlotPair(property->PropertyFeedbackSlot());
2649 old_value = BuildKeyedSuperLoad(receiver, home_object, key, slot); 2648 old_value = BuildKeyedSuperLoad(receiver, home_object, key, pair);
2650 states.AddToNode(old_value, property->LoadId(), 2649 states.AddToNode(old_value, property->LoadId(),
2651 OutputFrameStateCombine::Push()); 2650 OutputFrameStateCombine::Push());
2652 stack_depth = 3; 2651 stack_depth = 3;
2653 break; 2652 break;
2654 } 2653 }
2655 } 2654 }
2656 2655
2657 // Convert old value into a number. 2656 // Convert old value into a number.
2658 old_value = NewNode(javascript()->ToNumber(), old_value); 2657 old_value = NewNode(javascript()->ToNumber(), old_value);
2659 PrepareFrameState(old_value, expr->ToNumberId(), 2658 PrepareFrameState(old_value, expr->ToNumberId(),
(...skipping 13 matching lines...) Expand all
2673 FrameStateBeforeAndAfter states(this, BailoutId::None()); 2672 FrameStateBeforeAndAfter states(this, BailoutId::None());
2674 value = 2673 value =
2675 BuildBinaryOp(old_value, jsgraph()->OneConstant(), expr->binary_op()); 2674 BuildBinaryOp(old_value, jsgraph()->OneConstant(), expr->binary_op());
2676 // This should never deoptimize because we have converted to number 2675 // This should never deoptimize because we have converted to number
2677 // before. 2676 // before.
2678 states.AddToNode(value, BailoutId::None(), 2677 states.AddToNode(value, BailoutId::None(),
2679 OutputFrameStateCombine::Ignore()); 2678 OutputFrameStateCombine::Ignore());
2680 } 2679 }
2681 2680
2682 // Store the value. 2681 // Store the value.
2683 ResolvedFeedbackSlot slot = ResolveFeedbackSlot(expr->CountSlot()); 2682 VectorSlotPair feedback = CreateVectorSlotPair(expr->CountSlot());
2684 switch (assign_type) { 2683 switch (assign_type) {
2685 case VARIABLE: { 2684 case VARIABLE: {
2686 Variable* variable = expr->expression()->AsVariableProxy()->var(); 2685 Variable* variable = expr->expression()->AsVariableProxy()->var();
2687 environment()->Push(value); 2686 environment()->Push(value);
2688 BuildVariableAssignment(variable, value, expr->op(), slot, 2687 BuildVariableAssignment(variable, value, expr->op(), feedback,
2689 expr->AssignmentId(), store_states); 2688 expr->AssignmentId(), store_states);
2690 environment()->Pop(); 2689 environment()->Pop();
2691 break; 2690 break;
2692 } 2691 }
2693 case NAMED_PROPERTY: { 2692 case NAMED_PROPERTY: {
2694 Node* object = environment()->Pop(); 2693 Node* object = environment()->Pop();
2695 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName(); 2694 Handle<Name> name = property->key()->AsLiteral()->AsPropertyName();
2696 Node* store = BuildNamedStore(object, name, value, slot, 2695 Node* store = BuildNamedStore(object, name, value, feedback,
2697 expr->CountStoreFeedbackId()); 2696 expr->CountStoreFeedbackId());
2698 environment()->Push(value); 2697 environment()->Push(value);
2699 store_states.AddToNode(store, expr->AssignmentId(), 2698 store_states.AddToNode(store, expr->AssignmentId(),
2700 OutputFrameStateCombine::Ignore()); 2699 OutputFrameStateCombine::Ignore());
2701 environment()->Pop(); 2700 environment()->Pop();
2702 break; 2701 break;
2703 } 2702 }
2704 case KEYED_PROPERTY: { 2703 case KEYED_PROPERTY: {
2705 Node* key = environment()->Pop(); 2704 Node* key = environment()->Pop();
2706 Node* object = environment()->Pop(); 2705 Node* object = environment()->Pop();
2707 Node* store = BuildKeyedStore(object, key, value, slot, 2706 Node* store = BuildKeyedStore(object, key, value, feedback,
2708 expr->CountStoreFeedbackId()); 2707 expr->CountStoreFeedbackId());
2709 environment()->Push(value); 2708 environment()->Push(value);
2710 store_states.AddToNode(store, expr->AssignmentId(), 2709 store_states.AddToNode(store, expr->AssignmentId(),
2711 OutputFrameStateCombine::Ignore()); 2710 OutputFrameStateCombine::Ignore());
2712 environment()->Pop(); 2711 environment()->Pop();
2713 break; 2712 break;
2714 } 2713 }
2715 case NAMED_SUPER_PROPERTY: { 2714 case NAMED_SUPER_PROPERTY: {
2716 Node* home_object = environment()->Pop(); 2715 Node* home_object = environment()->Pop();
2717 Node* receiver = environment()->Pop(); 2716 Node* receiver = environment()->Pop();
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2920 ast_context()->ProduceValue(value); 2919 ast_context()->ProduceValue(value);
2921 } 2920 }
2922 2921
2923 2922
2924 void AstGraphBuilder::VisitTypeof(UnaryOperation* expr) { 2923 void AstGraphBuilder::VisitTypeof(UnaryOperation* expr) {
2925 Node* operand; 2924 Node* operand;
2926 if (expr->expression()->IsVariableProxy()) { 2925 if (expr->expression()->IsVariableProxy()) {
2927 // Typeof does not throw a reference error on global variables, hence we 2926 // Typeof does not throw a reference error on global variables, hence we
2928 // perform a non-contextual load in case the operand is a variable proxy. 2927 // perform a non-contextual load in case the operand is a variable proxy.
2929 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 2928 VariableProxy* proxy = expr->expression()->AsVariableProxy();
2930 ResolvedFeedbackSlot slot = 2929 VectorSlotPair pair = CreateVectorSlotPair(proxy->VariableFeedbackSlot());
2931 ResolveFeedbackSlot(proxy->VariableFeedbackSlot());
2932 FrameStateBeforeAndAfter states(this, BeforeId(proxy)); 2930 FrameStateBeforeAndAfter states(this, BeforeId(proxy));
2933 operand = 2931 operand =
2934 BuildVariableLoad(proxy->var(), expr->expression()->id(), states, slot, 2932 BuildVariableLoad(proxy->var(), expr->expression()->id(), states, pair,
2935 OutputFrameStateCombine::Push(), NOT_CONTEXTUAL); 2933 OutputFrameStateCombine::Push(), NOT_CONTEXTUAL);
2936 } else { 2934 } else {
2937 VisitForValue(expr->expression()); 2935 VisitForValue(expr->expression());
2938 operand = environment()->Pop(); 2936 operand = environment()->Pop();
2939 } 2937 }
2940 Node* value = NewNode(javascript()->TypeOf(), operand); 2938 Node* value = NewNode(javascript()->TypeOf(), operand);
2941 ast_context()->ProduceValue(value); 2939 ast_context()->ProduceValue(value);
2942 } 2940 }
2943 2941
2944 2942
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2985 compare_if.End(); 2983 compare_if.End();
2986 ast_context()->ReplaceValue(); 2984 ast_context()->ReplaceValue();
2987 } 2985 }
2988 2986
2989 2987
2990 LanguageMode AstGraphBuilder::language_mode() const { 2988 LanguageMode AstGraphBuilder::language_mode() const {
2991 return info()->language_mode(); 2989 return info()->language_mode();
2992 } 2990 }
2993 2991
2994 2992
2995 ResolvedFeedbackSlot AstGraphBuilder::ResolveFeedbackSlot( 2993 VectorSlotPair AstGraphBuilder::CreateVectorSlotPair(
2996 FeedbackVectorICSlot slot) const { 2994 FeedbackVectorICSlot slot) const {
2997 return ResolvedFeedbackSlot(handle(info()->shared_info()->feedback_vector()), 2995 return VectorSlotPair(handle(info()->shared_info()->feedback_vector()), slot);
2998 slot);
2999 } 2996 }
3000 2997
3001 2998
3002 uint32_t AstGraphBuilder::ComputeBitsetForDynamicGlobal(Variable* variable) { 2999 uint32_t AstGraphBuilder::ComputeBitsetForDynamicGlobal(Variable* variable) {
3003 DCHECK_EQ(DYNAMIC_GLOBAL, variable->mode()); 3000 DCHECK_EQ(DYNAMIC_GLOBAL, variable->mode());
3004 bool found_eval_scope = false; 3001 bool found_eval_scope = false;
3005 EnumSet<int, uint32_t> check_depths; 3002 EnumSet<int, uint32_t> check_depths;
3006 for (Scope* s = current_scope(); s != nullptr; s = s->outer_scope()) { 3003 for (Scope* s = current_scope(); s != nullptr; s = s->outer_scope()) {
3007 if (s->num_heap_slots() <= 0) continue; 3004 if (s->num_heap_slots() <= 0) continue;
3008 // TODO(mstarzinger): If we have reached an eval scope, we check all 3005 // TODO(mstarzinger): If we have reached an eval scope, we check all
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 3136
3140 // Allocate and initialize a new arguments object. 3137 // Allocate and initialize a new arguments object.
3141 Node* callee = GetFunctionClosure(); 3138 Node* callee = GetFunctionClosure();
3142 const Operator* op = javascript()->CallRuntime(Runtime::kNewArguments, 1); 3139 const Operator* op = javascript()->CallRuntime(Runtime::kNewArguments, 1);
3143 Node* object = NewNode(op, callee); 3140 Node* object = NewNode(op, callee);
3144 3141
3145 // Assign the object to the arguments variable. 3142 // Assign the object to the arguments variable.
3146 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); 3143 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated());
3147 // This should never lazy deopt, so it is fine to send invalid bailout id. 3144 // This should never lazy deopt, so it is fine to send invalid bailout id.
3148 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3145 FrameStateBeforeAndAfter states(this, BailoutId::None());
3149 ResolvedFeedbackSlot slot; 3146 VectorSlotPair feedback;
3150 BuildVariableAssignment(arguments, object, Token::ASSIGN, slot, 3147 BuildVariableAssignment(arguments, object, Token::ASSIGN, feedback,
3151 BailoutId::None(), states); 3148 BailoutId::None(), states);
3152 3149
3153 return object; 3150 return object;
3154 } 3151 }
3155 3152
3156 3153
3157 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) { 3154 Node* AstGraphBuilder::BuildRestArgumentsArray(Variable* rest, int index) {
3158 if (rest == NULL) return NULL; 3155 if (rest == NULL) return NULL;
3159 3156
3160 DCHECK(index >= 0); 3157 DCHECK(index >= 0);
3161 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 2); 3158 const Operator* op = javascript()->CallRuntime(Runtime::kNewRestParamSlow, 2);
3162 Node* object = NewNode(op, jsgraph()->SmiConstant(index), 3159 Node* object = NewNode(op, jsgraph()->SmiConstant(index),
3163 jsgraph()->SmiConstant(language_mode())); 3160 jsgraph()->SmiConstant(language_mode()));
3164 3161
3165 // Assign the object to the rest array 3162 // Assign the object to the rest array
3166 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated()); 3163 DCHECK(rest->IsContextSlot() || rest->IsStackAllocated());
3167 // This should never lazy deopt, so it is fine to send invalid bailout id. 3164 // This should never lazy deopt, so it is fine to send invalid bailout id.
3168 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3165 FrameStateBeforeAndAfter states(this, BailoutId::None());
3169 ResolvedFeedbackSlot slot; 3166 VectorSlotPair feedback;
3170 BuildVariableAssignment(rest, object, Token::ASSIGN, slot, BailoutId::None(), 3167 BuildVariableAssignment(rest, object, Token::ASSIGN, feedback,
3171 states); 3168 BailoutId::None(), states);
3172 3169
3173 return object; 3170 return object;
3174 } 3171 }
3175 3172
3176 3173
3177 Node* AstGraphBuilder::BuildThisFunctionVar(Variable* this_function_var) { 3174 Node* AstGraphBuilder::BuildThisFunctionVar(Variable* this_function_var) {
3178 if (this_function_var == nullptr) return nullptr; 3175 if (this_function_var == nullptr) return nullptr;
3179 3176
3180 Node* this_function = GetFunctionClosure(); 3177 Node* this_function = GetFunctionClosure();
3181 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3178 FrameStateBeforeAndAfter states(this, BailoutId::None());
3182 ResolvedFeedbackSlot slot; 3179 VectorSlotPair feedback;
3183 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST, 3180 BuildVariableAssignment(this_function_var, this_function, Token::INIT_CONST,
3184 slot, BailoutId::None(), states); 3181 feedback, BailoutId::None(), states);
3185 return this_function; 3182 return this_function;
3186 } 3183 }
3187 3184
3188 3185
3189 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, 3186 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole,
3190 Node* not_hole) { 3187 Node* not_hole) {
3191 Node* the_hole = jsgraph()->TheHoleConstant(); 3188 Node* the_hole = jsgraph()->TheHoleConstant();
3192 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole); 3189 Node* check = NewNode(javascript()->StrictEqual(), value, the_hole);
3193 return NewNode(common()->Select(kMachAnyTagged, BranchHint::kFalse), check, 3190 return NewNode(common()->Select(kMachAnyTagged, BranchHint::kFalse), check,
3194 for_hole, not_hole); 3191 for_hole, not_hole);
(...skipping 30 matching lines...) Expand all
3225 prototype_check.Else(); 3222 prototype_check.Else();
3226 environment()->Push(name); 3223 environment()->Push(name);
3227 prototype_check.End(); 3224 prototype_check.End();
3228 return environment()->Pop(); 3225 return environment()->Pop();
3229 } 3226 }
3230 3227
3231 3228
3232 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable, 3229 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable,
3233 BailoutId bailout_id, 3230 BailoutId bailout_id,
3234 FrameStateBeforeAndAfter& states, 3231 FrameStateBeforeAndAfter& states,
3235 const ResolvedFeedbackSlot& feedback, 3232 const VectorSlotPair& feedback,
3236 OutputFrameStateCombine combine, 3233 OutputFrameStateCombine combine,
3237 ContextualMode contextual_mode) { 3234 ContextualMode contextual_mode) {
3238 Node* the_hole = jsgraph()->TheHoleConstant(); 3235 Node* the_hole = jsgraph()->TheHoleConstant();
3239 VariableMode mode = variable->mode(); 3236 VariableMode mode = variable->mode();
3240 switch (variable->location()) { 3237 switch (variable->location()) {
3241 case Variable::UNALLOCATED: { 3238 case Variable::UNALLOCATED: {
3242 // Global var, const, or let variable. 3239 // Global var, const, or let variable.
3243 Node* global = BuildLoadGlobalObject(); 3240 Node* global = BuildLoadGlobalObject();
3244 Handle<Name> name = variable->name(); 3241 Handle<Name> name = variable->name();
3245 Node* value = BuildNamedLoad(global, name, feedback, contextual_mode); 3242 Node* value = BuildNamedLoad(global, name, feedback, contextual_mode);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3360 return result; 3357 return result;
3361 } 3358 }
3362 } 3359 }
3363 UNREACHABLE(); 3360 UNREACHABLE();
3364 return NULL; 3361 return NULL;
3365 } 3362 }
3366 3363
3367 3364
3368 Node* AstGraphBuilder::BuildVariableAssignment( 3365 Node* AstGraphBuilder::BuildVariableAssignment(
3369 Variable* variable, Node* value, Token::Value op, 3366 Variable* variable, Node* value, Token::Value op,
3370 const ResolvedFeedbackSlot& slot, BailoutId bailout_id, 3367 const VectorSlotPair& feedback, BailoutId bailout_id,
3371 FrameStateBeforeAndAfter& states, OutputFrameStateCombine combine) { 3368 FrameStateBeforeAndAfter& states, OutputFrameStateCombine combine) {
3372 Node* the_hole = jsgraph()->TheHoleConstant(); 3369 Node* the_hole = jsgraph()->TheHoleConstant();
3373 VariableMode mode = variable->mode(); 3370 VariableMode mode = variable->mode();
3374 switch (variable->location()) { 3371 switch (variable->location()) {
3375 case Variable::UNALLOCATED: { 3372 case Variable::UNALLOCATED: {
3376 // Global var, const, or let variable. 3373 // Global var, const, or let variable.
3377 Node* global = BuildLoadGlobalObject(); 3374 Node* global = BuildLoadGlobalObject();
3378 Handle<Name> name = variable->name(); 3375 Handle<Name> name = variable->name();
3379 Node* store = 3376 Node* store = BuildNamedStore(global, name, value, feedback,
3380 BuildNamedStore(global, name, value, slot, TypeFeedbackId::None()); 3377 TypeFeedbackId::None());
3381 states.AddToNode(store, bailout_id, combine); 3378 states.AddToNode(store, bailout_id, combine);
3382 return store; 3379 return store;
3383 } 3380 }
3384 case Variable::PARAMETER: 3381 case Variable::PARAMETER:
3385 case Variable::LOCAL: 3382 case Variable::LOCAL:
3386 // Local var, const, or let variable. 3383 // Local var, const, or let variable.
3387 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) { 3384 if (mode == CONST_LEGACY && op == Token::INIT_CONST_LEGACY) {
3388 // Perform an initialization check for legacy const variables. 3385 // Perform an initialization check for legacy const variables.
3389 Node* current = environment()->Lookup(variable); 3386 Node* current = environment()->Lookup(variable);
3390 if (current->op() != the_hole->op()) { 3387 if (current->op() != the_hole->op()) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3485 static inline Node* Record(JSTypeFeedbackTable* js_type_feedback, Node* node, 3482 static inline Node* Record(JSTypeFeedbackTable* js_type_feedback, Node* node,
3486 TypeFeedbackId id) { 3483 TypeFeedbackId id) {
3487 if (js_type_feedback) { 3484 if (js_type_feedback) {
3488 js_type_feedback->Record(node, id); 3485 js_type_feedback->Record(node, id);
3489 } 3486 }
3490 return node; 3487 return node;
3491 } 3488 }
3492 3489
3493 3490
3494 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key, 3491 Node* AstGraphBuilder::BuildKeyedLoad(Node* object, Node* key,
3495 const ResolvedFeedbackSlot& feedback) { 3492 const VectorSlotPair& feedback) {
3496 const Operator* op = javascript()->LoadProperty(feedback); 3493 const Operator* op = javascript()->LoadProperty(feedback);
3497 return Record(js_type_feedback_, 3494 return Record(js_type_feedback_,
3498 NewNode(op, object, key, GetFeedbackVector()), feedback.slot()); 3495 NewNode(op, object, key, GetFeedbackVector()), feedback.slot());
3499 } 3496 }
3500 3497
3501 3498
3502 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name, 3499 Node* AstGraphBuilder::BuildNamedLoad(Node* object, Handle<Name> name,
3503 const ResolvedFeedbackSlot& feedback, 3500 const VectorSlotPair& feedback,
3504 ContextualMode mode) { 3501 ContextualMode mode) {
3505 const Operator* op = 3502 const Operator* op =
3506 javascript()->LoadNamed(MakeUnique(name), feedback, mode); 3503 javascript()->LoadNamed(MakeUnique(name), feedback, mode);
3507 return Record(js_type_feedback_, NewNode(op, object, GetFeedbackVector()), 3504 return Record(js_type_feedback_, NewNode(op, object, GetFeedbackVector()),
3508 feedback.slot()); 3505 feedback.slot());
3509 } 3506 }
3510 3507
3511 3508
3512 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value, 3509 Node* AstGraphBuilder::BuildKeyedStore(Node* object, Node* key, Node* value,
3513 const ResolvedFeedbackSlot& feedback, 3510 const VectorSlotPair& feedback,
3514 TypeFeedbackId id) { 3511 TypeFeedbackId id) {
3515 const Operator* op = javascript()->StoreProperty(language_mode(), feedback); 3512 const Operator* op = javascript()->StoreProperty(language_mode(), feedback);
3516 return Record(js_type_feedback_, NewNode(op, object, key, value), id); 3513 return Record(js_type_feedback_, NewNode(op, object, key, value), id);
3517 } 3514 }
3518 3515
3519 3516
3520 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name, 3517 Node* AstGraphBuilder::BuildNamedStore(Node* object, Handle<Name> name,
3521 Node* value, 3518 Node* value,
3522 const ResolvedFeedbackSlot& feedback, 3519 const VectorSlotPair& feedback,
3523 TypeFeedbackId id) { 3520 TypeFeedbackId id) {
3524 const Operator* op = 3521 const Operator* op =
3525 javascript()->StoreNamed(language_mode(), MakeUnique(name), feedback); 3522 javascript()->StoreNamed(language_mode(), MakeUnique(name), feedback);
3526 return Record(js_type_feedback_, NewNode(op, object, value), id); 3523 return Record(js_type_feedback_, NewNode(op, object, value), id);
3527 } 3524 }
3528 3525
3529 3526
3530 Node* AstGraphBuilder::BuildNamedSuperLoad( 3527 Node* AstGraphBuilder::BuildNamedSuperLoad(Node* receiver, Node* home_object,
3531 Node* receiver, Node* home_object, Handle<Name> name, 3528 Handle<Name> name,
3532 const ResolvedFeedbackSlot& feedback) { 3529 const VectorSlotPair& feedback) {
3533 Node* name_node = jsgraph()->Constant(name); 3530 Node* name_node = jsgraph()->Constant(name);
3534 const Operator* op = javascript()->CallRuntime(Runtime::kLoadFromSuper, 3); 3531 const Operator* op = javascript()->CallRuntime(Runtime::kLoadFromSuper, 3);
3535 Node* value = NewNode(op, receiver, home_object, name_node); 3532 Node* value = NewNode(op, receiver, home_object, name_node);
3536 return Record(js_type_feedback_, value, feedback.slot()); 3533 return Record(js_type_feedback_, value, feedback.slot());
3537 } 3534 }
3538 3535
3539 3536
3540 Node* AstGraphBuilder::BuildKeyedSuperLoad( 3537 Node* AstGraphBuilder::BuildKeyedSuperLoad(Node* receiver, Node* home_object,
3541 Node* receiver, Node* home_object, Node* key, 3538 Node* key,
3542 const ResolvedFeedbackSlot& feedback) { 3539 const VectorSlotPair& feedback) {
3543 const Operator* op = 3540 const Operator* op =
3544 javascript()->CallRuntime(Runtime::kLoadKeyedFromSuper, 3); 3541 javascript()->CallRuntime(Runtime::kLoadKeyedFromSuper, 3);
3545 Node* value = NewNode(op, receiver, home_object, key); 3542 Node* value = NewNode(op, receiver, home_object, key);
3546 return Record(js_type_feedback_, value, feedback.slot()); 3543 return Record(js_type_feedback_, value, feedback.slot());
3547 } 3544 }
3548 3545
3549 3546
3550 Node* AstGraphBuilder::BuildKeyedSuperStore(Node* receiver, Node* home_object, 3547 Node* AstGraphBuilder::BuildKeyedSuperStore(Node* receiver, Node* home_object,
3551 Node* key, Node* value, 3548 Node* key, Node* value,
3552 TypeFeedbackId id) { 3549 TypeFeedbackId id) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
3661 3658
3662 Node* AstGraphBuilder::BuildToObject(Node* input, BailoutId bailout_id) { 3659 Node* AstGraphBuilder::BuildToObject(Node* input, BailoutId bailout_id) {
3663 Node* object = NewNode(javascript()->ToObject(), input); 3660 Node* object = NewNode(javascript()->ToObject(), input);
3664 PrepareFrameState(object, bailout_id, OutputFrameStateCombine::Push()); 3661 PrepareFrameState(object, bailout_id, OutputFrameStateCombine::Push());
3665 return object; 3662 return object;
3666 } 3663 }
3667 3664
3668 3665
3669 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object, 3666 Node* AstGraphBuilder::BuildSetHomeObject(Node* value, Node* home_object,
3670 Expression* expr, 3667 Expression* expr,
3671 const ResolvedFeedbackSlot& slot) { 3668 const VectorSlotPair& feedback) {
3672 if (!FunctionLiteral::NeedsHomeObject(expr)) return value; 3669 if (!FunctionLiteral::NeedsHomeObject(expr)) return value;
3673 Handle<Name> name = isolate()->factory()->home_object_symbol(); 3670 Handle<Name> name = isolate()->factory()->home_object_symbol();
3674 FrameStateBeforeAndAfter states(this, BailoutId::None()); 3671 FrameStateBeforeAndAfter states(this, BailoutId::None());
3675 Node* store = 3672 Node* store = BuildNamedStore(value, name, home_object, feedback,
3676 BuildNamedStore(value, name, home_object, slot, TypeFeedbackId::None()); 3673 TypeFeedbackId::None());
3677 states.AddToNode(store, BailoutId::None(), OutputFrameStateCombine::Ignore()); 3674 states.AddToNode(store, BailoutId::None(), OutputFrameStateCombine::Ignore());
3678 return store; 3675 return store;
3679 } 3676 }
3680 3677
3681 3678
3682 Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) { 3679 Node* AstGraphBuilder::BuildThrowError(Node* exception, BailoutId bailout_id) {
3683 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1); 3680 const Operator* op = javascript()->CallRuntime(Runtime::kThrow, 1);
3684 Node* call = NewNode(op, exception); 3681 Node* call = NewNode(op, exception);
3685 PrepareFrameState(call, bailout_id); 3682 PrepareFrameState(call, bailout_id);
3686 Node* control = NewNode(common()->Throw(), call); 3683 Node* control = NewNode(common()->Throw(), call);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
4115 // Phi does not exist yet, introduce one. 4112 // Phi does not exist yet, introduce one.
4116 value = NewPhi(inputs, value, control); 4113 value = NewPhi(inputs, value, control);
4117 value->ReplaceInput(inputs - 1, other); 4114 value->ReplaceInput(inputs - 1, other);
4118 } 4115 }
4119 return value; 4116 return value;
4120 } 4117 }
4121 4118
4122 } // namespace compiler 4119 } // namespace compiler
4123 } // namespace internal 4120 } // namespace internal
4124 } // namespace v8 4121 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.h ('k') | src/compiler/js-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698