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/x64/codegen-x64.h" | 5 #include "src/x64/codegen-x64.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // ------------------------------------------------------------------------- | 60 // ------------------------------------------------------------------------- |
61 // Code generators | 61 // Code generators |
62 | 62 |
63 #define __ ACCESS_MASM(masm) | 63 #define __ ACCESS_MASM(masm) |
64 | 64 |
65 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | 65 void StringCharLoadGenerator::Generate(MacroAssembler* masm, |
66 Register string, | 66 Register string, |
67 Register index, | 67 Register index, |
68 Register result, | 68 Register result, |
69 Label* call_runtime) { | 69 Label* call_runtime) { |
| 70 Label indirect_string_loaded; |
| 71 __ bind(&indirect_string_loaded); |
| 72 |
70 // Fetch the instance type of the receiver into result register. | 73 // Fetch the instance type of the receiver into result register. |
71 __ movp(result, FieldOperand(string, HeapObject::kMapOffset)); | 74 __ movp(result, FieldOperand(string, HeapObject::kMapOffset)); |
72 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); | 75 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); |
73 | 76 |
74 // We need special handling for indirect strings. | 77 // We need special handling for indirect strings. |
75 Label check_sequential; | 78 Label check_sequential; |
76 __ testb(result, Immediate(kIsIndirectStringMask)); | 79 __ testb(result, Immediate(kIsIndirectStringMask)); |
77 __ j(zero, &check_sequential, Label::kNear); | 80 __ j(zero, &check_sequential, Label::kNear); |
78 | 81 |
79 // Dispatch on the indirect string shape: slice or cons. | 82 // Dispatch on the indirect string shape: slice or cons. |
80 Label cons_string; | 83 Label cons_string, thin_string; |
81 __ testb(result, Immediate(kSlicedNotConsMask)); | 84 __ andl(result, Immediate(kStringRepresentationMask)); |
82 __ j(zero, &cons_string, Label::kNear); | 85 __ cmpl(result, Immediate(kConsStringTag)); |
| 86 __ j(equal, &cons_string, Label::kNear); |
| 87 __ cmpl(result, Immediate(kThinStringTag)); |
| 88 __ j(equal, &thin_string, Label::kNear); |
83 | 89 |
84 // Handle slices. | 90 // Handle slices. |
85 Label indirect_string_loaded; | |
86 __ SmiToInteger32(result, FieldOperand(string, SlicedString::kOffsetOffset)); | 91 __ SmiToInteger32(result, FieldOperand(string, SlicedString::kOffsetOffset)); |
87 __ addp(index, result); | 92 __ addp(index, result); |
88 __ movp(string, FieldOperand(string, SlicedString::kParentOffset)); | 93 __ movp(string, FieldOperand(string, SlicedString::kParentOffset)); |
89 __ jmp(&indirect_string_loaded, Label::kNear); | 94 __ jmp(&indirect_string_loaded); |
| 95 |
| 96 // Handle thin strings. |
| 97 __ bind(&thin_string); |
| 98 __ movp(string, FieldOperand(string, ThinString::kActualOffset)); |
| 99 __ jmp(&indirect_string_loaded); |
90 | 100 |
91 // Handle cons strings. | 101 // Handle cons strings. |
92 // Check whether the right hand side is the empty string (i.e. if | 102 // Check whether the right hand side is the empty string (i.e. if |
93 // this is really a flat string in a cons string). If that is not | 103 // this is really a flat string in a cons string). If that is not |
94 // the case we would rather go to the runtime system now to flatten | 104 // the case we would rather go to the runtime system now to flatten |
95 // the string. | 105 // the string. |
96 __ bind(&cons_string); | 106 __ bind(&cons_string); |
97 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset), | 107 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset), |
98 Heap::kempty_stringRootIndex); | 108 Heap::kempty_stringRootIndex); |
99 __ j(not_equal, call_runtime); | 109 __ j(not_equal, call_runtime); |
100 __ movp(string, FieldOperand(string, ConsString::kFirstOffset)); | 110 __ movp(string, FieldOperand(string, ConsString::kFirstOffset)); |
101 | 111 __ jmp(&indirect_string_loaded); |
102 __ bind(&indirect_string_loaded); | |
103 __ movp(result, FieldOperand(string, HeapObject::kMapOffset)); | |
104 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); | |
105 | 112 |
106 // Distinguish sequential and external strings. Only these two string | 113 // Distinguish sequential and external strings. Only these two string |
107 // representations can reach here (slices and flat cons strings have been | 114 // representations can reach here (slices and flat cons strings have been |
108 // reduced to the underlying sequential or external string). | 115 // reduced to the underlying sequential or external string). |
109 Label seq_string; | 116 Label seq_string; |
110 __ bind(&check_sequential); | 117 __ bind(&check_sequential); |
111 STATIC_ASSERT(kSeqStringTag == 0); | 118 STATIC_ASSERT(kSeqStringTag == 0); |
112 __ testb(result, Immediate(kStringRepresentationMask)); | 119 __ testb(result, Immediate(kStringRepresentationMask)); |
113 __ j(zero, &seq_string, Label::kNear); | 120 __ j(zero, &seq_string, Label::kNear); |
114 | 121 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return Operand(base_reg_, argument_count_reg_, times_pointer_size, | 246 return Operand(base_reg_, argument_count_reg_, times_pointer_size, |
240 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); | 247 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); |
241 } | 248 } |
242 } | 249 } |
243 | 250 |
244 | 251 |
245 } // namespace internal | 252 } // namespace internal |
246 } // namespace v8 | 253 } // namespace v8 |
247 | 254 |
248 #endif // V8_TARGET_ARCH_X64 | 255 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |