OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/js-native-context-specialization.h" | 5 #include "src/compiler/js-native-context-specialization.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 // is in element access mode and not MEGAMORPHIC, otherwise there's no | 688 // is in element access mode and not MEGAMORPHIC, otherwise there's no |
689 // guard for the bounds check below. | 689 // guard for the bounds check below. |
690 if (nexus.ic_state() != MEGAMORPHIC && nexus.GetKeyType() == ELEMENT) { | 690 if (nexus.ic_state() != MEGAMORPHIC && nexus.GetKeyType() == ELEMENT) { |
691 // Strings are immutable in JavaScript. | 691 // Strings are immutable in JavaScript. |
692 if (access_mode == AccessMode::kStore) return NoChange(); | 692 if (access_mode == AccessMode::kStore) return NoChange(); |
693 | 693 |
694 // Properly deal with constant {index}. | 694 // Properly deal with constant {index}. |
695 NumberMatcher mindex(index); | 695 NumberMatcher mindex(index); |
696 if (mindex.IsInteger() && mindex.IsInRange(0.0, string->length() - 1)) { | 696 if (mindex.IsInteger() && mindex.IsInRange(0.0, string->length() - 1)) { |
697 // Constant-fold the {index} access to {string}. | 697 // Constant-fold the {index} access to {string}. |
698 Node* value = | 698 Node* value = jsgraph()->HeapConstant( |
699 jsgraph()->Constant(string->Get(static_cast<int>(mindex.Value()))); | 699 factory()->LookupSingleCharacterStringFromCode( |
| 700 string->Get(static_cast<int>(mindex.Value())))); |
700 ReplaceWithValue(node, value, effect, control); | 701 ReplaceWithValue(node, value, effect, control); |
701 return Replace(value); | 702 return Replace(value); |
702 } else if (flags() & kDeoptimizationEnabled) { | 703 } else if (flags() & kDeoptimizationEnabled) { |
703 // Ensure that {index} is less than {receiver} length. | 704 // Ensure that {index} is less than {receiver} length. |
704 Node* length = jsgraph()->Constant(string->length()); | 705 Node* length = jsgraph()->Constant(string->length()); |
705 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, | 706 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, |
706 length, effect, control); | 707 length, effect, control); |
707 | 708 |
708 // Load the character from the {receiver}. | 709 // Load the character from the {receiver}. |
709 value = graph()->NewNode(simplified()->StringCharCodeAt(), receiver, | 710 value = graph()->NewNode(simplified()->StringCharCodeAt(), receiver, |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 return jsgraph()->javascript(); | 1618 return jsgraph()->javascript(); |
1618 } | 1619 } |
1619 | 1620 |
1620 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 1621 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
1621 return jsgraph()->simplified(); | 1622 return jsgraph()->simplified(); |
1622 } | 1623 } |
1623 | 1624 |
1624 } // namespace compiler | 1625 } // namespace compiler |
1625 } // namespace internal | 1626 } // namespace internal |
1626 } // namespace v8 | 1627 } // namespace v8 |
OLD | NEW |