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

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

Issue 2070813002: Revert of [builtins] Introduce proper Float64Exp operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/js/math.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
37 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) { 74 UnaryMathFunctionWithIsolate CreateSqrtFunction(Isolate* isolate) {
38 size_t actual_size; 75 size_t actual_size;
39 // Allocate buffer in executable space. 76 // Allocate buffer in executable space.
40 byte* buffer = 77 byte* buffer =
41 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); 78 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true));
42 if (buffer == nullptr) return nullptr; 79 if (buffer == nullptr) return nullptr;
43 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size), 80 MacroAssembler masm(isolate, buffer, static_cast<int>(actual_size),
44 CodeObjectRequired::kNo); 81 CodeObjectRequired::kNo);
45 // esp[1 * kPointerSize]: raw double input 82 // esp[1 * kPointerSize]: raw double input
46 // esp[0 * kPointerSize]: return address 83 // esp[0 * kPointerSize]: return address
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 // One-byte string. 921 // One-byte string.
885 // Load the byte into the result register. 922 // Load the byte into the result register.
886 __ bind(&one_byte); 923 __ bind(&one_byte);
887 __ movzx_b(result, FieldOperand(string, 924 __ movzx_b(result, FieldOperand(string,
888 index, 925 index,
889 times_1, 926 times_1,
890 SeqOneByteString::kHeaderSize)); 927 SeqOneByteString::kHeaderSize));
891 __ bind(&done); 928 __ bind(&done);
892 } 929 }
893 930
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
894 #undef __ 989 #undef __
895 990
896 991
897 CodeAgingHelper::CodeAgingHelper(Isolate* isolate) { 992 CodeAgingHelper::CodeAgingHelper(Isolate* isolate) {
898 USE(isolate); 993 USE(isolate);
899 DCHECK(young_sequence_.length() == kNoCodeAgeSequenceLength); 994 DCHECK(young_sequence_.length() == kNoCodeAgeSequenceLength);
900 CodePatcher patcher(isolate, young_sequence_.start(), 995 CodePatcher patcher(isolate, young_sequence_.start(),
901 young_sequence_.length()); 996 young_sequence_.length());
902 patcher.masm()->push(ebp); 997 patcher.masm()->push(ebp);
903 patcher.masm()->mov(ebp, esp); 998 patcher.masm()->mov(ebp, esp);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 CodePatcher patcher(isolate, sequence, young_length); 1043 CodePatcher patcher(isolate, sequence, young_length);
949 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); 1044 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32);
950 } 1045 }
951 } 1046 }
952 1047
953 1048
954 } // namespace internal 1049 } // namespace internal
955 } // namespace v8 1050 } // namespace v8
956 1051
957 #endif // V8_TARGET_ARCH_IA32 1052 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.h ('k') | src/js/math.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698