OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 4399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4410 void MacroAssembler::CopyBytes(Register destination, | 4410 void MacroAssembler::CopyBytes(Register destination, |
4411 Register source, | 4411 Register source, |
4412 Register length, | 4412 Register length, |
4413 int min_length, | 4413 int min_length, |
4414 Register scratch) { | 4414 Register scratch) { |
4415 ASSERT(min_length >= 0); | 4415 ASSERT(min_length >= 0); |
4416 if (emit_debug_code()) { | 4416 if (emit_debug_code()) { |
4417 cmpl(length, Immediate(min_length)); | 4417 cmpl(length, Immediate(min_length)); |
4418 Assert(greater_equal, kInvalidMinLength); | 4418 Assert(greater_equal, kInvalidMinLength); |
4419 } | 4419 } |
4420 Label loop, done, short_string, short_loop; | 4420 Label short_loop, len8, len16, len24, done, short_string; |
4421 | 4421 |
4422 const int kLongStringLimit = 20; | 4422 const int kLongStringLimit = 4 * kPointerSize; |
4423 if (min_length <= kLongStringLimit) { | 4423 if (min_length <= kLongStringLimit) { |
4424 cmpl(length, Immediate(kLongStringLimit)); | 4424 cmpl(length, Immediate(kPointerSize)); |
4425 j(less_equal, &short_string); | 4425 j(below, &short_string, Label::kNear); |
4426 } | 4426 } |
4427 | 4427 |
4428 ASSERT(source.is(rsi)); | 4428 ASSERT(source.is(rsi)); |
4429 ASSERT(destination.is(rdi)); | 4429 ASSERT(destination.is(rdi)); |
4430 ASSERT(length.is(rcx)); | 4430 ASSERT(length.is(rcx)); |
4431 | 4431 |
| 4432 if (min_length <= kLongStringLimit) { |
| 4433 cmpl(length, Immediate(2 * kPointerSize)); |
| 4434 j(below_equal, &len8, Label::kNear); |
| 4435 cmpl(length, Immediate(3 * kPointerSize)); |
| 4436 j(below_equal, &len16, Label::kNear); |
| 4437 cmpl(length, Immediate(4 * kPointerSize)); |
| 4438 j(below_equal, &len24, Label::kNear); |
| 4439 } |
| 4440 |
4432 // Because source is 8-byte aligned in our uses of this function, | 4441 // Because source is 8-byte aligned in our uses of this function, |
4433 // we keep source aligned for the rep movs operation by copying the odd bytes | 4442 // we keep source aligned for the rep movs operation by copying the odd bytes |
4434 // at the end of the ranges. | 4443 // at the end of the ranges. |
4435 movq(scratch, length); | 4444 movq(scratch, length); |
4436 shrl(length, Immediate(kPointerSizeLog2)); | 4445 shrl(length, Immediate(kPointerSizeLog2)); |
4437 repmovsq(); | 4446 repmovsq(); |
4438 // Move remaining bytes of length. | 4447 // Move remaining bytes of length. |
4439 andl(scratch, Immediate(kPointerSize - 1)); | 4448 andl(scratch, Immediate(kPointerSize - 1)); |
4440 movq(length, Operand(source, scratch, times_1, -kPointerSize)); | 4449 movq(length, Operand(source, scratch, times_1, -kPointerSize)); |
4441 movq(Operand(destination, scratch, times_1, -kPointerSize), length); | 4450 movq(Operand(destination, scratch, times_1, -kPointerSize), length); |
4442 addq(destination, scratch); | 4451 addq(destination, scratch); |
4443 | 4452 |
4444 if (min_length <= kLongStringLimit) { | 4453 if (min_length <= kLongStringLimit) { |
4445 jmp(&done); | 4454 jmp(&done, Label::kNear); |
| 4455 bind(&len24); |
| 4456 movq(scratch, Operand(source, 2 * kPointerSize)); |
| 4457 movq(Operand(destination, 2 * kPointerSize), scratch); |
| 4458 bind(&len16); |
| 4459 movq(scratch, Operand(source, kPointerSize)); |
| 4460 movq(Operand(destination, kPointerSize), scratch); |
| 4461 bind(&len8); |
| 4462 movq(scratch, Operand(source, 0)); |
| 4463 movq(Operand(destination, 0), scratch); |
| 4464 // Move remaining bytes of length. |
| 4465 movq(scratch, Operand(source, length, times_1, -kPointerSize)); |
| 4466 movq(Operand(destination, length, times_1, -kPointerSize), scratch); |
| 4467 addq(destination, length); |
| 4468 jmp(&done, Label::kNear); |
4446 | 4469 |
4447 bind(&short_string); | 4470 bind(&short_string); |
4448 if (min_length == 0) { | 4471 if (min_length == 0) { |
4449 testl(length, length); | 4472 testl(length, length); |
4450 j(zero, &done); | 4473 j(zero, &done, Label::kNear); |
4451 } | 4474 } |
4452 lea(scratch, Operand(destination, length, times_1, 0)); | |
4453 | 4475 |
4454 bind(&short_loop); | 4476 bind(&short_loop); |
4455 movb(length, Operand(source, 0)); | 4477 movb(scratch, Operand(source, 0)); |
4456 movb(Operand(destination, 0), length); | 4478 movb(Operand(destination, 0), scratch); |
4457 incq(source); | 4479 incq(source); |
4458 incq(destination); | 4480 incq(destination); |
4459 cmpq(destination, scratch); | 4481 decl(length); |
4460 j(not_equal, &short_loop); | 4482 j(not_zero, &short_loop); |
| 4483 } |
4461 | 4484 |
4462 bind(&done); | 4485 bind(&done); |
4463 } | |
4464 } | 4486 } |
4465 | 4487 |
4466 | 4488 |
4467 void MacroAssembler::InitializeFieldsWithFiller(Register start_offset, | 4489 void MacroAssembler::InitializeFieldsWithFiller(Register start_offset, |
4468 Register end_offset, | 4490 Register end_offset, |
4469 Register filler) { | 4491 Register filler) { |
4470 Label loop, entry; | 4492 Label loop, entry; |
4471 jmp(&entry); | 4493 jmp(&entry); |
4472 bind(&loop); | 4494 bind(&loop); |
4473 movq(Operand(start_offset, 0), filler); | 4495 movq(Operand(start_offset, 0), filler); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5001 j(equal, found); | 5023 j(equal, found); |
5002 movq(current, FieldOperand(current, Map::kPrototypeOffset)); | 5024 movq(current, FieldOperand(current, Map::kPrototypeOffset)); |
5003 CompareRoot(current, Heap::kNullValueRootIndex); | 5025 CompareRoot(current, Heap::kNullValueRootIndex); |
5004 j(not_equal, &loop_again); | 5026 j(not_equal, &loop_again); |
5005 } | 5027 } |
5006 | 5028 |
5007 | 5029 |
5008 } } // namespace v8::internal | 5030 } } // namespace v8::internal |
5009 | 5031 |
5010 #endif // V8_TARGET_ARCH_X64 | 5032 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |