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 11 matching lines...) Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #include "double.h" | 30 #include "double.h" |
31 #include "factory.h" | 31 #include "factory.h" |
32 #include "hydrogen.h" | 32 #include "hydrogen-phases.h" |
33 | 33 |
34 #if V8_TARGET_ARCH_IA32 | 34 #if V8_TARGET_ARCH_IA32 |
35 #include "ia32/lithium-ia32.h" | 35 #include "ia32/lithium-ia32.h" |
36 #elif V8_TARGET_ARCH_X64 | 36 #elif V8_TARGET_ARCH_X64 |
37 #include "x64/lithium-x64.h" | 37 #include "x64/lithium-x64.h" |
38 #elif V8_TARGET_ARCH_ARM | 38 #elif V8_TARGET_ARCH_ARM |
39 #include "arm/lithium-arm.h" | 39 #include "arm/lithium-arm.h" |
40 #elif V8_TARGET_ARCH_MIPS | 40 #elif V8_TARGET_ARCH_MIPS |
41 #include "mips/lithium-mips.h" | 41 #include "mips/lithium-mips.h" |
42 #else | 42 #else |
(...skipping 28 matching lines...) Loading... |
71 void HValue::AssumeRepresentation(Representation r) { | 71 void HValue::AssumeRepresentation(Representation r) { |
72 if (CheckFlag(kFlexibleRepresentation)) { | 72 if (CheckFlag(kFlexibleRepresentation)) { |
73 ChangeRepresentation(r); | 73 ChangeRepresentation(r); |
74 // The representation of the value is dictated by type feedback and | 74 // The representation of the value is dictated by type feedback and |
75 // will not be changed later. | 75 // will not be changed later. |
76 ClearFlag(kFlexibleRepresentation); | 76 ClearFlag(kFlexibleRepresentation); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 void HValue::InferRepresentation(HInferRepresentation* h_infer) { | 81 void HValue::InferRepresentation(HInferRepresentationPhase* h_infer) { |
82 ASSERT(CheckFlag(kFlexibleRepresentation)); | 82 ASSERT(CheckFlag(kFlexibleRepresentation)); |
83 Representation new_rep = RepresentationFromInputs(); | 83 Representation new_rep = RepresentationFromInputs(); |
84 UpdateRepresentation(new_rep, h_infer, "inputs"); | 84 UpdateRepresentation(new_rep, h_infer, "inputs"); |
85 new_rep = RepresentationFromUses(); | 85 new_rep = RepresentationFromUses(); |
86 UpdateRepresentation(new_rep, h_infer, "uses"); | 86 UpdateRepresentation(new_rep, h_infer, "uses"); |
87 new_rep = RepresentationFromUseRequirements(); | 87 new_rep = RepresentationFromUseRequirements(); |
88 if (new_rep.fits_into(Representation::Integer32())) { | 88 if (new_rep.fits_into(Representation::Integer32())) { |
89 UpdateRepresentation(new_rep, h_infer, "use requirements"); | 89 UpdateRepresentation(new_rep, h_infer, "use requirements"); |
90 } | 90 } |
91 } | 91 } |
(...skipping 25 matching lines...) Loading... |
117 if (tagged_count > 0) return Representation::Tagged(); | 117 if (tagged_count > 0) return Representation::Tagged(); |
118 if (double_count > 0) return Representation::Double(); | 118 if (double_count > 0) return Representation::Double(); |
119 if (int32_count > 0) return Representation::Integer32(); | 119 if (int32_count > 0) return Representation::Integer32(); |
120 if (smi_count > 0) return Representation::Smi(); | 120 if (smi_count > 0) return Representation::Smi(); |
121 | 121 |
122 return Representation::None(); | 122 return Representation::None(); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 void HValue::UpdateRepresentation(Representation new_rep, | 126 void HValue::UpdateRepresentation(Representation new_rep, |
127 HInferRepresentation* h_infer, | 127 HInferRepresentationPhase* h_infer, |
128 const char* reason) { | 128 const char* reason) { |
129 Representation r = representation(); | 129 Representation r = representation(); |
130 if (new_rep.is_more_general_than(r)) { | 130 if (new_rep.is_more_general_than(r)) { |
131 if (CheckFlag(kCannotBeTagged) && new_rep.IsTagged()) return; | 131 if (CheckFlag(kCannotBeTagged) && new_rep.IsTagged()) return; |
132 if (FLAG_trace_representation) { | 132 if (FLAG_trace_representation) { |
133 PrintF("Changing #%d %s representation %s -> %s based on %s\n", | 133 PrintF("Changing #%d %s representation %s -> %s based on %s\n", |
134 id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason); | 134 id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason); |
135 } | 135 } |
136 ChangeRepresentation(new_rep); | 136 ChangeRepresentation(new_rep); |
137 AddDependantsToWorklist(h_infer); | 137 AddDependantsToWorklist(h_infer); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 | 141 |
142 void HValue::AddDependantsToWorklist(HInferRepresentation* h_infer) { | 142 void HValue::AddDependantsToWorklist(HInferRepresentationPhase* h_infer) { |
143 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 143 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
144 h_infer->AddToWorklist(it.value()); | 144 h_infer->AddToWorklist(it.value()); |
145 } | 145 } |
146 for (int i = 0; i < OperandCount(); ++i) { | 146 for (int i = 0; i < OperandCount(); ++i) { |
147 h_infer->AddToWorklist(OperandAt(i)); | 147 h_infer->AddToWorklist(OperandAt(i)); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 | 151 |
152 // This method is recursive but it is guaranteed to terminate because | 152 // This method is recursive but it is guaranteed to terminate because |
(...skipping 990 matching lines...) Loading... |
1143 stream->Add("index"); | 1143 stream->Add("index"); |
1144 } | 1144 } |
1145 stream->Add(" + %d) >> %d)", offset(), scale()); | 1145 stream->Add(" + %d) >> %d)", offset(), scale()); |
1146 } | 1146 } |
1147 if (skip_check()) { | 1147 if (skip_check()) { |
1148 stream->Add(" [DISABLED]"); | 1148 stream->Add(" [DISABLED]"); |
1149 } | 1149 } |
1150 } | 1150 } |
1151 | 1151 |
1152 | 1152 |
1153 void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) { | 1153 void HBoundsCheck::InferRepresentation(HInferRepresentationPhase* h_infer) { |
1154 ASSERT(CheckFlag(kFlexibleRepresentation)); | 1154 ASSERT(CheckFlag(kFlexibleRepresentation)); |
1155 HValue* actual_index = index()->ActualValue(); | 1155 HValue* actual_index = index()->ActualValue(); |
1156 HValue* actual_length = length()->ActualValue(); | 1156 HValue* actual_length = length()->ActualValue(); |
1157 Representation index_rep = actual_index->representation(); | 1157 Representation index_rep = actual_index->representation(); |
1158 Representation length_rep = actual_length->representation(); | 1158 Representation length_rep = actual_length->representation(); |
1159 if (index_rep.IsTagged() && actual_index->type().IsSmi()) { | 1159 if (index_rep.IsTagged() && actual_index->type().IsSmi()) { |
1160 index_rep = Representation::Smi(); | 1160 index_rep = Representation::Smi(); |
1161 } | 1161 } |
1162 if (length_rep.IsTagged() && actual_length->type().IsSmi()) { | 1162 if (length_rep.IsTagged() && actual_length->type().IsSmi()) { |
1163 length_rep = Representation::Smi(); | 1163 length_rep = Representation::Smi(); |
(...skipping 1153 matching lines...) Loading... |
2317 | 2317 |
2318 void HBinaryOperation::PrintDataTo(StringStream* stream) { | 2318 void HBinaryOperation::PrintDataTo(StringStream* stream) { |
2319 left()->PrintNameTo(stream); | 2319 left()->PrintNameTo(stream); |
2320 stream->Add(" "); | 2320 stream->Add(" "); |
2321 right()->PrintNameTo(stream); | 2321 right()->PrintNameTo(stream); |
2322 if (CheckFlag(kCanOverflow)) stream->Add(" !"); | 2322 if (CheckFlag(kCanOverflow)) stream->Add(" !"); |
2323 if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?"); | 2323 if (CheckFlag(kBailoutOnMinusZero)) stream->Add(" -0?"); |
2324 } | 2324 } |
2325 | 2325 |
2326 | 2326 |
2327 void HBinaryOperation::InferRepresentation(HInferRepresentation* h_infer) { | 2327 void HBinaryOperation::InferRepresentation(HInferRepresentationPhase* h_infer) { |
2328 ASSERT(CheckFlag(kFlexibleRepresentation)); | 2328 ASSERT(CheckFlag(kFlexibleRepresentation)); |
2329 Representation new_rep = RepresentationFromInputs(); | 2329 Representation new_rep = RepresentationFromInputs(); |
2330 UpdateRepresentation(new_rep, h_infer, "inputs"); | 2330 UpdateRepresentation(new_rep, h_infer, "inputs"); |
2331 // When the operation has information about its own output type, don't look | 2331 // When the operation has information about its own output type, don't look |
2332 // at uses. | 2332 // at uses. |
2333 if (!observed_output_representation_.IsNone()) return; | 2333 if (!observed_output_representation_.IsNone()) return; |
2334 new_rep = RepresentationFromUses(); | 2334 new_rep = RepresentationFromUses(); |
2335 UpdateRepresentation(new_rep, h_infer, "uses"); | 2335 UpdateRepresentation(new_rep, h_infer, "uses"); |
2336 new_rep = RepresentationFromUseRequirements(); | 2336 new_rep = RepresentationFromUseRequirements(); |
2337 if (new_rep.fits_into(Representation::Integer32())) { | 2337 if (new_rep.fits_into(Representation::Integer32())) { |
(...skipping 42 matching lines...) Loading... |
2380 } | 2380 } |
2381 | 2381 |
2382 | 2382 |
2383 void HBinaryOperation::AssumeRepresentation(Representation r) { | 2383 void HBinaryOperation::AssumeRepresentation(Representation r) { |
2384 set_observed_input_representation(1, r); | 2384 set_observed_input_representation(1, r); |
2385 set_observed_input_representation(2, r); | 2385 set_observed_input_representation(2, r); |
2386 HValue::AssumeRepresentation(r); | 2386 HValue::AssumeRepresentation(r); |
2387 } | 2387 } |
2388 | 2388 |
2389 | 2389 |
2390 void HMathMinMax::InferRepresentation(HInferRepresentation* h_infer) { | 2390 void HMathMinMax::InferRepresentation(HInferRepresentationPhase* h_infer) { |
2391 ASSERT(CheckFlag(kFlexibleRepresentation)); | 2391 ASSERT(CheckFlag(kFlexibleRepresentation)); |
2392 Representation new_rep = RepresentationFromInputs(); | 2392 Representation new_rep = RepresentationFromInputs(); |
2393 UpdateRepresentation(new_rep, h_infer, "inputs"); | 2393 UpdateRepresentation(new_rep, h_infer, "inputs"); |
2394 // Do not care about uses. | 2394 // Do not care about uses. |
2395 } | 2395 } |
2396 | 2396 |
2397 | 2397 |
2398 Range* HBitwise::InferRange(Zone* zone) { | 2398 Range* HBitwise::InferRange(Zone* zone) { |
2399 if (op() == Token::BIT_XOR) { | 2399 if (op() == Token::BIT_XOR) { |
2400 if (left()->HasRange() && right()->HasRange()) { | 2400 if (left()->HasRange() && right()->HasRange()) { |
(...skipping 158 matching lines...) Loading... |
2559 right()->PrintNameTo(stream); | 2559 right()->PrintNameTo(stream); |
2560 HControlInstruction::PrintDataTo(stream); | 2560 HControlInstruction::PrintDataTo(stream); |
2561 } | 2561 } |
2562 | 2562 |
2563 | 2563 |
2564 void HGoto::PrintDataTo(StringStream* stream) { | 2564 void HGoto::PrintDataTo(StringStream* stream) { |
2565 stream->Add("B%d", SuccessorAt(0)->block_id()); | 2565 stream->Add("B%d", SuccessorAt(0)->block_id()); |
2566 } | 2566 } |
2567 | 2567 |
2568 | 2568 |
2569 void HCompareIDAndBranch::InferRepresentation(HInferRepresentation* h_infer) { | 2569 void HCompareIDAndBranch::InferRepresentation( |
| 2570 HInferRepresentationPhase* h_infer) { |
2570 Representation left_rep = left()->representation(); | 2571 Representation left_rep = left()->representation(); |
2571 Representation right_rep = right()->representation(); | 2572 Representation right_rep = right()->representation(); |
2572 Representation observed_left = observed_input_representation(0); | 2573 Representation observed_left = observed_input_representation(0); |
2573 Representation observed_right = observed_input_representation(1); | 2574 Representation observed_right = observed_input_representation(1); |
2574 | 2575 |
2575 Representation rep = Representation::None(); | 2576 Representation rep = Representation::None(); |
2576 rep = rep.generalize(observed_left); | 2577 rep = rep.generalize(observed_left); |
2577 rep = rep.generalize(observed_right); | 2578 rep = rep.generalize(observed_right); |
2578 if (rep.IsNone() || rep.IsSmiOrInteger32()) { | 2579 if (rep.IsNone() || rep.IsSmiOrInteger32()) { |
2579 if (!left_rep.IsTagged()) rep = rep.generalize(left_rep); | 2580 if (!left_rep.IsTagged()) rep = rep.generalize(left_rep); |
(...skipping 1084 matching lines...) Loading... |
3664 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 3665 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
3665 HValue* use = it.value(); | 3666 HValue* use = it.value(); |
3666 if (use->IsBinaryOperation()) { | 3667 if (use->IsBinaryOperation()) { |
3667 HBinaryOperation::cast(use)->set_observed_input_representation( | 3668 HBinaryOperation::cast(use)->set_observed_input_representation( |
3668 it.index(), Representation::Integer32()); | 3669 it.index(), Representation::Integer32()); |
3669 } | 3670 } |
3670 } | 3671 } |
3671 } | 3672 } |
3672 | 3673 |
3673 | 3674 |
3674 void HPhi::InferRepresentation(HInferRepresentation* h_infer) { | 3675 void HPhi::InferRepresentation(HInferRepresentationPhase* h_infer) { |
3675 ASSERT(CheckFlag(kFlexibleRepresentation)); | 3676 ASSERT(CheckFlag(kFlexibleRepresentation)); |
3676 Representation new_rep = RepresentationFromInputs(); | 3677 Representation new_rep = RepresentationFromInputs(); |
3677 UpdateRepresentation(new_rep, h_infer, "inputs"); | 3678 UpdateRepresentation(new_rep, h_infer, "inputs"); |
3678 new_rep = RepresentationFromUses(); | 3679 new_rep = RepresentationFromUses(); |
3679 UpdateRepresentation(new_rep, h_infer, "uses"); | 3680 UpdateRepresentation(new_rep, h_infer, "uses"); |
3680 new_rep = RepresentationFromUseRequirements(); | 3681 new_rep = RepresentationFromUseRequirements(); |
3681 UpdateRepresentation(new_rep, h_infer, "use requirements"); | 3682 UpdateRepresentation(new_rep, h_infer, "use requirements"); |
3682 } | 3683 } |
3683 | 3684 |
3684 | 3685 |
(...skipping 193 matching lines...) Loading... |
3878 case kBackingStore: | 3879 case kBackingStore: |
3879 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3880 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
3880 stream->Add("[backing-store]"); | 3881 stream->Add("[backing-store]"); |
3881 break; | 3882 break; |
3882 } | 3883 } |
3883 | 3884 |
3884 stream->Add("@%d", offset()); | 3885 stream->Add("@%d", offset()); |
3885 } | 3886 } |
3886 | 3887 |
3887 } } // namespace v8::internal | 3888 } } // namespace v8::internal |
OLD | NEW |