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/s390/codegen-s390.h" | 5 #include "src/s390/codegen-s390.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_S390 | 7 #if V8_TARGET_ARCH_S390 |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // ------------------------------------------------------------------------- | 64 // ------------------------------------------------------------------------- |
65 // Code generators | 65 // Code generators |
66 | 66 |
67 #define __ ACCESS_MASM(masm) | 67 #define __ ACCESS_MASM(masm) |
68 | 68 |
69 // assume ip can be used as a scratch register below | 69 // assume ip can be used as a scratch register below |
70 void StringCharLoadGenerator::Generate(MacroAssembler* masm, Register string, | 70 void StringCharLoadGenerator::Generate(MacroAssembler* masm, Register string, |
71 Register index, Register result, | 71 Register index, Register result, |
72 Label* call_runtime) { | 72 Label* call_runtime) { |
73 Label indirect_string_loaded; | |
74 __ bind(&indirect_string_loaded); | |
75 | |
76 // Fetch the instance type of the receiver into result register. | 73 // Fetch the instance type of the receiver into result register. |
77 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); | 74 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
78 __ LoadlB(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); | 75 __ LoadlB(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
79 | 76 |
80 // We need special handling for indirect strings. | 77 // We need special handling for indirect strings. |
81 Label check_sequential; | 78 Label check_sequential; |
82 __ mov(r0, Operand(kIsIndirectStringMask)); | 79 __ mov(r0, Operand(kIsIndirectStringMask)); |
83 __ AndP(r0, result); | 80 __ AndP(r0, result); |
84 __ beq(&check_sequential, Label::kNear /*, cr0*/); | 81 __ beq(&check_sequential, Label::kNear /*, cr0*/); |
85 | 82 |
86 // Dispatch on the indirect string shape: slice or cons. | 83 // Dispatch on the indirect string shape: slice or cons. |
87 Label cons_string, thin_string; | 84 Label cons_string; |
88 __ LoadRR(ip, result); | 85 __ mov(ip, Operand(kSlicedNotConsMask)); |
89 __ nilf(ip, Operand(kStringRepresentationMask)); | 86 __ LoadRR(r0, result); |
90 __ CmpP(ip, Operand(kConsStringTag)); | 87 __ AndP(r0, ip /*, SetRC*/); // Should be okay to remove RC |
91 __ beq(&cons_string); | 88 __ beq(&cons_string, Label::kNear /*, cr0*/); |
92 __ CmpP(ip, Operand(kThinStringTag)); | |
93 __ beq(&thin_string); | |
94 | 89 |
95 // Handle slices. | 90 // Handle slices. |
| 91 Label indirect_string_loaded; |
96 __ LoadP(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); | 92 __ LoadP(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); |
97 __ LoadP(string, FieldMemOperand(string, SlicedString::kParentOffset)); | 93 __ LoadP(string, FieldMemOperand(string, SlicedString::kParentOffset)); |
98 __ SmiUntag(ip, result); | 94 __ SmiUntag(ip, result); |
99 __ AddP(index, ip); | 95 __ AddP(index, ip); |
100 __ b(&indirect_string_loaded); | 96 __ b(&indirect_string_loaded, Label::kNear); |
101 | |
102 // Handle thin strings. | |
103 __ bind(&thin_string); | |
104 __ LoadP(string, FieldMemOperand(string, ThinString::kActualOffset)); | |
105 __ b(&indirect_string_loaded); | |
106 | 97 |
107 // Handle cons strings. | 98 // Handle cons strings. |
108 // Check whether the right hand side is the empty string (i.e. if | 99 // Check whether the right hand side is the empty string (i.e. if |
109 // this is really a flat string in a cons string). If that is not | 100 // this is really a flat string in a cons string). If that is not |
110 // the case we would rather go to the runtime system now to flatten | 101 // the case we would rather go to the runtime system now to flatten |
111 // the string. | 102 // the string. |
112 __ bind(&cons_string); | 103 __ bind(&cons_string); |
113 __ LoadP(result, FieldMemOperand(string, ConsString::kSecondOffset)); | 104 __ LoadP(result, FieldMemOperand(string, ConsString::kSecondOffset)); |
114 __ CompareRoot(result, Heap::kempty_stringRootIndex); | 105 __ CompareRoot(result, Heap::kempty_stringRootIndex); |
115 __ bne(call_runtime); | 106 __ bne(call_runtime); |
116 // Get the first of the two strings and load its instance type. | 107 // Get the first of the two strings and load its instance type. |
117 __ LoadP(string, FieldMemOperand(string, ConsString::kFirstOffset)); | 108 __ LoadP(string, FieldMemOperand(string, ConsString::kFirstOffset)); |
118 __ b(&indirect_string_loaded); | 109 |
| 110 __ bind(&indirect_string_loaded); |
| 111 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 112 __ LoadlB(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
119 | 113 |
120 // Distinguish sequential and external strings. Only these two string | 114 // Distinguish sequential and external strings. Only these two string |
121 // representations can reach here (slices and flat cons strings have been | 115 // representations can reach here (slices and flat cons strings have been |
122 // reduced to the underlying sequential or external string). | 116 // reduced to the underlying sequential or external string). |
123 Label external_string, check_encoding; | 117 Label external_string, check_encoding; |
124 __ bind(&check_sequential); | 118 __ bind(&check_sequential); |
125 STATIC_ASSERT(kSeqStringTag == 0); | 119 STATIC_ASSERT(kSeqStringTag == 0); |
126 __ mov(r0, Operand(kStringRepresentationMask)); | 120 __ mov(r0, Operand(kStringRepresentationMask)); |
127 __ AndP(r0, result); | 121 __ AndP(r0, result); |
128 __ bne(&external_string, Label::kNear); | 122 __ bne(&external_string, Label::kNear); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // (kNoCodeAgeSequenceLength - kCodeAgingSequenceLength) bytes. | 225 // (kNoCodeAgeSequenceLength - kCodeAgingSequenceLength) bytes. |
232 patcher.masm()->nop(); // 2-byte nops(). | 226 patcher.masm()->nop(); // 2-byte nops(). |
233 } | 227 } |
234 } | 228 } |
235 } | 229 } |
236 | 230 |
237 } // namespace internal | 231 } // namespace internal |
238 } // namespace v8 | 232 } // namespace v8 |
239 | 233 |
240 #endif // V8_TARGET_ARCH_S390 | 234 #endif // V8_TARGET_ARCH_S390 |
OLD | NEW |