| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 | 118 |
| 119 void TraceGVN(const char* msg, ...) { | 119 void TraceGVN(const char* msg, ...) { |
| 120 va_list arguments; | 120 va_list arguments; |
| 121 va_start(arguments, msg); | 121 va_start(arguments, msg); |
| 122 OS::VPrint(msg, arguments); | 122 OS::VPrint(msg, arguments); |
| 123 va_end(arguments); | 123 va_end(arguments); |
| 124 } | 124 } |
| 125 | 125 |
| 126 |
| 126 // Wrap TraceGVN in macros to avoid the expense of evaluating its arguments when | 127 // Wrap TraceGVN in macros to avoid the expense of evaluating its arguments when |
| 127 // --trace-gvn is off. | 128 // --trace-gvn is off. |
| 128 #define TRACE_GVN_1(msg, a1) \ | 129 #define TRACE_GVN_1(msg, a1) \ |
| 129 if (FLAG_trace_gvn) { \ | 130 if (FLAG_trace_gvn) { \ |
| 130 TraceGVN(msg, a1); \ | 131 TraceGVN(msg, a1); \ |
| 131 } | 132 } |
| 132 | 133 |
| 133 #define TRACE_GVN_2(msg, a1, a2) \ | 134 #define TRACE_GVN_2(msg, a1, a2) \ |
| 134 if (FLAG_trace_gvn) { \ | 135 if (FLAG_trace_gvn) { \ |
| 135 TraceGVN(msg, a1, a2); \ | 136 TraceGVN(msg, a1, a2); \ |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 333 } |
| 333 | 334 |
| 334 | 335 |
| 335 HSideEffectMap& HSideEffectMap::operator= (const HSideEffectMap& other) { | 336 HSideEffectMap& HSideEffectMap::operator= (const HSideEffectMap& other) { |
| 336 if (this != &other) { | 337 if (this != &other) { |
| 337 OS::MemCopy(data_, other.data_, kNumberOfTrackedSideEffects * kPointerSize); | 338 OS::MemCopy(data_, other.data_, kNumberOfTrackedSideEffects * kPointerSize); |
| 338 } | 339 } |
| 339 return *this; | 340 return *this; |
| 340 } | 341 } |
| 341 | 342 |
| 343 |
| 342 void HSideEffectMap::Kill(GVNFlagSet flags) { | 344 void HSideEffectMap::Kill(GVNFlagSet flags) { |
| 343 for (int i = 0; i < kNumberOfTrackedSideEffects; i++) { | 345 for (int i = 0; i < kNumberOfTrackedSideEffects; i++) { |
| 344 GVNFlag changes_flag = HValue::ChangesFlagFromInt(i); | 346 GVNFlag changes_flag = HValue::ChangesFlagFromInt(i); |
| 345 if (flags.Contains(changes_flag)) { | 347 if (flags.Contains(changes_flag)) { |
| 346 if (data_[i] != NULL) count_--; | 348 if (data_[i] != NULL) count_--; |
| 347 data_[i] = NULL; | 349 data_[i] = NULL; |
| 348 } | 350 } |
| 349 } | 351 } |
| 350 } | 352 } |
| 351 | 353 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 void HGlobalValueNumberingPhase::ComputeBlockSideEffects() { | 389 void HGlobalValueNumberingPhase::ComputeBlockSideEffects() { |
| 388 // The Analyze phase of GVN can be called multiple times. Clear loop side | 390 // The Analyze phase of GVN can be called multiple times. Clear loop side |
| 389 // effects before computing them to erase the contents from previous Analyze | 391 // effects before computing them to erase the contents from previous Analyze |
| 390 // passes. | 392 // passes. |
| 391 for (int i = 0; i < loop_side_effects_.length(); ++i) { | 393 for (int i = 0; i < loop_side_effects_.length(); ++i) { |
| 392 loop_side_effects_[i].RemoveAll(); | 394 loop_side_effects_[i].RemoveAll(); |
| 393 } | 395 } |
| 394 for (int i = graph()->blocks()->length() - 1; i >= 0; --i) { | 396 for (int i = graph()->blocks()->length() - 1; i >= 0; --i) { |
| 395 // Compute side effects for the block. | 397 // Compute side effects for the block. |
| 396 HBasicBlock* block = graph()->blocks()->at(i); | 398 HBasicBlock* block = graph()->blocks()->at(i); |
| 397 HInstruction* instr = block->first(); | |
| 398 int id = block->block_id(); | 399 int id = block->block_id(); |
| 399 GVNFlagSet side_effects; | 400 GVNFlagSet side_effects; |
| 400 while (instr != NULL) { | 401 for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
| 402 HInstruction* instr = it.Current(); |
| 401 side_effects.Add(instr->ChangesFlags()); | 403 side_effects.Add(instr->ChangesFlags()); |
| 402 if (instr->IsSoftDeoptimize()) { | 404 if (instr->IsSoftDeoptimize()) { |
| 403 block_side_effects_[id].RemoveAll(); | 405 block_side_effects_[id].RemoveAll(); |
| 404 side_effects.RemoveAll(); | 406 side_effects.RemoveAll(); |
| 405 break; | 407 break; |
| 406 } | 408 } |
| 407 instr = instr->next(); | |
| 408 } | 409 } |
| 409 block_side_effects_[id].Add(side_effects); | 410 block_side_effects_[id].Add(side_effects); |
| 410 | 411 |
| 411 // Loop headers are part of their loop. | 412 // Loop headers are part of their loop. |
| 412 if (block->IsLoopHeader()) { | 413 if (block->IsLoopHeader()) { |
| 413 loop_side_effects_[id].Add(side_effects); | 414 loop_side_effects_[id].Add(side_effects); |
| 414 } | 415 } |
| 415 | 416 |
| 416 // Propagate loop side effects upwards. | 417 // Propagate loop side effects upwards. |
| 417 if (block->HasParentLoopHeader()) { | 418 if (block->HasParentLoopHeader()) { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 743 |
| 743 GvnBasicBlockState* previous_; | 744 GvnBasicBlockState* previous_; |
| 744 GvnBasicBlockState* next_; | 745 GvnBasicBlockState* next_; |
| 745 HBasicBlock* block_; | 746 HBasicBlock* block_; |
| 746 HValueMap* map_; | 747 HValueMap* map_; |
| 747 HSideEffectMap dominators_; | 748 HSideEffectMap dominators_; |
| 748 int dominated_index_; | 749 int dominated_index_; |
| 749 int length_; | 750 int length_; |
| 750 }; | 751 }; |
| 751 | 752 |
| 753 |
| 752 // This is a recursive traversal of the dominator tree but it has been turned | 754 // This is a recursive traversal of the dominator tree but it has been turned |
| 753 // into a loop to avoid stack overflows. | 755 // into a loop to avoid stack overflows. |
| 754 // The logical "stack frames" of the recursion are kept in a list of | 756 // The logical "stack frames" of the recursion are kept in a list of |
| 755 // GvnBasicBlockState instances. | 757 // GvnBasicBlockState instances. |
| 756 void HGlobalValueNumberingPhase::AnalyzeGraph() { | 758 void HGlobalValueNumberingPhase::AnalyzeGraph() { |
| 757 HBasicBlock* entry_block = graph()->entry_block(); | 759 HBasicBlock* entry_block = graph()->entry_block(); |
| 758 HValueMap* entry_map = new(zone()) HValueMap(zone()); | 760 HValueMap* entry_map = new(zone()) HValueMap(zone()); |
| 759 GvnBasicBlockState* current = | 761 GvnBasicBlockState* current = |
| 760 GvnBasicBlockState::CreateEntry(zone(), entry_block, entry_map); | 762 GvnBasicBlockState::CreateEntry(zone(), entry_block, entry_map); |
| 761 | 763 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 dominated); | 848 dominated); |
| 847 successor_map->Kill(side_effects_on_all_paths); | 849 successor_map->Kill(side_effects_on_all_paths); |
| 848 successor_dominators->Kill(side_effects_on_all_paths); | 850 successor_dominators->Kill(side_effects_on_all_paths); |
| 849 } | 851 } |
| 850 } | 852 } |
| 851 current = next; | 853 current = next; |
| 852 } | 854 } |
| 853 } | 855 } |
| 854 | 856 |
| 855 } } // namespace v8::internal | 857 } } // namespace v8::internal |
| OLD | NEW |