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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 | 232 |
| 233 private: | 233 private: |
| 234 void AddBlock(HBasicBlock* block); | 234 void AddBlock(HBasicBlock* block); |
| 235 | 235 |
| 236 ZoneList<HBasicBlock*> back_edges_; | 236 ZoneList<HBasicBlock*> back_edges_; |
| 237 HBasicBlock* loop_header_; | 237 HBasicBlock* loop_header_; |
| 238 ZoneList<HBasicBlock*> blocks_; | 238 ZoneList<HBasicBlock*> blocks_; |
| 239 HStackCheck* stack_check_; | 239 HStackCheck* stack_check_; |
| 240 }; | 240 }; |
| 241 | 241 |
| 242 | |
| 243 class TransitionRecord BASE_EMBEDDED { | |
|
danno
2012/11/14 15:28:18
I hate being overly fussy about names, but they ar
mvstanton
2012/11/16 15:15:06
Bad suggestion TransitionElementsBookmark sounds p
| |
| 244 public: | |
| 245 TransitionRecord(HTransitionElementsKind* transition_instr, Handle<Map> map_fr om, | |
|
danno
2012/11/14 15:28:18
80 col
mvstanton
2012/11/16 15:15:06
Done.
| |
| 246 Handle<Map> map_to); | |
| 247 ElementsKind from() const { return map_from_->elements_kind(); } | |
| 248 ElementsKind to() const { return map_to_->elements_kind(); } | |
| 249 Handle<Map> map_from() const { return map_from_; } | |
| 250 Handle<Map> map_to() const { return map_to_; } | |
| 251 Handle<Map>& map_to_ref() { return map_to_; } | |
|
danno
2012/11/14 15:28:18
We really avoid & (refs) everywhere else in the co
mvstanton
2012/11/16 15:15:06
Done.
| |
| 252 Handle<Map> map_family() const { return map_family_; } | |
| 253 Handle<Map> optimistic_holey() const { return optimistic_holey_; } | |
| 254 Handle<Map>& optimistic_holey_ref() { return optimistic_holey_; } | |
|
danno
2012/11/14 15:28:18
Again, please void the ref.
mvstanton
2012/11/16 15:15:06
Done.
| |
| 255 HTransitionElementsKind* transition_instruction() const { return transition_in str_; } | |
| 256 | |
| 257 bool equal(const TransitionRecord& other) const { | |
|
danno
2012/11/14 15:28:18
Equals
mvstanton
2012/11/16 15:15:06
Done.
| |
| 258 return *map_from() == *(other.map_from()) && *map_to() == *(other.map_to()) && | |
| 259 *map_family() == *(other.map_family()); | |
| 260 } | |
| 261 | |
| 262 private: | |
| 263 HTransitionElementsKind* transition_instr_; | |
|
danno
2012/11/14 15:28:18
Just transition_?
mvstanton
2012/11/16 15:15:06
Done.
| |
| 264 Handle<Map> map_from_; | |
|
danno
2012/11/14 15:28:18
how about just "from_", "to_", "family_"
mvstanton
2012/11/16 15:15:06
Done.
| |
| 265 Handle<Map> map_to_; | |
| 266 Handle<Map> map_family_; | |
| 267 Handle<Map> optimistic_holey_; | |
|
danno
2012/11/14 15:28:18
Isn't this the "pesimistic_holey_" map? i.e. the o
mvstanton
2012/11/16 15:15:06
Done.
| |
| 268 }; | |
| 269 | |
| 270 | |
| 271 typedef ZoneList<HInstruction*> TerminalNodeList; | |
|
danno
2012/11/14 15:28:18
Are these HInstructions or HValues? If it's just H
mvstanton
2012/11/16 15:15:06
I do treat them as HInstructions a few times...
| |
| 272 | |
| 273 class DeferredTransitions BASE_EMBEDDED { | |
|
danno
2012/11/14 15:28:18
PontentialTransitionElementsGroup?
mvstanton
2012/11/16 15:15:06
I went with MarkedTransitionElementsGroup. "markin
| |
| 274 public: | |
| 275 DeferredTransitions(HInstruction* keyedInstr, HCheckNonSmi* checknonsmi, | |
|
danno
2012/11/14 15:28:18
keyed_instruction and other style guide stuff on o
mvstanton
2012/11/16 15:15:06
Done.
| |
| 276 HCheckMaps* checkmaps, Zone* zone) | |
| 277 : zone_(zone), keyed_instr_(keyedInstr), checknonsmi_instr_(checknonsmi), | |
|
danno
2012/11/14 15:28:18
In general, for variables and members, separate ev
mvstanton
2012/11/16 15:15:06
Done.
| |
| 278 checkmaps_instr_(checkmaps), | |
| 279 invalid_(false), | |
| 280 records_(new (zone) ZoneList<TransitionRecord>(10, zone)), | |
| 281 terminal_nodes_(new (zone) TerminalNodeList(10, zone)) { | |
| 282 ASSERT((keyedInstr->IsLoadKeyed() && | |
| 283 !HLoadKeyed::cast(keyedInstr)->Initialized()) || | |
| 284 (keyedInstr->IsStoreKeyed() && | |
| 285 !HStoreKeyed::cast(keyedInstr)->Initialized())); | |
| 286 score_[0] = score_[1] = score_[2] = 0; | |
| 287 } | |
| 288 | |
| 289 HInstruction* instr() const { return keyed_instr_; } | |
| 290 HCheckMaps* checkmaps_instr() { return checkmaps_instr_; } | |
| 291 HCheckNonSmi* checknonsmi_instr() { return checknonsmi_instr_; } | |
| 292 | |
| 293 void add_transitions(const ZoneList<TransitionRecord>& records) { | |
|
danno
2012/11/14 15:28:18
"AddTransitions". Only trivial variable accessors
mvstanton
2012/11/16 15:15:06
Done.
| |
| 294 // Doesn't check for duplications | |
| 295 for (int i=0; i<records.length(); i++) { | |
| 296 records_->Add(records[i], zone_); | |
| 297 } | |
| 298 } | |
| 299 | |
| 300 void add_transition(const TransitionRecord& record) { | |
| 301 records_->Add(record, zone_); | |
| 302 } | |
| 303 | |
| 304 int transitions() const { return records_->length(); } | |
| 305 const TransitionRecord& transition(int index) const { | |
| 306 return (*records_)[index]; | |
| 307 } | |
| 308 | |
| 309 TransitionRecord& transition_ref(int index) { | |
| 310 return records_->at(index); | |
| 311 } | |
| 312 | |
| 313 void PrintTo(StringStream* stream) const; | |
| 314 void PrintToStd() const; | |
| 315 | |
| 316 // Populate terminal_nodes, initially empty | |
| 317 void ComputeTerminalNodes(int maximumGraphValueID); | |
| 318 | |
| 319 int terminal_nodes() const { return terminal_nodes_->length(); } | |
| 320 HInstruction* terminal_node(int index) const { return (*terminal_nodes_)[index ]; } | |
| 321 | |
| 322 enum ScoreType { | |
| 323 SCORE_POSITIVE, | |
| 324 SCORE_NEGATIVE, | |
| 325 SCORE_NEUTRAL | |
|
danno
2012/11/14 15:28:18
, SCORE_TYPE_COUNT // Must be last
mvstanton
2012/11/16 15:15:06
Done.
| |
| 326 }; | |
| 327 | |
| 328 ScoreType scoretype_from_loopdelta(int loopDelta) const { | |
| 329 if (loopDelta > 0) return SCORE_POSITIVE; | |
| 330 else if(loopDelta < 0) return SCORE_NEGATIVE; | |
| 331 return SCORE_NEUTRAL; | |
| 332 } | |
| 333 | |
| 334 int score(ScoreType type) const { return score_[type]; } | |
| 335 void increment_score(ScoreType type, int score) { score_[type] += score; } | |
| 336 | |
| 337 bool invalid() const { return invalid_; } | |
| 338 void set_invalid() { invalid_ = true; } | |
| 339 | |
| 340 void set_highest(Map* new_highest) { computed_highest_ = new_highest; } | |
| 341 Map* highest() const { return computed_highest_; } | |
| 342 | |
| 343 void Finalize() { | |
| 344 ASSERT(highest() != NULL); | |
| 345 ElementsKind elements_kind = highest()->elements_kind(); | |
| 346 if (instr()->IsLoadKeyed()) { | |
| 347 HLoadKeyed::cast(instr())->PerformDeferredInitialization(elements_kind); | |
|
danno
2012/11/14 15:28:18
Is it possible to move PerformDeferredInitializati
mvstanton
2012/11/16 15:15:06
Done.
| |
| 348 } else { | |
| 349 ASSERT(instr()->IsStoreKeyed()); | |
| 350 HStoreKeyed::cast(instr())->PerformDeferredInitialization(elements_kind); | |
| 351 } | |
| 352 } | |
| 353 | |
| 354 // Fill in highest from local values | |
| 355 void compute_highest(); | |
| 356 Zone* zone() const { return zone_; } | |
| 357 | |
| 358 Map* map_family() const { | |
| 359 Map* family = NULL; | |
| 360 if (transitions()) { | |
| 361 family = *(transition(0).map_family().location()); | |
| 362 } | |
| 363 | |
| 364 #ifdef DEBUG | |
| 365 for (int i=1; i<transitions(); i++) { | |
| 366 const TransitionRecord& tr = transition(i); | |
| 367 ASSERT(*(tr.map_family().location()) == family); | |
| 368 } | |
| 369 #endif | |
| 370 return family; | |
| 371 } | |
| 372 | |
| 373 private: | |
| 374 Zone* zone_; | |
| 375 HInstruction *keyed_instr_; | |
|
danno
2012/11/14 15:28:18
load_or_store_?
mvstanton
2012/11/16 15:15:06
Done.
| |
| 376 HCheckNonSmi* checknonsmi_instr_; | |
|
danno
2012/11/14 15:28:18
how about just smi_check_?
mvstanton
2012/11/16 15:15:06
Done.
| |
| 377 HCheckMaps* checkmaps_instr_; | |
|
danno
2012/11/14 15:28:18
map_check_?
mvstanton
2012/11/16 15:15:06
Done.
| |
| 378 Map* computed_highest_; | |
| 379 int score_[3]; | |
|
danno
2012/11/14 15:28:18
score_[SCORE_TYPE_COUNT]
mvstanton
2012/11/16 15:15:06
Done.
| |
| 380 bool invalid_; | |
| 381 ZoneList<TransitionRecord> *records_; | |
| 382 TerminalNodeList *terminal_nodes_; | |
|
danno
2012/11/14 15:28:18
I think "Terminal" might not be the right to use.
mvstanton
2012/11/16 15:15:06
Done.
| |
| 383 }; | |
| 384 | |
| 242 class BoundsCheckTable; | 385 class BoundsCheckTable; |
| 243 class HGraph: public ZoneObject { | 386 class HGraph: public ZoneObject { |
| 244 public: | 387 public: |
| 245 explicit HGraph(CompilationInfo* info); | 388 explicit HGraph(CompilationInfo* info); |
| 246 | 389 |
| 247 Isolate* isolate() { return isolate_; } | 390 Isolate* isolate() { return isolate_; } |
| 248 Zone* zone() const { return zone_; } | 391 Zone* zone() const { return zone_; } |
| 249 CompilationInfo* info() const { return info_; } | 392 CompilationInfo* info() const { return info_; } |
| 250 | 393 |
| 251 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } | 394 const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 return is_recursive_; | 502 return is_recursive_; |
| 360 } | 503 } |
| 361 | 504 |
| 362 void RecordUint32Instruction(HInstruction* instr) { | 505 void RecordUint32Instruction(HInstruction* instr) { |
| 363 if (uint32_instructions_ == NULL) { | 506 if (uint32_instructions_ == NULL) { |
| 364 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); | 507 uint32_instructions_ = new(zone()) ZoneList<HInstruction*>(4, zone()); |
| 365 } | 508 } |
| 366 uint32_instructions_->Add(instr, zone()); | 509 uint32_instructions_->Add(instr, zone()); |
| 367 } | 510 } |
| 368 | 511 |
| 512 void AddDeferredTransitions(const DeferredTransitions& todo) { | |
| 513 deferred_transitions_.Add(todo, zone()); | |
| 514 } | |
| 515 | |
| 369 private: | 516 private: |
| 370 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, | 517 HConstant* GetConstant(SetOncePointer<HConstant>* pointer, |
| 371 Handle<Object> value); | 518 Handle<Object> value); |
| 372 HConstant* GetConstantInt32(SetOncePointer<HConstant>* pointer, | 519 HConstant* GetConstantInt32(SetOncePointer<HConstant>* pointer, |
| 373 int32_t integer_value); | 520 int32_t integer_value); |
| 374 | 521 |
| 375 void MarkAsDeoptimizingRecursively(HBasicBlock* block); | 522 void MarkAsDeoptimizingRecursively(HBasicBlock* block); |
| 523 void InsertElementsTransitions(); | |
| 524 void InitializeTerminalMap(ZoneHashMap& terminalMap); | |
| 376 void InsertTypeConversions(HInstruction* instr); | 525 void InsertTypeConversions(HInstruction* instr); |
| 377 void PropagateMinusZeroChecks(HValue* value, BitVector* visited); | 526 void PropagateMinusZeroChecks(HValue* value, BitVector* visited); |
| 378 void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi); | 527 void RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi); |
| 379 void InsertRepresentationChangeForUse(HValue* value, | 528 void InsertRepresentationChangeForUse(HValue* value, |
| 380 HValue* use_value, | 529 HValue* use_value, |
| 381 int use_index, | 530 int use_index, |
| 382 Representation to); | 531 Representation to); |
| 383 void InsertRepresentationChangesForValue(HValue* value); | 532 void InsertRepresentationChangesForValue(HValue* value); |
| 384 void InferTypes(ZoneList<HValue*>* worklist); | 533 void InferTypes(ZoneList<HValue*>* worklist); |
| 385 void InitializeInferredTypes(int from_inclusive, int to_inclusive); | 534 void InitializeInferredTypes(int from_inclusive, int to_inclusive); |
| 386 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); | 535 void CheckForBackEdge(HBasicBlock* block, HBasicBlock* successor); |
| 387 void EliminateRedundantBoundsChecks(HBasicBlock* bb, BoundsCheckTable* table); | 536 void EliminateRedundantBoundsChecks(HBasicBlock* bb, BoundsCheckTable* table); |
| 388 | 537 |
| 389 Isolate* isolate_; | 538 Isolate* isolate_; |
| 390 int next_block_id_; | 539 int next_block_id_; |
| 391 HBasicBlock* entry_block_; | 540 HBasicBlock* entry_block_; |
| 392 HEnvironment* start_environment_; | 541 HEnvironment* start_environment_; |
| 393 ZoneList<HBasicBlock*> blocks_; | 542 ZoneList<HBasicBlock*> blocks_; |
| 394 ZoneList<HValue*> values_; | 543 ZoneList<HValue*> values_; |
| 395 ZoneList<HPhi*>* phi_list_; | 544 ZoneList<HPhi*>* phi_list_; |
| 396 ZoneList<HInstruction*>* uint32_instructions_; | 545 ZoneList<HInstruction*>* uint32_instructions_; |
| 546 ZoneList<DeferredTransitions> deferred_transitions_; | |
| 397 SetOncePointer<HConstant> undefined_constant_; | 547 SetOncePointer<HConstant> undefined_constant_; |
| 398 SetOncePointer<HConstant> constant_1_; | 548 SetOncePointer<HConstant> constant_1_; |
| 399 SetOncePointer<HConstant> constant_minus1_; | 549 SetOncePointer<HConstant> constant_minus1_; |
| 400 SetOncePointer<HConstant> constant_true_; | 550 SetOncePointer<HConstant> constant_true_; |
| 401 SetOncePointer<HConstant> constant_false_; | 551 SetOncePointer<HConstant> constant_false_; |
| 402 SetOncePointer<HConstant> constant_hole_; | 552 SetOncePointer<HConstant> constant_hole_; |
| 403 SetOncePointer<HArgumentsObject> arguments_object_; | 553 SetOncePointer<HArgumentsObject> arguments_object_; |
| 404 | 554 |
| 405 SetOncePointer<HBasicBlock> osr_loop_entry_; | 555 SetOncePointer<HBasicBlock> osr_loop_entry_; |
| 406 SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_; | 556 SetOncePointer<ZoneList<HUnknownOSRValue*> > osr_values_; |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 854 | 1004 |
| 855 // Search the break stack for a break or continue target. | 1005 // Search the break stack for a break or continue target. |
| 856 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); | 1006 HBasicBlock* Get(BreakableStatement* stmt, BreakType type, int* drop_extra); |
| 857 | 1007 |
| 858 private: | 1008 private: |
| 859 BreakAndContinueInfo* info_; | 1009 BreakAndContinueInfo* info_; |
| 860 HGraphBuilder* owner_; | 1010 HGraphBuilder* owner_; |
| 861 BreakAndContinueScope* next_; | 1011 BreakAndContinueScope* next_; |
| 862 }; | 1012 }; |
| 863 | 1013 |
| 1014 | |
|
danno
2012/11/14 15:28:18
nit: extra whitespace :-)
mvstanton
2012/11/16 15:15:06
Done.
| |
| 864 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle); | 1015 HGraphBuilder(CompilationInfo* info, TypeFeedbackOracle* oracle); |
| 865 | 1016 |
| 866 HGraph* CreateGraph(); | 1017 HGraph* CreateGraph(); |
| 867 | 1018 |
| 868 // Simple accessors. | 1019 // Simple accessors. |
| 869 HGraph* graph() const { return graph_; } | 1020 HGraph* graph() const { return graph_; } |
| 870 BreakAndContinueScope* break_scope() const { return break_scope_; } | 1021 BreakAndContinueScope* break_scope() const { return break_scope_; } |
| 871 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } | 1022 void set_break_scope(BreakAndContinueScope* head) { break_scope_ = head; } |
| 872 | 1023 |
| 873 HBasicBlock* current_block() const { return current_block_; } | 1024 HBasicBlock* current_block() const { return current_block_; } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1117 HInstruction* BuildBinaryOperation(BinaryOperation* expr, | 1268 HInstruction* BuildBinaryOperation(BinaryOperation* expr, |
| 1118 HValue* left, | 1269 HValue* left, |
| 1119 HValue* right); | 1270 HValue* right); |
| 1120 HInstruction* BuildIncrement(bool returns_original_input, | 1271 HInstruction* BuildIncrement(bool returns_original_input, |
| 1121 CountOperation* expr); | 1272 CountOperation* expr); |
| 1122 HInstruction* BuildFastElementAccess(HValue* elements, | 1273 HInstruction* BuildFastElementAccess(HValue* elements, |
| 1123 HValue* checked_key, | 1274 HValue* checked_key, |
| 1124 HValue* val, | 1275 HValue* val, |
| 1125 HValue* dependency, | 1276 HValue* dependency, |
| 1126 ElementsKind elements_kind, | 1277 ElementsKind elements_kind, |
| 1127 bool is_store); | 1278 bool is_store, |
| 1279 bool defer_initialization); | |
| 1128 | 1280 |
| 1129 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, | 1281 HInstruction* TryBuildConsolidatedElementLoad(HValue* object, |
| 1130 HValue* key, | 1282 HValue* key, |
| 1131 HValue* val, | 1283 HValue* val, |
| 1132 SmallMapList* maps); | 1284 SmallMapList* maps); |
| 1133 | 1285 |
| 1134 HInstruction* BuildUncheckedMonomorphicElementAccess(HValue* object, | 1286 HInstruction* BuildUncheckedMonomorphicElementAccess(HValue* object, |
| 1135 HValue* key, | 1287 HValue* key, |
| 1136 HValue* val, | 1288 HValue* val, |
| 1137 HCheckMaps* mapcheck, | 1289 HCheckMaps* mapcheck, |
| 1138 Handle<Map> map, | 1290 Handle<Map> map, |
| 1139 bool is_store); | 1291 bool is_store, |
| 1292 bool defer_initialization ); | |
| 1140 | 1293 |
| 1141 HInstruction* BuildMonomorphicElementAccess(HValue* object, | 1294 HInstruction* BuildMonomorphicElementAccess(HValue* object, |
| 1142 HValue* key, | 1295 HValue* key, |
| 1143 HValue* val, | 1296 HValue* val, |
| 1144 HValue* dependency, | 1297 HValue* dependency, |
| 1145 Handle<Map> map, | 1298 Handle<Map> map, |
| 1146 bool is_store); | 1299 bool is_store, |
| 1300 HCheckMaps** checkmap_instr=NULL); | |
|
danno
2012/11/14 15:28:18
extra <sp> around =
mvstanton
2012/11/16 15:15:06
Done.
| |
| 1147 | 1301 |
| 1148 HValue* HandlePolymorphicElementAccess(HValue* object, | 1302 HValue* HandlePolymorphicElementAccess(HValue* object, |
| 1149 HValue* key, | 1303 HValue* key, |
| 1150 HValue* val, | 1304 HValue* val, |
| 1151 Expression* prop, | 1305 Expression* prop, |
| 1152 BailoutId ast_id, | 1306 BailoutId ast_id, |
| 1153 int position, | 1307 int position, |
| 1154 bool is_store, | 1308 bool is_store, |
| 1155 bool* has_side_effects); | 1309 bool* has_side_effects); |
| 1156 | 1310 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1496 const char* filename_; | 1650 const char* filename_; |
| 1497 HeapStringAllocator string_allocator_; | 1651 HeapStringAllocator string_allocator_; |
| 1498 StringStream trace_; | 1652 StringStream trace_; |
| 1499 int indent_; | 1653 int indent_; |
| 1500 }; | 1654 }; |
| 1501 | 1655 |
| 1502 | 1656 |
| 1503 } } // namespace v8::internal | 1657 } } // namespace v8::internal |
| 1504 | 1658 |
| 1505 #endif // V8_HYDROGEN_H_ | 1659 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |