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 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2257 // to Integer32. | 2257 // to Integer32. |
2258 if (observed_output_representation_.is_more_general_than(rep) && | 2258 if (observed_output_representation_.is_more_general_than(rep) && |
2259 !IgnoreObservedOutputRepresentation(rep)) { | 2259 !IgnoreObservedOutputRepresentation(rep)) { |
2260 rep = observed_output_representation_; | 2260 rep = observed_output_representation_; |
2261 } | 2261 } |
2262 return rep; | 2262 return rep; |
2263 } | 2263 } |
2264 | 2264 |
2265 | 2265 |
2266 void HBinaryOperation::AssumeRepresentation(Representation r) { | 2266 void HBinaryOperation::AssumeRepresentation(Representation r) { |
2267 set_observed_input_representation(r, r); | 2267 set_observed_input_representation(1, r); |
| 2268 set_observed_input_representation(2, r); |
2268 HValue::AssumeRepresentation(r); | 2269 HValue::AssumeRepresentation(r); |
2269 } | 2270 } |
2270 | 2271 |
2271 | 2272 |
2272 void HMathMinMax::InferRepresentation(HInferRepresentation* h_infer) { | 2273 void HMathMinMax::InferRepresentation(HInferRepresentation* h_infer) { |
2273 ASSERT(CheckFlag(kFlexibleRepresentation)); | 2274 ASSERT(CheckFlag(kFlexibleRepresentation)); |
2274 Representation new_rep = RepresentationFromInputs(); | 2275 Representation new_rep = RepresentationFromInputs(); |
2275 UpdateRepresentation(new_rep, h_infer, "inputs"); | 2276 UpdateRepresentation(new_rep, h_infer, "inputs"); |
2276 // Do not care about uses. | 2277 // Do not care about uses. |
2277 } | 2278 } |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3455 } | 3456 } |
3456 | 3457 |
3457 | 3458 |
3458 void HBitwise::PrintDataTo(StringStream* stream) { | 3459 void HBitwise::PrintDataTo(StringStream* stream) { |
3459 stream->Add(Token::Name(op_)); | 3460 stream->Add(Token::Name(op_)); |
3460 stream->Add(" "); | 3461 stream->Add(" "); |
3461 HBitwiseBinaryOperation::PrintDataTo(stream); | 3462 HBitwiseBinaryOperation::PrintDataTo(stream); |
3462 } | 3463 } |
3463 | 3464 |
3464 | 3465 |
| 3466 void HPhi::SimplifyConstantInputs() { |
| 3467 // Convert constant inputs to integers when all uses are truncating. |
| 3468 // This must happen before representation inference takes place. |
| 3469 if (!CheckUsesForFlag(kTruncatingToInt32)) return; |
| 3470 for (int i = 0; i < OperandCount(); ++i) { |
| 3471 if (!OperandAt(i)->IsConstant()) return; |
| 3472 } |
| 3473 HGraph* graph = block()->graph(); |
| 3474 for (int i = 0; i < OperandCount(); ++i) { |
| 3475 HConstant* operand = HConstant::cast(OperandAt(i)); |
| 3476 if (operand->HasInteger32Value()) { |
| 3477 continue; |
| 3478 } else if (operand->HasDoubleValue()) { |
| 3479 HConstant* integer_input = |
| 3480 new(graph->zone()) HConstant(DoubleToInt32(operand->DoubleValue()), |
| 3481 Representation::Integer32()); |
| 3482 integer_input->InsertAfter(operand); |
| 3483 SetOperandAt(i, integer_input); |
| 3484 } else if (operand == graph->GetConstantTrue()) { |
| 3485 SetOperandAt(i, graph->GetConstant1()); |
| 3486 } else { |
| 3487 // This catches |false|, |undefined|, strings and objects. |
| 3488 SetOperandAt(i, graph->GetConstant0()); |
| 3489 } |
| 3490 } |
| 3491 // Overwrite observed input representations because they are likely Tagged. |
| 3492 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { |
| 3493 HValue* use = it.value(); |
| 3494 if (use->IsBinaryOperation()) { |
| 3495 HBinaryOperation::cast(use)->set_observed_input_representation( |
| 3496 it.index(), Representation::Integer32()); |
| 3497 } |
| 3498 } |
| 3499 } |
| 3500 |
| 3501 |
3465 void HPhi::InferRepresentation(HInferRepresentation* h_infer) { | 3502 void HPhi::InferRepresentation(HInferRepresentation* h_infer) { |
3466 ASSERT(CheckFlag(kFlexibleRepresentation)); | 3503 ASSERT(CheckFlag(kFlexibleRepresentation)); |
3467 // If there are non-Phi uses, and all of them have observed the same | 3504 // If there are non-Phi uses, and all of them have observed the same |
3468 // representation, than that's what this Phi is going to use. | 3505 // representation, than that's what this Phi is going to use. |
3469 Representation new_rep = RepresentationObservedByAllNonPhiUses(); | 3506 Representation new_rep = RepresentationObservedByAllNonPhiUses(); |
3470 if (!new_rep.IsNone()) { | 3507 if (!new_rep.IsNone()) { |
3471 UpdateRepresentation(new_rep, h_infer, "unanimous use observations"); | 3508 UpdateRepresentation(new_rep, h_infer, "unanimous use observations"); |
3472 return; | 3509 return; |
3473 } | 3510 } |
3474 new_rep = RepresentationFromInputs(); | 3511 new_rep = RepresentationFromInputs(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3604 | 3641 |
3605 | 3642 |
3606 void HCheckFunction::Verify() { | 3643 void HCheckFunction::Verify() { |
3607 HInstruction::Verify(); | 3644 HInstruction::Verify(); |
3608 ASSERT(HasNoUses()); | 3645 ASSERT(HasNoUses()); |
3609 } | 3646 } |
3610 | 3647 |
3611 #endif | 3648 #endif |
3612 | 3649 |
3613 } } // namespace v8::internal | 3650 } } // namespace v8::internal |
OLD | NEW |