Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: src/ia32/codegen-ia32.cc

Issue 2077533002: [builtins] Introduce proper Float64Exp operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Import tests from Raymond. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ia32/codegen-ia32.h" 5 #include "src/ia32/codegen-ia32.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/heap/heap.h" 10 #include "src/heap/heap.h"
(...skipping 16 matching lines...) Expand all
27 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { 27 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const {
28 masm->LeaveFrame(StackFrame::INTERNAL); 28 masm->LeaveFrame(StackFrame::INTERNAL);
29 DCHECK(masm->has_frame()); 29 DCHECK(masm->has_frame());
30 masm->set_has_frame(false); 30 masm->set_has_frame(false);
31 } 31 }
32 32
33 33
34 #define __ masm. 34 #define __ masm.
35 35
36 36
37 UnaryMathFunctionWithIsolate CreateExpFunction(Isolate* isolate) {
38 size_t actual_size;
39 byte* buffer =
40 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
41 if (buffer == nullptr) return nullptr;
42 ExternalReference::InitializeMathExpData();
43
44 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
45 CodeObjectRequired::kNo);
46 // esp[1 * kPointerSize]: raw double input
47 // esp[0 * kPointerSize]: return address
48 {
49 XMMRegister input = xmm1;
50 XMMRegister result = xmm2;
51 __ movsd(input, Operand(esp, 1 * kPointerSize));
52 __ push(eax);
53 __ push(ebx);
54
55 MathExpGenerator::EmitMathExp(&masm, input, result, xmm0, eax, ebx);
56
57 __ pop(ebx);
58 __ pop(eax);
59 __ movsd(Operand(esp, 1 * kPointerSize), result);
60 __ fld_d(Operand(esp, 1 * kPointerSize));
61 __ Ret();
62 }
63
64 CodeDesc desc;
65 masm.GetCode(&desc);
66 DCHECK(!RelocInfo::RequiresRelocation(desc));
67
68 Assembler::FlushICache(isolate, buffer, actual_size);
69 base::OS::ProtectCode(buffer, actual_size);
70 return FUNCTION_CAST<UnaryMathFunctionWithIsolate>(buffer);
71 }
72
73
74 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { 37 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) {
75 size_t actual_size; 38 size_t actual_size;
76 // Allocate buffer in executable space. 39 // Allocate buffer in executable space.
77 byte* buffer = 40 byte* buffer =
78 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); 41 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
79 if (buffer == nullptr) return nullptr; 42 if (buffer == nullptr) return nullptr;
80 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), 43 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
81 CodeObjectRequired::kNo); 44 CodeObjectRequired::kNo);
82 // esp[1 * kPointerSize]: raw double input 45 // esp[1 * kPointerSize]: raw double input
83 // esp[0 * kPointerSize]: return address 46 // esp[0 * kPointerSize]: return address
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 // One-byte string. 884 // One-byte string.
922 // Load the byte into the result register. 885 // Load the byte into the result register.
923 __ bind(&one_byte); 886 __ bind(&one_byte);
924 __ movzx_b(result, FieldOperand(string, 887 __ movzx_b(result, FieldOperand(string,
925 index, 888 index,
926 times_1, 889 times_1,
927 SeqOneByteString::kHeaderSize)); 890 SeqOneByteString::kHeaderSize));
928 __ bind(&done); 891 __ bind(&done);
929 } 892 }
930 893
931
932 static Operand ExpConstant(int index) {
933 return Operand::StaticVariable(ExternalReference::math_exp_constants(index));
934 }
935
936
937 void MathExpGenerator::EmitMathExp(MacroAssembler* masm,
938 XMMRegister input,
939 XMMRegister result,
940 XMMRegister double_scratch,
941 Register temp1,
942 Register temp2) {
943 DCHECK(!input.is(double_scratch));
944 DCHECK(!input.is(result));
945 DCHECK(!result.is(double_scratch));
946 DCHECK(!temp1.is(temp2));
947 DCHECK(ExternalReference::math_exp_constants(0).address() != NULL);
948 DCHECK(!masm->serializer_enabled()); // External references not serializable.
949
950 Label done;
951
952 __ movsd(double_scratch, ExpConstant(0));
953 __ xorpd(result, result);
954 __ ucomisd(double_scratch, input);
955 __ j(above_equal, &done);
956 __ ucomisd(input, ExpConstant(1));
957 __ movsd(result, ExpConstant(2));
958 __ j(above_equal, &done);
959 __ movsd(double_scratch, ExpConstant(3));
960 __ movsd(result, ExpConstant(4));
961 __ mulsd(double_scratch, input);
962 __ addsd(double_scratch, result);
963 __ movd(temp2, double_scratch);
964 __ subsd(double_scratch, result);
965 __ movsd(result, ExpConstant(6));
966 __ mulsd(double_scratch, ExpConstant(5));
967 __ subsd(double_scratch, input);
968 __ subsd(result, double_scratch);
969 __ movsd(input, double_scratch);
970 __ mulsd(input, double_scratch);
971 __ mulsd(result, input);
972 __ mov(temp1, temp2);
973 __ mulsd(result, ExpConstant(7));
974 __ subsd(result, double_scratch);
975 __ add(temp1, Immediate(0x1ff800));
976 __ addsd(result, ExpConstant(8));
977 __ and_(temp2, Immediate(0x7ff));
978 __ shr(temp1, 11);
979 __ shl(temp1, 20);
980 __ movd(input, temp1);
981 __ pshufd(input, input, static_cast<uint8_t>(0xe1)); // Order: 11 10 00 01
982 __ movsd(double_scratch, Operand::StaticArray(
983 temp2, times_8, ExternalReference::math_exp_log_table()));
984 __ orps(input, double_scratch);
985 __ mulsd(result, input);
986 __ bind(&done);
987 }
988
989 #undef __ 894 #undef __
990 895
991 896
992 CodeAgingHelper::CodeAgingHelper(Isolate* isolate) { 897 CodeAgingHelper::CodeAgingHelper(Isolate* isolate) {
993 USE(isolate); 898 USE(isolate);
994 DCHECK(young_sequence_.length() == kNoCodeAgeSequenceLength); 899 DCHECK(young_sequence_.length() == kNoCodeAgeSequenceLength);
995 CodePatcher patcher(isolate, young_sequence_.start(), 900 CodePatcher patcher(isolate, young_sequence_.start(),
996 young_sequence_.length()); 901 young_sequence_.length());
997 patcher.masm()->push(ebp); 902 patcher.masm()->push(ebp);
998 patcher.masm()->mov(ebp, esp); 903 patcher.masm()->mov(ebp, esp);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 CodePatcher patcher(isolate, sequence, young_length); 948 CodePatcher patcher(isolate, sequence, young_length);
1044 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); 949 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32);
1045 } 950 }
1046 } 951 }
1047 952
1048 953
1049 } // namespace internal 954 } // namespace internal
1050 } // namespace v8 955 } // namespace v8
1051 956
1052 #endif // V8_TARGET_ARCH_IA32 957 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/js/math.js » ('j') | test/unittests/base/ieee754-unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698