Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/hydrogen.h

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 bool EqualToOrDominates(HBasicBlock* other) const;
115 int LoopNestingDepth() const; 116 int LoopNestingDepth() const;
116 117
117 void SetInitialEnvironment(HEnvironment* env); 118 void SetInitialEnvironment(HEnvironment* env);
118 void ClearEnvironment() { 119 void ClearEnvironment() {
119 ASSERT(IsFinished()); 120 ASSERT(IsFinished());
120 ASSERT(end()->SuccessorCount() == 0); 121 ASSERT(end()->SuccessorCount() == 0);
121 last_environment_ = NULL; 122 last_environment_ = NULL;
122 } 123 }
123 bool HasEnvironment() const { return last_environment_ != NULL; } 124 bool HasEnvironment() const { return last_environment_ != NULL; }
124 void UpdateEnvironment(HEnvironment* env); 125 void UpdateEnvironment(HEnvironment* env);
125 HBasicBlock* parent_loop_header() const { return parent_loop_header_; } 126 HBasicBlock* parent_loop_header() const { return parent_loop_header_; }
126 127
127 void set_parent_loop_header(HBasicBlock* block) { 128 void set_parent_loop_header(HBasicBlock* block) {
128 ASSERT(parent_loop_header_ == NULL); 129 ASSERT(parent_loop_header_ == NULL);
129 parent_loop_header_ = block; 130 parent_loop_header_ = block;
130 } 131 }
131 132
132 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; } 133 bool HasParentLoopHeader() const { return parent_loop_header_ != NULL; }
133 134
134 void SetJoinId(BailoutId ast_id); 135 void SetJoinId(BailoutId ast_id);
135 136
136 int PredecessorIndexOf(HBasicBlock* predecessor) const; 137 int PredecessorIndexOf(HBasicBlock* predecessor) const;
137 HPhi* AddNewPhi(int merged_index); 138 HPhi* AddNewPhi(int merged_index);
138 HSimulate* AddNewSimulate(BailoutId ast_id, 139 HSimulate* AddNewSimulate(BailoutId ast_id,
139 int position, 140 HSourcePosition position,
140 RemovableSimulate removable = FIXED_SIMULATE) { 141 RemovableSimulate removable = FIXED_SIMULATE) {
141 HSimulate* instr = CreateSimulate(ast_id, removable); 142 HSimulate* instr = CreateSimulate(ast_id, removable);
142 AddInstruction(instr, position); 143 AddInstruction(instr, position);
143 return instr; 144 return instr;
144 } 145 }
145 void AssignCommonDominator(HBasicBlock* other); 146 void AssignCommonDominator(HBasicBlock* other);
146 void AssignLoopSuccessorDominators(); 147 void AssignLoopSuccessorDominators();
147 148
148 // If a target block is tagged as an inline function return, all 149 // If a target block is tagged as an inline function return, all
149 // predecessors should contain the inlined exit sequence: 150 // predecessors should contain the inlined exit sequence:
(...skipping 16 matching lines...) Expand all
166 bool IsUnreachable() const { return !is_reachable_; } 167 bool IsUnreachable() const { return !is_reachable_; }
167 bool IsReachable() const { return is_reachable_; } 168 bool IsReachable() const { return is_reachable_; }
168 169
169 bool IsLoopSuccessorDominator() const { 170 bool IsLoopSuccessorDominator() const {
170 return dominates_loop_successors_; 171 return dominates_loop_successors_;
171 } 172 }
172 void MarkAsLoopSuccessorDominator() { 173 void MarkAsLoopSuccessorDominator() {
173 dominates_loop_successors_ = true; 174 dominates_loop_successors_ = true;
174 } 175 }
175 176
177 void MarkSuccEdgeUnreachable(int succ);
178
176 inline Zone* zone() const; 179 inline Zone* zone() const;
177 180
178 #ifdef DEBUG 181 #ifdef DEBUG
179 void Verify(); 182 void Verify();
180 #endif 183 #endif
181 184
182 protected: 185 protected:
183 friend class HGraphBuilder; 186 friend class HGraphBuilder;
184 187
185 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable); 188 HSimulate* CreateSimulate(BailoutId ast_id, RemovableSimulate removable);
186 void Finish(HControlInstruction* last, int position); 189 void Finish(HControlInstruction* last, HSourcePosition position);
187 void FinishExit(HControlInstruction* instruction, int position); 190 void FinishExit(HControlInstruction* instruction, HSourcePosition position);
188 void Goto(HBasicBlock* block, 191 void Goto(HBasicBlock* block,
189 int position, 192 HSourcePosition position,
190 FunctionState* state = NULL, 193 FunctionState* state = NULL,
191 bool add_simulate = true); 194 bool add_simulate = true);
192 void GotoNoSimulate(HBasicBlock* block, int position) { 195 void GotoNoSimulate(HBasicBlock* block, HSourcePosition position) {
193 Goto(block, position, NULL, false); 196 Goto(block, position, NULL, false);
194 } 197 }
195 198
196 // Add the inlined function exit sequence, adding an HLeaveInlined 199 // Add the inlined function exit sequence, adding an HLeaveInlined
197 // instruction and updating the bailout environment. 200 // instruction and updating the bailout environment.
198 void AddLeaveInlined(HValue* return_value, 201 void AddLeaveInlined(HValue* return_value,
199 FunctionState* state, 202 FunctionState* state,
200 int position); 203 HSourcePosition position);
201 204
202 private: 205 private:
203 void RegisterPredecessor(HBasicBlock* pred); 206 void RegisterPredecessor(HBasicBlock* pred);
204 void AddDominatedBlock(HBasicBlock* block); 207 void AddDominatedBlock(HBasicBlock* block);
205 208
206 int block_id_; 209 int block_id_;
207 HGraph* graph_; 210 HGraph* graph_;
208 ZoneList<HPhi*> phis_; 211 ZoneList<HPhi*> phis_;
209 HInstruction* first_; 212 HInstruction* first_;
210 HInstruction* last_; 213 HInstruction* last_;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 if (uint32_instructions_ == NULL) { 464 if (uint32_instructions_ == NULL) {
462 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); 465 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone());
463 } 466 }
464 uint32_instructions_->Add(instr, zone()); 467 uint32_instructions_->Add(instr, zone());
465 } 468 }
466 469
467 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; } 470 void IncrementInNoSideEffectsScope() { no_side_effects_scope_count_++; }
468 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; } 471 void DecrementInNoSideEffectsScope() { no_side_effects_scope_count_--; }
469 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; } 472 bool IsInsideNoSideEffectsScope() { return no_side_effects_scope_count_ > 0; }
470 473
474 // If we are tracking source positions then this function assigns a unique
475 // identifier to each inlining and dumps function source if it was inlined
476 // for the first time during the current optimization.
477 int TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
478 HSourcePosition position);
479
480 // Converts given HSourcePosition to the absolute offset from the start of
481 // the corresponding script.
482 int SourcePositionToScriptPosition(HSourcePosition position);
483
471 private: 484 private:
472 HConstant* ReinsertConstantIfNecessary(HConstant* constant); 485 HConstant* ReinsertConstantIfNecessary(HConstant* constant);
473 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, 486 HConstant* GetConstant(SetOncePointer<HConstant>* pointer,
474 int32_t integer_value); 487 int32_t integer_value);
475 488
476 template<class Phase> 489 template<class Phase>
477 void Run() { 490 void Run() {
478 Phase phase(this); 491 Phase phase(this);
479 phase.Run(); 492 phase.Run();
480 } 493 }
(...skipping 25 matching lines...) Expand all
506 Zone* zone_; 519 Zone* zone_;
507 520
508 bool is_recursive_; 521 bool is_recursive_;
509 bool use_optimistic_licm_; 522 bool use_optimistic_licm_;
510 bool depends_on_empty_array_proto_elements_; 523 bool depends_on_empty_array_proto_elements_;
511 int type_change_checksum_; 524 int type_change_checksum_;
512 int maximum_environment_size_; 525 int maximum_environment_size_;
513 int no_side_effects_scope_count_; 526 int no_side_effects_scope_count_;
514 bool disallow_adding_new_values_; 527 bool disallow_adding_new_values_;
515 528
529 class InlinedFunctionInfo {
530 public:
531 explicit InlinedFunctionInfo(Handle<SharedFunctionInfo> shared)
532 : shared_(shared), start_position_(shared->start_position()) {
533 }
534
535 Handle<SharedFunctionInfo> shared() const { return shared_; }
536 int start_position() const { return start_position_; }
537
538 private:
539 Handle<SharedFunctionInfo> shared_;
540 int start_position_;
541 };
542
543 int next_inline_id_;
544 ZoneList<InlinedFunctionInfo> inlined_functions_;
545
516 DISALLOW_COPY_AND_ASSIGN(HGraph); 546 DISALLOW_COPY_AND_ASSIGN(HGraph);
517 }; 547 };
518 548
519 549
520 Zone* HBasicBlock::zone() const { return graph_->zone(); } 550 Zone* HBasicBlock::zone() const { return graph_->zone(); }
521 551
522 552
523 // Type of stack frame an environment might refer to. 553 // Type of stack frame an environment might refer to.
524 enum FrameType { 554 enum FrameType {
525 JS_FUNCTION, 555 JS_FUNCTION,
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 Expression* condition_; 902 Expression* condition_;
873 HBasicBlock* if_true_; 903 HBasicBlock* if_true_;
874 HBasicBlock* if_false_; 904 HBasicBlock* if_false_;
875 }; 905 };
876 906
877 907
878 class FunctionState V8_FINAL { 908 class FunctionState V8_FINAL {
879 public: 909 public:
880 FunctionState(HOptimizedGraphBuilder* owner, 910 FunctionState(HOptimizedGraphBuilder* owner,
881 CompilationInfo* info, 911 CompilationInfo* info,
882 InliningKind inlining_kind); 912 InliningKind inlining_kind,
913 int inlining_id);
883 ~FunctionState(); 914 ~FunctionState();
884 915
885 CompilationInfo* compilation_info() { return compilation_info_; } 916 CompilationInfo* compilation_info() { return compilation_info_; }
886 AstContext* call_context() { return call_context_; } 917 AstContext* call_context() { return call_context_; }
887 InliningKind inlining_kind() const { return inlining_kind_; } 918 InliningKind inlining_kind() const { return inlining_kind_; }
888 HBasicBlock* function_return() { return function_return_; } 919 HBasicBlock* function_return() { return function_return_; }
889 TestContext* test_context() { return test_context_; } 920 TestContext* test_context() { return test_context_; }
890 void ClearInlinedTestContext() { 921 void ClearInlinedTestContext() {
891 delete test_context_; 922 delete test_context_;
892 test_context_ = NULL; 923 test_context_ = NULL;
893 } 924 }
894 925
895 FunctionState* outer() { return outer_; } 926 FunctionState* outer() { return outer_; }
896 927
897 HEnterInlined* entry() { return entry_; } 928 HEnterInlined* entry() { return entry_; }
898 void set_entry(HEnterInlined* entry) { entry_ = entry; } 929 void set_entry(HEnterInlined* entry) { entry_ = entry; }
899 930
900 HArgumentsObject* arguments_object() { return arguments_object_; } 931 HArgumentsObject* arguments_object() { return arguments_object_; }
901 void set_arguments_object(HArgumentsObject* arguments_object) { 932 void set_arguments_object(HArgumentsObject* arguments_object) {
902 arguments_object_ = arguments_object; 933 arguments_object_ = arguments_object;
903 } 934 }
904 935
905 HArgumentsElements* arguments_elements() { return arguments_elements_; } 936 HArgumentsElements* arguments_elements() { return arguments_elements_; }
906 void set_arguments_elements(HArgumentsElements* arguments_elements) { 937 void set_arguments_elements(HArgumentsElements* arguments_elements) {
907 arguments_elements_ = arguments_elements; 938 arguments_elements_ = arguments_elements;
908 } 939 }
909 940
910 bool arguments_pushed() { return arguments_elements() != NULL; } 941 bool arguments_pushed() { return arguments_elements() != NULL; }
911 942
943 int inlining_id() const { return inlining_id_; }
944
912 private: 945 private:
913 HOptimizedGraphBuilder* owner_; 946 HOptimizedGraphBuilder* owner_;
914 947
915 CompilationInfo* compilation_info_; 948 CompilationInfo* compilation_info_;
916 949
917 // During function inlining, expression context of the call being 950 // During function inlining, expression context of the call being
918 // inlined. NULL when not inlining. 951 // inlined. NULL when not inlining.
919 AstContext* call_context_; 952 AstContext* call_context_;
920 953
921 // The kind of call which is currently being inlined. 954 // The kind of call which is currently being inlined.
922 InliningKind inlining_kind_; 955 InliningKind inlining_kind_;
923 956
924 // When inlining in an effect or value context, this is the return block. 957 // 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 958 // 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 959 // pair of return blocks in the context. When not inlining, there is no
927 // local return point. 960 // local return point.
928 HBasicBlock* function_return_; 961 HBasicBlock* function_return_;
929 962
930 // When inlining a call in a test context, a context containing a pair of 963 // When inlining a call in a test context, a context containing a pair of
931 // return blocks. NULL in all other cases. 964 // return blocks. NULL in all other cases.
932 TestContext* test_context_; 965 TestContext* test_context_;
933 966
934 // When inlining HEnterInlined instruction corresponding to the function 967 // When inlining HEnterInlined instruction corresponding to the function
935 // entry. 968 // entry.
936 HEnterInlined* entry_; 969 HEnterInlined* entry_;
937 970
938 HArgumentsObject* arguments_object_; 971 HArgumentsObject* arguments_object_;
939 HArgumentsElements* arguments_elements_; 972 HArgumentsElements* arguments_elements_;
940 973
974 int inlining_id_;
975 HSourcePosition outer_source_position_;
976
941 FunctionState* outer_; 977 FunctionState* outer_;
942 }; 978 };
943 979
944 980
945 class HIfContinuation V8_FINAL { 981 class HIfContinuation V8_FINAL {
946 public: 982 public:
947 HIfContinuation() 983 HIfContinuation()
948 : continuation_captured_(false), 984 : continuation_captured_(false),
949 true_branch_(NULL), 985 true_branch_(NULL),
950 false_branch_(NULL) {} 986 false_branch_(NULL) {}
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 PretenureFlag pretenure_flag_; 1050 PretenureFlag pretenure_flag_;
1015 }; 1051 };
1016 1052
1017 1053
1018 class HGraphBuilder { 1054 class HGraphBuilder {
1019 public: 1055 public:
1020 explicit HGraphBuilder(CompilationInfo* info) 1056 explicit HGraphBuilder(CompilationInfo* info)
1021 : info_(info), 1057 : info_(info),
1022 graph_(NULL), 1058 graph_(NULL),
1023 current_block_(NULL), 1059 current_block_(NULL),
1024 position_(RelocInfo::kNoPosition) {} 1060 position_(HSourcePosition::Unknown()),
1061 start_position_(0) {}
1025 virtual ~HGraphBuilder() {} 1062 virtual ~HGraphBuilder() {}
1026 1063
1027 HBasicBlock* current_block() const { return current_block_; } 1064 HBasicBlock* current_block() const { return current_block_; }
1028 void set_current_block(HBasicBlock* block) { current_block_ = block; } 1065 void set_current_block(HBasicBlock* block) { current_block_ = block; }
1029 HEnvironment* environment() const { 1066 HEnvironment* environment() const {
1030 return current_block()->last_environment(); 1067 return current_block()->last_environment();
1031 } 1068 }
1032 Zone* zone() const { return info_->zone(); } 1069 Zone* zone() const { return info_->zone(); }
1033 HGraph* graph() const { return graph_; } 1070 HGraph* graph() const { return graph_; }
1034 Isolate* isolate() const { return graph_->isolate(); } 1071 Isolate* isolate() const { return graph_->isolate(); }
1035 CompilationInfo* top_info() { return info_; } 1072 CompilationInfo* top_info() { return info_; }
1036 1073
1037 HGraph* CreateGraph(); 1074 HGraph* CreateGraph();
1038 1075
1039 // Bailout environment manipulation. 1076 // Bailout environment manipulation.
1040 void Push(HValue* value) { environment()->Push(value); } 1077 void Push(HValue* value) { environment()->Push(value); }
1041 HValue* Pop() { return environment()->Pop(); } 1078 HValue* Pop() { return environment()->Pop(); }
1042 1079
1043 virtual HValue* context() = 0; 1080 virtual HValue* context() = 0;
1044 1081
1045 // Adding instructions. 1082 // Adding instructions.
1046 HInstruction* AddInstruction(HInstruction* instr); 1083 HInstruction* AddInstruction(HInstruction* instr);
1047 void FinishCurrentBlock(HControlInstruction* last); 1084 void FinishCurrentBlock(HControlInstruction* last);
1048 void FinishExitCurrentBlock(HControlInstruction* instruction); 1085 void FinishExitCurrentBlock(HControlInstruction* instruction);
1049 1086
1050 void Goto(HBasicBlock* from, 1087 void Goto(HBasicBlock* from,
1051 HBasicBlock* target, 1088 HBasicBlock* target,
1052 FunctionState* state = NULL, 1089 FunctionState* state = NULL,
1053 bool add_simulate = true) { 1090 bool add_simulate = true) {
1054 from->Goto(target, position_, state, add_simulate); 1091 from->Goto(target, source_position(), state, add_simulate);
1055 } 1092 }
1056 void Goto(HBasicBlock* target, 1093 void Goto(HBasicBlock* target,
1057 FunctionState* state = NULL, 1094 FunctionState* state = NULL,
1058 bool add_simulate = true) { 1095 bool add_simulate = true) {
1059 Goto(current_block(), target, state, add_simulate); 1096 Goto(current_block(), target, state, add_simulate);
1060 } 1097 }
1061 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) { 1098 void GotoNoSimulate(HBasicBlock* from, HBasicBlock* target) {
1062 Goto(from, target, NULL, false); 1099 Goto(from, target, NULL, false);
1063 } 1100 }
1064 void GotoNoSimulate(HBasicBlock* target) { 1101 void GotoNoSimulate(HBasicBlock* target) {
1065 Goto(target, NULL, false); 1102 Goto(target, NULL, false);
1066 } 1103 }
1067 void AddLeaveInlined(HBasicBlock* block, 1104 void AddLeaveInlined(HBasicBlock* block,
1068 HValue* return_value, 1105 HValue* return_value,
1069 FunctionState* state) { 1106 FunctionState* state) {
1070 block->AddLeaveInlined(return_value, state, position_); 1107 block->AddLeaveInlined(return_value, state, source_position());
1071 } 1108 }
1072 void AddLeaveInlined(HValue* return_value, FunctionState* state) { 1109 void AddLeaveInlined(HValue* return_value, FunctionState* state) {
1073 return AddLeaveInlined(current_block(), return_value, state); 1110 return AddLeaveInlined(current_block(), return_value, state);
1074 } 1111 }
1075 1112
1076 template<class I> 1113 template<class I>
1077 HInstruction* NewUncasted() { return I::New(zone(), context()); } 1114 HInstruction* NewUncasted() { return I::New(zone(), context()); }
1078 1115
1079 template<class I> 1116 template<class I>
1080 I* New() { return I::New(zone(), context()); } 1117 I* New() { return I::New(zone(), context()); }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 } 1303 }
1267 1304
1268 template<class I, class P1, class P2, class P3, class P4, 1305 template<class I, class P1, class P2, class P3, class P4,
1269 class P5, class P6, class P7, class P8> 1306 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) { 1307 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)); 1308 return AddInstructionTyped(New<I>(p1, p2, p3, p4, p5, p6, p7, p8));
1272 } 1309 }
1273 1310
1274 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE); 1311 void AddSimulate(BailoutId id, RemovableSimulate removable = FIXED_SIMULATE);
1275 1312
1276 int position() const { return position_; }
1277
1278 protected: 1313 protected:
1279 virtual bool BuildGraph() = 0; 1314 virtual bool BuildGraph() = 0;
1280 1315
1281 HBasicBlock* CreateBasicBlock(HEnvironment* env); 1316 HBasicBlock* CreateBasicBlock(HEnvironment* env);
1282 HBasicBlock* CreateLoopHeaderBlock(); 1317 HBasicBlock* CreateLoopHeaderBlock();
1283 1318
1284 HValue* BuildCheckHeapObject(HValue* object); 1319 HValue* BuildCheckHeapObject(HValue* object);
1285 HValue* BuildCheckMap(HValue* obj, Handle<Map> map); 1320 HValue* BuildCheckMap(HValue* obj, Handle<Map> map);
1286 HValue* BuildCheckString(HValue* string); 1321 HValue* BuildCheckString(HValue* string);
1287 HValue* BuildWrapReceiver(HValue* object, HValue* function); 1322 HValue* BuildWrapReceiver(HValue* object, HValue* function);
1288 1323
1289 // Building common constructs 1324 // Building common constructs
1290 HValue* BuildCheckForCapacityGrow(HValue* object, 1325 HValue* BuildCheckForCapacityGrow(HValue* object,
1291 HValue* elements, 1326 HValue* elements,
1292 ElementsKind kind, 1327 ElementsKind kind,
1293 HValue* length, 1328 HValue* length,
1294 HValue* key, 1329 HValue* key,
1295 bool is_js_array, 1330 bool is_js_array,
1296 bool is_store); 1331 PropertyAccessType access_type);
1297 1332
1298 HValue* BuildCopyElementsOnWrite(HValue* object, 1333 HValue* BuildCopyElementsOnWrite(HValue* object,
1299 HValue* elements, 1334 HValue* elements,
1300 ElementsKind kind, 1335 ElementsKind kind,
1301 HValue* length); 1336 HValue* length);
1302 1337
1303 void BuildTransitionElementsKind(HValue* object, 1338 void BuildTransitionElementsKind(HValue* object,
1304 HValue* map, 1339 HValue* map,
1305 ElementsKind from_kind, 1340 ElementsKind from_kind,
1306 ElementsKind to_kind, 1341 ElementsKind to_kind,
1307 bool is_jsarray); 1342 bool is_jsarray);
1308 1343
1309 HValue* BuildNumberToString(HValue* object, Handle<Type> type); 1344 HValue* BuildNumberToString(HValue* object, Type* type);
1310 1345
1311 HValue* BuildUncheckedDictionaryElementLoad(HValue* receiver, 1346 HValue* BuildUncheckedDictionaryElementLoad(HValue* receiver,
1312 HValue* key); 1347 HValue* key);
1313 1348
1349 HValue* BuildRegExpConstructResult(HValue* length,
1350 HValue* index,
1351 HValue* input);
1352
1314 // Allocates a new object according with the given allocation properties. 1353 // Allocates a new object according with the given allocation properties.
1315 HAllocate* BuildAllocate(HValue* object_size, 1354 HAllocate* BuildAllocate(HValue* object_size,
1316 HType type, 1355 HType type,
1317 InstanceType instance_type, 1356 InstanceType instance_type,
1318 HAllocationMode allocation_mode); 1357 HAllocationMode allocation_mode);
1319 // Computes the sum of two string lengths, taking care of overflow handling. 1358 // Computes the sum of two string lengths, taking care of overflow handling.
1320 HValue* BuildAddStringLengths(HValue* left_length, HValue* right_length); 1359 HValue* BuildAddStringLengths(HValue* left_length, HValue* right_length);
1321 // Creates a cons string using the two input strings. 1360 // Creates a cons string using the two input strings.
1322 HValue* BuildCreateConsString(HValue* length, 1361 HValue* BuildCreateConsString(HValue* length,
1323 HValue* left, 1362 HValue* left,
(...skipping 15 matching lines...) Expand all
1339 HValue* BuildStringAdd(HValue* left, 1378 HValue* BuildStringAdd(HValue* left,
1340 HValue* right, 1379 HValue* right,
1341 HAllocationMode allocation_mode); 1380 HAllocationMode allocation_mode);
1342 1381
1343 HInstruction* BuildUncheckedMonomorphicElementAccess( 1382 HInstruction* BuildUncheckedMonomorphicElementAccess(
1344 HValue* checked_object, 1383 HValue* checked_object,
1345 HValue* key, 1384 HValue* key,
1346 HValue* val, 1385 HValue* val,
1347 bool is_js_array, 1386 bool is_js_array,
1348 ElementsKind elements_kind, 1387 ElementsKind elements_kind,
1349 bool is_store, 1388 PropertyAccessType access_type,
1350 LoadKeyedHoleMode load_mode, 1389 LoadKeyedHoleMode load_mode,
1351 KeyedAccessStoreMode store_mode); 1390 KeyedAccessStoreMode store_mode);
1352 1391
1353 HInstruction* AddElementAccess( 1392 HInstruction* AddElementAccess(
1354 HValue* elements, 1393 HValue* elements,
1355 HValue* checked_key, 1394 HValue* checked_key,
1356 HValue* val, 1395 HValue* val,
1357 HValue* dependency, 1396 HValue* dependency,
1358 ElementsKind elements_kind, 1397 ElementsKind elements_kind,
1359 bool is_store, 1398 PropertyAccessType access_type,
1360 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE); 1399 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE);
1361 1400
1362 HLoadNamedField* BuildLoadNamedField(HValue* object, HObjectAccess access);
1363 HInstruction* AddLoadNamedField(HValue* object, HObjectAccess access);
1364 HInstruction* AddLoadStringInstanceType(HValue* string); 1401 HInstruction* AddLoadStringInstanceType(HValue* string);
1365 HInstruction* AddLoadStringLength(HValue* string); 1402 HInstruction* AddLoadStringLength(HValue* string);
1366 HStoreNamedField* AddStoreMapNoWriteBarrier(HValue* object, HValue* map) { 1403 HStoreNamedField* AddStoreMapNoWriteBarrier(HValue* object, HValue* map) {
1367 HStoreNamedField* store_map = Add<HStoreNamedField>( 1404 HStoreNamedField* store_map = Add<HStoreNamedField>(
1368 object, HObjectAccess::ForMap(), map); 1405 object, HObjectAccess::ForMap(), map);
1369 store_map->SkipWriteBarrier(); 1406 store_map->SkipWriteBarrier();
1370 return store_map; 1407 return store_map;
1371 } 1408 }
1372 HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map> map); 1409 HStoreNamedField* AddStoreMapConstant(HValue* object, Handle<Map> map);
1373 HStoreNamedField* AddStoreMapConstantNoWriteBarrier(HValue* object, 1410 HStoreNamedField* AddStoreMapConstantNoWriteBarrier(HValue* object,
1374 Handle<Map> map) { 1411 Handle<Map> map) {
1375 HStoreNamedField* store_map = AddStoreMapConstant(object, map); 1412 HStoreNamedField* store_map = AddStoreMapConstant(object, map);
1376 store_map->SkipWriteBarrier(); 1413 store_map->SkipWriteBarrier();
1377 return store_map; 1414 return store_map;
1378 } 1415 }
1379 HLoadNamedField* AddLoadElements(HValue* object); 1416 HLoadNamedField* AddLoadElements(HValue* object);
1380 1417
1381 bool MatchRotateRight(HValue* left, 1418 bool MatchRotateRight(HValue* left,
1382 HValue* right, 1419 HValue* right,
1383 HValue** operand, 1420 HValue** operand,
1384 HValue** shift_amount); 1421 HValue** shift_amount);
1385 1422
1386 HValue* BuildBinaryOperation(Token::Value op, 1423 HValue* BuildBinaryOperation(Token::Value op,
1387 HValue* left, 1424 HValue* left,
1388 HValue* right, 1425 HValue* right,
1389 Handle<Type> left_type, 1426 Type* left_type,
1390 Handle<Type> right_type, 1427 Type* right_type,
1391 Handle<Type> result_type, 1428 Type* result_type,
1392 Maybe<int> fixed_right_arg, 1429 Maybe<int> fixed_right_arg,
1393 HAllocationMode allocation_mode); 1430 HAllocationMode allocation_mode);
1394 1431
1395 HLoadNamedField* AddLoadFixedArrayLength(HValue *object); 1432 HLoadNamedField* AddLoadFixedArrayLength(HValue *object);
1396 1433
1397 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin); 1434 HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin);
1398 1435
1399 HValue* EnforceNumberType(HValue* number, Handle<Type> expected); 1436 HValue* EnforceNumberType(HValue* number, Type* expected);
1400 HValue* TruncateToNumber(HValue* value, Handle<Type>* expected); 1437 HValue* TruncateToNumber(HValue* value, Type** expected);
1401 1438
1402 void FinishExitWithHardDeoptimization(const char* reason, 1439 void FinishExitWithHardDeoptimization(const char* reason);
1403 HBasicBlock* continuation);
1404 1440
1405 void AddIncrementCounter(StatsCounter* counter); 1441 void AddIncrementCounter(StatsCounter* counter);
1406 1442
1407 class IfBuilder V8_FINAL { 1443 class IfBuilder V8_FINAL {
1408 public: 1444 public:
1409 explicit IfBuilder(HGraphBuilder* builder); 1445 explicit IfBuilder(HGraphBuilder* builder);
1410 IfBuilder(HGraphBuilder* builder, 1446 IfBuilder(HGraphBuilder* builder,
1411 HIfContinuation* continuation); 1447 HIfContinuation* continuation);
1412 1448
1413 ~IfBuilder() { 1449 ~IfBuilder() {
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 HValue* BuildCloneShallowArray(HValue* boilerplate, 1782 HValue* BuildCloneShallowArray(HValue* boilerplate,
1747 HValue* allocation_site, 1783 HValue* allocation_site,
1748 AllocationSiteMode mode, 1784 AllocationSiteMode mode,
1749 ElementsKind kind, 1785 ElementsKind kind,
1750 int length); 1786 int length);
1751 1787
1752 HValue* BuildElementIndexHash(HValue* index); 1788 HValue* BuildElementIndexHash(HValue* index);
1753 1789
1754 void BuildCompareNil( 1790 void BuildCompareNil(
1755 HValue* value, 1791 HValue* value,
1756 Handle<Type> type, 1792 Type* type,
1757 HIfContinuation* continuation); 1793 HIfContinuation* continuation);
1758 1794
1759 void BuildCreateAllocationMemento(HValue* previous_object, 1795 void BuildCreateAllocationMemento(HValue* previous_object,
1760 HValue* previous_object_size, 1796 HValue* previous_object_size,
1761 HValue* payload); 1797 HValue* payload);
1762 1798
1763 HInstruction* BuildConstantMapCheck(Handle<JSObject> constant, 1799 HInstruction* BuildConstantMapCheck(Handle<JSObject> constant,
1764 CompilationInfo* info); 1800 CompilationInfo* info);
1765 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype, 1801 HInstruction* BuildCheckPrototypeMaps(Handle<JSObject> prototype,
1766 Handle<JSObject> holder); 1802 Handle<JSObject> holder);
1767 1803
1768 HInstruction* BuildGetNativeContext(HValue* closure); 1804 HInstruction* BuildGetNativeContext(HValue* closure);
1769 HInstruction* BuildGetNativeContext(); 1805 HInstruction* BuildGetNativeContext();
1770 HInstruction* BuildGetArrayFunction(); 1806 HInstruction* BuildGetArrayFunction();
1771 1807
1772 protected: 1808 protected:
1773 void SetSourcePosition(int position) { 1809 void SetSourcePosition(int position) {
1774 ASSERT(position != RelocInfo::kNoPosition); 1810 ASSERT(position != RelocInfo::kNoPosition);
1811 position_.set_position(position - start_position_);
1812 }
1813
1814 void EnterInlinedSource(int start_position, int id) {
1815 if (FLAG_hydrogen_track_positions) {
1816 start_position_ = start_position;
1817 position_.set_inlining_id(id);
1818 }
1819 }
1820
1821 // Convert the given absolute offset from the start of the script to
1822 // the HSourcePosition assuming that this position corresponds to the
1823 // same function as current position_.
1824 HSourcePosition ScriptPositionToSourcePosition(int position) {
1825 HSourcePosition pos = position_;
1826 pos.set_position(position - start_position_);
1827 return pos;
1828 }
1829
1830 HSourcePosition source_position() { return position_; }
1831 void set_source_position(HSourcePosition position) {
1775 position_ = position; 1832 position_ = position;
1776 } 1833 }
1777 1834
1778 template <typename ViewClass> 1835 template <typename ViewClass>
1779 void BuildArrayBufferViewInitialization(HValue* obj, 1836 void BuildArrayBufferViewInitialization(HValue* obj,
1780 HValue* buffer, 1837 HValue* buffer,
1781 HValue* byte_offset, 1838 HValue* byte_offset,
1782 HValue* byte_length); 1839 HValue* byte_length);
1783 1840
1784 private: 1841 private:
1785 HGraphBuilder(); 1842 HGraphBuilder();
1786 1843
1787 HValue* BuildUncheckedDictionaryElementLoadHelper( 1844 HValue* BuildUncheckedDictionaryElementLoadHelper(
1788 HValue* elements, 1845 HValue* elements,
1789 HValue* key, 1846 HValue* key,
1790 HValue* hash, 1847 HValue* hash,
1791 HValue* mask, 1848 HValue* mask,
1792 int current_probe); 1849 int current_probe);
1793 1850
1794 void PadEnvironmentForContinuation(HBasicBlock* from,
1795 HBasicBlock* continuation);
1796
1797 template <class I> 1851 template <class I>
1798 I* AddInstructionTyped(I* instr) { 1852 I* AddInstructionTyped(I* instr) {
1799 return I::cast(AddInstruction(instr)); 1853 return I::cast(AddInstruction(instr));
1800 } 1854 }
1801 1855
1802 CompilationInfo* info_; 1856 CompilationInfo* info_;
1803 HGraph* graph_; 1857 HGraph* graph_;
1804 HBasicBlock* current_block_; 1858 HBasicBlock* current_block_;
1805 int position_; 1859 HSourcePosition position_;
1860 int start_position_;
1806 }; 1861 };
1807 1862
1808 1863
1809 template<> 1864 template<>
1810 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>( 1865 inline HDeoptimize* HGraphBuilder::Add<HDeoptimize>(
1811 const char* reason, Deoptimizer::BailoutType type) { 1866 const char* reason, Deoptimizer::BailoutType type) {
1812 if (type == Deoptimizer::SOFT) { 1867 if (type == Deoptimizer::SOFT) {
1813 isolate()->counters()->soft_deopts_requested()->Increment(); 1868 isolate()->counters()->soft_deopts_requested()->Increment();
1814 if (FLAG_always_opt) return NULL; 1869 if (FLAG_always_opt) return NULL;
1815 } 1870 }
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); 2227 template <class Instruction> HInstruction* PreProcessCall(Instruction* call);
2173 void PushArgumentsFromEnvironment(int count); 2228 void PushArgumentsFromEnvironment(int count);
2174 2229
2175 void SetUpScope(Scope* scope); 2230 void SetUpScope(Scope* scope);
2176 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE; 2231 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE;
2177 2232
2178 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE; 2233 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE;
2179 AST_NODE_LIST(DECLARE_VISIT) 2234 AST_NODE_LIST(DECLARE_VISIT)
2180 #undef DECLARE_VISIT 2235 #undef DECLARE_VISIT
2181 2236
2237 Type* ToType(Handle<Map> map) { return IC::MapToType<Type>(map, zone()); }
2238
2182 private: 2239 private:
2183 // Helpers for flow graph construction. 2240 // Helpers for flow graph construction.
2184 enum GlobalPropertyAccess { 2241 enum GlobalPropertyAccess {
2185 kUseCell, 2242 kUseCell,
2186 kUseGeneric 2243 kUseGeneric
2187 }; 2244 };
2188 GlobalPropertyAccess LookupGlobalProperty(Variable* var, 2245 GlobalPropertyAccess LookupGlobalProperty(Variable* var,
2189 LookupResult* lookup, 2246 LookupResult* lookup,
2190 bool is_store); 2247 PropertyAccessType access_type);
2191 2248
2192 void EnsureArgumentsArePushedForAccess(); 2249 void EnsureArgumentsArePushedForAccess();
2193 bool TryArgumentsAccess(Property* expr); 2250 bool TryArgumentsAccess(Property* expr);
2194 2251
2195 // Try to optimize fun.apply(receiver, arguments) pattern. 2252 // Try to optimize fun.apply(receiver, arguments) pattern.
2196 bool TryCallApply(Call* expr); 2253 bool TryCallApply(Call* expr);
2197 2254
2198 HValue* ImplicitReceiverFor(HValue* function, 2255 HValue* ImplicitReceiverFor(HValue* function,
2199 Handle<JSFunction> target); 2256 Handle<JSFunction> target);
2200 2257
2201 int InliningAstSize(Handle<JSFunction> target); 2258 int InliningAstSize(Handle<JSFunction> target);
2202 bool TryInline(Handle<JSFunction> target, 2259 bool TryInline(Handle<JSFunction> target,
2203 int arguments_count, 2260 int arguments_count,
2204 HValue* implicit_return_value, 2261 HValue* implicit_return_value,
2205 BailoutId ast_id, 2262 BailoutId ast_id,
2206 BailoutId return_id, 2263 BailoutId return_id,
2207 InliningKind inlining_kind); 2264 InliningKind inlining_kind,
2265 HSourcePosition position);
2208 2266
2209 bool TryInlineCall(Call* expr, bool drop_extra = false); 2267 bool TryInlineCall(Call* expr);
2210 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value); 2268 bool TryInlineConstruct(CallNew* expr, HValue* implicit_return_value);
2211 bool TryInlineGetter(Handle<JSFunction> getter, 2269 bool TryInlineGetter(Handle<JSFunction> getter,
2270 Handle<Map> receiver_map,
2212 BailoutId ast_id, 2271 BailoutId ast_id,
2213 BailoutId return_id); 2272 BailoutId return_id);
2214 bool TryInlineSetter(Handle<JSFunction> setter, 2273 bool TryInlineSetter(Handle<JSFunction> setter,
2274 Handle<Map> receiver_map,
2215 BailoutId id, 2275 BailoutId id,
2216 BailoutId assignment_id, 2276 BailoutId assignment_id,
2217 HValue* implicit_return_value); 2277 HValue* implicit_return_value);
2218 bool TryInlineApply(Handle<JSFunction> function, 2278 bool TryInlineApply(Handle<JSFunction> function,
2219 Call* expr, 2279 Call* expr,
2220 int arguments_count); 2280 int arguments_count);
2221 bool TryInlineBuiltinMethodCall(Call* expr, 2281 bool TryInlineBuiltinMethodCall(Call* expr,
2222 HValue* receiver, 2282 HValue* receiver,
2223 Handle<Map> receiver_map, 2283 Handle<Map> receiver_map);
2224 CheckType check_type); 2284 bool TryInlineBuiltinFunctionCall(Call* expr);
2225 bool TryInlineBuiltinFunctionCall(Call* expr, bool drop_extra); 2285 enum ApiCallType {
2286 kCallApiFunction,
2287 kCallApiMethod,
2288 kCallApiGetter,
2289 kCallApiSetter
2290 };
2291 bool TryInlineApiMethodCall(Call* expr,
2292 HValue* receiver,
2293 SmallMapList* receiver_types);
2294 bool TryInlineApiFunctionCall(Call* expr, HValue* receiver);
2295 bool TryInlineApiGetter(Handle<JSFunction> function,
2296 Handle<Map> receiver_map,
2297 BailoutId ast_id);
2298 bool TryInlineApiSetter(Handle<JSFunction> function,
2299 Handle<Map> receiver_map,
2300 BailoutId ast_id);
2301 bool TryInlineApiCall(Handle<JSFunction> function,
2302 HValue* receiver,
2303 SmallMapList* receiver_maps,
2304 int argc,
2305 BailoutId ast_id,
2306 ApiCallType call_type);
2226 2307
2227 // If --trace-inlining, print a line of the inlining trace. Inlining 2308 // If --trace-inlining, print a line of the inlining trace. Inlining
2228 // succeeded if the reason string is NULL and failed if there is a 2309 // succeeded if the reason string is NULL and failed if there is a
2229 // non-NULL reason string. 2310 // non-NULL reason string.
2230 void TraceInline(Handle<JSFunction> target, 2311 void TraceInline(Handle<JSFunction> target,
2231 Handle<JSFunction> caller, 2312 Handle<JSFunction> caller,
2232 const char* failure_reason); 2313 const char* failure_reason);
2233 2314
2234 void HandleGlobalVariableAssignment(Variable* var, 2315 void HandleGlobalVariableAssignment(Variable* var,
2235 HValue* value, 2316 HValue* value,
2236 BailoutId ast_id); 2317 BailoutId ast_id);
2237 2318
2238 void HandlePropertyAssignment(Assignment* expr); 2319 void HandlePropertyAssignment(Assignment* expr);
2239 void HandleCompoundAssignment(Assignment* expr); 2320 void HandleCompoundAssignment(Assignment* expr);
2240 void HandlePolymorphicLoadNamedField(BailoutId ast_id, 2321 void HandlePolymorphicNamedFieldAccess(PropertyAccessType access_type,
2241 BailoutId return_id, 2322 BailoutId ast_id,
2242 HValue* object, 2323 BailoutId return_id,
2243 SmallMapList* types, 2324 HValue* object,
2244 Handle<String> name); 2325 HValue* value,
2326 SmallMapList* types,
2327 Handle<String> name);
2245 2328
2246 void VisitTypedArrayInitialize(CallRuntime* expr); 2329 void VisitTypedArrayInitialize(CallRuntime* expr);
2247 2330
2248 bool IsCallNewArrayInlineable(CallNew* expr); 2331 bool IsCallNewArrayInlineable(CallNew* expr);
2249 void BuildInlinedCallNewArray(CallNew* expr); 2332 void BuildInlinedCallNewArray(CallNew* expr);
2250 2333
2251 void VisitDataViewInitialize(CallRuntime* expr); 2334 void VisitDataViewInitialize(CallRuntime* expr);
2252 2335
2253 class PropertyAccessInfo { 2336 class PropertyAccessInfo {
2254 public: 2337 public:
2255 PropertyAccessInfo(Isolate* isolate, Handle<Map> map, Handle<String> name) 2338 PropertyAccessInfo(HOptimizedGraphBuilder* builder,
2256 : lookup_(isolate), 2339 PropertyAccessType access_type,
2257 map_(map), 2340 Type* type,
2341 Handle<String> name)
2342 : lookup_(builder->isolate()),
2343 builder_(builder),
2344 access_type_(access_type),
2345 type_(type),
2258 name_(name), 2346 name_(name),
2259 access_(HObjectAccess::ForMap()) { } 2347 access_(HObjectAccess::ForMap()) { }
2260 2348
2261 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic 2349 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic
2262 // load named. It additionally fills in the fields necessary to generate the 2350 // load named. It additionally fills in the fields necessary to generate the
2263 // lookup code. 2351 // lookup code.
2264 bool CanLoadMonomorphic(); 2352 bool CanAccessMonomorphic();
2265 2353
2266 // Checks whether all types behave uniform when loading name. If all maps 2354 // Checks whether all types behave uniform when loading name. If all maps
2267 // behave the same, a single monomorphic load instruction can be emitted, 2355 // behave the same, a single monomorphic load instruction can be emitted,
2268 // guarded by a single map-checks instruction that whether the receiver is 2356 // guarded by a single map-checks instruction that whether the receiver is
2269 // an instance of any of the types. 2357 // an instance of any of the types.
2270 // This method skips the first type in types, assuming that this 2358 // This method skips the first type in types, assuming that this
2271 // PropertyAccessInfo is built for types->first(). 2359 // PropertyAccessInfo is built for types->first().
2272 bool CanLoadAsMonomorphic(SmallMapList* types); 2360 bool CanAccessAsMonomorphic(SmallMapList* types);
2361
2362 Handle<Map> map() {
2363 if (type_->Is(Type::Number())) {
2364 Context* context = current_info()->closure()->context();
2365 context = context->native_context();
2366 return handle(context->number_function()->initial_map());
2367 } else if (type_->Is(Type::Boolean())) {
2368 Context* context = current_info()->closure()->context();
2369 context = context->native_context();
2370 return handle(context->boolean_function()->initial_map());
2371 } else if (type_->Is(Type::String())) {
2372 Context* context = current_info()->closure()->context();
2373 context = context->native_context();
2374 return handle(context->string_function()->initial_map());
2375 } else {
2376 return type_->AsClass();
2377 }
2378 }
2379 Type* type() const { return type_; }
2380 Handle<String> name() const { return name_; }
2273 2381
2274 bool IsJSObjectFieldAccessor() { 2382 bool IsJSObjectFieldAccessor() {
2275 int offset; // unused 2383 int offset; // unused
2276 return Accessors::IsJSObjectFieldAccessor(map_, name_, &offset); 2384 return Accessors::IsJSObjectFieldAccessor<Type>(type_, name_, &offset);
2277 } 2385 }
2278 2386
2279 bool GetJSObjectFieldAccess(HObjectAccess* access) { 2387 bool GetJSObjectFieldAccess(HObjectAccess* access) {
2280 if (IsStringLength()) { 2388 int offset;
2281 *access = HObjectAccess::ForStringLength(); 2389 if (Accessors::IsJSObjectFieldAccessor<Type>(type_, name_, &offset)) {
2390 if (type_->Is(Type::String())) {
2391 ASSERT(name_->Equals(isolate()->heap()->length_string()));
2392 *access = HObjectAccess::ForStringLength();
2393 } else if (type_->Is(Type::Array())) {
2394 ASSERT(name_->Equals(isolate()->heap()->length_string()));
2395 *access = HObjectAccess::ForArrayLength(map()->elements_kind());
2396 } else {
2397 *access = HObjectAccess::ForMapAndOffset(map(), offset);
2398 }
2282 return true; 2399 return true;
2283 } else if (IsArrayLength()) {
2284 *access = HObjectAccess::ForArrayLength(map_->elements_kind());
2285 return true;
2286 } else {
2287 int offset;
2288 if (Accessors::IsJSObjectFieldAccessor(map_, name_, &offset)) {
2289 *access = HObjectAccess::ForJSObjectOffset(offset);
2290 return true;
2291 }
2292 return false;
2293 } 2400 }
2401 return false;
2294 } 2402 }
2295 2403
2296 bool has_holder() { return !holder_.is_null(); } 2404 bool has_holder() { return !holder_.is_null(); }
2405 bool IsLoad() const { return access_type_ == LOAD; }
2297 2406
2298 LookupResult* lookup() { return &lookup_; } 2407 LookupResult* lookup() { return &lookup_; }
2299 Handle<Map> map() { return map_; }
2300 Handle<JSObject> holder() { return holder_; } 2408 Handle<JSObject> holder() { return holder_; }
2301 Handle<JSFunction> accessor() { return accessor_; } 2409 Handle<JSFunction> accessor() { return accessor_; }
2302 Handle<Object> constant() { return constant_; } 2410 Handle<Object> constant() { return constant_; }
2411 Handle<Map> transition() { return handle(lookup_.GetTransitionTarget()); }
2303 HObjectAccess access() { return access_; } 2412 HObjectAccess access() { return access_; }
2304 2413
2305 private: 2414 private:
2415 Type* ToType(Handle<Map> map) { return builder_->ToType(map); }
2306 Isolate* isolate() { return lookup_.isolate(); } 2416 Isolate* isolate() { return lookup_.isolate(); }
2307 2417 CompilationInfo* current_info() { return builder_->current_info(); }
2308 bool IsStringLength() {
2309 return map_->instance_type() < FIRST_NONSTRING_TYPE &&
2310 name_->Equals(isolate()->heap()->length_string());
2311 }
2312
2313 bool IsArrayLength() {
2314 return map_->instance_type() == JS_ARRAY_TYPE &&
2315 name_->Equals(isolate()->heap()->length_string());
2316 }
2317 2418
2318 bool LoadResult(Handle<Map> map); 2419 bool LoadResult(Handle<Map> map);
2319 bool LookupDescriptor(); 2420 bool LookupDescriptor();
2320 bool LookupInPrototypes(); 2421 bool LookupInPrototypes();
2321 bool IsCompatibleForLoad(PropertyAccessInfo* other); 2422 bool IsCompatible(PropertyAccessInfo* other);
2322 2423
2323 void GeneralizeRepresentation(Representation r) { 2424 void GeneralizeRepresentation(Representation r) {
2324 access_ = access_.WithRepresentation( 2425 access_ = access_.WithRepresentation(
2325 access_.representation().generalize(r)); 2426 access_.representation().generalize(r));
2326 } 2427 }
2327 2428
2328 LookupResult lookup_; 2429 LookupResult lookup_;
2329 Handle<Map> map_; 2430 HOptimizedGraphBuilder* builder_;
2431 PropertyAccessType access_type_;
2432 Type* type_;
2330 Handle<String> name_; 2433 Handle<String> name_;
2331 Handle<JSObject> holder_; 2434 Handle<JSObject> holder_;
2332 Handle<JSFunction> accessor_; 2435 Handle<JSFunction> accessor_;
2436 Handle<JSObject> api_holder_;
2333 Handle<Object> constant_; 2437 Handle<Object> constant_;
2334 HObjectAccess access_; 2438 HObjectAccess access_;
2335 }; 2439 };
2336 2440
2337 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, 2441 HInstruction* BuildMonomorphicAccess(PropertyAccessInfo* info,
2338 HValue* object, 2442 HValue* object,
2339 HInstruction* checked_object, 2443 HValue* checked_object,
2340 BailoutId ast_id, 2444 HValue* value,
2341 BailoutId return_id, 2445 BailoutId ast_id,
2342 bool can_inline_accessor = true); 2446 BailoutId return_id,
2447 bool can_inline_accessor = true);
2343 2448
2344 void HandlePolymorphicStoreNamedField(BailoutId assignment_id, 2449 HInstruction* BuildNamedAccess(PropertyAccessType access,
2345 HValue* object, 2450 BailoutId ast_id,
2346 HValue* value, 2451 BailoutId reutrn_id,
2347 SmallMapList* types, 2452 Expression* expr,
2348 Handle<String> name); 2453 HValue* object,
2349 bool TryStorePolymorphicAsMonomorphic(BailoutId assignment_id, 2454 Handle<String> name,
2350 HValue* object, 2455 HValue* value,
2351 HValue* value, 2456 bool is_uninitialized = false);
2352 SmallMapList* types, 2457
2353 Handle<String> name);
2354 void HandlePolymorphicCallNamed(Call* expr, 2458 void HandlePolymorphicCallNamed(Call* expr,
2355 HValue* receiver, 2459 HValue* receiver,
2356 SmallMapList* types, 2460 SmallMapList* types,
2357 Handle<String> name); 2461 Handle<String> name);
2358 bool TryCallPolymorphicAsMonomorphic(Call* expr,
2359 HValue* receiver,
2360 SmallMapList* types,
2361 Handle<String> name);
2362 void HandleLiteralCompareTypeof(CompareOperation* expr, 2462 void HandleLiteralCompareTypeof(CompareOperation* expr,
2363 Expression* sub_expr, 2463 Expression* sub_expr,
2364 Handle<String> check); 2464 Handle<String> check);
2365 void HandleLiteralCompareNil(CompareOperation* expr, 2465 void HandleLiteralCompareNil(CompareOperation* expr,
2366 Expression* sub_expr, 2466 Expression* sub_expr,
2367 NilValue nil); 2467 NilValue nil);
2368 HControlInstruction* BuildCompareInstruction(Token::Value op, 2468
2369 HValue* left, 2469 enum PushBeforeSimulateBehavior {
2370 HValue* right, 2470 PUSH_BEFORE_SIMULATE,
2371 Handle<Type> left_type, 2471 NO_PUSH_BEFORE_SIMULATE
2372 Handle<Type> right_type, 2472 };
2373 Handle<Type> combined_type, 2473
2374 int left_position, 2474 HControlInstruction* BuildCompareInstruction(
2375 int right_position, 2475 Token::Value op,
2376 BailoutId bailout_id); 2476 HValue* left,
2477 HValue* right,
2478 Type* left_type,
2479 Type* right_type,
2480 Type* combined_type,
2481 HSourcePosition left_position,
2482 HSourcePosition right_position,
2483 PushBeforeSimulateBehavior push_sim_result,
2484 BailoutId bailout_id);
2377 2485
2378 HInstruction* BuildStringCharCodeAt(HValue* string, 2486 HInstruction* BuildStringCharCodeAt(HValue* string,
2379 HValue* index); 2487 HValue* index);
2380 HValue* BuildBinaryOperation(BinaryOperation* expr, 2488
2381 HValue* left, 2489 HValue* BuildBinaryOperation(
2382 HValue* right); 2490 BinaryOperation* expr,
2491 HValue* left,
2492 HValue* right,
2493 PushBeforeSimulateBehavior push_sim_result);
2383 HInstruction* BuildIncrement(bool returns_original_input, 2494 HInstruction* BuildIncrement(bool returns_original_input,
2384 CountOperation* expr); 2495 CountOperation* expr);
2385 HInstruction* BuildLoadKeyedGeneric(HValue* object, 2496 HInstruction* BuildKeyedGeneric(PropertyAccessType access_type,
2386 HValue* key); 2497 HValue* object,
2498 HValue* key,
2499 HValue* value);
2387 2500
2388 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, 2501 HInstruction* TryBuildConsolidatedElementLoad(HValue* object,
2389 HValue* key, 2502 HValue* key,
2390 HValue* val, 2503 HValue* val,
2391 SmallMapList* maps); 2504 SmallMapList* maps);
2392 2505
2393 LoadKeyedHoleMode BuildKeyedHoleMode(Handle<Map> map); 2506 LoadKeyedHoleMode BuildKeyedHoleMode(Handle<Map> map);
2394 2507
2395 HInstruction* BuildMonomorphicElementAccess(HValue* object, 2508 HInstruction* BuildMonomorphicElementAccess(HValue* object,
2396 HValue* key, 2509 HValue* key,
2397 HValue* val, 2510 HValue* val,
2398 HValue* dependency, 2511 HValue* dependency,
2399 Handle<Map> map, 2512 Handle<Map> map,
2400 bool is_store, 2513 PropertyAccessType access_type,
2401 KeyedAccessStoreMode store_mode); 2514 KeyedAccessStoreMode store_mode);
2402 2515
2403 HValue* HandlePolymorphicElementAccess(HValue* object, 2516 HValue* HandlePolymorphicElementAccess(HValue* object,
2404 HValue* key, 2517 HValue* key,
2405 HValue* val, 2518 HValue* val,
2406 SmallMapList* maps, 2519 SmallMapList* maps,
2407 bool is_store, 2520 PropertyAccessType access_type,
2408 KeyedAccessStoreMode store_mode, 2521 KeyedAccessStoreMode store_mode,
2409 bool* has_side_effects); 2522 bool* has_side_effects);
2410 2523
2411 HValue* HandleKeyedElementAccess(HValue* obj, 2524 HValue* HandleKeyedElementAccess(HValue* obj,
2412 HValue* key, 2525 HValue* key,
2413 HValue* val, 2526 HValue* val,
2414 Expression* expr, 2527 Expression* expr,
2415 bool is_store, 2528 PropertyAccessType access_type,
2416 bool* has_side_effects); 2529 bool* has_side_effects);
2417 2530
2418 HInstruction* BuildLoadNamedGeneric(HValue* object, 2531 HInstruction* BuildNamedGeneric(PropertyAccessType access,
2419 Handle<String> name, 2532 HValue* object,
2420 Property* expr); 2533 Handle<String> name,
2534 HValue* value,
2535 bool is_uninitialized = false);
2421 2536
2422 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map); 2537 HCheckMaps* AddCheckMap(HValue* object, Handle<Map> map);
2423 2538
2424 void BuildLoad(Property* property, 2539 void BuildLoad(Property* property,
2425 BailoutId ast_id); 2540 BailoutId ast_id);
2426 void PushLoad(Property* property, 2541 void PushLoad(Property* property,
2427 HValue* object, 2542 HValue* object,
2428 HValue* key); 2543 HValue* key);
2429 2544
2430 void BuildStoreForEffect(Expression* expression, 2545 void BuildStoreForEffect(Expression* expression,
2431 Property* prop, 2546 Property* prop,
2432 BailoutId ast_id, 2547 BailoutId ast_id,
2433 BailoutId return_id, 2548 BailoutId return_id,
2434 HValue* object, 2549 HValue* object,
2435 HValue* key, 2550 HValue* key,
2436 HValue* value); 2551 HValue* value);
2437 2552
2438 void BuildStore(Expression* expression, 2553 void BuildStore(Expression* expression,
2439 Property* prop, 2554 Property* prop,
2440 BailoutId ast_id, 2555 BailoutId ast_id,
2441 BailoutId return_id, 2556 BailoutId return_id,
2442 bool is_uninitialized = false); 2557 bool is_uninitialized = false);
2443 2558
2444 HInstruction* BuildStoreNamedField(HValue* object, 2559 HInstruction* BuildLoadNamedField(PropertyAccessInfo* info,
2445 Handle<String> name, 2560 HValue* checked_object);
2446 HValue* value, 2561 HInstruction* BuildStoreNamedField(PropertyAccessInfo* info,
2447 Handle<Map> map, 2562 HValue* checked_object,
2448 LookupResult* lookup); 2563 HValue* value);
2449 HInstruction* BuildStoreNamedGeneric(HValue* object,
2450 Handle<String> name,
2451 HValue* value);
2452 HInstruction* BuildStoreNamedMonomorphic(HValue* object,
2453 Handle<String> name,
2454 HValue* value,
2455 Handle<Map> map);
2456 HInstruction* BuildStoreKeyedGeneric(HValue* object,
2457 HValue* key,
2458 HValue* value);
2459 2564
2460 HValue* BuildContextChainWalk(Variable* var); 2565 HValue* BuildContextChainWalk(Variable* var);
2461 2566
2462 HInstruction* BuildThisFunction(); 2567 HInstruction* BuildThisFunction();
2463 2568
2464 HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object, 2569 HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object,
2465 AllocationSiteUsageContext* site_context); 2570 AllocationSiteUsageContext* site_context);
2466 2571
2467 void BuildEmitObjectHeader(Handle<JSObject> boilerplate_object, 2572 void BuildEmitObjectHeader(Handle<JSObject> boilerplate_object,
2468 HInstruction* object); 2573 HInstruction* object);
(...skipping 17 matching lines...) Expand all
2486 HValue* object_elements); 2591 HValue* object_elements);
2487 2592
2488 void BuildEmitFixedArray(Handle<FixedArrayBase> elements, 2593 void BuildEmitFixedArray(Handle<FixedArrayBase> elements,
2489 ElementsKind kind, 2594 ElementsKind kind,
2490 HValue* object_elements, 2595 HValue* object_elements,
2491 AllocationSiteUsageContext* site_context); 2596 AllocationSiteUsageContext* site_context);
2492 2597
2493 void AddCheckPrototypeMaps(Handle<JSObject> holder, 2598 void AddCheckPrototypeMaps(Handle<JSObject> holder,
2494 Handle<Map> receiver_map); 2599 Handle<Map> receiver_map);
2495 2600
2496 void AddCheckConstantFunction(Handle<JSObject> holder,
2497 HValue* receiver,
2498 Handle<Map> receiver_map);
2499
2500 HInstruction* NewPlainFunctionCall(HValue* fun, 2601 HInstruction* NewPlainFunctionCall(HValue* fun,
2501 int argument_count, 2602 int argument_count,
2502 bool pass_argument_count); 2603 bool pass_argument_count);
2503 2604
2504 HInstruction* NewArgumentAdaptorCall(HValue* fun, HValue* context, 2605 HInstruction* NewArgumentAdaptorCall(HValue* fun, HValue* context,
2505 int argument_count, 2606 int argument_count,
2506 HValue* expected_param_count); 2607 HValue* expected_param_count);
2507 2608
2508 HInstruction* BuildCallConstantFunction(Handle<JSFunction> target, 2609 HInstruction* BuildCallConstantFunction(Handle<JSFunction> target,
2509 int argument_count); 2610 int argument_count);
2510 2611
2511 HInstruction* NewCallKeyed(HValue* key, int argument_count);
2512
2513 HInstruction* NewCallNamed(Handle<String> name, int argument_count);
2514
2515 // The translation state of the currently-being-translated function. 2612 // The translation state of the currently-being-translated function.
2516 FunctionState* function_state_; 2613 FunctionState* function_state_;
2517 2614
2518 // The base of the function state stack. 2615 // The base of the function state stack.
2519 FunctionState initial_function_state_; 2616 FunctionState initial_function_state_;
2520 2617
2521 // Expression context of the currently visited subexpression. NULL when 2618 // Expression context of the currently visited subexpression. NULL when
2522 // visiting statements. 2619 // visiting statements.
2523 AstContext* ast_context_; 2620 AstContext* ast_context_;
2524 2621
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 } 2793 }
2697 2794
2698 private: 2795 private:
2699 HGraphBuilder* builder_; 2796 HGraphBuilder* builder_;
2700 }; 2797 };
2701 2798
2702 2799
2703 } } // namespace v8::internal 2800 } } // namespace v8::internal
2704 2801
2705 #endif // V8_HYDROGEN_H_ 2802 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/heap-snapshot-generator.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698