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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 566 |
567 // Determine the {receiver} length. | 567 // Determine the {receiver} length. |
568 Node* length = effect = graph()->NewNode( | 568 Node* length = effect = graph()->NewNode( |
569 simplified()->LoadField(AccessBuilder::ForStringLength()), receiver, | 569 simplified()->LoadField(AccessBuilder::ForStringLength()), receiver, |
570 effect, control); | 570 effect, control); |
571 | 571 |
572 // Ensure that {index} is less than {receiver} length. | 572 // Ensure that {index} is less than {receiver} length. |
573 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, | 573 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, |
574 length, effect, control); | 574 length, effect, control); |
575 | 575 |
576 // Load the character from the {receiver}. | 576 // Return the character from the {receiver} as single character string. |
577 value = graph()->NewNode(simplified()->StringCharCodeAt(), receiver, index, | 577 value = graph()->NewNode(simplified()->StringCharAt(), receiver, index, |
578 control); | 578 control); |
579 | |
580 // Return it as a single character string. | |
581 value = graph()->NewNode(simplified()->StringFromCharCode(), value); | |
582 } else { | 579 } else { |
583 // Retrieve the native context from the given {node}. | 580 // Retrieve the native context from the given {node}. |
584 // Compute element access infos for the receiver maps. | 581 // Compute element access infos for the receiver maps. |
585 AccessInfoFactory access_info_factory(dependencies(), native_context(), | 582 AccessInfoFactory access_info_factory(dependencies(), native_context(), |
586 graph()->zone()); | 583 graph()->zone()); |
587 ZoneVector<ElementAccessInfo> access_infos(zone()); | 584 ZoneVector<ElementAccessInfo> access_infos(zone()); |
588 if (!access_info_factory.ComputeElementAccessInfos( | 585 if (!access_info_factory.ComputeElementAccessInfos( |
589 receiver_maps, access_mode, &access_infos)) { | 586 receiver_maps, access_mode, &access_infos)) { |
590 return NoChange(); | 587 return NoChange(); |
591 } | 588 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 factory()->LookupSingleCharacterStringFromCode( | 821 factory()->LookupSingleCharacterStringFromCode( |
825 string->Get(static_cast<int>(mindex.Value())))); | 822 string->Get(static_cast<int>(mindex.Value())))); |
826 ReplaceWithValue(node, value, effect, control); | 823 ReplaceWithValue(node, value, effect, control); |
827 return Replace(value); | 824 return Replace(value); |
828 } else if (flags() & kDeoptimizationEnabled) { | 825 } else if (flags() & kDeoptimizationEnabled) { |
829 // Ensure that {index} is less than {receiver} length. | 826 // Ensure that {index} is less than {receiver} length. |
830 Node* length = jsgraph()->Constant(string->length()); | 827 Node* length = jsgraph()->Constant(string->length()); |
831 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, | 828 index = effect = graph()->NewNode(simplified()->CheckBounds(), index, |
832 length, effect, control); | 829 length, effect, control); |
833 | 830 |
834 // Load the character from the {receiver}. | 831 // Return the character from the {receiver} as single character string. |
835 value = graph()->NewNode(simplified()->StringCharCodeAt(), receiver, | 832 value = graph()->NewNode(simplified()->StringCharAt(), receiver, index, |
836 index, control); | 833 control); |
837 | |
838 // Return it as a single character string. | |
839 value = graph()->NewNode(simplified()->StringFromCharCode(), value); | |
840 ReplaceWithValue(node, value, effect, control); | 834 ReplaceWithValue(node, value, effect, control); |
841 return Replace(value); | 835 return Replace(value); |
842 } | 836 } |
843 } | 837 } |
844 } | 838 } |
845 | 839 |
846 // Check if the {nexus} reports type feedback for the IC. | 840 // Check if the {nexus} reports type feedback for the IC. |
847 if (nexus.IsUninitialized()) { | 841 if (nexus.IsUninitialized()) { |
848 if ((flags() & kDeoptimizationEnabled) && | 842 if ((flags() & kDeoptimizationEnabled) && |
849 (flags() & kBailoutOnUninitialized)) { | 843 (flags() & kBailoutOnUninitialized)) { |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 return jsgraph()->javascript(); | 1823 return jsgraph()->javascript(); |
1830 } | 1824 } |
1831 | 1825 |
1832 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { | 1826 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { |
1833 return jsgraph()->simplified(); | 1827 return jsgraph()->simplified(); |
1834 } | 1828 } |
1835 | 1829 |
1836 } // namespace compiler | 1830 } // namespace compiler |
1837 } // namespace internal | 1831 } // namespace internal |
1838 } // namespace v8 | 1832 } // namespace v8 |
OLD | NEW |