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

Side by Side Diff: src/hydrogen.cc

Issue 18666006: Refactor compute minus zero checks into a proper HPhase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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/hydrogen.h ('k') | src/hydrogen-minus-zero.h » ('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 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 22 matching lines...) Expand all
33 #include "codegen.h" 33 #include "codegen.h"
34 #include "full-codegen.h" 34 #include "full-codegen.h"
35 #include "hashmap.h" 35 #include "hashmap.h"
36 #include "hydrogen-bce.h" 36 #include "hydrogen-bce.h"
37 #include "hydrogen-dce.h" 37 #include "hydrogen-dce.h"
38 #include "hydrogen-environment-liveness.h" 38 #include "hydrogen-environment-liveness.h"
39 #include "hydrogen-escape-analysis.h" 39 #include "hydrogen-escape-analysis.h"
40 #include "hydrogen-infer-representation.h" 40 #include "hydrogen-infer-representation.h"
41 #include "hydrogen-infer-types.h" 41 #include "hydrogen-infer-types.h"
42 #include "hydrogen-gvn.h" 42 #include "hydrogen-gvn.h"
43 #include "hydrogen-minus-zero.h"
43 #include "hydrogen-osr.h" 44 #include "hydrogen-osr.h"
44 #include "hydrogen-range-analysis.h" 45 #include "hydrogen-range-analysis.h"
45 #include "hydrogen-redundant-phi.h" 46 #include "hydrogen-redundant-phi.h"
46 #include "hydrogen-representation-changes.h" 47 #include "hydrogen-representation-changes.h"
47 #include "hydrogen-sce.h" 48 #include "hydrogen-sce.h"
48 #include "hydrogen-uint32-analysis.h" 49 #include "hydrogen-uint32-analysis.h"
49 #include "lithium-allocator.h" 50 #include "lithium-allocator.h"
50 #include "parser.h" 51 #include "parser.h"
51 #include "scopeinfo.h" 52 #include "scopeinfo.h"
52 #include "scopes.h" 53 #include "scopes.h"
(...skipping 2574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 2628
2628 if (!mergelist.is_empty()) { 2629 if (!mergelist.is_empty()) {
2629 // Merge the accumulated simulates at the end of the block. 2630 // Merge the accumulated simulates at the end of the block.
2630 HSimulate* last = mergelist.RemoveLast(); 2631 HSimulate* last = mergelist.RemoveLast();
2631 last->MergeWith(&mergelist); 2632 last->MergeWith(&mergelist);
2632 } 2633 }
2633 } 2634 }
2634 } 2635 }
2635 2636
2636 2637
2637 void HGraph::PropagateMinusZeroChecks(HValue* value, BitVector* visited) {
2638 HValue* current = value;
2639 while (current != NULL) {
2640 if (visited->Contains(current->id())) return;
2641
2642 // For phis, we must propagate the check to all of its inputs.
2643 if (current->IsPhi()) {
2644 visited->Add(current->id());
2645 HPhi* phi = HPhi::cast(current);
2646 for (int i = 0; i < phi->OperandCount(); ++i) {
2647 PropagateMinusZeroChecks(phi->OperandAt(i), visited);
2648 }
2649 break;
2650 }
2651
2652 // For multiplication, division, and Math.min/max(), we must propagate
2653 // to the left and the right side.
2654 if (current->IsMul()) {
2655 HMul* mul = HMul::cast(current);
2656 mul->EnsureAndPropagateNotMinusZero(visited);
2657 PropagateMinusZeroChecks(mul->left(), visited);
2658 PropagateMinusZeroChecks(mul->right(), visited);
2659 } else if (current->IsDiv()) {
2660 HDiv* div = HDiv::cast(current);
2661 div->EnsureAndPropagateNotMinusZero(visited);
2662 PropagateMinusZeroChecks(div->left(), visited);
2663 PropagateMinusZeroChecks(div->right(), visited);
2664 } else if (current->IsMathMinMax()) {
2665 HMathMinMax* minmax = HMathMinMax::cast(current);
2666 visited->Add(minmax->id());
2667 PropagateMinusZeroChecks(minmax->left(), visited);
2668 PropagateMinusZeroChecks(minmax->right(), visited);
2669 }
2670
2671 current = current->EnsureAndPropagateNotMinusZero(visited);
2672 }
2673 }
2674
2675
2676 void HGraph::RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi) { 2638 void HGraph::RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi* phi) {
2677 if (!phi->CheckFlag(HValue::kAllowUndefinedAsNaN)) return; 2639 if (!phi->CheckFlag(HValue::kAllowUndefinedAsNaN)) return;
2678 phi->ClearFlag(HValue::kAllowUndefinedAsNaN); 2640 phi->ClearFlag(HValue::kAllowUndefinedAsNaN);
2679 for (int i = 0; i < phi->OperandCount(); ++i) { 2641 for (int i = 0; i < phi->OperandCount(); ++i) {
2680 HValue* input = phi->OperandAt(i); 2642 HValue* input = phi->OperandAt(i);
2681 if (input->IsPhi()) { 2643 if (input->IsPhi()) {
2682 RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi::cast(input)); 2644 RecursivelyMarkPhiDeoptimizeOnUndefined(HPhi::cast(input));
2683 } 2645 }
2684 } 2646 }
2685 } 2647 }
(...skipping 12 matching lines...) Expand all
2698 HValue* use_value = it.value(); 2660 HValue* use_value = it.value();
2699 if (!use_value->CheckFlag(HValue::kAllowUndefinedAsNaN)) { 2661 if (!use_value->CheckFlag(HValue::kAllowUndefinedAsNaN)) {
2700 RecursivelyMarkPhiDeoptimizeOnUndefined(phi); 2662 RecursivelyMarkPhiDeoptimizeOnUndefined(phi);
2701 break; 2663 break;
2702 } 2664 }
2703 } 2665 }
2704 } 2666 }
2705 } 2667 }
2706 2668
2707 2669
2708 void HGraph::ComputeMinusZeroChecks() {
2709 HPhase phase("H_Compute minus zero checks", this);
2710 BitVector visited(GetMaximumValueID(), zone());
2711 for (int i = 0; i < blocks_.length(); ++i) {
2712 for (HInstructionIterator it(blocks_[i]); !it.Done(); it.Advance()) {
2713 HInstruction* current = it.Current();
2714 if (current->IsChange()) {
2715 HChange* change = HChange::cast(current);
2716 // Propagate flags for negative zero checks upwards from conversions
2717 // int32-to-tagged and int32-to-double.
2718 Representation from = change->value()->representation();
2719 ASSERT(from.Equals(change->from()));
2720 if (from.IsInteger32()) {
2721 ASSERT(change->to().IsTagged() ||
2722 change->to().IsDouble() ||
2723 change->to().IsSmi());
2724 ASSERT(visited.IsEmpty());
2725 PropagateMinusZeroChecks(change->value(), &visited);
2726 visited.Clear();
2727 }
2728 }
2729 }
2730 }
2731 }
2732
2733
2734 // Implementation of utility class to encapsulate the translation state for 2670 // Implementation of utility class to encapsulate the translation state for
2735 // a (possibly inlined) function. 2671 // a (possibly inlined) function.
2736 FunctionState::FunctionState(HOptimizedGraphBuilder* owner, 2672 FunctionState::FunctionState(HOptimizedGraphBuilder* owner,
2737 CompilationInfo* info, 2673 CompilationInfo* info,
2738 InliningKind inlining_kind) 2674 InliningKind inlining_kind)
2739 : owner_(owner), 2675 : owner_(owner),
2740 compilation_info_(info), 2676 compilation_info_(info),
2741 call_context_(NULL), 2677 call_context_(NULL),
2742 inlining_kind_(inlining_kind), 2678 inlining_kind_(inlining_kind),
2743 function_return_(NULL), 2679 function_return_(NULL),
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
3214 if (FLAG_opt_safe_uint32_operations) Run<HUint32AnalysisPhase>(); 3150 if (FLAG_opt_safe_uint32_operations) Run<HUint32AnalysisPhase>();
3215 3151
3216 if (FLAG_use_canonicalizing) Canonicalize(); 3152 if (FLAG_use_canonicalizing) Canonicalize();
3217 3153
3218 if (FLAG_use_escape_analysis) Run<HEscapeAnalysisPhase>(); 3154 if (FLAG_use_escape_analysis) Run<HEscapeAnalysisPhase>();
3219 3155
3220 if (FLAG_use_gvn) Run<HGlobalValueNumberingPhase>(); 3156 if (FLAG_use_gvn) Run<HGlobalValueNumberingPhase>();
3221 3157
3222 if (FLAG_use_range) Run<HRangeAnalysisPhase>(); 3158 if (FLAG_use_range) Run<HRangeAnalysisPhase>();
3223 3159
3224 ComputeMinusZeroChecks(); 3160 Run<HComputeMinusZeroChecksPhase>();
3225 3161
3226 // Eliminate redundant stack checks on backwards branches. 3162 // Eliminate redundant stack checks on backwards branches.
3227 Run<HStackCheckEliminationPhase>(); 3163 Run<HStackCheckEliminationPhase>();
3228 3164
3229 if (FLAG_idefs) SetupInformativeDefinitions(); 3165 if (FLAG_idefs) SetupInformativeDefinitions();
3230 if (FLAG_array_bounds_checks_elimination && !FLAG_idefs) { 3166 if (FLAG_array_bounds_checks_elimination && !FLAG_idefs) {
3231 Run<HBoundsCheckEliminationPhase>(); 3167 Run<HBoundsCheckEliminationPhase>();
3232 } 3168 }
3233 if (FLAG_array_index_dehoisting) DehoistSimpleArrayIndexComputations(); 3169 if (FLAG_array_index_dehoisting) DehoistSimpleArrayIndexComputations();
3234 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>(); 3170 if (FLAG_dead_code_elimination) Run<HDeadCodeEliminationPhase>();
(...skipping 7005 matching lines...) Expand 10 before | Expand all | Expand 10 after
10240 if (ShouldProduceTraceOutput()) { 10176 if (ShouldProduceTraceOutput()) {
10241 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 10177 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
10242 } 10178 }
10243 10179
10244 #ifdef DEBUG 10180 #ifdef DEBUG
10245 graph_->Verify(false); // No full verify. 10181 graph_->Verify(false); // No full verify.
10246 #endif 10182 #endif
10247 } 10183 }
10248 10184
10249 } } // namespace v8::internal 10185 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-minus-zero.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698