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

Unified Diff: src/hydrogen-instructions.cc

Issue 17057004: Only infer int32 in HBoundsCheck if input is double or int32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index b36706b49b48119b6332a54e6782a9904e929ee5..42b866efd93db16a34932e08f76e4bf24badda42 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1147,19 +1147,14 @@ void HBoundsCheck::PrintDataTo(StringStream* stream) {
void HBoundsCheck::InferRepresentation(HInferRepresentation* h_infer) {
ASSERT(CheckFlag(kFlexibleRepresentation));
- Representation r;
HValue* actual_index = index()->ActualValue();
HValue* actual_length = length()->ActualValue();
Representation index_rep = actual_index->representation();
- if (!actual_length->representation().IsSmiOrTagged()) {
- r = Representation::Integer32();
- } else if ((index_rep.IsTagged() && actual_index->type().IsSmi()) ||
- index_rep.IsSmi()) {
- // If the index is smi, allow the length to be smi, since it is usually
- // already smi from loading it out of the length field of a JSArray. This
- // allows for direct comparison without untagging.
- r = Representation::Smi();
- } else {
+ Representation length_rep = actual_length->representation();
+ if (index_rep.IsTagged()) index_rep = Representation::Smi();
+ if (length_rep.IsTagged()) length_rep = Representation::Smi();
+ Representation r = index_rep.generalize(length_rep);
+ if (r.is_more_general_than(Representation::Integer32())) {
r = Representation::Integer32();
}
UpdateRepresentation(r, h_infer, "boundscheck");
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698