| 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 ReturnHandlingFlag return_handling) 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 // Build the shared core part of the translation unpacking a value into | 694 // Build the shared core part of the translation unpacking a value into |
| 697 // control flow. | 695 // control flow. |
| 698 void BuildBranch(HValue* value); | 696 void BuildBranch(HValue* value); |
| 699 | 697 |
| 700 Expression* condition_; | 698 Expression* condition_; |
| 701 HBasicBlock* if_true_; | 699 HBasicBlock* if_true_; |
| 702 HBasicBlock* if_false_; | 700 HBasicBlock* if_false_; |
| 703 }; | 701 }; |
| 704 | 702 |
| 705 | 703 |
| 706 enum ReturnHandlingFlag { | |
| 707 NORMAL_RETURN, | |
| 708 DROP_EXTRA_ON_RETURN, | |
| 709 CONSTRUCT_CALL_RETURN | |
| 710 }; | |
| 711 | |
| 712 | |
| 713 class FunctionState { | 704 class FunctionState { |
| 714 public: | 705 public: |
| 715 FunctionState(HGraphBuilder* owner, | 706 FunctionState(HGraphBuilder* owner, |
| 716 CompilationInfo* info, | 707 CompilationInfo* info, |
| 717 TypeFeedbackOracle* oracle, | 708 TypeFeedbackOracle* oracle, |
| 718 ReturnHandlingFlag return_handling); | 709 ReturnHandlingFlag return_handling); |
| 719 ~FunctionState(); | 710 ~FunctionState(); |
| 720 | 711 |
| 721 CompilationInfo* compilation_info() { return compilation_info_; } | 712 CompilationInfo* compilation_info() { return compilation_info_; } |
| 722 TypeFeedbackOracle* oracle() { return oracle_; } | 713 TypeFeedbackOracle* oracle() { return oracle_; } |
| 723 AstContext* call_context() { return call_context_; } | 714 AstContext* call_context() { return call_context_; } |
| 724 bool drop_extra() { return return_handling_ == DROP_EXTRA_ON_RETURN; } | 715 ReturnHandlingFlag return_handling() const { return return_handling_; } |
| 725 bool is_construct() { return return_handling_ == CONSTRUCT_CALL_RETURN; } | |
| 726 HBasicBlock* function_return() { return function_return_; } | 716 HBasicBlock* function_return() { return function_return_; } |
| 727 TestContext* test_context() { return test_context_; } | 717 TestContext* test_context() { return test_context_; } |
| 728 void ClearInlinedTestContext() { | 718 void ClearInlinedTestContext() { |
| 729 delete test_context_; | 719 delete test_context_; |
| 730 test_context_ = NULL; | 720 test_context_ = NULL; |
| 731 } | 721 } |
| 732 | 722 |
| 733 FunctionState* outer() { return outer_; } | 723 FunctionState* outer() { return outer_; } |
| 734 | 724 |
| 735 HEnterInlined* entry() { return entry_; } | 725 HEnterInlined* entry() { return entry_; } |
| 736 void set_entry(HEnterInlined* entry) { entry_ = entry; } | 726 void set_entry(HEnterInlined* entry) { entry_ = entry; } |
| 737 | 727 |
| 738 HArgumentsElements* arguments_elements() { return arguments_elements_; } | 728 HArgumentsElements* arguments_elements() { return arguments_elements_; } |
| 739 void set_arguments_elements(HArgumentsElements* arguments_elements) { | 729 void set_arguments_elements(HArgumentsElements* arguments_elements) { |
| 740 arguments_elements_ = arguments_elements; | 730 arguments_elements_ = arguments_elements; |
| 741 } | 731 } |
| 742 | 732 |
| 743 bool arguments_pushed() { return arguments_elements() != NULL; } | 733 bool arguments_pushed() { return arguments_elements() != NULL; } |
| 744 | 734 |
| 745 private: | 735 private: |
| 746 HGraphBuilder* owner_; | 736 HGraphBuilder* owner_; |
| 747 | 737 |
| 748 CompilationInfo* compilation_info_; | 738 CompilationInfo* compilation_info_; |
| 749 TypeFeedbackOracle* oracle_; | 739 TypeFeedbackOracle* oracle_; |
| 750 | 740 |
| 751 // During function inlining, expression context of the call being | 741 // During function inlining, expression context of the call being |
| 752 // inlined. NULL when not inlining. | 742 // inlined. NULL when not inlining. |
| 753 AstContext* call_context_; | 743 AstContext* call_context_; |
| 754 | 744 |
| 755 // Indicate whether we have to perform special handling on return from | |
| 756 // inlined functions. | |
| 757 // - DROP_EXTRA_ON_RETURN: Drop an extra value from the environment. | |
| 758 // - CONSTRUCT_CALL_RETURN: Either use allocated receiver or return value. | |
| 759 ReturnHandlingFlag return_handling_; | 745 ReturnHandlingFlag return_handling_; |
| 760 | 746 |
| 761 // When inlining in an effect or value context, this is the return block. | 747 // When inlining in an effect or value context, this is the return block. |
| 762 // It is NULL otherwise. When inlining in a test context, there are a | 748 // It is NULL otherwise. When inlining in a test context, there are a |
| 763 // pair of return blocks in the context. When not inlining, there is no | 749 // pair of return blocks in the context. When not inlining, there is no |
| 764 // local return point. | 750 // local return point. |
| 765 HBasicBlock* function_return_; | 751 HBasicBlock* function_return_; |
| 766 | 752 |
| 767 // When inlining a call in a test context, a context containing a pair of | 753 // When inlining a call in a test context, a context containing a pair of |
| 768 // return blocks. NULL in all other cases. | 754 // return blocks. NULL in all other cases. |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 void EnsureArgumentsArePushedForAccess(); | 1012 void EnsureArgumentsArePushedForAccess(); |
| 1027 bool TryArgumentsAccess(Property* expr); | 1013 bool TryArgumentsAccess(Property* expr); |
| 1028 | 1014 |
| 1029 // Try to optimize fun.apply(receiver, arguments) pattern. | 1015 // Try to optimize fun.apply(receiver, arguments) pattern. |
| 1030 bool TryCallApply(Call* expr); | 1016 bool TryCallApply(Call* expr); |
| 1031 | 1017 |
| 1032 int InliningAstSize(Handle<JSFunction> target); | 1018 int InliningAstSize(Handle<JSFunction> target); |
| 1033 bool TryInline(CallKind call_kind, | 1019 bool TryInline(CallKind call_kind, |
| 1034 Handle<JSFunction> target, | 1020 Handle<JSFunction> target, |
| 1035 int arguments_count, | 1021 int arguments_count, |
| 1036 HValue* receiver, | 1022 HValue* implicit_return_value, |
| 1037 BailoutId ast_id, | 1023 BailoutId ast_id, |
| 1038 BailoutId return_id, | 1024 BailoutId return_id, |
| 1039 ReturnHandlingFlag return_handling); | 1025 ReturnHandlingFlag return_handling); |
| 1040 | 1026 |
| 1041 bool TryInlineCall(Call* expr, bool drop_extra = false); | 1027 bool TryInlineCall(Call* expr, bool drop_extra = false); |
| 1042 bool TryInlineConstruct(CallNew* expr, HValue* receiver); | 1028 bool TryInlineConstruct(CallNew* expr, HValue* receiver); |
| 1043 bool TryInlineGetter(Handle<JSFunction> getter, Property* prop); | 1029 bool TryInlineGetter(Handle<JSFunction> getter, Property* prop); |
| 1030 bool TryInlineSetter(Handle<JSFunction> setter, |
| 1031 Assignment* assignment, |
| 1032 HValue* implicit_return_value); |
| 1044 bool TryInlineBuiltinMethodCall(Call* expr, | 1033 bool TryInlineBuiltinMethodCall(Call* expr, |
| 1045 HValue* receiver, | 1034 HValue* receiver, |
| 1046 Handle<Map> receiver_map, | 1035 Handle<Map> receiver_map, |
| 1047 CheckType check_type); | 1036 CheckType check_type); |
| 1048 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra); | 1037 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra); |
| 1049 | 1038 |
| 1050 // If --trace-inlining, print a line of the inlining trace. Inlining | 1039 // If --trace-inlining, print a line of the inlining trace. Inlining |
| 1051 // succeeded if the reason string is NULL and failed if there is a | 1040 // succeeded if the reason string is NULL and failed if there is a |
| 1052 // non-NULL reason string. | 1041 // non-NULL reason string. |
| 1053 void TraceInline(Handle<JSFunction> target, | 1042 void TraceInline(Handle<JSFunction> target, |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 const char* filename_; | 1456 const char* filename_; |
| 1468 HeapStringAllocator string_allocator_; | 1457 HeapStringAllocator string_allocator_; |
| 1469 StringStream trace_; | 1458 StringStream trace_; |
| 1470 int indent_; | 1459 int indent_; |
| 1471 }; | 1460 }; |
| 1472 | 1461 |
| 1473 | 1462 |
| 1474 } } // namespace v8::internal | 1463 } } // namespace v8::internal |
| 1475 | 1464 |
| 1476 #endif // V8_HYDROGEN_H_ | 1465 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |