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 3928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3939 int checksum = type_info->own_type_change_checksum(); | 3939 int checksum = type_info->own_type_change_checksum(); |
3940 int composite_checksum = graph()->update_type_change_checksum(checksum); | 3940 int composite_checksum = graph()->update_type_change_checksum(checksum); |
3941 graph()->set_use_optimistic_licm( | 3941 graph()->set_use_optimistic_licm( |
3942 !type_info->matches_inlined_type_change_checksum(composite_checksum)); | 3942 !type_info->matches_inlined_type_change_checksum(composite_checksum)); |
3943 type_info->set_inlined_type_change_checksum(composite_checksum); | 3943 type_info->set_inlined_type_change_checksum(composite_checksum); |
3944 | 3944 |
3945 return true; | 3945 return true; |
3946 } | 3946 } |
3947 | 3947 |
3948 | 3948 |
3949 // Perform common subexpression elimination and loop-invariant code motion. | |
3950 void HGraph::GlobalValueNumbering() { | |
3951 HPhase phase("H_Global value numbering", this); | |
3952 HGlobalValueNumberer gvn(this, info()); | |
3953 bool removed_side_effects = gvn.Analyze(); | |
3954 // Trigger a second analysis pass to further eliminate duplicate values that | |
3955 // could only be discovered by removing side-effect-generating instructions | |
3956 // during the first pass. | |
3957 if (FLAG_smi_only_arrays && removed_side_effects) { | |
3958 removed_side_effects = gvn.Analyze(); | |
3959 ASSERT(!removed_side_effects); | |
3960 } | |
3961 } | |
3962 | |
3963 | |
3964 bool HGraph::Optimize(SmartArrayPointer<char>* bailout_reason) { | 3949 bool HGraph::Optimize(SmartArrayPointer<char>* bailout_reason) { |
3965 *bailout_reason = SmartArrayPointer<char>(); | 3950 *bailout_reason = SmartArrayPointer<char>(); |
3966 OrderBlocks(); | 3951 OrderBlocks(); |
3967 AssignDominators(); | 3952 AssignDominators(); |
3968 | 3953 |
3969 // We need to create a HConstant "zero" now so that GVN will fold every | 3954 // We need to create a HConstant "zero" now so that GVN will fold every |
3970 // zero-valued constant in the graph together. | 3955 // zero-valued constant in the graph together. |
3971 // The constant is needed to make idef-based bounds check work: the pass | 3956 // The constant is needed to make idef-based bounds check work: the pass |
3972 // evaluates relations with "zero" and that zero cannot be created after GVN. | 3957 // evaluates relations with "zero" and that zero cannot be created after GVN. |
3973 GetConstant0(); | 3958 GetConstant0(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4022 | 4007 |
4023 InitializeInferredTypes(); | 4008 InitializeInferredTypes(); |
4024 | 4009 |
4025 // Must be performed before canonicalization to ensure that Canonicalize | 4010 // Must be performed before canonicalization to ensure that Canonicalize |
4026 // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with | 4011 // will not remove semantically meaningful ToInt32 operations e.g. BIT_OR with |
4027 // zero. | 4012 // zero. |
4028 if (FLAG_opt_safe_uint32_operations) ComputeSafeUint32Operations(); | 4013 if (FLAG_opt_safe_uint32_operations) ComputeSafeUint32Operations(); |
4029 | 4014 |
4030 if (FLAG_use_canonicalizing) Canonicalize(); | 4015 if (FLAG_use_canonicalizing) Canonicalize(); |
4031 | 4016 |
4032 if (FLAG_use_gvn) GlobalValueNumbering(); | 4017 if (FLAG_use_gvn) { |
| 4018 HGlobalValueNumberingPhase phase(this); |
| 4019 phase.Run(); |
| 4020 } |
4033 | 4021 |
4034 if (FLAG_use_range) { | 4022 if (FLAG_use_range) { |
4035 HRangeAnalysis rangeAnalysis(this); | 4023 HRangeAnalysis rangeAnalysis(this); |
4036 rangeAnalysis.Analyze(); | 4024 rangeAnalysis.Analyze(); |
4037 } | 4025 } |
4038 ComputeMinusZeroChecks(); | 4026 ComputeMinusZeroChecks(); |
4039 | 4027 |
4040 // Eliminate redundant stack checks on backwards branches. | 4028 // Eliminate redundant stack checks on backwards branches. |
4041 HStackCheckEliminator sce(this); | 4029 HStackCheckEliminator sce(this); |
4042 sce.Process(); | 4030 sce.Process(); |
(...skipping 7511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11554 if (ShouldProduceTraceOutput()) { | 11542 if (ShouldProduceTraceOutput()) { |
11555 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11543 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11556 } | 11544 } |
11557 | 11545 |
11558 #ifdef DEBUG | 11546 #ifdef DEBUG |
11559 graph_->Verify(false); // No full verify. | 11547 graph_->Verify(false); // No full verify. |
11560 #endif | 11548 #endif |
11561 } | 11549 } |
11562 | 11550 |
11563 } } // namespace v8::internal | 11551 } } // namespace v8::internal |
OLD | NEW |