OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void AddSimulate(BailoutId ast_id) { AddInstruction(CreateSimulate(ast_id)); } | 128 void AddSimulate(BailoutId ast_id) { AddInstruction(CreateSimulate(ast_id)); } |
129 void AssignCommonDominator(HBasicBlock* other); | 129 void AssignCommonDominator(HBasicBlock* other); |
130 void AssignLoopSuccessorDominators(); | 130 void AssignLoopSuccessorDominators(); |
131 | 131 |
132 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { | 132 void FinishExitWithDeoptimization(HDeoptimize::UseEnvironment has_uses) { |
133 FinishExit(CreateDeoptimize(has_uses)); | 133 FinishExit(CreateDeoptimize(has_uses)); |
134 } | 134 } |
135 | 135 |
136 // Add the inlined function exit sequence, adding an HLeaveInlined | 136 // Add the inlined function exit sequence, adding an HLeaveInlined |
137 // instruction and updating the bailout environment. | 137 // instruction and updating the bailout environment. |
138 void AddLeaveInlined(HValue* return_value, | 138 void AddLeaveInlined(HValue* return_value, FunctionState* state); |
139 HBasicBlock* target, | |
140 FunctionState* state = NULL); | |
141 | 139 |
142 // If a target block is tagged as an inline function return, all | 140 // If a target block is tagged as an inline function return, all |
143 // predecessors should contain the inlined exit sequence: | 141 // predecessors should contain the inlined exit sequence: |
144 // | 142 // |
145 // LeaveInlined | 143 // LeaveInlined |
146 // Simulate (caller's environment) | 144 // Simulate (caller's environment) |
147 // Goto (target block) | 145 // Goto (target block) |
148 bool IsInlineReturnTarget() const { return is_inline_return_target_; } | 146 bool IsInlineReturnTarget() const { return is_inline_return_target_; } |
149 void MarkAsInlineReturnTarget() { is_inline_return_target_ = true; } | 147 void MarkAsInlineReturnTarget() { is_inline_return_target_ = true; } |
150 | 148 |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; | 501 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; |
504 | 502 |
505 // Create an "inlined version" of this environment, where the original | 503 // Create an "inlined version" of this environment, where the original |
506 // environment is the outer environment but the top expression stack | 504 // environment is the outer environment but the top expression stack |
507 // elements are moved to an inner environment as parameters. | 505 // elements are moved to an inner environment as parameters. |
508 HEnvironment* CopyForInlining(Handle<JSFunction> target, | 506 HEnvironment* CopyForInlining(Handle<JSFunction> target, |
509 int arguments, | 507 int arguments, |
510 FunctionLiteral* function, | 508 FunctionLiteral* function, |
511 HConstant* undefined, | 509 HConstant* undefined, |
512 CallKind call_kind, | 510 CallKind call_kind, |
513 bool is_construct) const; | 511 InliningKind inlining_kind) const; |
514 | 512 |
515 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other); | 513 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other); |
516 | 514 |
517 void ClearHistory() { | 515 void ClearHistory() { |
518 pop_count_ = 0; | 516 pop_count_ = 0; |
519 push_count_ = 0; | 517 push_count_ = 0; |
520 assigned_variables_.Rewind(0); | 518 assigned_variables_.Rewind(0); |
521 } | 519 } |
522 | 520 |
523 void SetValueAt(int index, HValue* value) { | 521 void SetValueAt(int index, HValue* value) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 // control flow. | 698 // control flow. |
701 void BuildBranch(HValue* value); | 699 void BuildBranch(HValue* value); |
702 | 700 |
703 Expression* condition_; | 701 Expression* condition_; |
704 TypeFeedbackOracle* oracle_; | 702 TypeFeedbackOracle* oracle_; |
705 HBasicBlock* if_true_; | 703 HBasicBlock* if_true_; |
706 HBasicBlock* if_false_; | 704 HBasicBlock* if_false_; |
707 }; | 705 }; |
708 | 706 |
709 | 707 |
710 enum ReturnHandlingFlag { | |
711 NORMAL_RETURN, | |
712 DROP_EXTRA_ON_RETURN, | |
713 CONSTRUCT_CALL_RETURN | |
714 }; | |
715 | |
716 | |
717 class FunctionState { | 708 class FunctionState { |
718 public: | 709 public: |
719 FunctionState(HGraphBuilder* owner, | 710 FunctionState(HGraphBuilder* owner, |
720 CompilationInfo* info, | 711 CompilationInfo* info, |
721 TypeFeedbackOracle* oracle, | 712 TypeFeedbackOracle* oracle, |
722 ReturnHandlingFlag return_handling); | 713 InliningKind inlining_kind); |
723 ~FunctionState(); | 714 ~FunctionState(); |
724 | 715 |
725 CompilationInfo* compilation_info() { return compilation_info_; } | 716 CompilationInfo* compilation_info() { return compilation_info_; } |
726 TypeFeedbackOracle* oracle() { return oracle_; } | 717 TypeFeedbackOracle* oracle() { return oracle_; } |
727 AstContext* call_context() { return call_context_; } | 718 AstContext* call_context() { return call_context_; } |
728 bool drop_extra() { return return_handling_ == DROP_EXTRA_ON_RETURN; } | 719 InliningKind inlining_kind() const { return inlining_kind_; } |
729 bool is_construct() { return return_handling_ == CONSTRUCT_CALL_RETURN; } | |
730 HBasicBlock* function_return() { return function_return_; } | 720 HBasicBlock* function_return() { return function_return_; } |
731 TestContext* test_context() { return test_context_; } | 721 TestContext* test_context() { return test_context_; } |
732 void ClearInlinedTestContext() { | 722 void ClearInlinedTestContext() { |
733 delete test_context_; | 723 delete test_context_; |
734 test_context_ = NULL; | 724 test_context_ = NULL; |
735 } | 725 } |
736 | 726 |
737 FunctionState* outer() { return outer_; } | 727 FunctionState* outer() { return outer_; } |
738 | 728 |
739 HEnterInlined* entry() { return entry_; } | 729 HEnterInlined* entry() { return entry_; } |
740 void set_entry(HEnterInlined* entry) { entry_ = entry; } | 730 void set_entry(HEnterInlined* entry) { entry_ = entry; } |
741 | 731 |
742 HArgumentsElements* arguments_elements() { return arguments_elements_; } | 732 HArgumentsElements* arguments_elements() { return arguments_elements_; } |
743 void set_arguments_elements(HArgumentsElements* arguments_elements) { | 733 void set_arguments_elements(HArgumentsElements* arguments_elements) { |
744 arguments_elements_ = arguments_elements; | 734 arguments_elements_ = arguments_elements; |
745 } | 735 } |
746 | 736 |
747 bool arguments_pushed() { return arguments_elements() != NULL; } | 737 bool arguments_pushed() { return arguments_elements() != NULL; } |
748 | 738 |
749 private: | 739 private: |
750 HGraphBuilder* owner_; | 740 HGraphBuilder* owner_; |
751 | 741 |
752 CompilationInfo* compilation_info_; | 742 CompilationInfo* compilation_info_; |
753 TypeFeedbackOracle* oracle_; | 743 TypeFeedbackOracle* oracle_; |
754 | 744 |
755 // During function inlining, expression context of the call being | 745 // During function inlining, expression context of the call being |
756 // inlined. NULL when not inlining. | 746 // inlined. NULL when not inlining. |
757 AstContext* call_context_; | 747 AstContext* call_context_; |
758 | 748 |
759 // Indicate whether we have to perform special handling on return from | 749 // The kind of call which is currently being inlined. |
760 // inlined functions. | 750 InliningKind inlining_kind_; |
761 // - DROP_EXTRA_ON_RETURN: Drop an extra value from the environment. | |
762 // - CONSTRUCT_CALL_RETURN: Either use allocated receiver or return value. | |
763 ReturnHandlingFlag return_handling_; | |
764 | 751 |
765 // When inlining in an effect or value context, this is the return block. | 752 // When inlining in an effect or value context, this is the return block. |
766 // It is NULL otherwise. When inlining in a test context, there are a | 753 // It is NULL otherwise. When inlining in a test context, there are a |
767 // pair of return blocks in the context. When not inlining, there is no | 754 // pair of return blocks in the context. When not inlining, there is no |
768 // local return point. | 755 // local return point. |
769 HBasicBlock* function_return_; | 756 HBasicBlock* function_return_; |
770 | 757 |
771 // When inlining a call in a test context, a context containing a pair of | 758 // When inlining a call in a test context, a context containing a pair of |
772 // return blocks. NULL in all other cases. | 759 // return blocks. NULL in all other cases. |
773 TestContext* test_context_; | 760 TestContext* test_context_; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 void EnsureArgumentsArePushedForAccess(); | 1017 void EnsureArgumentsArePushedForAccess(); |
1031 bool TryArgumentsAccess(Property* expr); | 1018 bool TryArgumentsAccess(Property* expr); |
1032 | 1019 |
1033 // Try to optimize fun.apply(receiver, arguments) pattern. | 1020 // Try to optimize fun.apply(receiver, arguments) pattern. |
1034 bool TryCallApply(Call* expr); | 1021 bool TryCallApply(Call* expr); |
1035 | 1022 |
1036 int InliningAstSize(Handle<JSFunction> target); | 1023 int InliningAstSize(Handle<JSFunction> target); |
1037 bool TryInline(CallKind call_kind, | 1024 bool TryInline(CallKind call_kind, |
1038 Handle<JSFunction> target, | 1025 Handle<JSFunction> target, |
1039 int arguments_count, | 1026 int arguments_count, |
1040 HValue* receiver, | 1027 HValue* implicit_return_value, |
1041 BailoutId ast_id, | 1028 BailoutId ast_id, |
1042 BailoutId return_id, | 1029 BailoutId return_id, |
1043 ReturnHandlingFlag return_handling); | 1030 InliningKind inlining_kind); |
1044 | 1031 |
1045 bool TryInlineCall(Call* expr, bool drop_extra = false); | 1032 bool TryInlineCall(Call* expr, bool drop_extra = false); |
1046 bool TryInlineConstruct(CallNew* expr, HValue* receiver); | 1033 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); |
1047 bool TryInlineGetter(Handle<JSFunction> getter, Property* prop); | 1034 bool TryInlineGetter(Handle<JSFunction> getter, Property* prop); |
| 1035 bool TryInlineSetter(Handle<JSFunction> setter, |
| 1036 Assignment* assignment, |
| 1037 HValue* implicit_return_value); |
1048 bool TryInlineBuiltinMethodCall(Call* expr, | 1038 bool TryInlineBuiltinMethodCall(Call* expr, |
1049 HValue* receiver, | 1039 HValue* receiver, |
1050 Handle<Map> receiver_map, | 1040 Handle<Map> receiver_map, |
1051 CheckType check_type); | 1041 CheckType check_type); |
1052 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra); | 1042 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra); |
1053 | 1043 |
1054 // If --trace-inlining, print a line of the inlining trace. Inlining | 1044 // If --trace-inlining, print a line of the inlining trace. Inlining |
1055 // succeeded if the reason string is NULL and failed if there is a | 1045 // succeeded if the reason string is NULL and failed if there is a |
1056 // non-NULL reason string. | 1046 // non-NULL reason string. |
1057 void TraceInline(Handle<JSFunction> target, | 1047 void TraceInline(Handle<JSFunction> target, |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 const char* filename_; | 1461 const char* filename_; |
1472 HeapStringAllocator string_allocator_; | 1462 HeapStringAllocator string_allocator_; |
1473 StringStream trace_; | 1463 StringStream trace_; |
1474 int indent_; | 1464 int indent_; |
1475 }; | 1465 }; |
1476 | 1466 |
1477 | 1467 |
1478 } } // namespace v8::internal | 1468 } } // namespace v8::internal |
1479 | 1469 |
1480 #endif // V8_HYDROGEN_H_ | 1470 #endif // V8_HYDROGEN_H_ |
OLD | NEW |