Chromium Code Reviews| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 | 103 |
| 104 void AttachLoopInformation(); | 104 void AttachLoopInformation(); |
| 105 void DetachLoopInformation(); | 105 void DetachLoopInformation(); |
| 106 bool IsLoopHeader() const { return loop_information() != NULL; } | 106 bool IsLoopHeader() const { return loop_information() != NULL; } |
| 107 bool IsStartBlock() const { return block_id() == 0; } | 107 bool IsStartBlock() const { return block_id() == 0; } |
| 108 void PostProcessLoopHeader(IterationStatement* stmt); | 108 void PostProcessLoopHeader(IterationStatement* stmt); |
| 109 | 109 |
| 110 bool IsFinished() const { return end_ != NULL; } | 110 bool IsFinished() const { return end_ != NULL; } |
| 111 void AddPhi(HPhi* phi); | 111 void AddPhi(HPhi* phi); |
| 112 void RemovePhi(HPhi* phi); | 112 void RemovePhi(HPhi* phi); |
| 113 void AddInstruction(HInstruction* instr, int position); | 113 void AddInstruction(HInstruction* instr, HSourcePosition position); |
| 114 bool Dominates(HBasicBlock* other) const; | 114 bool Dominates(HBasicBlock* other) const; |
| 115 int LoopNestingDepth() const; | 115 int LoopNestingDepth() const; |
| 116 | 116 |
| 117 void SetInitialEnvironment(HEnvironment* env); | 117 void SetInitialEnvironment(HEnvironment* env); |
| 118 void ClearEnvironment() { | 118 void ClearEnvironment() { |
| 119 ASSERT(IsFinished()); | 119 ASSERT(IsFinished()); |
| 120 ASSERT(end()->SuccessorCount() == 0); | 120 ASSERT(end()->SuccessorCount() == 0); |
| 121 last_environment_ = NULL; | 121 last_environment_ = NULL; |
| 122 } | 122 } |
| 123 bool HasEnvironment() const { return last_environment_ != NULL; } | 123 bool HasEnvironment() const { return last_environment_ != NULL; } |
| 124 void UpdateEnvironment(HEnvironment* env); | 124 void UpdateEnvironment(HEnvironment* env); |
| 125 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } | 125 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } |
| 126 | 126 |
| 127 void set_parent_loop_header(HBasicBlock* block) { | 127 void set_parent_loop_header(HBasicBlock* block) { |
| 128 ASSERT(parent_loop_header_ == NULL); | 128 ASSERT(parent_loop_header_ == NULL); |
| 129 parent_loop_header_ = block; | 129 parent_loop_header_ = block; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } | 132 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } |
| 133 | 133 |
| 134 void SetJoinId(BailoutId ast_id); | 134 void SetJoinId(BailoutId ast_id); |
| 135 | 135 |
| 136 int PredecessorIndexOf(HBasicBlock* predecessor) const; | 136 int PredecessorIndexOf(HBasicBlock* predecessor) const; |
| 137 HPhi* AddNewPhi(int merged_index); | 137 HPhi* AddNewPhi(int merged_index); |
| 138 HSimulate* AddNewSimulate(BailoutId ast_id, | 138 HSimulate* AddNewSimulate(BailoutId ast_id, |
| 139 int position, | 139 HSourcePosition position, |
| 140 RemovableSimulate removable = FIXED_SIMULATE) { | 140 RemovableSimulate removable = FIXED_SIMULATE) { |
| 141 HSimulate* instr = CreateSimulate(ast_id, removable); | 141 HSimulate* instr = CreateSimulate(ast_id, removable); |
| 142 AddInstruction(instr, position); | 142 AddInstruction(instr, position); |
| 143 return instr; | 143 return instr; |
| 144 } | 144 } |
| 145 void AssignCommonDominator(HBasicBlock* other); | 145 void AssignCommonDominator(HBasicBlock* other); |
| 146 void AssignLoopSuccessorDominators(); | 146 void AssignLoopSuccessorDominators(); |
| 147 | 147 |
| 148 // If a target block is tagged as an inline function return, all | 148 // If a target block is tagged as an inline function return, all |
| 149 // predecessors should contain the inlined exit sequence: | 149 // predecessors should contain the inlined exit sequence: |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 176 inline Zone* zone() const; | 176 inline Zone* zone() const; |
| 177 | 177 |
| 178 #ifdef DEBUG | 178 #ifdef DEBUG |
| 179 void Verify(); | 179 void Verify(); |
| 180 #endif | 180 #endif |
| 181 | 181 |
| 182 protected: | 182 protected: |
| 183 friend class HGraphBuilder; | 183 friend class HGraphBuilder; |
| 184 | 184 |
| 185 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); | 185 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); |
| 186 void Finish(HControlInstruction* last, int position); | 186 void Finish(HControlInstruction* last, HSourcePosition position); |
| 187 void FinishExit(HControlInstruction* instruction, int position); | 187 void FinishExit(HControlInstruction* instruction, HSourcePosition position); |
| 188 void Goto(HBasicBlock* block, | 188 void Goto(HBasicBlock* block, |
| 189 int position, | 189 HSourcePosition position, |
| 190 FunctionState* state = NULL, | 190 FunctionState* state = NULL, |
| 191 bool add_simulate = true); | 191 bool add_simulate = true); |
| 192 void GotoNoSimulate(HBasicBlock* block, int position) { | 192 void GotoNoSimulate(HBasicBlock* block, HSourcePosition position) { |
| 193 Goto(block, position, NULL, false); | 193 Goto(block, position, NULL, false); |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Add the inlined function exit sequence, adding an HLeaveInlined | 196 // Add the inlined function exit sequence, adding an HLeaveInlined |
| 197 // instruction and updating the bailout environment. | 197 // instruction and updating the bailout environment. |
| 198 void AddLeaveInlined(HValue* return_value, | 198 void AddLeaveInlined(HValue* return_value, |
| 199 FunctionState* state, | 199 FunctionState* state, |
| 200 int position); | 200 HSourcePosition position); |
| 201 | 201 |
| 202 private: | 202 private: |
| 203 void RegisterPredecessor(HBasicBlock* pred); | 203 void RegisterPredecessor(HBasicBlock* pred); |
| 204 void AddDominatedBlock(HBasicBlock* block); | 204 void AddDominatedBlock(HBasicBlock* block); |
| 205 | 205 |
| 206 int block_id_; | 206 int block_id_; |
| 207 HGraph* graph_; | 207 HGraph* graph_; |
| 208 ZoneList<HPhi*> phis_; | 208 ZoneList<HPhi*> phis_; |
| 209 HInstruction* first_; | 209 HInstruction* first_; |
| 210 HInstruction* last_; | 210 HInstruction* last_; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 if (uint32_instructions_ == NULL) { | 461 if (uint32_instructions_ == NULL) { |
| 462 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); | 462 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); |
| 463 } | 463 } |
| 464 uint32_instructions_->Add(instr, zone()); | 464 uint32_instructions_->Add(instr, zone()); |
| 465 } | 465 } |
| 466 | 466 |
| 467 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } | 467 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } |
| 468 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } | 468 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } |
| 469 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } | 469 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } |
| 470 | 470 |
| 471 // If we are tracking source positions then this function assigns a unique | |
| 472 // identifier to each inlining and dumps function source if it was inlined | |
| 473 // for the first time during the current optimization. | |
| 474 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | |
| 475 HSourcePosition position); | |
| 476 | |
| 477 // Converts given HSourcePosition to the absolute offset from the start of | |
| 478 // the corresponding script. | |
| 479 int SourcePositionToScriptPosition(HSourcePosition position); | |
| 480 | |
| 471 private: | 481 private: |
| 472 HConstant* ReinsertConstantIfNecessary(HConstant* constant); | 482 HConstant* ReinsertConstantIfNecessary(HConstant* constant); |
| 473 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, | 483 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, |
| 474 int32_t integer_value); | 484 int32_t integer_value); |
| 475 | 485 |
| 476 template<class Phase> | 486 template<class Phase> |
| 477 void Run() { | 487 void Run() { |
| 478 Phase phase(this); | 488 Phase phase(this); |
| 479 phase.Run(); | 489 phase.Run(); |
| 480 } | 490 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 506 Zone* zone_; | 516 Zone* zone_; |
| 507 | 517 |
| 508 bool is_recursive_; | 518 bool is_recursive_; |
| 509 bool use_optimistic_licm_; | 519 bool use_optimistic_licm_; |
| 510 bool depends_on_empty_array_proto_elements_; | 520 bool depends_on_empty_array_proto_elements_; |
| 511 int type_change_checksum_; | 521 int type_change_checksum_; |
| 512 int maximum_environment_size_; | 522 int maximum_environment_size_; |
| 513 int no_side_effects_scope_count_; | 523 int no_side_effects_scope_count_; |
| 514 bool disallow_adding_new_values_; | 524 bool disallow_adding_new_values_; |
| 515 | 525 |
| 526 class InlinedFunctionInfo { | |
| 527 public: | |
| 528 explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared) | |
| 529 : shared_(shared), start_position_(shared->start_position()) { | |
| 530 } | |
| 531 | |
| 532 Handle<SharedFunctionInfo> shared() const { return shared_; } | |
| 533 int start_position() const { return start_position_; } | |
| 534 | |
| 535 private: | |
| 536 Handle<SharedFunctionInfo> shared_; | |
| 537 int start_position_; | |
| 538 }; | |
| 539 | |
| 540 int next_inline_id_; | |
| 541 ZoneList<InlinedFunctionInfo> inlined_functions_; | |
| 542 | |
| 516 DISALLOW_COPY_AND_ASSIGN(HGraph); | 543 DISALLOW_COPY_AND_ASSIGN(HGraph); |
| 517 }; | 544 }; |
| 518 | 545 |
| 519 | 546 |
| 520 Zone* HBasicBlock::zone() const { return graph_->zone(); } | 547 Zone* HBasicBlock::zone() const { return graph_->zone(); } |
| 521 | 548 |
| 522 | 549 |
| 523 // Type of stack frame an environment might refer to. | 550 // Type of stack frame an environment might refer to. |
| 524 enum FrameType { | 551 enum FrameType { |
| 525 JS_FUNCTION, | 552 JS_FUNCTION, |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 Expression* condition_; | 899 Expression* condition_; |
| 873 HBasicBlock* if_true_; | 900 HBasicBlock* if_true_; |
| 874 HBasicBlock* if_false_; | 901 HBasicBlock* if_false_; |
| 875 }; | 902 }; |
| 876 | 903 |
| 877 | 904 |
| 878 class FunctionState V8_FINAL { | 905 class FunctionState V8_FINAL { |
| 879 public: | 906 public: |
| 880 FunctionState(HOptimizedGraphBuilder* owner, | 907 FunctionState(HOptimizedGraphBuilder* owner, |
| 881 CompilationInfo* info, | 908 CompilationInfo* info, |
| 882 InliningKind inlining_kind); | 909 InliningKind inlining_kind, |
| 910 int inlining_id); | |
| 883 ~FunctionState(); | 911 ~FunctionState(); |
| 884 | 912 |
| 885 CompilationInfo* compilation_info() { return compilation_info_; } | 913 CompilationInfo* compilation_info() { return compilation_info_; } |
| 886 AstContext* call_context() { return call_context_; } | 914 AstContext* call_context() { return call_context_; } |
| 887 InliningKind inlining_kind() const { return inlining_kind_; } | 915 InliningKind inlining_kind() const { return inlining_kind_; } |
| 888 HBasicBlock* function_return() { return function_return_; } | 916 HBasicBlock* function_return() { return function_return_; } |
| 889 TestContext* test_context() { return test_context_; } | 917 TestContext* test_context() { return test_context_; } |
| 890 void ClearInlinedTestContext() { | 918 void ClearInlinedTestContext() { |
| 891 delete test_context_; | 919 delete test_context_; |
| 892 test_context_ = NULL; | 920 test_context_ = NULL; |
| 893 } | 921 } |
| 894 | 922 |
| 895 FunctionState* outer() { return outer_; } | 923 FunctionState* outer() { return outer_; } |
| 896 | 924 |
| 897 HEnterInlined* entry() { return entry_; } | 925 HEnterInlined* entry() { return entry_; } |
| 898 void set_entry(HEnterInlined* entry) { entry_ = entry; } | 926 void set_entry(HEnterInlined* entry) { entry_ = entry; } |
| 899 | 927 |
| 900 HArgumentsObject* arguments_object() { return arguments_object_; } | 928 HArgumentsObject* arguments_object() { return arguments_object_; } |
| 901 void set_arguments_object(HArgumentsObject* arguments_object) { | 929 void set_arguments_object(HArgumentsObject* arguments_object) { |
| 902 arguments_object_ = arguments_object; | 930 arguments_object_ = arguments_object; |
| 903 } | 931 } |
| 904 | 932 |
| 905 HArgumentsElements* arguments_elements() { return arguments_elements_; } | 933 HArgumentsElements* arguments_elements() { return arguments_elements_; } |
| 906 void set_arguments_elements(HArgumentsElements* arguments_elements) { | 934 void set_arguments_elements(HArgumentsElements* arguments_elements) { |
| 907 arguments_elements_ = arguments_elements; | 935 arguments_elements_ = arguments_elements; |
| 908 } | 936 } |
| 909 | 937 |
| 910 bool arguments_pushed() { return arguments_elements() != NULL; } | 938 bool arguments_pushed() { return arguments_elements() != NULL; } |
| 911 | 939 |
| 940 int inlining_id() const { return inlining_id_; } | |
| 941 | |
| 912 private: | 942 private: |
| 913 HOptimizedGraphBuilder* owner_; | 943 HOptimizedGraphBuilder* owner_; |
| 914 | 944 |
| 915 CompilationInfo* compilation_info_; | 945 CompilationInfo* compilation_info_; |
| 916 | 946 |
| 917 // During function inlining, expression context of the call being | 947 // During function inlining, expression context of the call being |
| 918 // inlined. NULL when not inlining. | 948 // inlined. NULL when not inlining. |
| 919 AstContext* call_context_; | 949 AstContext* call_context_; |
| 920 | 950 |
| 921 // The kind of call which is currently being inlined. | 951 // The kind of call which is currently being inlined. |
| 922 InliningKind inlining_kind_; | 952 InliningKind inlining_kind_; |
| 923 | 953 |
| 924 // When inlining in an effect or value context, this is the return block. | 954 // When inlining in an effect or value context, this is the return block. |
| 925 // It is NULL otherwise. When inlining in a test context, there are a | 955 // It is NULL otherwise. When inlining in a test context, there are a |
| 926 // pair of return blocks in the context. When not inlining, there is no | 956 // pair of return blocks in the context. When not inlining, there is no |
| 927 // local return point. | 957 // local return point. |
| 928 HBasicBlock* function_return_; | 958 HBasicBlock* function_return_; |
| 929 | 959 |
| 930 // When inlining a call in a test context, a context containing a pair of | 960 // When inlining a call in a test context, a context containing a pair of |
| 931 // return blocks. NULL in all other cases. | 961 // return blocks. NULL in all other cases. |
| 932 TestContext* test_context_; | 962 TestContext* test_context_; |
| 933 | 963 |
| 934 // When inlining HEnterInlined instruction corresponding to the function | 964 // When inlining HEnterInlined instruction corresponding to the function |
| 935 // entry. | 965 // entry. |
| 936 HEnterInlined* entry_; | 966 HEnterInlined* entry_; |
| 937 | 967 |
| 938 HArgumentsObject* arguments_object_; | 968 HArgumentsObject* arguments_object_; |
| 939 HArgumentsElements* arguments_elements_; | 969 HArgumentsElements* arguments_elements_; |
| 940 | 970 |
| 971 int inlining_id_; | |
| 972 HSourcePosition outer_source_position_; | |
| 973 | |
| 941 FunctionState* outer_; | 974 FunctionState* outer_; |
| 942 }; | 975 }; |
| 943 | 976 |
| 944 | 977 |
| 945 class HIfContinuation V8_FINAL { | 978 class HIfContinuation V8_FINAL { |
| 946 public: | 979 public: |
| 947 HIfContinuation() | 980 HIfContinuation() |
| 948 : continuation_captured_(false), | 981 : continuation_captured_(false), |
| 949 true_branch_(NULL), | 982 true_branch_(NULL), |
| 950 false_branch_(NULL) {} | 983 false_branch_(NULL) {} |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1014 PretenureFlag pretenure_flag_; | 1047 PretenureFlag pretenure_flag_; |
| 1015 }; | 1048 }; |
| 1016 | 1049 |
| 1017 | 1050 |
| 1018 class HGraphBuilder { | 1051 class HGraphBuilder { |
| 1019 public: | 1052 public: |
| 1020 explicit HGraphBuilder(CompilationInfo* info) | 1053 explicit HGraphBuilder(CompilationInfo* info) |
| 1021 : info_(info), | 1054 : info_(info), |
| 1022 graph_(NULL), | 1055 graph_(NULL), |
| 1023 current_block_(NULL), | 1056 current_block_(NULL), |
| 1024 position_(RelocInfo::kNoPosition) {} | 1057 position_(HSourcePosition::Unknown()), |
| 1058 start_position_(0) {} | |
| 1025 virtual ~HGraphBuilder() {} | 1059 virtual ~HGraphBuilder() {} |
| 1026 | 1060 |
| 1027 HBasicBlock* current_block() const { return current_block_; } | 1061 HBasicBlock* current_block() const { return current_block_; } |
| 1028 void set_current_block(HBasicBlock* block) { current_block_ = block; } | 1062 void set_current_block(HBasicBlock* block) { current_block_ = block; } |
| 1029 HEnvironment* environment() const { | 1063 HEnvironment* environment() const { |
| 1030 return current_block()->last_environment(); | 1064 return current_block()->last_environment(); |
| 1031 } | 1065 } |
| 1032 Zone* zone() const { return info_->zone(); } | 1066 Zone* zone() const { return info_->zone(); } |
| 1033 HGraph* graph() const { return graph_; } | 1067 HGraph* graph() const { return graph_; } |
| 1034 Isolate* isolate() const { return graph_->isolate(); } | 1068 Isolate* isolate() const { return graph_->isolate(); } |
| 1035 CompilationInfo* top_info() { return info_; } | 1069 CompilationInfo* top_info() { return info_; } |
| 1036 | 1070 |
| 1037 HGraph* CreateGraph(); | 1071 HGraph* CreateGraph(); |
| 1038 | 1072 |
| 1039 // Bailout environment manipulation. | 1073 // Bailout environment manipulation. |
| 1040 void Push(HValue* value) { environment()->Push(value); } | 1074 void Push(HValue* value) { environment()->Push(value); } |
| 1041 HValue* Pop() { return environment()->Pop(); } | 1075 HValue* Pop() { return environment()->Pop(); } |
| 1042 | 1076 |
| 1043 virtual HValue* context() = 0; | 1077 virtual HValue* context() = 0; |
| 1044 | 1078 |
| 1045 // Adding instructions. | 1079 // Adding instructions. |
| 1046 HInstruction* AddInstruction(HInstruction* instr); | 1080 HInstruction* AddInstruction(HInstruction* instr); |
| 1047 void FinishCurrentBlock(HControlInstruction* last); | 1081 void FinishCurrentBlock(HControlInstruction* last); |
| 1048 void FinishExitCurrentBlock(HControlInstruction* instruction); | 1082 void FinishExitCurrentBlock(HControlInstruction* instruction); |
| 1049 | 1083 |
| 1050 void Goto(HBasicBlock* from, | 1084 void Goto(HBasicBlock* from, |
| 1051 HBasicBlock* target, | 1085 HBasicBlock* target, |
| 1052 FunctionState* state = NULL, | 1086 FunctionState* state = NULL, |
| 1053 bool add_simulate = true) { | 1087 bool add_simulate = true) { |
| 1054 from->Goto(target, position_, state, add_simulate); | 1088 from->Goto(target, source_position(), state, add_simulate); |
| 1055 } | 1089 } |
| 1056 void Goto(HBasicBlock* target, | 1090 void Goto(HBasicBlock* target, |
| 1057 FunctionState* state = NULL, | 1091 FunctionState* state = NULL, |
| 1058 bool add_simulate = true) { | 1092 bool add_simulate = true) { |
| 1059 Goto(current_block(), target, state, add_simulate); | 1093 Goto(current_block(), target, state, add_simulate); |
| 1060 } | 1094 } |
| 1061 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { | 1095 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { |
| 1062 Goto(from, target, NULL, false); | 1096 Goto(from, target, NULL, false); |
| 1063 } | 1097 } |
| 1064 void GotoNoSimulate(HBasicBlock* target) { | 1098 void GotoNoSimulate(HBasicBlock* target) { |
| 1065 Goto(target, NULL, false); | 1099 Goto(target, NULL, false); |
| 1066 } | 1100 } |
| 1067 void AddLeaveInlined(HBasicBlock* block, | 1101 void AddLeaveInlined(HBasicBlock* block, |
| 1068 HValue* return_value, | 1102 HValue* return_value, |
| 1069 FunctionState* state) { | 1103 FunctionState* state) { |
| 1070 block->AddLeaveInlined(return_value, state, position_); | 1104 block->AddLeaveInlined(return_value, state, source_position()); |
| 1071 } | 1105 } |
| 1072 void AddLeaveInlined(HValue* return_value, FunctionState* state) { | 1106 void AddLeaveInlined(HValue* return_value, FunctionState* state) { |
| 1073 return AddLeaveInlined(current_block(), return_value, state); | 1107 return AddLeaveInlined(current_block(), return_value, state); |
| 1074 } | 1108 } |
| 1075 | 1109 |
| 1076 template<class I> | 1110 template<class I> |
| 1077 HInstruction* NewUncasted() { return I::New(zone(), context()); } | 1111 HInstruction* NewUncasted() { return I::New(zone(), context()); } |
| 1078 | 1112 |
| 1079 template<class I> | 1113 template<class I> |
| 1080 I* New() { return I::New(zone(), context()); } | 1114 I* New() { return I::New(zone(), context()); } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 } | 1300 } |
| 1267 | 1301 |
| 1268 template<class I, class P1, class P2, class P3, class P4, | 1302 template<class I, class P1, class P2, class P3, class P4, |
| 1269 class P5, class P6, class P7, class P8> | 1303 class P5, class P6, class P7, class P8> |
| 1270 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { | 1304 I* Add(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) { |
| 1271 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8)); | 1305 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8)); |
| 1272 } | 1306 } |
| 1273 | 1307 |
| 1274 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); | 1308 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); |
| 1275 | 1309 |
| 1276 int position() const { return position_; } | |
| 1277 | |
| 1278 protected: | 1310 protected: |
| 1279 virtual bool BuildGraph() = 0; | 1311 virtual bool BuildGraph() = 0; |
| 1280 | 1312 |
| 1281 HBasicBlock* CreateBasicBlock(HEnvironment* env); | 1313 HBasicBlock* CreateBasicBlock(HEnvironment* env); |
| 1282 HBasicBlock* CreateLoopHeaderBlock(); | 1314 HBasicBlock* CreateLoopHeaderBlock(); |
| 1283 | 1315 |
| 1284 HValue* BuildCheckHeapObject(HValue* object); | 1316 HValue* BuildCheckHeapObject(HValue* object); |
| 1285 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); | 1317 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); |
| 1286 HValue* BuildCheckString(HValue* string); | 1318 HValue* BuildCheckString(HValue* string); |
| 1287 HValue* BuildWrapReceiver(HValue* object, HValue* function); | 1319 HValue* BuildWrapReceiver(HValue* object, HValue* function); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1765 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, | 1797 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, |
| 1766 Handle<JSObject> holder); | 1798 Handle<JSObject> holder); |
| 1767 | 1799 |
| 1768 HInstruction* BuildGetNativeContext(HValue* closure); | 1800 HInstruction* BuildGetNativeContext(HValue* closure); |
| 1769 HInstruction* BuildGetNativeContext(); | 1801 HInstruction* BuildGetNativeContext(); |
| 1770 HInstruction* BuildGetArrayFunction(); | 1802 HInstruction* BuildGetArrayFunction(); |
| 1771 | 1803 |
| 1772 protected: | 1804 protected: |
| 1773 void SetSourcePosition(int position) { | 1805 void SetSourcePosition(int position) { |
| 1774 ASSERT(position != RelocInfo::kNoPosition); | 1806 ASSERT(position != RelocInfo::kNoPosition); |
| 1807 position_.set_position(position - start_position_); | |
| 1808 } | |
| 1809 | |
| 1810 void EnterInlinedSource(int start_position, int id) { | |
| 1811 if (FLAG_hydrogen_track_positions) { | |
| 1812 start_position_ = start_position; | |
| 1813 position_.set_inlining_id(id); | |
| 1814 } | |
| 1815 } | |
| 1816 | |
| 1817 // Convert the given absolute offset from the start of the script to | |
| 1818 // the HSourcePosition assuming that this position corresponds to the | |
| 1819 // same function as current position_. | |
| 1820 HSourcePosition ScriptPositionToSourcePosition(int position) { | |
| 1821 HSourcePosition pos = position_; | |
| 1822 pos.set_position(position - start_position_); | |
| 1823 return pos; | |
| 1824 } | |
| 1825 | |
| 1826 HSourcePosition source_position() { return position_; } | |
| 1827 void set_source_position(HSourcePosition position) { | |
| 1775 position_ = position; | 1828 position_ = position; |
| 1776 } | 1829 } |
| 1777 | 1830 |
| 1778 template <typename ViewClass> | 1831 template <typename ViewClass> |
| 1779 void BuildArrayBufferViewInitialization(HValue* obj, | 1832 void BuildArrayBufferViewInitialization(HValue* obj, |
| 1780 HValue* buffer, | 1833 HValue* buffer, |
| 1781 HValue* byte_offset, | 1834 HValue* byte_offset, |
| 1782 HValue* byte_length); | 1835 HValue* byte_length); |
| 1783 | 1836 |
| 1784 private: | 1837 private: |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1795 HBasicBlock* continuation); | 1848 HBasicBlock* continuation); |
| 1796 | 1849 |
| 1797 template <class I> | 1850 template <class I> |
| 1798 I* AddInstructionTyped(I* instr) { | 1851 I* AddInstructionTyped(I* instr) { |
| 1799 return I::cast(AddInstruction(instr)); | 1852 return I::cast(AddInstruction(instr)); |
| 1800 } | 1853 } |
| 1801 | 1854 |
| 1802 CompilationInfo* info_; | 1855 CompilationInfo* info_; |
| 1803 HGraph* graph_; | 1856 HGraph* graph_; |
| 1804 HBasicBlock* current_block_; | 1857 HBasicBlock* current_block_; |
| 1805 int position_; | 1858 HSourcePosition position_; |
| 1859 int start_position_; | |
| 1806 }; | 1860 }; |
| 1807 | 1861 |
| 1808 | 1862 |
| 1809 template<> | 1863 template<> |
| 1810 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( | 1864 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( |
| 1811 const char* reason, Deoptimizer::BailoutType type) { | 1865 const char* reason, Deoptimizer::BailoutType type) { |
| 1812 if (type == Deoptimizer::SOFT) { | 1866 if (type == Deoptimizer::SOFT) { |
| 1813 isolate()->counters()->soft_deopts_requested()->Increment(); | 1867 isolate()->counters()->soft_deopts_requested()->Increment(); |
| 1814 if (FLAG_always_opt) return NULL; | 1868 if (FLAG_always_opt) return NULL; |
| 1815 } | 1869 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2026 static const int kUnlimitedMaxInlinedSourceSize = 100000; | 2080 static const int kUnlimitedMaxInlinedSourceSize = 100000; |
| 2027 static const int kUnlimitedMaxInlinedNodes = 10000; | 2081 static const int kUnlimitedMaxInlinedNodes = 10000; |
| 2028 static const int kUnlimitedMaxInlinedNodesCumulative = 10000; | 2082 static const int kUnlimitedMaxInlinedNodesCumulative = 10000; |
| 2029 | 2083 |
| 2030 // Maximum depth and total number of elements and properties for literal | 2084 // Maximum depth and total number of elements and properties for literal |
| 2031 // graphs to be considered for fast deep-copying. | 2085 // graphs to be considered for fast deep-copying. |
| 2032 static const int kMaxFastLiteralDepth = 3; | 2086 static const int kMaxFastLiteralDepth = 3; |
| 2033 static const int kMaxFastLiteralProperties = 8; | 2087 static const int kMaxFastLiteralProperties = 8; |
| 2034 | 2088 |
| 2035 // Simple accessors. | 2089 // Simple accessors. |
| 2036 void set_function_state(FunctionState* state) { function_state_ = state; } | 2090 void set_function_state(FunctionState* state) { |
| 2091 function_state_ = state; | |
|
Yang
2014/02/12 17:32:06
stray edit?
Vyacheslav Egorov (Chromium)
2014/02/13 16:17:43
Done.
| |
| 2092 } | |
| 2037 | 2093 |
| 2038 AstContext* ast_context() const { return ast_context_; } | 2094 AstContext* ast_context() const { return ast_context_; } |
| 2039 void set_ast_context(AstContext* context) { ast_context_ = context; } | 2095 void set_ast_context(AstContext* context) { ast_context_ = context; } |
| 2040 | 2096 |
| 2041 // Accessors forwarded to the function state. | 2097 // Accessors forwarded to the function state. |
| 2042 CompilationInfo* current_info() const { | 2098 CompilationInfo* current_info() const { |
| 2043 return function_state()->compilation_info(); | 2099 return function_state()->compilation_info(); |
| 2044 } | 2100 } |
| 2045 AstContext* call_context() const { | 2101 AstContext* call_context() const { |
| 2046 return function_state()->call_context(); | 2102 return function_state()->call_context(); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2197 | 2253 |
| 2198 HValue* ImplicitReceiverFor(HValue* function, | 2254 HValue* ImplicitReceiverFor(HValue* function, |
| 2199 Handle<JSFunction> target); | 2255 Handle<JSFunction> target); |
| 2200 | 2256 |
| 2201 int InliningAstSize(Handle<JSFunction> target); | 2257 int InliningAstSize(Handle<JSFunction> target); |
| 2202 bool TryInline(Handle<JSFunction> target, | 2258 bool TryInline(Handle<JSFunction> target, |
| 2203 int arguments_count, | 2259 int arguments_count, |
| 2204 HValue* implicit_return_value, | 2260 HValue* implicit_return_value, |
| 2205 BailoutId ast_id, | 2261 BailoutId ast_id, |
| 2206 BailoutId return_id, | 2262 BailoutId return_id, |
| 2207 InliningKind inlining_kind); | 2263 InliningKind inlining_kind, |
| 2264 HSourcePosition position); | |
| 2208 | 2265 |
| 2209 bool TryInlineCall(Call* expr, bool drop_extra = false); | 2266 bool TryInlineCall(Call* expr, bool drop_extra = false); |
| 2210 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); | 2267 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); |
| 2211 bool TryInlineGetter(Handle<JSFunction> getter, | 2268 bool TryInlineGetter(Handle<JSFunction> getter, |
| 2212 BailoutId ast_id, | 2269 BailoutId ast_id, |
| 2213 BailoutId return_id); | 2270 BailoutId return_id); |
| 2214 bool TryInlineSetter(Handle<JSFunction> setter, | 2271 bool TryInlineSetter(Handle<JSFunction> setter, |
| 2215 BailoutId id, | 2272 BailoutId id, |
| 2216 BailoutId assignment_id, | 2273 BailoutId assignment_id, |
| 2217 HValue* implicit_return_value); | 2274 HValue* implicit_return_value); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2364 Handle<String> check); | 2421 Handle<String> check); |
| 2365 void HandleLiteralCompareNil(CompareOperation* expr, | 2422 void HandleLiteralCompareNil(CompareOperation* expr, |
| 2366 Expression* sub_expr, | 2423 Expression* sub_expr, |
| 2367 NilValue nil); | 2424 NilValue nil); |
| 2368 HControlInstruction* BuildCompareInstruction(Token::Value op, | 2425 HControlInstruction* BuildCompareInstruction(Token::Value op, |
| 2369 HValue* left, | 2426 HValue* left, |
| 2370 HValue* right, | 2427 HValue* right, |
| 2371 Type* left_type, | 2428 Type* left_type, |
| 2372 Type* right_type, | 2429 Type* right_type, |
| 2373 Type* combined_type, | 2430 Type* combined_type, |
| 2374 int left_position, | 2431 HSourcePosition left_position, |
| 2375 int right_position, | 2432 HSourcePosition right_position, |
| 2376 BailoutId bailout_id); | 2433 BailoutId bailout_id); |
| 2377 | 2434 |
| 2378 HInstruction* BuildStringCharCodeAt(HValue* string, | 2435 HInstruction* BuildStringCharCodeAt(HValue* string, |
| 2379 HValue* index); | 2436 HValue* index); |
| 2380 HValue* BuildBinaryOperation(BinaryOperation* expr, | 2437 HValue* BuildBinaryOperation(BinaryOperation* expr, |
| 2381 HValue* left, | 2438 HValue* left, |
| 2382 HValue* right); | 2439 HValue* right); |
| 2383 HInstruction* BuildIncrement(bool returns_original_input, | 2440 HInstruction* BuildIncrement(bool returns_original_input, |
| 2384 CountOperation* expr); | 2441 CountOperation* expr); |
| 2385 HInstruction* BuildLoadKeyedGeneric(HValue* object, | 2442 HInstruction* BuildLoadKeyedGeneric(HValue* object, |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2696 } | 2753 } |
| 2697 | 2754 |
| 2698 private: | 2755 private: |
| 2699 HGraphBuilder* builder_; | 2756 HGraphBuilder* builder_; |
| 2700 }; | 2757 }; |
| 2701 | 2758 |
| 2702 | 2759 |
| 2703 } } // namespace v8::internal | 2760 } } // namespace v8::internal |
| 2704 | 2761 |
| 2705 #endif // V8_HYDROGEN_H_ | 2762 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |