| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #if V8_TARGET_ARCH_A64 | 30 #if V8_TARGET_ARCH_ARM64 |
| 31 | 31 |
| 32 #include "codegen.h" | 32 #include "codegen.h" |
| 33 #include "macro-assembler.h" | 33 #include "macro-assembler.h" |
| 34 #include "simulator-a64.h" | 34 #include "simulator-arm64.h" |
| 35 | 35 |
| 36 namespace v8 { | 36 namespace v8 { |
| 37 namespace internal { | 37 namespace internal { |
| 38 | 38 |
| 39 #define __ ACCESS_MASM(masm) | 39 #define __ ACCESS_MASM(masm) |
| 40 | 40 |
| 41 #if defined(USE_SIMULATOR) | 41 #if defined(USE_SIMULATOR) |
| 42 byte* fast_exp_a64_machine_code = NULL; | 42 byte* fast_exp_arm64_machine_code = NULL; |
| 43 double fast_exp_simulator(double x) { | 43 double fast_exp_simulator(double x) { |
| 44 Simulator * simulator = Simulator::current(Isolate::Current()); | 44 Simulator * simulator = Simulator::current(Isolate::Current()); |
| 45 Simulator::CallArgument args[] = { | 45 Simulator::CallArgument args[] = { |
| 46 Simulator::CallArgument(x), | 46 Simulator::CallArgument(x), |
| 47 Simulator::CallArgument::End() | 47 Simulator::CallArgument::End() |
| 48 }; | 48 }; |
| 49 return simulator->CallDouble(fast_exp_a64_machine_code, args); | 49 return simulator->CallDouble(fast_exp_arm64_machine_code, args); |
| 50 } | 50 } |
| 51 #endif | 51 #endif |
| 52 | 52 |
| 53 | 53 |
| 54 UnaryMathFunction CreateExpFunction() { | 54 UnaryMathFunction CreateExpFunction() { |
| 55 if (!FLAG_fast_math) return &std::exp; | 55 if (!FLAG_fast_math) return &std::exp; |
| 56 | 56 |
| 57 // Use the Math.exp implemetation in MathExpGenerator::EmitMathExp() to create | 57 // Use the Math.exp implemetation in MathExpGenerator::EmitMathExp() to create |
| 58 // an AAPCS64-compliant exp() function. This will be faster than the C | 58 // an AAPCS64-compliant exp() function. This will be faster than the C |
| 59 // library's exp() function, but probably less accurate. | 59 // library's exp() function, but probably less accurate. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 85 CodeDesc desc; | 85 CodeDesc desc; |
| 86 masm.GetCode(&desc); | 86 masm.GetCode(&desc); |
| 87 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 87 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
| 88 | 88 |
| 89 CPU::FlushICache(buffer, actual_size); | 89 CPU::FlushICache(buffer, actual_size); |
| 90 OS::ProtectCode(buffer, actual_size); | 90 OS::ProtectCode(buffer, actual_size); |
| 91 | 91 |
| 92 #if !defined(USE_SIMULATOR) | 92 #if !defined(USE_SIMULATOR) |
| 93 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 93 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
| 94 #else | 94 #else |
| 95 fast_exp_a64_machine_code = buffer; | 95 fast_exp_arm64_machine_code = buffer; |
| 96 return &fast_exp_simulator; | 96 return &fast_exp_simulator; |
| 97 #endif | 97 #endif |
| 98 } | 98 } |
| 99 | 99 |
| 100 | 100 |
| 101 UnaryMathFunction CreateSqrtFunction() { | 101 UnaryMathFunction CreateSqrtFunction() { |
| 102 return &std::sqrt; | 102 return &std::sqrt; |
| 103 } | 103 } |
| 104 | 104 |
| 105 | 105 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 // NZCV | 539 // NZCV |
| 540 // 1000 -708.4 < input < 709.8 result = exp(input) | 540 // 1000 -708.4 < input < 709.8 result = exp(input) |
| 541 // 0110 input == 709.8 result = +infinity | 541 // 0110 input == 709.8 result = +infinity |
| 542 // 0010 input > 709.8 result = +infinity | 542 // 0010 input > 709.8 result = +infinity |
| 543 // 0011 input is NaN result = input | 543 // 0011 input is NaN result = input |
| 544 // 0000 input <= -708.4 result = +0.0 | 544 // 0000 input <= -708.4 result = +0.0 |
| 545 | 545 |
| 546 // Continue the common case first. 'mi' tests N == 1. | 546 // Continue the common case first. 'mi' tests N == 1. |
| 547 __ B(&result_is_finite_non_zero, mi); | 547 __ B(&result_is_finite_non_zero, mi); |
| 548 | 548 |
| 549 // TODO(jbramley): Consider adding a +infinity register for A64. | 549 // TODO(jbramley): Consider adding a +infinity register for ARM64. |
| 550 __ Ldr(double_temp2, ExpConstant(constants, 2)); // Synthesize +infinity. | 550 __ Ldr(double_temp2, ExpConstant(constants, 2)); // Synthesize +infinity. |
| 551 | 551 |
| 552 // Select between +0.0 and +infinity. 'lo' tests C == 0. | 552 // Select between +0.0 and +infinity. 'lo' tests C == 0. |
| 553 __ Fcsel(result, fp_zero, double_temp2, lo); | 553 __ Fcsel(result, fp_zero, double_temp2, lo); |
| 554 // Select between {+0.0 or +infinity} and input. 'vc' tests V == 0. | 554 // Select between {+0.0 or +infinity} and input. 'vc' tests V == 0. |
| 555 __ Fcsel(result, result, input, vc); | 555 __ Fcsel(result, result, input, vc); |
| 556 __ B(&done); | 556 __ B(&done); |
| 557 | 557 |
| 558 // The rest is magic, as described in InitializeMathExpData(). | 558 // The rest is magic, as described in InitializeMathExpData(). |
| 559 __ Bind(&result_is_finite_non_zero); | 559 __ Bind(&result_is_finite_non_zero); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 | 605 |
| 606 __ Fmul(result, double_temp3, double_temp1); | 606 __ Fmul(result, double_temp3, double_temp1); |
| 607 | 607 |
| 608 __ Bind(&done); | 608 __ Bind(&done); |
| 609 } | 609 } |
| 610 | 610 |
| 611 #undef __ | 611 #undef __ |
| 612 | 612 |
| 613 } } // namespace v8::internal | 613 } } // namespace v8::internal |
| 614 | 614 |
| 615 #endif // V8_TARGET_ARCH_A64 | 615 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |