OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 8782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8793 } else { | 8793 } else { |
8794 DCHECK_EQ(kLastIndexOf, mode); | 8794 DCHECK_EQ(kLastIndexOf, mode); |
8795 initial = length; | 8795 initial = length; |
8796 terminating = graph()->GetConstant0(); | 8796 terminating = graph()->GetConstant0(); |
8797 token = Token::GT; | 8797 token = Token::GT; |
8798 direction = LoopBuilder::kPreDecrement; | 8798 direction = LoopBuilder::kPreDecrement; |
8799 } | 8799 } |
8800 | 8800 |
8801 Push(graph()->GetConstantMinus1()); | 8801 Push(graph()->GetConstantMinus1()); |
8802 if (IsFastDoubleElementsKind(kind) || IsFastSmiElementsKind(kind)) { | 8802 if (IsFastDoubleElementsKind(kind) || IsFastSmiElementsKind(kind)) { |
| 8803 // Make sure that we can actually compare numbers correctly below, see |
| 8804 // https://code.google.com/p/chromium/issues/detail?id=407946 for details. |
| 8805 search_element = AddUncasted<HForceRepresentation>( |
| 8806 search_element, IsFastSmiElementsKind(kind) ? Representation::Smi() |
| 8807 : Representation::Double()); |
| 8808 |
8803 LoopBuilder loop(this, context(), direction); | 8809 LoopBuilder loop(this, context(), direction); |
8804 { | 8810 { |
8805 HValue* index = loop.BeginBody(initial, terminating, token); | 8811 HValue* index = loop.BeginBody(initial, terminating, token); |
8806 HValue* element = AddUncasted<HLoadKeyed>( | 8812 HValue* element = AddUncasted<HLoadKeyed>( |
8807 elements, index, static_cast<HValue*>(NULL), | 8813 elements, index, static_cast<HValue*>(NULL), |
8808 kind, ALLOW_RETURN_HOLE); | 8814 kind, ALLOW_RETURN_HOLE); |
8809 IfBuilder if_issame(this); | 8815 IfBuilder if_issame(this); |
8810 if (IsFastDoubleElementsKind(kind)) { | 8816 if_issame.If<HCompareNumericAndBranch>(element, search_element, |
8811 if_issame.If<HCompareNumericAndBranch>( | 8817 Token::EQ_STRICT); |
8812 element, search_element, Token::EQ_STRICT); | |
8813 } else { | |
8814 if_issame.If<HCompareObjectEqAndBranch>(element, search_element); | |
8815 } | |
8816 if_issame.Then(); | 8818 if_issame.Then(); |
8817 { | 8819 { |
8818 Drop(1); | 8820 Drop(1); |
8819 Push(index); | 8821 Push(index); |
8820 loop.Break(); | 8822 loop.Break(); |
8821 } | 8823 } |
8822 if_issame.End(); | 8824 if_issame.End(); |
8823 } | 8825 } |
8824 loop.EndBody(); | 8826 loop.EndBody(); |
8825 } else { | 8827 } else { |
(...skipping 3655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12481 if (ShouldProduceTraceOutput()) { | 12483 if (ShouldProduceTraceOutput()) { |
12482 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12484 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12483 } | 12485 } |
12484 | 12486 |
12485 #ifdef DEBUG | 12487 #ifdef DEBUG |
12486 graph_->Verify(false); // No full verify. | 12488 graph_->Verify(false); // No full verify. |
12487 #endif | 12489 #endif |
12488 } | 12490 } |
12489 | 12491 |
12490 } } // namespace v8::internal | 12492 } } // namespace v8::internal |
OLD | NEW |