OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/x64/codegen-x64.h" | 5 #include "src/x64/codegen-x64.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { | 25 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { |
26 masm->LeaveFrame(StackFrame::INTERNAL); | 26 masm->LeaveFrame(StackFrame::INTERNAL); |
27 DCHECK(masm->has_frame()); | 27 DCHECK(masm->has_frame()); |
28 masm->set_has_frame(false); | 28 masm->set_has_frame(false); |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 #define __ masm. | 32 #define __ masm. |
33 | 33 |
34 | 34 |
| 35 UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) { |
| 36 size_t actual_size; |
| 37 byte* buffer = |
| 38 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
| 39 if (buffer == nullptr) return nullptr; |
| 40 ExternalReference::InitializeMathExpData(); |
| 41 |
| 42 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), |
| 43 CodeObjectRequired::kNo); |
| 44 // xmm0: raw double input. |
| 45 XMMRegister input = xmm0; |
| 46 XMMRegister result = xmm1; |
| 47 __ pushq(rax); |
| 48 __ pushq(rbx); |
| 49 |
| 50 MathExpGenerator::EmitMathExp(&masm, input, result, xmm2, rax, rbx); |
| 51 |
| 52 __ popq(rbx); |
| 53 __ popq(rax); |
| 54 __ Movsd(xmm0, result); |
| 55 __ Ret(); |
| 56 |
| 57 CodeDesc desc; |
| 58 masm.GetCode(&desc); |
| 59 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
| 60 |
| 61 Assembler::FlushICache(isolate, buffer, actual_size); |
| 62 base::OS::ProtectCode(buffer, actual_size); |
| 63 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer); |
| 64 } |
| 65 |
| 66 |
35 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { | 67 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { |
36 size_t actual_size; | 68 size_t actual_size; |
37 // Allocate buffer in executable space. | 69 // Allocate buffer in executable space. |
38 byte* buffer = | 70 byte* buffer = |
39 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 71 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
40 if (buffer == nullptr) return nullptr; | 72 if (buffer == nullptr) return nullptr; |
41 | 73 |
42 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), | 74 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), |
43 CodeObjectRequired::kNo); | 75 CodeObjectRequired::kNo); |
44 // xmm0: raw double input. | 76 // xmm0: raw double input. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 // One-byte string. | 492 // One-byte string. |
461 // Load the byte into the result register. | 493 // Load the byte into the result register. |
462 __ bind(&one_byte); | 494 __ bind(&one_byte); |
463 __ movzxbl(result, FieldOperand(string, | 495 __ movzxbl(result, FieldOperand(string, |
464 index, | 496 index, |
465 times_1, | 497 times_1, |
466 SeqOneByteString::kHeaderSize)); | 498 SeqOneByteString::kHeaderSize)); |
467 __ bind(&done); | 499 __ bind(&done); |
468 } | 500 } |
469 | 501 |
| 502 |
| 503 void MathExpGenerator::EmitMathExp(MacroAssembler* masm, |
| 504 XMMRegister input, |
| 505 XMMRegister result, |
| 506 XMMRegister double_scratch, |
| 507 Register temp1, |
| 508 Register temp2) { |
| 509 DCHECK(!input.is(result)); |
| 510 DCHECK(!input.is(double_scratch)); |
| 511 DCHECK(!result.is(double_scratch)); |
| 512 DCHECK(!temp1.is(temp2)); |
| 513 DCHECK(ExternalReference::math_exp_constants(0).address() != NULL); |
| 514 DCHECK(!masm->serializer_enabled()); // External references not serializable. |
| 515 |
| 516 Label done; |
| 517 |
| 518 __ Move(kScratchRegister, ExternalReference::math_exp_constants(0)); |
| 519 __ Movsd(double_scratch, Operand(kScratchRegister, 0 * kDoubleSize)); |
| 520 __ Xorpd(result, result); |
| 521 __ Ucomisd(double_scratch, input); |
| 522 __ j(above_equal, &done); |
| 523 __ Ucomisd(input, Operand(kScratchRegister, 1 * kDoubleSize)); |
| 524 __ Movsd(result, Operand(kScratchRegister, 2 * kDoubleSize)); |
| 525 __ j(above_equal, &done); |
| 526 __ Movsd(double_scratch, Operand(kScratchRegister, 3 * kDoubleSize)); |
| 527 __ Movsd(result, Operand(kScratchRegister, 4 * kDoubleSize)); |
| 528 __ Mulsd(double_scratch, input); |
| 529 __ Addsd(double_scratch, result); |
| 530 __ Movq(temp2, double_scratch); |
| 531 __ Subsd(double_scratch, result); |
| 532 __ Movsd(result, Operand(kScratchRegister, 6 * kDoubleSize)); |
| 533 __ leaq(temp1, Operand(temp2, 0x1ff800)); |
| 534 __ andq(temp2, Immediate(0x7ff)); |
| 535 __ shrq(temp1, Immediate(11)); |
| 536 __ Mulsd(double_scratch, Operand(kScratchRegister, 5 * kDoubleSize)); |
| 537 __ Move(kScratchRegister, ExternalReference::math_exp_log_table()); |
| 538 __ shlq(temp1, Immediate(52)); |
| 539 __ orq(temp1, Operand(kScratchRegister, temp2, times_8, 0)); |
| 540 __ Move(kScratchRegister, ExternalReference::math_exp_constants(0)); |
| 541 __ Subsd(double_scratch, input); |
| 542 __ Movsd(input, double_scratch); |
| 543 __ Subsd(result, double_scratch); |
| 544 __ Mulsd(input, double_scratch); |
| 545 __ Mulsd(result, input); |
| 546 __ Movq(input, temp1); |
| 547 __ Mulsd(result, Operand(kScratchRegister, 7 * kDoubleSize)); |
| 548 __ Subsd(result, double_scratch); |
| 549 __ Addsd(result, Operand(kScratchRegister, 8 * kDoubleSize)); |
| 550 __ Mulsd(result, input); |
| 551 |
| 552 __ bind(&done); |
| 553 } |
| 554 |
470 #undef __ | 555 #undef __ |
471 | 556 |
472 | 557 |
473 CodeAgingHelper::CodeAgingHelper(Isolate* isolate) { | 558 CodeAgingHelper::CodeAgingHelper(Isolate* isolate) { |
474 USE(isolate); | 559 USE(isolate); |
475 DCHECK(young_sequence_.length() == kNoCodeAgeSequenceLength); | 560 DCHECK(young_sequence_.length() == kNoCodeAgeSequenceLength); |
476 // The sequence of instructions that is patched out for aging code is the | 561 // The sequence of instructions that is patched out for aging code is the |
477 // following boilerplate stack-building prologue that is found both in | 562 // following boilerplate stack-building prologue that is found both in |
478 // FUNCTION and OPTIMIZED_FUNCTION code: | 563 // FUNCTION and OPTIMIZED_FUNCTION code: |
479 CodePatcher patcher(isolate, young_sequence_.start(), | 564 CodePatcher patcher(isolate, young_sequence_.start(), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 return Operand(base_reg_, argument_count_reg_, times_pointer_size, | 635 return Operand(base_reg_, argument_count_reg_, times_pointer_size, |
551 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); | 636 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); |
552 } | 637 } |
553 } | 638 } |
554 | 639 |
555 | 640 |
556 } // namespace internal | 641 } // namespace internal |
557 } // namespace v8 | 642 } // namespace v8 |
558 | 643 |
559 #endif // V8_TARGET_ARCH_X64 | 644 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |