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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
6 | 6 |
7 #include "src/regexp/ppc/regexp-macro-assembler-ppc.h" | 7 #include "src/regexp/ppc/regexp-macro-assembler-ppc.h" |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 void RegExpMacroAssemblerPPC::CheckStackLimit() { | 1262 void RegExpMacroAssemblerPPC::CheckStackLimit() { |
1263 ExternalReference stack_limit = | 1263 ExternalReference stack_limit = |
1264 ExternalReference::address_of_regexp_stack_limit(isolate()); | 1264 ExternalReference::address_of_regexp_stack_limit(isolate()); |
1265 __ mov(r3, Operand(stack_limit)); | 1265 __ mov(r3, Operand(stack_limit)); |
1266 __ LoadP(r3, MemOperand(r3)); | 1266 __ LoadP(r3, MemOperand(r3)); |
1267 __ cmpl(backtrack_stackpointer(), r3); | 1267 __ cmpl(backtrack_stackpointer(), r3); |
1268 SafeCall(&stack_overflow_label_, le); | 1268 SafeCall(&stack_overflow_label_, le); |
1269 } | 1269 } |
1270 | 1270 |
1271 | 1271 |
1272 bool RegExpMacroAssemblerPPC::CanReadUnaligned() { | |
1273 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES) && !slow_safe(); | |
1274 } | |
1275 | |
1276 | |
1277 void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset, | 1272 void RegExpMacroAssemblerPPC::LoadCurrentCharacterUnchecked(int cp_offset, |
1278 int characters) { | 1273 int characters) { |
1279 Register offset = current_input_offset(); | 1274 Register offset = current_input_offset(); |
1280 if (cp_offset != 0) { | 1275 if (cp_offset != 0) { |
1281 // r25 is not being used to store the capture start index at this point. | 1276 // r25 is not being used to store the capture start index at this point. |
1282 __ addi(r25, current_input_offset(), Operand(cp_offset * char_size())); | 1277 __ addi(r25, current_input_offset(), Operand(cp_offset * char_size())); |
1283 offset = r25; | 1278 offset = r25; |
1284 } | 1279 } |
1285 // The lwz, stw, lhz, sth instructions can do unaligned accesses, if the CPU | 1280 // The lwz, stw, lhz, sth instructions can do unaligned accesses, if the CPU |
1286 // and the operating system running on the target allow it. | 1281 // and the operating system running on the target allow it. |
1287 // We assume we don't want to do unaligned loads on PPC, so this function | 1282 // We assume we don't want to do unaligned loads on PPC, so this function |
1288 // must only be used to load a single character at a time. | 1283 // must only be used to load a single character at a time. |
1289 | 1284 |
1290 DCHECK(characters == 1); | |
1291 __ add(current_character(), end_of_input_address(), offset); | 1285 __ add(current_character(), end_of_input_address(), offset); |
| 1286 #if V8_TARGET_LITTLE_ENDIAN |
1292 if (mode_ == LATIN1) { | 1287 if (mode_ == LATIN1) { |
1293 __ lbz(current_character(), MemOperand(current_character())); | 1288 if (characters == 4) { |
| 1289 __ lwz(current_character(), MemOperand(current_character())); |
| 1290 } else if (characters == 2) { |
| 1291 __ lhz(current_character(), MemOperand(current_character())); |
| 1292 } else { |
| 1293 DCHECK(characters == 1); |
| 1294 __ lbz(current_character(), MemOperand(current_character())); |
| 1295 } |
1294 } else { | 1296 } else { |
1295 DCHECK(mode_ == UC16); | 1297 DCHECK(mode_ == UC16); |
1296 __ lhz(current_character(), MemOperand(current_character())); | 1298 if (characters == 2) { |
| 1299 __ lwz(current_character(), MemOperand(current_character())); |
| 1300 } else { |
| 1301 DCHECK(characters == 1); |
| 1302 __ lhz(current_character(), MemOperand(current_character())); |
| 1303 } |
1297 } | 1304 } |
| 1305 #else |
| 1306 if (mode_ == LATIN1) { |
| 1307 if (characters == 4) { |
| 1308 __ lwbrx(current_character(), MemOperand(r0, current_character())); |
| 1309 } else if (characters == 2) { |
| 1310 __ lhbrx(current_character(), MemOperand(r0, current_character())); |
| 1311 } else { |
| 1312 DCHECK(characters == 1); |
| 1313 __ lbz(current_character(), MemOperand(current_character())); |
| 1314 } |
| 1315 } else { |
| 1316 DCHECK(mode_ == UC16); |
| 1317 if (characters == 2) { |
| 1318 __ lwz(current_character(), MemOperand(current_character())); |
| 1319 __ rlwinm(current_character(), current_character(), 16, 0, 31); |
| 1320 } else { |
| 1321 DCHECK(characters == 1); |
| 1322 __ lhz(current_character(), MemOperand(current_character())); |
| 1323 } |
| 1324 } |
| 1325 #endif |
1298 } | 1326 } |
1299 | 1327 |
1300 | 1328 |
1301 #undef __ | 1329 #undef __ |
1302 | 1330 |
1303 #endif // V8_INTERPRETED_REGEXP | 1331 #endif // V8_INTERPRETED_REGEXP |
1304 } // namespace internal | 1332 } // namespace internal |
1305 } // namespace v8 | 1333 } // namespace v8 |
1306 | 1334 |
1307 #endif // V8_TARGET_ARCH_PPC | 1335 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |