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

Side by Side Diff: src/hydrogen-instructions.cc

Issue 17005004: Cleanup RepresentationFromUseRequirements, move it to HValue and use it where relevant (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Missing case Created 7 years, 6 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-instructions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 Representation HValue::RepresentationFromUseRequirements() {
3664 Representation all_uses_require = Representation::None(); 3672 Representation rep = Representation::None();
3665 bool all_uses_require_the_same = true;
3666 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { 3673 for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
Jakob Kummerow 2013/06/14 13:36:43 Please add a high-level comment outlining the algo
Toon Verwaest 2013/06/14 13:58:12 Done.
3667 // We check for observed_input_representation elsewhere. 3674 // We check for observed_input_representation elsewhere.
3668 Representation use_rep = 3675 Representation use_rep =
3669 it.value()->RequiredInputRepresentation(it.index()); 3676 it.value()->RequiredInputRepresentation(it.index());
3670 // No useful info from this use -> look at the next one. 3677 if (rep.IsNone()) {
3671 if (use_rep.IsNone()) { 3678 rep = use_rep;
3672 continue; 3679 continue;
3673 } 3680 }
3674 if (use_rep.Equals(all_uses_require)) { 3681 if (use_rep.IsNone() || rep.Equals(use_rep)) continue;
3682 if (rep.generalize(use_rep).IsInteger32()) {
3683 rep = Representation::Integer32();
3675 continue; 3684 continue;
3676 } 3685 }
3677 // This use's representation contradicts what we've seen so far. 3686 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 } 3687 }
3686 if (all_uses_require_the_same) { 3688 return rep;
3687 return all_uses_require;
3688 }
3689
3690 return Representation::None();
3691 } 3689 }
3692 3690
3693 3691
3694 // Node-specific verification code is only included in debug mode. 3692 // Node-specific verification code is only included in debug mode.
3695 #ifdef DEBUG 3693 #ifdef DEBUG
3696 3694
3697 void HPhi::Verify() { 3695 void HPhi::Verify() {
3698 ASSERT(OperandCount() == block()->predecessors()->length()); 3696 ASSERT(OperandCount() == block()->predecessors()->length());
3699 for (int i = 0; i < OperandCount(); ++i) { 3697 for (int i = 0; i < OperandCount(); ++i) {
3700 HValue* value = OperandAt(i); 3698 HValue* value = OperandAt(i);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3855 case kBackingStore: 3853 case kBackingStore:
3856 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 3854 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3857 stream->Add("[backing-store]"); 3855 stream->Add("[backing-store]");
3858 break; 3856 break;
3859 } 3857 }
3860 3858
3861 stream->Add("@%d", offset()); 3859 stream->Add("@%d", offset());
3862 } 3860 }
3863 3861
3864 } } // namespace v8::internal 3862 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698