| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 8 | 8 |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 // Distinguish sequential and external strings. Only these two string | 855 // Distinguish sequential and external strings. Only these two string |
| 856 // representations can reach here (slices and flat cons strings have been | 856 // representations can reach here (slices and flat cons strings have been |
| 857 // reduced to the underlying sequential or external string). | 857 // reduced to the underlying sequential or external string). |
| 858 Label seq_string; | 858 Label seq_string; |
| 859 __ bind(&check_sequential); | 859 __ bind(&check_sequential); |
| 860 STATIC_ASSERT(kSeqStringTag == 0); | 860 STATIC_ASSERT(kSeqStringTag == 0); |
| 861 __ test(result, Immediate(kStringRepresentationMask)); | 861 __ test(result, Immediate(kStringRepresentationMask)); |
| 862 __ j(zero, &seq_string, Label::kNear); | 862 __ j(zero, &seq_string, Label::kNear); |
| 863 | 863 |
| 864 // Handle external strings. | 864 // Handle external strings. |
| 865 Label ascii_external, done; | 865 Label one_byte_external, done; |
| 866 if (FLAG_debug_code) { | 866 if (FLAG_debug_code) { |
| 867 // Assert that we do not have a cons or slice (indirect strings) here. | 867 // Assert that we do not have a cons or slice (indirect strings) here. |
| 868 // Sequential strings have already been ruled out. | 868 // Sequential strings have already been ruled out. |
| 869 __ test(result, Immediate(kIsIndirectStringMask)); | 869 __ test(result, Immediate(kIsIndirectStringMask)); |
| 870 __ Assert(zero, kExternalStringExpectedButNotFound); | 870 __ Assert(zero, kExternalStringExpectedButNotFound); |
| 871 } | 871 } |
| 872 // Rule out short external strings. | 872 // Rule out short external strings. |
| 873 STATIC_ASSERT(kShortExternalStringTag != 0); | 873 STATIC_ASSERT(kShortExternalStringTag != 0); |
| 874 __ test_b(result, kShortExternalStringMask); | 874 __ test_b(result, kShortExternalStringMask); |
| 875 __ j(not_zero, call_runtime); | 875 __ j(not_zero, call_runtime); |
| 876 // Check encoding. | 876 // Check encoding. |
| 877 STATIC_ASSERT(kTwoByteStringTag == 0); | 877 STATIC_ASSERT(kTwoByteStringTag == 0); |
| 878 __ test_b(result, kStringEncodingMask); | 878 __ test_b(result, kStringEncodingMask); |
| 879 __ mov(result, FieldOperand(string, ExternalString::kResourceDataOffset)); | 879 __ mov(result, FieldOperand(string, ExternalString::kResourceDataOffset)); |
| 880 __ j(not_equal, &ascii_external, Label::kNear); | 880 __ j(not_equal, &one_byte_external, Label::kNear); |
| 881 // Two-byte string. | 881 // Two-byte string. |
| 882 __ movzx_w(result, Operand(result, index, times_2, 0)); | 882 __ movzx_w(result, Operand(result, index, times_2, 0)); |
| 883 __ jmp(&done, Label::kNear); | 883 __ jmp(&done, Label::kNear); |
| 884 __ bind(&ascii_external); | 884 __ bind(&one_byte_external); |
| 885 // Ascii string. | 885 // One-byte string. |
| 886 __ movzx_b(result, Operand(result, index, times_1, 0)); | 886 __ movzx_b(result, Operand(result, index, times_1, 0)); |
| 887 __ jmp(&done, Label::kNear); | 887 __ jmp(&done, Label::kNear); |
| 888 | 888 |
| 889 // Dispatch on the encoding: ASCII or two-byte. | 889 // Dispatch on the encoding: one-byte or two-byte. |
| 890 Label ascii; | 890 Label one_byte; |
| 891 __ bind(&seq_string); | 891 __ bind(&seq_string); |
| 892 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); | 892 STATIC_ASSERT((kStringEncodingMask & kOneByteStringTag) != 0); |
| 893 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); | 893 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); |
| 894 __ test(result, Immediate(kStringEncodingMask)); | 894 __ test(result, Immediate(kStringEncodingMask)); |
| 895 __ j(not_zero, &ascii, Label::kNear); | 895 __ j(not_zero, &one_byte, Label::kNear); |
| 896 | 896 |
| 897 // Two-byte string. | 897 // Two-byte string. |
| 898 // Load the two-byte character code into the result register. | 898 // Load the two-byte character code into the result register. |
| 899 __ movzx_w(result, FieldOperand(string, | 899 __ movzx_w(result, FieldOperand(string, |
| 900 index, | 900 index, |
| 901 times_2, | 901 times_2, |
| 902 SeqTwoByteString::kHeaderSize)); | 902 SeqTwoByteString::kHeaderSize)); |
| 903 __ jmp(&done, Label::kNear); | 903 __ jmp(&done, Label::kNear); |
| 904 | 904 |
| 905 // Ascii string. | 905 // One-byte string. |
| 906 // Load the byte into the result register. | 906 // Load the byte into the result register. |
| 907 __ bind(&ascii); | 907 __ bind(&one_byte); |
| 908 __ movzx_b(result, FieldOperand(string, | 908 __ movzx_b(result, FieldOperand(string, |
| 909 index, | 909 index, |
| 910 times_1, | 910 times_1, |
| 911 SeqOneByteString::kHeaderSize)); | 911 SeqOneByteString::kHeaderSize)); |
| 912 __ bind(&done); | 912 __ bind(&done); |
| 913 } | 913 } |
| 914 | 914 |
| 915 | 915 |
| 916 static Operand ExpConstant(int index) { | 916 static Operand ExpConstant(int index) { |
| 917 return Operand::StaticVariable(ExternalReference::math_exp_constants(index)); | 917 return Operand::StaticVariable(ExternalReference::math_exp_constants(index)); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 Code* stub = GetCodeAgeStub(isolate, age, parity); | 1024 Code* stub = GetCodeAgeStub(isolate, age, parity); |
| 1025 CodePatcher patcher(sequence, young_length); | 1025 CodePatcher patcher(sequence, young_length); |
| 1026 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 1026 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
| 1027 } | 1027 } |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 | 1030 |
| 1031 } } // namespace v8::internal | 1031 } } // namespace v8::internal |
| 1032 | 1032 |
| 1033 #endif // V8_TARGET_ARCH_IA32 | 1033 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |