OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/ppc/codegen-ppc.h" | 5 #include "src/ppc/codegen-ppc.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_PPC | 7 #if V8_TARGET_ARCH_PPC |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 // ------------------------------------------------------------------------- | 71 // ------------------------------------------------------------------------- |
72 // Code generators | 72 // Code generators |
73 | 73 |
74 #define __ ACCESS_MASM(masm) | 74 #define __ ACCESS_MASM(masm) |
75 | 75 |
76 // assume ip can be used as a scratch register below | 76 // assume ip can be used as a scratch register below |
77 void StringCharLoadGenerator::Generate(MacroAssembler* masm, Register string, | 77 void StringCharLoadGenerator::Generate(MacroAssembler* masm, Register string, |
78 Register index, Register result, | 78 Register index, Register result, |
79 Label* call_runtime) { | 79 Label* call_runtime) { |
80 Label indirect_string_loaded; | |
81 __ bind(&indirect_string_loaded); | |
82 | |
83 // Fetch the instance type of the receiver into result register. | 80 // Fetch the instance type of the receiver into result register. |
84 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); | 81 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
85 __ lbz(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); | 82 __ lbz(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
86 | 83 |
87 // We need special handling for indirect strings. | 84 // We need special handling for indirect strings. |
88 Label check_sequential; | 85 Label check_sequential; |
89 __ andi(r0, result, Operand(kIsIndirectStringMask)); | 86 __ andi(r0, result, Operand(kIsIndirectStringMask)); |
90 __ beq(&check_sequential, cr0); | 87 __ beq(&check_sequential, cr0); |
91 | 88 |
92 // Dispatch on the indirect string shape: slice or cons or thin. | 89 // Dispatch on the indirect string shape: slice or cons. |
93 Label cons_string, thin_string; | 90 Label cons_string; |
94 __ andi(ip, result, Operand(kStringRepresentationMask)); | 91 __ mov(ip, Operand(kSlicedNotConsMask)); |
95 __ cmpi(ip, Operand(kConsStringTag)); | 92 __ and_(r0, result, ip, SetRC); |
96 __ beq(&cons_string); | 93 __ beq(&cons_string, cr0); |
97 __ cmpi(ip, Operand(kThinStringTag)); | |
98 __ beq(&thin_string); | |
99 | 94 |
100 // Handle slices. | 95 // Handle slices. |
| 96 Label indirect_string_loaded; |
101 __ LoadP(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); | 97 __ LoadP(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); |
102 __ LoadP(string, FieldMemOperand(string, SlicedString::kParentOffset)); | 98 __ LoadP(string, FieldMemOperand(string, SlicedString::kParentOffset)); |
103 __ SmiUntag(ip, result); | 99 __ SmiUntag(ip, result); |
104 __ add(index, index, ip); | 100 __ add(index, index, ip); |
105 __ b(&indirect_string_loaded); | 101 __ b(&indirect_string_loaded); |
106 | 102 |
107 // Handle thin strings. | |
108 __ bind(&thin_string); | |
109 __ LoadP(string, FieldMemOperand(string, ThinString::kActualOffset)); | |
110 __ b(&indirect_string_loaded); | |
111 | |
112 // Handle cons strings. | 103 // Handle cons strings. |
113 // Check whether the right hand side is the empty string (i.e. if | 104 // Check whether the right hand side is the empty string (i.e. if |
114 // this is really a flat string in a cons string). If that is not | 105 // this is really a flat string in a cons string). If that is not |
115 // the case we would rather go to the runtime system now to flatten | 106 // the case we would rather go to the runtime system now to flatten |
116 // the string. | 107 // the string. |
117 __ bind(&cons_string); | 108 __ bind(&cons_string); |
118 __ LoadP(result, FieldMemOperand(string, ConsString::kSecondOffset)); | 109 __ LoadP(result, FieldMemOperand(string, ConsString::kSecondOffset)); |
119 __ CompareRoot(result, Heap::kempty_stringRootIndex); | 110 __ CompareRoot(result, Heap::kempty_stringRootIndex); |
120 __ bne(call_runtime); | 111 __ bne(call_runtime); |
121 // Get the first of the two strings and load its instance type. | 112 // Get the first of the two strings and load its instance type. |
122 __ LoadP(string, FieldMemOperand(string, ConsString::kFirstOffset)); | 113 __ LoadP(string, FieldMemOperand(string, ConsString::kFirstOffset)); |
123 __ b(&indirect_string_loaded); | 114 |
| 115 __ bind(&indirect_string_loaded); |
| 116 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 117 __ lbz(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
124 | 118 |
125 // Distinguish sequential and external strings. Only these two string | 119 // Distinguish sequential and external strings. Only these two string |
126 // representations can reach here (slices and flat cons strings have been | 120 // representations can reach here (slices and flat cons strings have been |
127 // reduced to the underlying sequential or external string). | 121 // reduced to the underlying sequential or external string). |
128 Label external_string, check_encoding; | 122 Label external_string, check_encoding; |
129 __ bind(&check_sequential); | 123 __ bind(&check_sequential); |
130 STATIC_ASSERT(kSeqStringTag == 0); | 124 STATIC_ASSERT(kSeqStringTag == 0); |
131 __ andi(r0, result, Operand(kStringRepresentationMask)); | 125 __ andi(r0, result, Operand(kStringRepresentationMask)); |
132 __ bne(&external_string, cr0); | 126 __ bne(&external_string, cr0); |
133 | 127 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 patcher.masm()->Jump(r3); | 225 patcher.masm()->Jump(r3); |
232 for (int i = 0; i < kCodeAgingSequenceNops; i++) { | 226 for (int i = 0; i < kCodeAgingSequenceNops; i++) { |
233 patcher.masm()->nop(); | 227 patcher.masm()->nop(); |
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_PPC | 234 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |