| 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 |
| 80 // Fetch the instance type of the receiver into result register. | 83 // Fetch the instance type of the receiver into result register. |
| 81 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); | 84 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 82 __ lbz(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); | 85 __ lbz(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); |
| 83 | 86 |
| 84 // We need special handling for indirect strings. | 87 // We need special handling for indirect strings. |
| 85 Label check_sequential; | 88 Label check_sequential; |
| 86 __ andi(r0, result, Operand(kIsIndirectStringMask)); | 89 __ andi(r0, result, Operand(kIsIndirectStringMask)); |
| 87 __ beq(&check_sequential, cr0); | 90 __ beq(&check_sequential, cr0); |
| 88 | 91 |
| 89 // Dispatch on the indirect string shape: slice or cons. | 92 // Dispatch on the indirect string shape: slice or cons or thin. |
| 90 Label cons_string; | 93 Label cons_string, thin_string; |
| 91 __ mov(ip, Operand(kSlicedNotConsMask)); | 94 __ andi(ip, result, Operand(kStringRepresentationMask)); |
| 92 __ and_(r0, result, ip, SetRC); | 95 __ cmpi(ip, Operand(kConsStringTag)); |
| 93 __ beq(&cons_string, cr0); | 96 __ beq(&cons_string); |
| 97 __ cmpi(ip, Operand(kThinStringTag)); |
| 98 __ beq(&thin_string); |
| 94 | 99 |
| 95 // Handle slices. | 100 // Handle slices. |
| 96 Label indirect_string_loaded; | |
| 97 __ LoadP(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); | 101 __ LoadP(result, FieldMemOperand(string, SlicedString::kOffsetOffset)); |
| 98 __ LoadP(string, FieldMemOperand(string, SlicedString::kParentOffset)); | 102 __ LoadP(string, FieldMemOperand(string, SlicedString::kParentOffset)); |
| 99 __ SmiUntag(ip, result); | 103 __ SmiUntag(ip, result); |
| 100 __ add(index, index, ip); | 104 __ add(index, index, ip); |
| 101 __ b(&indirect_string_loaded); | 105 __ b(&indirect_string_loaded); |
| 102 | 106 |
| 107 // Handle thin strings. |
| 108 __ bind(&thin_string); |
| 109 __ LoadP(string, FieldMemOperand(string, ThinString::kActualOffset)); |
| 110 __ b(&indirect_string_loaded); |
| 111 |
| 103 // Handle cons strings. | 112 // Handle cons strings. |
| 104 // Check whether the right hand side is the empty string (i.e. if | 113 // Check whether the right hand side is the empty string (i.e. if |
| 105 // this is really a flat string in a cons string). If that is not | 114 // this is really a flat string in a cons string). If that is not |
| 106 // the case we would rather go to the runtime system now to flatten | 115 // the case we would rather go to the runtime system now to flatten |
| 107 // the string. | 116 // the string. |
| 108 __ bind(&cons_string); | 117 __ bind(&cons_string); |
| 109 __ LoadP(result, FieldMemOperand(string, ConsString::kSecondOffset)); | 118 __ LoadP(result, FieldMemOperand(string, ConsString::kSecondOffset)); |
| 110 __ CompareRoot(result, Heap::kempty_stringRootIndex); | 119 __ CompareRoot(result, Heap::kempty_stringRootIndex); |
| 111 __ bne(call_runtime); | 120 __ bne(call_runtime); |
| 112 // Get the first of the two strings and load its instance type. | 121 // Get the first of the two strings and load its instance type. |
| 113 __ LoadP(string, FieldMemOperand(string, ConsString::kFirstOffset)); | 122 __ LoadP(string, FieldMemOperand(string, ConsString::kFirstOffset)); |
| 114 | 123 __ b(&indirect_string_loaded); |
| 115 __ bind(&indirect_string_loaded); | |
| 116 __ LoadP(result, FieldMemOperand(string, HeapObject::kMapOffset)); | |
| 117 __ lbz(result, FieldMemOperand(result, Map::kInstanceTypeOffset)); | |
| 118 | 124 |
| 119 // Distinguish sequential and external strings. Only these two string | 125 // Distinguish sequential and external strings. Only these two string |
| 120 // representations can reach here (slices and flat cons strings have been | 126 // representations can reach here (slices and flat cons strings have been |
| 121 // reduced to the underlying sequential or external string). | 127 // reduced to the underlying sequential or external string). |
| 122 Label external_string, check_encoding; | 128 Label external_string, check_encoding; |
| 123 __ bind(&check_sequential); | 129 __ bind(&check_sequential); |
| 124 STATIC_ASSERT(kSeqStringTag == 0); | 130 STATIC_ASSERT(kSeqStringTag == 0); |
| 125 __ andi(r0, result, Operand(kStringRepresentationMask)); | 131 __ andi(r0, result, Operand(kStringRepresentationMask)); |
| 126 __ bne(&external_string, cr0); | 132 __ bne(&external_string, cr0); |
| 127 | 133 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 patcher.masm()->Jump(r3); | 231 patcher.masm()->Jump(r3); |
| 226 for (int i = 0; i < kCodeAgingSequenceNops; i++) { | 232 for (int i = 0; i < kCodeAgingSequenceNops; i++) { |
| 227 patcher.masm()->nop(); | 233 patcher.masm()->nop(); |
| 228 } | 234 } |
| 229 } | 235 } |
| 230 } | 236 } |
| 231 } // namespace internal | 237 } // namespace internal |
| 232 } // namespace v8 | 238 } // namespace v8 |
| 233 | 239 |
| 234 #endif // V8_TARGET_ARCH_PPC | 240 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |