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

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

Issue 15692004: Update representation-from-uses to support smi. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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') | src/string-stream.h » ('j') | 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 PrintF("#%d %s is used by #%d %s as %s%s\n", 101 PrintF("#%d %s is used by #%d %s as %s%s\n",
102 id(), Mnemonic(), use->id(), use->Mnemonic(), rep.Mnemonic(), 102 id(), Mnemonic(), use->id(), use->Mnemonic(), rep.Mnemonic(),
103 (use->CheckFlag(kTruncatingToInt32) ? "-trunc" : "")); 103 (use->CheckFlag(kTruncatingToInt32) ? "-trunc" : ""));
104 } 104 }
105 use_count[rep.kind()] += use->LoopWeight(); 105 use_count[rep.kind()] += use->LoopWeight();
106 } 106 }
107 if (IsPhi()) HPhi::cast(this)->AddIndirectUsesTo(&use_count[0]); 107 if (IsPhi()) HPhi::cast(this)->AddIndirectUsesTo(&use_count[0]);
108 int tagged_count = use_count[Representation::kTagged]; 108 int tagged_count = use_count[Representation::kTagged];
109 int double_count = use_count[Representation::kDouble]; 109 int double_count = use_count[Representation::kDouble];
110 int int32_count = use_count[Representation::kInteger32]; 110 int int32_count = use_count[Representation::kInteger32];
111 int smi_count = use_count[Representation::kSmi];
111 112
112 if (tagged_count > 0) return Representation::Tagged(); 113 if (tagged_count > 0) return Representation::Tagged();
113 if (double_count > 0) return Representation::Double(); 114 if (double_count > 0) return Representation::Double();
114 if (int32_count > 0) return Representation::Integer32(); 115 if (int32_count > 0) return Representation::Integer32();
116 if (smi_count > 0) return Representation::Smi();
115 117
116 return Representation::None(); 118 return Representation::None();
117 } 119 }
118 120
119 121
120 void HValue::UpdateRepresentation(Representation new_rep, 122 void HValue::UpdateRepresentation(Representation new_rep,
121 HInferRepresentation* h_infer, 123 HInferRepresentation* h_infer,
122 const char* reason) { 124 const char* reason) {
123 Representation r = representation(); 125 Representation r = representation();
124 if (new_rep.is_more_general_than(r)) { 126 if (new_rep.is_more_general_than(r)) {
(...skipping 1777 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 1904
1903 1905
1904 void HPhi::PrintTo(StringStream* stream) { 1906 void HPhi::PrintTo(StringStream* stream) {
1905 stream->Add("["); 1907 stream->Add("[");
1906 for (int i = 0; i < OperandCount(); ++i) { 1908 for (int i = 0; i < OperandCount(); ++i) {
1907 HValue* value = OperandAt(i); 1909 HValue* value = OperandAt(i);
1908 stream->Add(" "); 1910 stream->Add(" ");
1909 value->PrintNameTo(stream); 1911 value->PrintNameTo(stream);
1910 stream->Add(" "); 1912 stream->Add(" ");
1911 } 1913 }
1912 stream->Add(" uses:%d_%di_%dd_%dt", 1914 stream->Add(" uses:%d_%ds_%di_%dd_%dt",
1913 UseCount(), 1915 UseCount(),
1916 smi_non_phi_uses() + smi_indirect_uses(),
1914 int32_non_phi_uses() + int32_indirect_uses(), 1917 int32_non_phi_uses() + int32_indirect_uses(),
1915 double_non_phi_uses() + double_indirect_uses(), 1918 double_non_phi_uses() + double_indirect_uses(),
1916 tagged_non_phi_uses() + tagged_indirect_uses()); 1919 tagged_non_phi_uses() + tagged_indirect_uses());
1917 if (!IsConvertibleToInteger()) stream->Add("_ncti"); 1920 if (!IsConvertibleToInteger()) stream->Add("_ncti");
1918 PrintRangeTo(stream); 1921 PrintRangeTo(stream);
1919 PrintTypeTo(stream); 1922 PrintTypeTo(stream);
1920 stream->Add("]"); 1923 stream->Add("]");
1921 } 1924 }
1922 1925
1923 1926
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 if (!value->IsSimulate() && !value->CheckFlag(kTruncatingToInt32)) { 1985 if (!value->IsSimulate() && !value->CheckFlag(kTruncatingToInt32)) {
1983 ClearFlag(kTruncatingToInt32); 1986 ClearFlag(kTruncatingToInt32);
1984 } 1987 }
1985 } 1988 }
1986 } 1989 }
1987 } 1990 }
1988 1991
1989 1992
1990 void HPhi::AddNonPhiUsesFrom(HPhi* other) { 1993 void HPhi::AddNonPhiUsesFrom(HPhi* other) {
1991 if (FLAG_trace_representation) { 1994 if (FLAG_trace_representation) {
1992 PrintF("adding to #%d Phi uses of #%d Phi: i%d d%d t%d\n", 1995 PrintF("adding to #%d Phi uses of #%d Phi: s%d i%d d%d t%d\n",
1993 id(), other->id(), 1996 id(), other->id(),
1997 other->non_phi_uses_[Representation::kSmi],
1994 other->non_phi_uses_[Representation::kInteger32], 1998 other->non_phi_uses_[Representation::kInteger32],
1995 other->non_phi_uses_[Representation::kDouble], 1999 other->non_phi_uses_[Representation::kDouble],
1996 other->non_phi_uses_[Representation::kTagged]); 2000 other->non_phi_uses_[Representation::kTagged]);
1997 } 2001 }
1998 2002
1999 for (int i = 0; i < Representation::kNumRepresentations; i++) { 2003 for (int i = 0; i < Representation::kNumRepresentations; i++) {
2000 indirect_uses_[i] += other->non_phi_uses_[i]; 2004 indirect_uses_[i] += other->non_phi_uses_[i];
2001 } 2005 }
2002 } 2006 }
2003 2007
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after
3539 new_rep = RepresentationFromUses(); 3543 new_rep = RepresentationFromUses();
3540 UpdateRepresentation(new_rep, h_infer, "uses"); 3544 UpdateRepresentation(new_rep, h_infer, "uses");
3541 new_rep = RepresentationFromUseRequirements(); 3545 new_rep = RepresentationFromUseRequirements();
3542 UpdateRepresentation(new_rep, h_infer, "use requirements"); 3546 UpdateRepresentation(new_rep, h_infer, "use requirements");
3543 } 3547 }
3544 3548
3545 3549
3546 Representation HPhi::RepresentationFromInputs() { 3550 Representation HPhi::RepresentationFromInputs() {
3547 bool double_occurred = false; 3551 bool double_occurred = false;
3548 bool int32_occurred = false; 3552 bool int32_occurred = false;
3553 bool smi_occurred = false;
3549 for (int i = 0; i < OperandCount(); ++i) { 3554 for (int i = 0; i < OperandCount(); ++i) {
3550 HValue* value = OperandAt(i); 3555 HValue* value = OperandAt(i);
3551 if (value->IsUnknownOSRValue()) { 3556 if (value->IsUnknownOSRValue()) {
3552 HPhi* hint_value = HUnknownOSRValue::cast(value)->incoming_value(); 3557 HPhi* hint_value = HUnknownOSRValue::cast(value)->incoming_value();
3553 if (hint_value != NULL) { 3558 if (hint_value != NULL) {
3554 Representation hint = hint_value->representation(); 3559 Representation hint = hint_value->representation();
3555 if (hint.IsSmiOrTagged()) return hint; 3560 if (hint.IsTagged()) return hint;
3556 if (hint.IsDouble()) double_occurred = true; 3561 if (hint.IsDouble()) double_occurred = true;
3557 if (hint.IsInteger32()) int32_occurred = true; 3562 if (hint.IsInteger32()) int32_occurred = true;
3563 if (hint.IsSmi()) smi_occurred = true;
3558 } 3564 }
3559 continue; 3565 continue;
3560 } 3566 }
3561 if (value->representation().IsDouble()) double_occurred = true; 3567 if (value->representation().IsDouble()) double_occurred = true;
3562 if (value->representation().IsInteger32()) int32_occurred = true; 3568 if (value->representation().IsInteger32()) int32_occurred = true;
3563 if (value->representation().IsSmiOrTagged()) { 3569 if (value->representation().IsSmi()) smi_occurred = true;
3570 if (value->representation().IsTagged()) {
3564 if (value->IsConstant()) { 3571 if (value->IsConstant()) {
3565 HConstant* constant = HConstant::cast(value); 3572 HConstant* constant = HConstant::cast(value);
3566 if (constant->IsConvertibleToInteger()) { 3573 if (constant->IsConvertibleToInteger()) {
3567 int32_occurred = true; 3574 int32_occurred = true;
3568 } else if (constant->HasNumberValue()) { 3575 } else if (constant->HasNumberValue()) {
3569 double_occurred = true; 3576 double_occurred = true;
3570 } else { 3577 } else {
3571 return Representation::Tagged(); 3578 return Representation::Tagged();
3572 } 3579 }
3573 } else { 3580 } else {
3574 if (value->IsPhi() && !IsConvertibleToInteger()) { 3581 if (value->IsPhi() && !IsConvertibleToInteger()) {
3575 return Representation::Tagged(); 3582 return Representation::Tagged();
3576 } 3583 }
3577 } 3584 }
3578 } 3585 }
3579 } 3586 }
3580 3587
3581 if (double_occurred) return Representation::Double(); 3588 if (double_occurred) return Representation::Double();
3582
3583 if (int32_occurred) return Representation::Integer32(); 3589 if (int32_occurred) return Representation::Integer32();
3590 if (smi_occurred) return Representation::Smi();
3584 3591
3585 return Representation::None(); 3592 return Representation::None();
3586 } 3593 }
3587 3594
3588 3595
3589 Representation HPhi::RepresentationFromUseRequirements() { 3596 Representation HPhi::RepresentationFromUseRequirements() {
3590 Representation all_uses_require = Representation::None(); 3597 Representation all_uses_require = Representation::None();
3591 bool all_uses_require_the_same = true; 3598 bool all_uses_require_the_same = true;
3592 for (HUseIterator it(uses()); !it.Done(); it.Advance()) { 3599 for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
3593 // We check for observed_input_representation elsewhere. 3600 // We check for observed_input_representation elsewhere.
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
3788 case kBackingStore: 3795 case kBackingStore:
3789 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 3796 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3790 stream->Add("[backing-store]"); 3797 stream->Add("[backing-store]");
3791 break; 3798 break;
3792 } 3799 }
3793 3800
3794 stream->Add("@%d", offset()); 3801 stream->Add("@%d", offset());
3795 } 3802 }
3796 3803
3797 } } // namespace v8::internal 3804 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/string-stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698