OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/full-codegen/full-codegen.h" | 5 #include "src/full-codegen/full-codegen.h" |
6 | 6 |
7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/prettyprinter.h" | 9 #include "src/ast/prettyprinter.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 1648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 // through this function. Avoid early returns. | 1659 // through this function. Avoid early returns. |
1660 expr->return_is_recorded_ = false; | 1660 expr->return_is_recorded_ = false; |
1661 #endif | 1661 #endif |
1662 | 1662 |
1663 Comment cmnt(masm_, (expr->tail_call_mode() == TailCallMode::kAllow) | 1663 Comment cmnt(masm_, (expr->tail_call_mode() == TailCallMode::kAllow) |
1664 ? "[ TailCall" | 1664 ? "[ TailCall" |
1665 : "[ Call"); | 1665 : "[ Call"); |
1666 Expression* callee = expr->expression(); | 1666 Expression* callee = expr->expression(); |
1667 Call::CallType call_type = expr->GetCallType(); | 1667 Call::CallType call_type = expr->GetCallType(); |
1668 | 1668 |
1669 switch (call_type) { | 1669 if (expr->is_possibly_eval()) { |
1670 case Call::POSSIBLY_EVAL_CALL: | 1670 EmitPossiblyEvalCall(expr); |
1671 EmitPossiblyEvalCall(expr); | 1671 } else { |
1672 break; | 1672 switch (call_type) { |
1673 case Call::GLOBAL_CALL: | 1673 case Call::GLOBAL_CALL: |
1674 EmitCallWithLoadIC(expr); | 1674 EmitCallWithLoadIC(expr); |
1675 break; | 1675 break; |
1676 case Call::WITH_CALL: | 1676 case Call::WITH_CALL: |
1677 // Call to a lookup slot looked up through a with scope. | 1677 // Call to a lookup slot looked up through a with scope. |
1678 PushCalleeAndWithBaseObject(expr); | 1678 PushCalleeAndWithBaseObject(expr); |
1679 EmitCall(expr); | 1679 EmitCall(expr); |
1680 break; | 1680 break; |
1681 case Call::NAMED_PROPERTY_CALL: { | 1681 case Call::NAMED_PROPERTY_CALL: { |
1682 Property* property = callee->AsProperty(); | 1682 Property* property = callee->AsProperty(); |
1683 VisitForStackValue(property->obj()); | 1683 VisitForStackValue(property->obj()); |
1684 EmitCallWithLoadIC(expr); | 1684 EmitCallWithLoadIC(expr); |
1685 break; | 1685 break; |
| 1686 } |
| 1687 case Call::KEYED_PROPERTY_CALL: { |
| 1688 Property* property = callee->AsProperty(); |
| 1689 VisitForStackValue(property->obj()); |
| 1690 EmitKeyedCallWithLoadIC(expr, property->key()); |
| 1691 break; |
| 1692 } |
| 1693 case Call::NAMED_SUPER_PROPERTY_CALL: |
| 1694 EmitSuperCallWithLoadIC(expr); |
| 1695 break; |
| 1696 case Call::KEYED_SUPER_PROPERTY_CALL: |
| 1697 EmitKeyedSuperCallWithLoadIC(expr); |
| 1698 break; |
| 1699 case Call::SUPER_CALL: |
| 1700 EmitSuperConstructorCall(expr); |
| 1701 break; |
| 1702 case Call::OTHER_CALL: |
| 1703 // Call to an arbitrary expression not handled specially above. |
| 1704 VisitForStackValue(callee); |
| 1705 OperandStackDepthIncrement(1); |
| 1706 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1707 // Emit function call. |
| 1708 EmitCall(expr); |
| 1709 break; |
1686 } | 1710 } |
1687 case Call::KEYED_PROPERTY_CALL: { | |
1688 Property* property = callee->AsProperty(); | |
1689 VisitForStackValue(property->obj()); | |
1690 EmitKeyedCallWithLoadIC(expr, property->key()); | |
1691 break; | |
1692 } | |
1693 case Call::NAMED_SUPER_PROPERTY_CALL: | |
1694 EmitSuperCallWithLoadIC(expr); | |
1695 break; | |
1696 case Call::KEYED_SUPER_PROPERTY_CALL: | |
1697 EmitKeyedSuperCallWithLoadIC(expr); | |
1698 break; | |
1699 case Call::SUPER_CALL: | |
1700 EmitSuperConstructorCall(expr); | |
1701 break; | |
1702 case Call::OTHER_CALL: | |
1703 // Call to an arbitrary expression not handled specially above. | |
1704 VisitForStackValue(callee); | |
1705 OperandStackDepthIncrement(1); | |
1706 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
1707 // Emit function call. | |
1708 EmitCall(expr); | |
1709 break; | |
1710 } | 1711 } |
1711 | 1712 |
1712 #ifdef DEBUG | 1713 #ifdef DEBUG |
1713 // RecordJSReturnSite should have been called. | 1714 // RecordJSReturnSite should have been called. |
1714 DCHECK(expr->return_is_recorded_); | 1715 DCHECK(expr->return_is_recorded_); |
1715 #endif | 1716 #endif |
1716 } | 1717 } |
1717 | 1718 |
1718 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 1719 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
1719 ZoneList<Expression*>* args = expr->arguments(); | 1720 ZoneList<Expression*>* args = expr->arguments(); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 return info_->has_simple_parameters(); | 1991 return info_->has_simple_parameters(); |
1991 } | 1992 } |
1992 | 1993 |
1993 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } | 1994 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } |
1994 | 1995 |
1995 #undef __ | 1996 #undef __ |
1996 | 1997 |
1997 | 1998 |
1998 } // namespace internal | 1999 } // namespace internal |
1999 } // namespace v8 | 2000 } // namespace v8 |
OLD | NEW |