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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // Fetch the instance type of the receiver into result register. | 70 // Fetch the instance type of the receiver into result register. |
71 __ movp(result, FieldOperand(string, HeapObject::kMapOffset)); | 71 __ movp(result, FieldOperand(string, HeapObject::kMapOffset)); |
72 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); | 72 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); |
73 | 73 |
74 // We need special handling for indirect strings. | 74 // We need special handling for indirect strings. |
75 Label check_sequential; | 75 Label check_sequential; |
76 __ testb(result, Immediate(kIsIndirectStringMask)); | 76 __ testb(result, Immediate(kIsIndirectStringMask)); |
77 __ j(zero, &check_sequential, Label::kNear); | 77 __ j(zero, &check_sequential, Label::kNear); |
78 | 78 |
79 // Dispatch on the indirect string shape: slice or cons. | 79 // Dispatch on the indirect string shape: slice or cons. |
80 Label cons_string; | 80 Label cons_string, thin_string; |
81 __ testb(result, Immediate(kSlicedNotConsMask)); | 81 __ andl(result, Immediate(kStringRepresentationMask)); |
82 __ j(zero, &cons_string, Label::kNear); | 82 __ cmpl(result, Immediate(kConsStringTag)); |
| 83 __ j(equal, &cons_string, Label::kNear); |
| 84 __ cmpl(result, Immediate(kThinStringTag)); |
| 85 __ j(equal, &thin_string, Label::kNear); |
83 | 86 |
84 // Handle slices. | 87 // Handle slices. |
85 Label indirect_string_loaded; | 88 Label indirect_string_loaded; |
86 __ SmiToInteger32(result, FieldOperand(string, SlicedString::kOffsetOffset)); | 89 __ SmiToInteger32(result, FieldOperand(string, SlicedString::kOffsetOffset)); |
87 __ addp(index, result); | 90 __ addp(index, result); |
88 __ movp(string, FieldOperand(string, SlicedString::kParentOffset)); | 91 __ movp(string, FieldOperand(string, SlicedString::kParentOffset)); |
89 __ jmp(&indirect_string_loaded, Label::kNear); | 92 __ jmp(&indirect_string_loaded, Label::kNear); |
90 | 93 |
| 94 // Handle thin strings. |
| 95 __ bind(&thin_string); |
| 96 __ movp(string, FieldOperand(string, ThinString::kActualOffset)); |
| 97 __ jmp(&indirect_string_loaded, Label::kNear); |
| 98 |
91 // Handle cons strings. | 99 // Handle cons strings. |
92 // Check whether the right hand side is the empty string (i.e. if | 100 // 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 | 101 // 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 | 102 // the case we would rather go to the runtime system now to flatten |
95 // the string. | 103 // the string. |
96 __ bind(&cons_string); | 104 __ bind(&cons_string); |
97 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset), | 105 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset), |
98 Heap::kempty_stringRootIndex); | 106 Heap::kempty_stringRootIndex); |
99 __ j(not_equal, call_runtime); | 107 __ j(not_equal, call_runtime); |
100 __ movp(string, FieldOperand(string, ConsString::kFirstOffset)); | 108 __ movp(string, FieldOperand(string, ConsString::kFirstOffset)); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 return Operand(base_reg_, argument_count_reg_, times_pointer_size, | 247 return Operand(base_reg_, argument_count_reg_, times_pointer_size, |
240 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); | 248 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); |
241 } | 249 } |
242 } | 250 } |
243 | 251 |
244 | 252 |
245 } // namespace internal | 253 } // namespace internal |
246 } // namespace v8 | 254 } // namespace v8 |
247 | 255 |
248 #endif // V8_TARGET_ARCH_X64 | 256 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |