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 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 | 1704 |
1705 class HGlobalValueNumberer BASE_EMBEDDED { | 1705 class HGlobalValueNumberer BASE_EMBEDDED { |
1706 public: | 1706 public: |
1707 explicit HGlobalValueNumberer(HGraph* graph, CompilationInfo* info) | 1707 explicit HGlobalValueNumberer(HGraph* graph, CompilationInfo* info) |
1708 : graph_(graph), | 1708 : graph_(graph), |
1709 info_(info), | 1709 info_(info), |
1710 removed_side_effects_(false), | 1710 removed_side_effects_(false), |
1711 block_side_effects_(graph->blocks()->length(), graph->zone()), | 1711 block_side_effects_(graph->blocks()->length(), graph->zone()), |
1712 loop_side_effects_(graph->blocks()->length(), graph->zone()), | 1712 loop_side_effects_(graph->blocks()->length(), graph->zone()), |
1713 visited_on_paths_(graph->zone(), graph->blocks()->length()) { | 1713 visited_on_paths_(graph->zone(), graph->blocks()->length()) { |
1714 ASSERT(info->isolate()->heap()->allow_allocation(false)); | 1714 ASSERT(!info->isolate()->heap()->IsAllocationAllowed()); |
1715 block_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(), | 1715 block_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(), |
1716 graph_->zone()); | 1716 graph_->zone()); |
1717 loop_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(), | 1717 loop_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(), |
1718 graph_->zone()); | 1718 graph_->zone()); |
1719 } | 1719 } |
1720 ~HGlobalValueNumberer() { | |
1721 ASSERT(!info_->isolate()->heap()->allow_allocation(true)); | |
1722 } | |
1723 | 1720 |
1724 // Returns true if values with side effects are removed. | 1721 // Returns true if values with side effects are removed. |
1725 bool Analyze(); | 1722 bool Analyze(); |
1726 | 1723 |
1727 private: | 1724 private: |
1728 GVNFlagSet CollectSideEffectsOnPathsToDominatedBlock( | 1725 GVNFlagSet CollectSideEffectsOnPathsToDominatedBlock( |
1729 HBasicBlock* dominator, | 1726 HBasicBlock* dominator, |
1730 HBasicBlock* dominated); | 1727 HBasicBlock* dominated); |
1731 void AnalyzeGraph(); | 1728 void AnalyzeGraph(); |
1732 void ComputeBlockSideEffects(); | 1729 void ComputeBlockSideEffects(); |
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined()); | 3075 HReturn* instr = new(zone()) HReturn(graph()->GetConstantUndefined()); |
3079 current_block()->FinishExit(instr); | 3076 current_block()->FinishExit(instr); |
3080 set_current_block(NULL); | 3077 set_current_block(NULL); |
3081 } | 3078 } |
3082 } | 3079 } |
3083 | 3080 |
3084 return graph(); | 3081 return graph(); |
3085 } | 3082 } |
3086 | 3083 |
3087 bool HGraph::Optimize(SmartArrayPointer<char>* bailout_reason) { | 3084 bool HGraph::Optimize(SmartArrayPointer<char>* bailout_reason) { |
| 3085 NoHandleAllocation no_handles; |
| 3086 AssertNoAllocation no_gc; |
| 3087 |
3088 *bailout_reason = SmartArrayPointer<char>(); | 3088 *bailout_reason = SmartArrayPointer<char>(); |
3089 OrderBlocks(); | 3089 OrderBlocks(); |
3090 AssignDominators(); | 3090 AssignDominators(); |
3091 | 3091 |
3092 #ifdef DEBUG | 3092 #ifdef DEBUG |
3093 // Do a full verify after building the graph and computing dominators. | 3093 // Do a full verify after building the graph and computing dominators. |
3094 Verify(true); | 3094 Verify(true); |
3095 #endif | 3095 #endif |
3096 | 3096 |
3097 PropagateDeoptimizingMark(); | 3097 PropagateDeoptimizingMark(); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3475 table->Insert(data->Key(), data->FatherInDominatorTree(), zone()); | 3475 table->Insert(data->Key(), data->FatherInDominatorTree(), zone()); |
3476 } else { | 3476 } else { |
3477 table->Delete(data->Key()); | 3477 table->Delete(data->Key()); |
3478 } | 3478 } |
3479 } | 3479 } |
3480 } | 3480 } |
3481 | 3481 |
3482 | 3482 |
3483 void HGraph::EliminateRedundantBoundsChecks() { | 3483 void HGraph::EliminateRedundantBoundsChecks() { |
3484 HPhase phase("H_Eliminate bounds checks", this); | 3484 HPhase phase("H_Eliminate bounds checks", this); |
3485 AssertNoAllocation no_gc; | |
3486 BoundsCheckTable checks_table(zone()); | 3485 BoundsCheckTable checks_table(zone()); |
3487 EliminateRedundantBoundsChecks(entry_block(), &checks_table); | 3486 EliminateRedundantBoundsChecks(entry_block(), &checks_table); |
3488 } | 3487 } |
3489 | 3488 |
3490 | 3489 |
3491 static void DehoistArrayIndex(ArrayInstructionInterface* array_operation) { | 3490 static void DehoistArrayIndex(ArrayInstructionInterface* array_operation) { |
3492 HValue* index = array_operation->GetKey(); | 3491 HValue* index = array_operation->GetKey(); |
3493 | 3492 |
3494 HConstant* constant; | 3493 HConstant* constant; |
3495 HValue* subexpression; | 3494 HValue* subexpression; |
(...skipping 6037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9533 } | 9532 } |
9534 } | 9533 } |
9535 | 9534 |
9536 #ifdef DEBUG | 9535 #ifdef DEBUG |
9537 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 9536 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
9538 if (allocator_ != NULL) allocator_->Verify(); | 9537 if (allocator_ != NULL) allocator_->Verify(); |
9539 #endif | 9538 #endif |
9540 } | 9539 } |
9541 | 9540 |
9542 } } // namespace v8::internal | 9541 } } // namespace v8::internal |
OLD | NEW |