| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
| 8 | 8 |
| 9 #include "src/arm64/simulator-arm64.h" | 9 #include "src/arm64/simulator-arm64.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 | 30 |
| 31 UnaryMathFunction CreateExpFunction() { | 31 UnaryMathFunction CreateExpFunction() { |
| 32 if (!FLAG_fast_math) return &std::exp; | 32 if (!FLAG_fast_math) return &std::exp; |
| 33 | 33 |
| 34 // Use the Math.exp implemetation in MathExpGenerator::EmitMathExp() to create | 34 // Use the Math.exp implemetation in MathExpGenerator::EmitMathExp() to create |
| 35 // an AAPCS64-compliant exp() function. This will be faster than the C | 35 // an AAPCS64-compliant exp() function. This will be faster than the C |
| 36 // library's exp() function, but probably less accurate. | 36 // library's exp() function, but probably less accurate. |
| 37 size_t actual_size; | 37 size_t actual_size; |
| 38 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); | 38 byte* buffer = |
| 39 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
| 39 if (buffer == NULL) return &std::exp; | 40 if (buffer == NULL) return &std::exp; |
| 40 | 41 |
| 41 ExternalReference::InitializeMathExpData(); | 42 ExternalReference::InitializeMathExpData(); |
| 42 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 43 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
| 43 masm.SetStackPointer(csp); | 44 masm.SetStackPointer(csp); |
| 44 | 45 |
| 45 // The argument will be in d0 on entry. | 46 // The argument will be in d0 on entry. |
| 46 DoubleRegister input = d0; | 47 DoubleRegister input = d0; |
| 47 // Use other caller-saved registers for all other values. | 48 // Use other caller-saved registers for all other values. |
| 48 DoubleRegister result = d1; | 49 DoubleRegister result = d1; |
| 49 DoubleRegister double_temp1 = d2; | 50 DoubleRegister double_temp1 = d2; |
| 50 DoubleRegister double_temp2 = d3; | 51 DoubleRegister double_temp2 = d3; |
| 51 Register temp1 = x10; | 52 Register temp1 = x10; |
| 52 Register temp2 = x11; | 53 Register temp2 = x11; |
| 53 Register temp3 = x12; | 54 Register temp3 = x12; |
| 54 | 55 |
| 55 MathExpGenerator::EmitMathExp(&masm, input, result, | 56 MathExpGenerator::EmitMathExp(&masm, input, result, |
| 56 double_temp1, double_temp2, | 57 double_temp1, double_temp2, |
| 57 temp1, temp2, temp3); | 58 temp1, temp2, temp3); |
| 58 // Move the result to the return register. | 59 // Move the result to the return register. |
| 59 masm.Fmov(d0, result); | 60 masm.Fmov(d0, result); |
| 60 masm.Ret(); | 61 masm.Ret(); |
| 61 | 62 |
| 62 CodeDesc desc; | 63 CodeDesc desc; |
| 63 masm.GetCode(&desc); | 64 masm.GetCode(&desc); |
| 64 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 65 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
| 65 | 66 |
| 66 CPU::FlushICache(buffer, actual_size); | 67 CpuFeatures::FlushICache(buffer, actual_size); |
| 67 OS::ProtectCode(buffer, actual_size); | 68 base::OS::ProtectCode(buffer, actual_size); |
| 68 | 69 |
| 69 #if !defined(USE_SIMULATOR) | 70 #if !defined(USE_SIMULATOR) |
| 70 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 71 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
| 71 #else | 72 #else |
| 72 fast_exp_arm64_machine_code = buffer; | 73 fast_exp_arm64_machine_code = buffer; |
| 73 return &fast_exp_simulator; | 74 return &fast_exp_simulator; |
| 74 #endif | 75 #endif |
| 75 } | 76 } |
| 76 | 77 |
| 77 | 78 |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 __ Fmul(result, double_temp3, double_temp1); | 612 __ Fmul(result, double_temp3, double_temp1); |
| 612 | 613 |
| 613 __ Bind(&done); | 614 __ Bind(&done); |
| 614 } | 615 } |
| 615 | 616 |
| 616 #undef __ | 617 #undef __ |
| 617 | 618 |
| 618 } } // namespace v8::internal | 619 } } // namespace v8::internal |
| 619 | 620 |
| 620 #endif // V8_TARGET_ARCH_ARM64 | 621 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |