| 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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 bool is_recursive_; | 387 bool is_recursive_; |
| 390 | 388 |
| 391 DISALLOW_COPY_AND_ASSIGN(HGraph); | 389 DISALLOW_COPY_AND_ASSIGN(HGraph); |
| 392 }; | 390 }; |
| 393 | 391 |
| 394 | 392 |
| 395 Zone* HBasicBlock::zone() const { return graph_->zone(); } | 393 Zone* HBasicBlock::zone() const { return graph_->zone(); } |
| 396 | 394 |
| 397 | 395 |
| 398 // Type of stack frame an environment might refer to. | 396 // Type of stack frame an environment might refer to. |
| 399 enum FrameType { JS_FUNCTION, JS_CONSTRUCT, ARGUMENTS_ADAPTOR }; | 397 enum FrameType { |
| 398 JS_FUNCTION, |
| 399 JS_CONSTRUCT, |
| 400 JS_SETTER, |
| 401 ARGUMENTS_ADAPTOR |
| 402 }; |
| 400 | 403 |
| 401 | 404 |
| 402 class HEnvironment: public ZoneObject { | 405 class HEnvironment: public ZoneObject { |
| 403 public: | 406 public: |
| 404 HEnvironment(HEnvironment* outer, | 407 HEnvironment(HEnvironment* outer, |
| 405 Scope* scope, | 408 Scope* scope, |
| 406 Handle<JSFunction> closure, | 409 Handle<JSFunction> closure, |
| 407 Zone* zone); | 410 Zone* zone); |
| 408 | 411 |
| 409 HEnvironment* DiscardInlined(bool drop_extra) { | 412 HEnvironment* DiscardInlined(bool drop_extra) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; | 506 HEnvironment* CopyAsLoopHeader(HBasicBlock* block) const; |
| 504 | 507 |
| 505 // Create an "inlined version" of this environment, where the original | 508 // Create an "inlined version" of this environment, where the original |
| 506 // environment is the outer environment but the top expression stack | 509 // environment is the outer environment but the top expression stack |
| 507 // elements are moved to an inner environment as parameters. | 510 // elements are moved to an inner environment as parameters. |
| 508 HEnvironment* CopyForInlining(Handle<JSFunction> target, | 511 HEnvironment* CopyForInlining(Handle<JSFunction> target, |
| 509 int arguments, | 512 int arguments, |
| 510 FunctionLiteral* function, | 513 FunctionLiteral* function, |
| 511 HConstant* undefined, | 514 HConstant* undefined, |
| 512 CallKind call_kind, | 515 CallKind call_kind, |
| 513 bool is_construct) const; | 516 InliningKind inlining_kind) const; |
| 514 | 517 |
| 515 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other); | 518 void AddIncomingEdge(HBasicBlock* block, HEnvironment* other); |
| 516 | 519 |
| 517 void ClearHistory() { | 520 void ClearHistory() { |
| 518 pop_count_ = 0; | 521 pop_count_ = 0; |
| 519 push_count_ = 0; | 522 push_count_ = 0; |
| 520 assigned_variables_.Rewind(0); | 523 assigned_variables_.Rewind(0); |
| 521 } | 524 } |
| 522 | 525 |
| 523 void SetValueAt(int index, HValue* value) { | 526 void SetValueAt(int index, HValue* value) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 // control flow. | 703 // control flow. |
| 701 void BuildBranch(HValue* value); | 704 void BuildBranch(HValue* value); |
| 702 | 705 |
| 703 Expression* condition_; | 706 Expression* condition_; |
| 704 TypeFeedbackOracle* oracle_; | 707 TypeFeedbackOracle* oracle_; |
| 705 HBasicBlock* if_true_; | 708 HBasicBlock* if_true_; |
| 706 HBasicBlock* if_false_; | 709 HBasicBlock* if_false_; |
| 707 }; | 710 }; |
| 708 | 711 |
| 709 | 712 |
| 710 enum ReturnHandlingFlag { | |
| 711 NORMAL_RETURN, | |
| 712 DROP_EXTRA_ON_RETURN, | |
| 713 CONSTRUCT_CALL_RETURN | |
| 714 }; | |
| 715 | |
| 716 | |
| 717 class FunctionState { | 713 class FunctionState { |
| 718 public: | 714 public: |
| 719 FunctionState(HGraphBuilder* owner, | 715 FunctionState(HGraphBuilder* owner, |
| 720 CompilationInfo* info, | 716 CompilationInfo* info, |
| 721 TypeFeedbackOracle* oracle, | 717 TypeFeedbackOracle* oracle, |
| 722 ReturnHandlingFlag return_handling); | 718 InliningKind inlining_kind); |
| 723 ~FunctionState(); | 719 ~FunctionState(); |
| 724 | 720 |
| 725 CompilationInfo* compilation_info() { return compilation_info_; } | 721 CompilationInfo* compilation_info() { return compilation_info_; } |
| 726 TypeFeedbackOracle* oracle() { return oracle_; } | 722 TypeFeedbackOracle* oracle() { return oracle_; } |
| 727 AstContext* call_context() { return call_context_; } | 723 AstContext* call_context() { return call_context_; } |
| 728 bool drop_extra() { return return_handling_ == DROP_EXTRA_ON_RETURN; } | 724 InliningKind inlining_kind() const { return inlining_kind_; } |
| 729 bool is_construct() { return return_handling_ == CONSTRUCT_CALL_RETURN; } | |
| 730 HBasicBlock* function_return() { return function_return_; } | 725 HBasicBlock* function_return() { return function_return_; } |
| 731 TestContext* test_context() { return test_context_; } | 726 TestContext* test_context() { return test_context_; } |
| 732 void ClearInlinedTestContext() { | 727 void ClearInlinedTestContext() { |
| 733 delete test_context_; | 728 delete test_context_; |
| 734 test_context_ = NULL; | 729 test_context_ = NULL; |
| 735 } | 730 } |
| 736 | 731 |
| 737 FunctionState* outer() { return outer_; } | 732 FunctionState* outer() { return outer_; } |
| 738 | 733 |
| 739 HEnterInlined* entry() { return entry_; } | 734 HEnterInlined* entry() { return entry_; } |
| 740 void set_entry(HEnterInlined* entry) { entry_ = entry; } | 735 void set_entry(HEnterInlined* entry) { entry_ = entry; } |
| 741 | 736 |
| 742 HArgumentsElements* arguments_elements() { return arguments_elements_; } | 737 HArgumentsElements* arguments_elements() { return arguments_elements_; } |
| 743 void set_arguments_elements(HArgumentsElements* arguments_elements) { | 738 void set_arguments_elements(HArgumentsElements* arguments_elements) { |
| 744 arguments_elements_ = arguments_elements; | 739 arguments_elements_ = arguments_elements; |
| 745 } | 740 } |
| 746 | 741 |
| 747 bool arguments_pushed() { return arguments_elements() != NULL; } | 742 bool arguments_pushed() { return arguments_elements() != NULL; } |
| 748 | 743 |
| 749 private: | 744 private: |
| 750 HGraphBuilder* owner_; | 745 HGraphBuilder* owner_; |
| 751 | 746 |
| 752 CompilationInfo* compilation_info_; | 747 CompilationInfo* compilation_info_; |
| 753 TypeFeedbackOracle* oracle_; | 748 TypeFeedbackOracle* oracle_; |
| 754 | 749 |
| 755 // During function inlining, expression context of the call being | 750 // During function inlining, expression context of the call being |
| 756 // inlined. NULL when not inlining. | 751 // inlined. NULL when not inlining. |
| 757 AstContext* call_context_; | 752 AstContext* call_context_; |
| 758 | 753 |
| 759 // Indicate whether we have to perform special handling on return from | 754 // The kind of call which is currently being inlined. |
| 760 // inlined functions. | 755 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 | 756 |
| 765 // When inlining in an effect or value context, this is the return block. | 757 // 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 | 758 // 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 | 759 // pair of return blocks in the context. When not inlining, there is no |
| 768 // local return point. | 760 // local return point. |
| 769 HBasicBlock* function_return_; | 761 HBasicBlock* function_return_; |
| 770 | 762 |
| 771 // When inlining a call in a test context, a context containing a pair of | 763 // When inlining a call in a test context, a context containing a pair of |
| 772 // return blocks. NULL in all other cases. | 764 // return blocks. NULL in all other cases. |
| 773 TestContext* test_context_; | 765 TestContext* test_context_; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 void EnsureArgumentsArePushedForAccess(); | 1022 void EnsureArgumentsArePushedForAccess(); |
| 1031 bool TryArgumentsAccess(Property* expr); | 1023 bool TryArgumentsAccess(Property* expr); |
| 1032 | 1024 |
| 1033 // Try to optimize fun.apply(receiver, arguments) pattern. | 1025 // Try to optimize fun.apply(receiver, arguments) pattern. |
| 1034 bool TryCallApply(Call* expr); | 1026 bool TryCallApply(Call* expr); |
| 1035 | 1027 |
| 1036 int InliningAstSize(Handle<JSFunction> target); | 1028 int InliningAstSize(Handle<JSFunction> target); |
| 1037 bool TryInline(CallKind call_kind, | 1029 bool TryInline(CallKind call_kind, |
| 1038 Handle<JSFunction> target, | 1030 Handle<JSFunction> target, |
| 1039 int arguments_count, | 1031 int arguments_count, |
| 1040 HValue* receiver, | 1032 HValue* implicit_return_value, |
| 1041 BailoutId ast_id, | 1033 BailoutId ast_id, |
| 1042 BailoutId return_id, | 1034 BailoutId return_id, |
| 1043 ReturnHandlingFlag return_handling); | 1035 InliningKind inlining_kind); |
| 1044 | 1036 |
| 1045 bool TryInlineCall(Call* expr, bool drop_extra = false); | 1037 bool TryInlineCall(Call* expr, bool drop_extra = false); |
| 1046 bool TryInlineConstruct(CallNew* expr, HValue* receiver); | 1038 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); |
| 1047 bool TryInlineGetter(Handle<JSFunction> getter, Property* prop); | 1039 bool TryInlineGetter(Handle<JSFunction> getter, Property* prop); |
| 1040 bool TryInlineSetter(Handle<JSFunction> setter, |
| 1041 Assignment* assignment, |
| 1042 HValue* implicit_return_value); |
| 1048 bool TryInlineBuiltinMethodCall(Call* expr, | 1043 bool TryInlineBuiltinMethodCall(Call* expr, |
| 1049 HValue* receiver, | 1044 HValue* receiver, |
| 1050 Handle<Map> receiver_map, | 1045 Handle<Map> receiver_map, |
| 1051 CheckType check_type); | 1046 CheckType check_type); |
| 1052 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra); | 1047 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra); |
| 1053 | 1048 |
| 1054 // If --trace-inlining, print a line of the inlining trace. Inlining | 1049 // 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 | 1050 // succeeded if the reason string is NULL and failed if there is a |
| 1056 // non-NULL reason string. | 1051 // non-NULL reason string. |
| 1057 void TraceInline(Handle<JSFunction> target, | 1052 void TraceInline(Handle<JSFunction> target, |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 const char* filename_; | 1466 const char* filename_; |
| 1472 HeapStringAllocator string_allocator_; | 1467 HeapStringAllocator string_allocator_; |
| 1473 StringStream trace_; | 1468 StringStream trace_; |
| 1474 int indent_; | 1469 int indent_; |
| 1475 }; | 1470 }; |
| 1476 | 1471 |
| 1477 | 1472 |
| 1478 } } // namespace v8::internal | 1473 } } // namespace v8::internal |
| 1479 | 1474 |
| 1480 #endif // V8_HYDROGEN_H_ | 1475 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |