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 #ifndef V8_FULL_CODEGEN_H_ | 5 #ifndef V8_FULL_CODEGEN_H_ |
6 #define V8_FULL_CODEGEN_H_ | 6 #define V8_FULL_CODEGEN_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 void EmitResolvePossiblyDirectEval(int arg_count); | 584 void EmitResolvePossiblyDirectEval(int arg_count); |
585 | 585 |
586 // Platform-specific support for allocating a new closure based on | 586 // Platform-specific support for allocating a new closure based on |
587 // the given function info. | 587 // the given function info. |
588 void EmitNewClosure(Handle<SharedFunctionInfo> info, bool pretenure); | 588 void EmitNewClosure(Handle<SharedFunctionInfo> info, bool pretenure); |
589 | 589 |
590 // Re-usable portions of CallRuntime | 590 // Re-usable portions of CallRuntime |
591 void EmitLoadJSRuntimeFunction(CallRuntime* expr); | 591 void EmitLoadJSRuntimeFunction(CallRuntime* expr); |
592 void EmitCallJSRuntimeFunction(CallRuntime* expr); | 592 void EmitCallJSRuntimeFunction(CallRuntime* expr); |
593 | 593 |
594 // Platform-specific support for compiling assignments. | |
595 | |
596 // Left-hand side can only be a property, a global or a (parameter or local) | |
597 // slot. | |
598 enum LhsKind { | |
599 VARIABLE, | |
600 NAMED_PROPERTY, | |
601 KEYED_PROPERTY, | |
602 NAMED_SUPER_PROPERTY, | |
603 KEYED_SUPER_PROPERTY | |
604 }; | |
605 | |
606 static LhsKind GetAssignType(Property* property) { | |
607 if (property == NULL) return VARIABLE; | |
608 bool super_access = property->IsSuperAccess(); | |
609 return (property->key()->IsPropertyName()) | |
610 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) | |
611 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); | |
612 } | |
613 | |
614 // Load a value from a named property. | 594 // Load a value from a named property. |
615 // The receiver is left on the stack by the IC. | 595 // The receiver is left on the stack by the IC. |
616 void EmitNamedPropertyLoad(Property* expr); | 596 void EmitNamedPropertyLoad(Property* expr); |
617 | 597 |
618 // Load a value from super.named property. | 598 // Load a value from super.named property. |
619 // Expect receiver ('this' value) and home_object on the stack. | 599 // Expect receiver ('this' value) and home_object on the stack. |
620 void EmitNamedSuperPropertyLoad(Property* expr); | 600 void EmitNamedSuperPropertyLoad(Property* expr); |
621 | 601 |
622 // Load a value from super[keyed] property. | 602 // Load a value from super[keyed] property. |
623 // Expect receiver ('this' value), home_object and key on the stack. | 603 // Expect receiver ('this' value), home_object and key on the stack. |
(...skipping 16 matching lines...) Expand all Loading... |
640 void EmitBinaryOp(BinaryOperation* expr, Token::Value op); | 620 void EmitBinaryOp(BinaryOperation* expr, Token::Value op); |
641 | 621 |
642 // Helper functions for generating inlined smi code for certain | 622 // Helper functions for generating inlined smi code for certain |
643 // binary operations. | 623 // binary operations. |
644 void EmitInlineSmiBinaryOp(BinaryOperation* expr, | 624 void EmitInlineSmiBinaryOp(BinaryOperation* expr, |
645 Token::Value op, | 625 Token::Value op, |
646 Expression* left, | 626 Expression* left, |
647 Expression* right); | 627 Expression* right); |
648 | 628 |
649 // Assign to the given expression as if via '='. The right-hand-side value | 629 // Assign to the given expression as if via '='. The right-hand-side value |
650 // is expected in the accumulator. | 630 // is expected in the accumulator. slot is only used if FLAG_vector_stores |
651 void EmitAssignment(Expression* expr); | 631 // is true. |
| 632 void EmitAssignment(Expression* expr, FeedbackVectorICSlot slot = |
| 633 FeedbackVectorICSlot::Invalid()); |
652 | 634 |
653 // Complete a variable assignment. The right-hand-side value is expected | 635 // Complete a variable assignment. The right-hand-side value is expected |
654 // in the accumulator. | 636 // in the accumulator. |
655 void EmitVariableAssignment(Variable* var, | 637 void EmitVariableAssignment( |
656 Token::Value op); | 638 Variable* var, Token::Value op, |
| 639 FeedbackVectorICSlot slot = FeedbackVectorICSlot::Invalid()); |
657 | 640 |
658 // Helper functions to EmitVariableAssignment | 641 // Helper functions to EmitVariableAssignment |
659 void EmitStoreToStackLocalOrContextSlot(Variable* var, | 642 void EmitStoreToStackLocalOrContextSlot(Variable* var, |
660 MemOperand location); | 643 MemOperand location); |
661 | 644 |
662 // Complete a named property assignment. The receiver is expected on top | 645 // Complete a named property assignment. The receiver is expected on top |
663 // of the stack and the right-hand-side value in the accumulator. | 646 // of the stack and the right-hand-side value in the accumulator. |
664 void EmitNamedPropertyAssignment(Assignment* expr); | 647 void EmitNamedPropertyAssignment(Assignment* expr); |
665 | 648 |
666 // Complete a super named property assignment. The right-hand-side value | 649 // Complete a super named property assignment. The right-hand-side value |
(...skipping 11 matching lines...) Expand all Loading... |
678 | 661 |
679 void EmitLoadHomeObject(SuperReference* expr); | 662 void EmitLoadHomeObject(SuperReference* expr); |
680 | 663 |
681 static bool NeedsHomeObject(Expression* expr) { | 664 static bool NeedsHomeObject(Expression* expr) { |
682 return FunctionLiteral::NeedsHomeObject(expr); | 665 return FunctionLiteral::NeedsHomeObject(expr); |
683 } | 666 } |
684 | 667 |
685 // Adds the [[HomeObject]] to |initializer| if it is a FunctionLiteral. | 668 // Adds the [[HomeObject]] to |initializer| if it is a FunctionLiteral. |
686 // The value of the initializer is expected to be at the top of the stack. | 669 // The value of the initializer is expected to be at the top of the stack. |
687 // |offset| is the offset in the stack where the home object can be found. | 670 // |offset| is the offset in the stack where the home object can be found. |
688 void EmitSetHomeObjectIfNeeded(Expression* initializer, int offset); | 671 void EmitSetHomeObjectIfNeeded( |
| 672 Expression* initializer, int offset, |
| 673 FeedbackVectorICSlot slot = FeedbackVectorICSlot::Invalid()); |
689 | 674 |
690 void EmitLoadSuperConstructor(); | 675 void EmitLoadSuperConstructor(); |
691 void EmitInitializeThisAfterSuper(SuperReference* super_ref); | 676 void EmitInitializeThisAfterSuper( |
| 677 SuperReference* super_ref, |
| 678 FeedbackVectorICSlot slot = FeedbackVectorICSlot::Invalid()); |
692 | 679 |
693 void CallIC(Handle<Code> code, | 680 void CallIC(Handle<Code> code, |
694 TypeFeedbackId id = TypeFeedbackId::None()); | 681 TypeFeedbackId id = TypeFeedbackId::None()); |
695 | 682 |
696 void CallLoadIC(ContextualMode mode, | 683 void CallLoadIC(ContextualMode mode, |
697 TypeFeedbackId id = TypeFeedbackId::None()); | 684 TypeFeedbackId id = TypeFeedbackId::None()); |
698 void CallGlobalLoadIC(Handle<String> name); | 685 void CallGlobalLoadIC(Handle<String> name); |
699 void CallStoreIC(TypeFeedbackId id = TypeFeedbackId::None()); | 686 void CallStoreIC(TypeFeedbackId id = TypeFeedbackId::None()); |
700 | 687 |
701 void SetFunctionPosition(FunctionLiteral* fun); | 688 void SetFunctionPosition(FunctionLiteral* fun); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 | 746 |
760 void VisitForTypeofValue(Expression* expr); | 747 void VisitForTypeofValue(Expression* expr); |
761 | 748 |
762 void Generate(); | 749 void Generate(); |
763 void PopulateDeoptimizationData(Handle<Code> code); | 750 void PopulateDeoptimizationData(Handle<Code> code); |
764 void PopulateTypeFeedbackInfo(Handle<Code> code); | 751 void PopulateTypeFeedbackInfo(Handle<Code> code); |
765 | 752 |
766 bool MustCreateObjectLiteralWithRuntime(ObjectLiteral* expr) const; | 753 bool MustCreateObjectLiteralWithRuntime(ObjectLiteral* expr) const; |
767 bool MustCreateArrayLiteralWithRuntime(ArrayLiteral* expr) const; | 754 bool MustCreateArrayLiteralWithRuntime(ArrayLiteral* expr) const; |
768 | 755 |
| 756 void EmitLoadStoreICSlot(FeedbackVectorICSlot slot); |
| 757 |
769 Handle<HandlerTable> handler_table() { return handler_table_; } | 758 Handle<HandlerTable> handler_table() { return handler_table_; } |
770 | 759 |
771 struct BailoutEntry { | 760 struct BailoutEntry { |
772 BailoutId id; | 761 BailoutId id; |
773 unsigned pc_and_state; | 762 unsigned pc_and_state; |
774 }; | 763 }; |
775 | 764 |
776 struct BackEdgeEntry { | 765 struct BackEdgeEntry { |
777 BailoutId id; | 766 BailoutId id; |
778 unsigned pc; | 767 unsigned pc; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 | 1085 |
1097 Address start_; | 1086 Address start_; |
1098 Address instruction_start_; | 1087 Address instruction_start_; |
1099 uint32_t length_; | 1088 uint32_t length_; |
1100 }; | 1089 }; |
1101 | 1090 |
1102 | 1091 |
1103 } } // namespace v8::internal | 1092 } } // namespace v8::internal |
1104 | 1093 |
1105 #endif // V8_FULL_CODEGEN_H_ | 1094 #endif // V8_FULL_CODEGEN_H_ |
OLD | NEW |