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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 | 80 |
81 void HValue::InferRepresentation(HInferRepresentation* h_infer) { | 81 void HValue::InferRepresentation(HInferRepresentation* 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(); |
| 88 if (new_rep.fits_into(Representation::Integer32())) { |
| 89 UpdateRepresentation(new_rep, h_infer, "use requirements"); |
| 90 } |
87 } | 91 } |
88 | 92 |
89 | 93 |
90 Representation HValue::RepresentationFromUses() { | 94 Representation HValue::RepresentationFromUses() { |
91 if (HasNoUses()) return Representation::None(); | 95 if (HasNoUses()) return Representation::None(); |
92 | 96 |
93 // Array of use counts for each representation. | 97 // Array of use counts for each representation. |
94 int use_count[Representation::kNumRepresentations] = { 0 }; | 98 int use_count[Representation::kNumRepresentations] = { 0 }; |
95 | 99 |
96 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 100 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2297 | 2301 |
2298 void HBinaryOperation::InferRepresentation(HInferRepresentation* h_infer) { | 2302 void HBinaryOperation::InferRepresentation(HInferRepresentation* h_infer) { |
2299 ASSERT(CheckFlag(kFlexibleRepresentation)); | 2303 ASSERT(CheckFlag(kFlexibleRepresentation)); |
2300 Representation new_rep = RepresentationFromInputs(); | 2304 Representation new_rep = RepresentationFromInputs(); |
2301 UpdateRepresentation(new_rep, h_infer, "inputs"); | 2305 UpdateRepresentation(new_rep, h_infer, "inputs"); |
2302 // When the operation has information about its own output type, don't look | 2306 // When the operation has information about its own output type, don't look |
2303 // at uses. | 2307 // at uses. |
2304 if (!observed_output_representation_.IsNone()) return; | 2308 if (!observed_output_representation_.IsNone()) return; |
2305 new_rep = RepresentationFromUses(); | 2309 new_rep = RepresentationFromUses(); |
2306 UpdateRepresentation(new_rep, h_infer, "uses"); | 2310 UpdateRepresentation(new_rep, h_infer, "uses"); |
| 2311 new_rep = RepresentationFromUseRequirements(); |
| 2312 if (new_rep.fits_into(Representation::Integer32())) { |
| 2313 UpdateRepresentation(new_rep, h_infer, "use requirements"); |
| 2314 } |
2307 } | 2315 } |
2308 | 2316 |
2309 | 2317 |
2310 bool HBinaryOperation::IgnoreObservedOutputRepresentation( | 2318 bool HBinaryOperation::IgnoreObservedOutputRepresentation( |
2311 Representation current_rep) { | 2319 Representation current_rep) { |
2312 return observed_output_representation_.IsDouble() && | 2320 return observed_output_representation_.IsDouble() && |
2313 current_rep.IsInteger32() && | 2321 current_rep.IsInteger32() && |
2314 // Mul in Integer32 mode would be too precise. | 2322 // Mul in Integer32 mode would be too precise. |
2315 !this->IsMul() && | 2323 !this->IsMul() && |
2316 CheckUsesForFlag(kTruncatingToInt32); | 2324 CheckUsesForFlag(kTruncatingToInt32); |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3653 | 3661 |
3654 Representation HPhi::RepresentationFromInputs() { | 3662 Representation HPhi::RepresentationFromInputs() { |
3655 Representation r = Representation::None(); | 3663 Representation r = Representation::None(); |
3656 for (int i = 0; i < OperandCount(); ++i) { | 3664 for (int i = 0; i < OperandCount(); ++i) { |
3657 r = r.generalize(OperandAt(i)->KnownOptimalRepresentation()); | 3665 r = r.generalize(OperandAt(i)->KnownOptimalRepresentation()); |
3658 } | 3666 } |
3659 return r; | 3667 return r; |
3660 } | 3668 } |
3661 | 3669 |
3662 | 3670 |
3663 Representation HPhi::RepresentationFromUseRequirements() { | 3671 // Returns a representation if all uses agree on the same representation. |
3664 Representation all_uses_require = Representation::None(); | 3672 // Integer32 is also returned when some uses are Smi but others are Integer32. |
3665 bool all_uses_require_the_same = true; | 3673 Representation HValue::RepresentationFromUseRequirements() { |
| 3674 Representation rep = Representation::None(); |
3666 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { | 3675 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
3667 // We check for observed_input_representation elsewhere. | 3676 // We check for observed_input_representation elsewhere. |
3668 Representation use_rep = | 3677 Representation use_rep = |
3669 it.value()->RequiredInputRepresentation(it.index()); | 3678 it.value()->RequiredInputRepresentation(it.index()); |
3670 // No useful info from this use -> look at the next one. | 3679 if (rep.IsNone()) { |
3671 if (use_rep.IsNone()) { | 3680 rep = use_rep; |
3672 continue; | 3681 continue; |
3673 } | 3682 } |
3674 if (use_rep.Equals(all_uses_require)) { | 3683 if (use_rep.IsNone() || rep.Equals(use_rep)) continue; |
| 3684 if (rep.generalize(use_rep).IsInteger32()) { |
| 3685 rep = Representation::Integer32(); |
3675 continue; | 3686 continue; |
3676 } | 3687 } |
3677 // This use's representation contradicts what we've seen so far. | 3688 return Representation::None(); |
3678 if (!all_uses_require.IsNone()) { | |
3679 ASSERT(!use_rep.Equals(all_uses_require)); | |
3680 all_uses_require_the_same = false; | |
3681 break; | |
3682 } | |
3683 // Otherwise, initialize observed representation. | |
3684 all_uses_require = use_rep; | |
3685 } | 3689 } |
3686 if (all_uses_require_the_same) { | 3690 return rep; |
3687 return all_uses_require; | |
3688 } | |
3689 | |
3690 return Representation::None(); | |
3691 } | 3691 } |
3692 | 3692 |
3693 | 3693 |
3694 // Node-specific verification code is only included in debug mode. | 3694 // Node-specific verification code is only included in debug mode. |
3695 #ifdef DEBUG | 3695 #ifdef DEBUG |
3696 | 3696 |
3697 void HPhi::Verify() { | 3697 void HPhi::Verify() { |
3698 ASSERT(OperandCount() == block()->predecessors()->length()); | 3698 ASSERT(OperandCount() == block()->predecessors()->length()); |
3699 for (int i = 0; i < OperandCount(); ++i) { | 3699 for (int i = 0; i < OperandCount(); ++i) { |
3700 HValue* value = OperandAt(i); | 3700 HValue* value = OperandAt(i); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3855 case kBackingStore: | 3855 case kBackingStore: |
3856 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3856 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
3857 stream->Add("[backing-store]"); | 3857 stream->Add("[backing-store]"); |
3858 break; | 3858 break; |
3859 } | 3859 } |
3860 | 3860 |
3861 stream->Add("@%d", offset()); | 3861 stream->Add("@%d", offset()); |
3862 } | 3862 } |
3863 | 3863 |
3864 } } // namespace v8::internal | 3864 } } // namespace v8::internal |
OLD | NEW |