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 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
494 | 494 |
495 | 495 |
496 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | 496 void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
497 Comment cmnt(masm_, "[ VariableProxy"); | 497 Comment cmnt(masm_, "[ VariableProxy"); |
498 EmitVariableLoad(expr); | 498 EmitVariableLoad(expr); |
499 } | 499 } |
500 | 500 |
501 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 501 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
502 TypeofMode typeof_mode) { | 502 TypeofMode typeof_mode) { |
503 Variable* var = proxy->var(); | 503 Variable* var = proxy->var(); |
504 DCHECK(var->IsUnallocated() || | 504 DCHECK(var->IsUnallocated()); |
505 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | |
506 __ Move(LoadDescriptor::NameRegister(), var->name()); | 505 __ Move(LoadDescriptor::NameRegister(), var->name()); |
507 | 506 |
508 EmitLoadSlot(LoadGlobalDescriptor::SlotRegister(), | 507 EmitLoadSlot(LoadGlobalDescriptor::SlotRegister(), |
509 proxy->VariableFeedbackSlot()); | 508 proxy->VariableFeedbackSlot()); |
510 Handle<Code> code = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code(); | 509 Handle<Code> code = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code(); |
511 __ Call(code, RelocInfo::CODE_TARGET); | 510 __ Call(code, RelocInfo::CODE_TARGET); |
512 RestoreContext(); | 511 RestoreContext(); |
513 } | 512 } |
514 | 513 |
515 void FullCodeGenerator::VisitSloppyBlockFunctionStatement( | 514 void FullCodeGenerator::VisitSloppyBlockFunctionStatement( |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
907 } | 906 } |
908 PrepareForBailoutForId(expr->LoadId(), BailoutState::TOS_REGISTER); | 907 PrepareForBailoutForId(expr->LoadId(), BailoutState::TOS_REGISTER); |
909 context()->Plug(result_register()); | 908 context()->Plug(result_register()); |
910 } | 909 } |
911 | 910 |
912 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 911 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
913 VariableProxy* proxy = expr->AsVariableProxy(); | 912 VariableProxy* proxy = expr->AsVariableProxy(); |
914 DCHECK(!context()->IsEffect()); | 913 DCHECK(!context()->IsEffect()); |
915 DCHECK(!context()->IsTest()); | 914 DCHECK(!context()->IsTest()); |
916 | 915 |
917 if (proxy != NULL && | 916 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
918 (proxy->var()->IsUnallocated() || proxy->var()->IsLookupSlot())) { | |
919 EmitVariableLoad(proxy, INSIDE_TYPEOF); | 917 EmitVariableLoad(proxy, INSIDE_TYPEOF); |
920 PrepareForBailout(proxy, BailoutState::TOS_REGISTER); | 918 PrepareForBailout(proxy, BailoutState::TOS_REGISTER); |
921 } else { | 919 } else { |
922 // This expression cannot throw a reference error at the top level. | 920 // This expression cannot throw a reference error at the top level. |
923 VisitInDuplicateContext(expr); | 921 VisitInDuplicateContext(expr); |
924 } | 922 } |
925 } | 923 } |
926 | 924 |
927 | 925 |
928 void FullCodeGenerator::VisitBlock(Block* stmt) { | 926 void FullCodeGenerator::VisitBlock(Block* stmt) { |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1663 // through this function. Avoid early returns. | 1661 // through this function. Avoid early returns. |
1664 expr->return_is_recorded_ = false; | 1662 expr->return_is_recorded_ = false; |
1665 #endif | 1663 #endif |
1666 | 1664 |
1667 Comment cmnt(masm_, (expr->tail_call_mode() == TailCallMode::kAllow) | 1665 Comment cmnt(masm_, (expr->tail_call_mode() == TailCallMode::kAllow) |
1668 ? "[ TailCall" | 1666 ? "[ TailCall" |
1669 : "[ Call"); | 1667 : "[ Call"); |
1670 Expression* callee = expr->expression(); | 1668 Expression* callee = expr->expression(); |
1671 Call::CallType call_type = expr->GetCallType(); | 1669 Call::CallType call_type = expr->GetCallType(); |
1672 | 1670 |
1673 if (expr->is_possibly_eval()) { | 1671 // Eval is unsupported. |
1674 EmitPossiblyEvalCall(expr); | 1672 if (expr->is_possibly_eval()) UNREACHABLE(); |
Michael Starzinger
2016/11/23 10:15:48
nit: Why not just [D]CHECK(!expr->is_possibly_eval
rmcilroy
2016/11/23 13:48:51
Done.
| |
1675 } else { | 1673 |
1676 switch (call_type) { | 1674 switch (call_type) { |
1677 case Call::GLOBAL_CALL: | 1675 case Call::GLOBAL_CALL: |
1678 EmitCallWithLoadIC(expr); | 1676 EmitCallWithLoadIC(expr); |
1679 break; | 1677 break; |
1680 case Call::WITH_CALL: | 1678 case Call::NAMED_PROPERTY_CALL: { |
1681 // Call to a lookup slot looked up through a with scope. | 1679 Property* property = callee->AsProperty(); |
1682 PushCalleeAndWithBaseObject(expr); | 1680 VisitForStackValue(property->obj()); |
1683 EmitCall(expr); | 1681 EmitCallWithLoadIC(expr); |
1684 break; | 1682 break; |
1685 case Call::NAMED_PROPERTY_CALL: { | |
1686 Property* property = callee->AsProperty(); | |
1687 VisitForStackValue(property->obj()); | |
1688 EmitCallWithLoadIC(expr); | |
1689 break; | |
1690 } | |
1691 case Call::KEYED_PROPERTY_CALL: { | |
1692 Property* property = callee->AsProperty(); | |
1693 VisitForStackValue(property->obj()); | |
1694 EmitKeyedCallWithLoadIC(expr, property->key()); | |
1695 break; | |
1696 } | |
1697 case Call::NAMED_SUPER_PROPERTY_CALL: | |
1698 EmitSuperCallWithLoadIC(expr); | |
1699 break; | |
1700 case Call::KEYED_SUPER_PROPERTY_CALL: | |
1701 EmitKeyedSuperCallWithLoadIC(expr); | |
1702 break; | |
1703 case Call::SUPER_CALL: | |
1704 EmitSuperConstructorCall(expr); | |
1705 break; | |
1706 case Call::OTHER_CALL: | |
1707 // Call to an arbitrary expression not handled specially above. | |
1708 VisitForStackValue(callee); | |
1709 OperandStackDepthIncrement(1); | |
1710 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
1711 // Emit function call. | |
1712 EmitCall(expr); | |
1713 break; | |
1714 } | 1683 } |
1684 case Call::KEYED_PROPERTY_CALL: { | |
1685 Property* property = callee->AsProperty(); | |
1686 VisitForStackValue(property->obj()); | |
1687 EmitKeyedCallWithLoadIC(expr, property->key()); | |
1688 break; | |
1689 } | |
1690 case Call::NAMED_SUPER_PROPERTY_CALL: | |
1691 EmitSuperCallWithLoadIC(expr); | |
1692 break; | |
1693 case Call::KEYED_SUPER_PROPERTY_CALL: | |
1694 EmitKeyedSuperCallWithLoadIC(expr); | |
1695 break; | |
1696 case Call::SUPER_CALL: | |
1697 EmitSuperConstructorCall(expr); | |
1698 break; | |
1699 case Call::OTHER_CALL: | |
1700 // Call to an arbitrary expression not handled specially above. | |
1701 VisitForStackValue(callee); | |
1702 OperandStackDepthIncrement(1); | |
1703 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
1704 // Emit function call. | |
1705 EmitCall(expr); | |
1706 break; | |
1707 case Call::WITH_CALL: | |
1708 UNREACHABLE(); | |
1715 } | 1709 } |
1716 | 1710 |
1717 #ifdef DEBUG | 1711 #ifdef DEBUG |
1718 // RecordJSReturnSite should have been called. | 1712 // RecordJSReturnSite should have been called. |
1719 DCHECK(expr->return_is_recorded_); | 1713 DCHECK(expr->return_is_recorded_); |
1720 #endif | 1714 #endif |
1721 } | 1715 } |
1722 | 1716 |
1723 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 1717 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
1724 ZoneList<Expression*>* args = expr->arguments(); | 1718 ZoneList<Expression*>* args = expr->arguments(); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1995 return info_->has_simple_parameters(); | 1989 return info_->has_simple_parameters(); |
1996 } | 1990 } |
1997 | 1991 |
1998 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } | 1992 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } |
1999 | 1993 |
2000 #undef __ | 1994 #undef __ |
2001 | 1995 |
2002 | 1996 |
2003 } // namespace internal | 1997 } // namespace internal |
2004 } // namespace v8 | 1998 } // namespace v8 |
OLD | NEW |