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 3489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3500 if (use->IsBinaryOperation()) { | 3500 if (use->IsBinaryOperation()) { |
3501 HBinaryOperation::cast(use)->set_observed_input_representation( | 3501 HBinaryOperation::cast(use)->set_observed_input_representation( |
3502 it.index(), Representation::Integer32()); | 3502 it.index(), Representation::Integer32()); |
3503 } | 3503 } |
3504 } | 3504 } |
3505 } | 3505 } |
3506 | 3506 |
3507 | 3507 |
3508 void HPhi::InferRepresentation(HInferRepresentation* h_infer) { | 3508 void HPhi::InferRepresentation(HInferRepresentation* h_infer) { |
3509 ASSERT(CheckFlag(kFlexibleRepresentation)); | 3509 ASSERT(CheckFlag(kFlexibleRepresentation)); |
3510 // If there are non-Phi uses, and all of them have observed the same | 3510 Representation new_rep = RepresentationFromInputs(); |
3511 // representation, than that's what this Phi is going to use. | |
3512 Representation new_rep = RepresentationObservedByAllNonPhiUses(); | |
3513 if (!new_rep.IsNone()) { | |
3514 UpdateRepresentation(new_rep, h_infer, "unanimous use observations"); | |
3515 return; | |
3516 } | |
3517 new_rep = RepresentationFromInputs(); | |
3518 UpdateRepresentation(new_rep, h_infer, "inputs"); | 3511 UpdateRepresentation(new_rep, h_infer, "inputs"); |
3519 new_rep = RepresentationFromUses(); | 3512 new_rep = RepresentationFromUses(); |
3520 UpdateRepresentation(new_rep, h_infer, "uses"); | 3513 UpdateRepresentation(new_rep, h_infer, "uses"); |
3521 new_rep = RepresentationFromUseRequirements(); | 3514 new_rep = RepresentationFromUseRequirements(); |
3522 UpdateRepresentation(new_rep, h_infer, "use requirements"); | 3515 UpdateRepresentation(new_rep, h_infer, "use requirements"); |
3523 } | 3516 } |
3524 | 3517 |
3525 | 3518 |
3526 Representation HPhi::RepresentationObservedByAllNonPhiUses() { | |
3527 int non_phi_use_count = 0; | |
3528 for (int i = Representation::kInteger32; | |
3529 i < Representation::kNumRepresentations; ++i) { | |
3530 non_phi_use_count += non_phi_uses_[i]; | |
3531 } | |
3532 if (non_phi_use_count <= 1) return Representation::None(); | |
3533 for (int i = 0; i < Representation::kNumRepresentations; ++i) { | |
3534 if (non_phi_uses_[i] == non_phi_use_count) { | |
3535 return Representation::FromKind(static_cast<Representation::Kind>(i)); | |
3536 } | |
3537 } | |
3538 return Representation::None(); | |
3539 } | |
3540 | |
3541 | |
3542 Representation HPhi::RepresentationFromInputs() { | 3519 Representation HPhi::RepresentationFromInputs() { |
3543 bool double_occurred = false; | 3520 bool double_occurred = false; |
3544 bool int32_occurred = false; | 3521 bool int32_occurred = false; |
3545 for (int i = 0; i < OperandCount(); ++i) { | 3522 for (int i = 0; i < OperandCount(); ++i) { |
3546 HValue* value = OperandAt(i); | 3523 HValue* value = OperandAt(i); |
3547 if (value->IsUnknownOSRValue()) { | 3524 if (value->IsUnknownOSRValue()) { |
3548 HPhi* hint_value = HUnknownOSRValue::cast(value)->incoming_value(); | 3525 HPhi* hint_value = HUnknownOSRValue::cast(value)->incoming_value(); |
3549 if (hint_value != NULL) { | 3526 if (hint_value != NULL) { |
3550 Representation hint = hint_value->representation(); | 3527 Representation hint = hint_value->representation(); |
3551 if (hint.IsTagged()) return hint; | 3528 if (hint.IsTagged()) return hint; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3647 | 3624 |
3648 | 3625 |
3649 void HCheckFunction::Verify() { | 3626 void HCheckFunction::Verify() { |
3650 HInstruction::Verify(); | 3627 HInstruction::Verify(); |
3651 ASSERT(HasNoUses()); | 3628 ASSERT(HasNoUses()); |
3652 } | 3629 } |
3653 | 3630 |
3654 #endif | 3631 #endif |
3655 | 3632 |
3656 } } // namespace v8::internal | 3633 } } // namespace v8::internal |
OLD | NEW |