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

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

Issue 9583037: Reland r10908 (Ensure consistent result of transcendental function0.) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { 48 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const {
49 masm->LeaveFrame(StackFrame::INTERNAL); 49 masm->LeaveFrame(StackFrame::INTERNAL);
50 ASSERT(masm->has_frame()); 50 ASSERT(masm->has_frame());
51 masm->set_has_frame(false); 51 masm->set_has_frame(false);
52 } 52 }
53 53
54 54
55 #define __ masm. 55 #define __ masm.
56 56
57
58 TranscendentalFunction CreateTranscendentalFunction(
59 TranscendentalCache::Type type) {
60 size_t actual_size;
61 // Allocate buffer in executable space.
62 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
63 &actual_size,
64 true));
65 if (buffer == NULL) {
66 // Fallback to library function if function cannot be created.
67 switch (type) {
68 case TranscendentalCache::SIN: return &sin;
69 case TranscendentalCache::COS: return &cos;
70 case TranscendentalCache::TAN: return &tan;
71 case TranscendentalCache::LOG: return &log;
72 default: UNIMPLEMENTED();
73 }
74 }
75
76 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
77 // xmm0: raw double input.
78 // Move double input into registers.
79 __ push(rbx);
80 __ push(rdi);
81 __ movq(rbx, xmm0);
82 __ push(rbx);
83 __ fld_d(Operand(rsp, 0));
84 TranscendentalCacheStub::GenerateOperation(&masm, type);
85 // The return value is expected to be in xmm0.
86 __ fstp_d(Operand(rsp, 0));
87 __ pop(rbx);
88 __ movq(xmm0, rbx);
89 __ pop(rdi);
90 __ pop(rbx);
91 __ Ret();
92
93 CodeDesc desc;
94 masm.GetCode(&desc);
95 ASSERT(desc.reloc_size == 0);
96
97 CPU::FlushICache(buffer, actual_size);
98 OS::ProtectCode(buffer, actual_size);
99 return FUNCTION_CAST<TranscendentalFunction>(buffer);
100 }
101
102
57 #ifdef _WIN64 103 #ifdef _WIN64
58 typedef double (*ModuloFunction)(double, double); 104 typedef double (*ModuloFunction)(double, double);
59 // Define custom fmod implementation. 105 // Define custom fmod implementation.
60 ModuloFunction CreateModuloFunction() { 106 ModuloFunction CreateModuloFunction() {
61 size_t actual_size; 107 size_t actual_size;
62 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 108 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
63 &actual_size, 109 &actual_size,
64 true)); 110 true));
65 CHECK(buffer); 111 CHECK(buffer);
66 Assembler masm(NULL, buffer, static_cast<int>(actual_size)); 112 Assembler masm(NULL, buffer, static_cast<int>(actual_size));
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 times_1, 542 times_1,
497 SeqAsciiString::kHeaderSize)); 543 SeqAsciiString::kHeaderSize));
498 __ bind(&done); 544 __ bind(&done);
499 } 545 }
500 546
501 #undef __ 547 #undef __
502 548
503 } } // namespace v8::internal 549 } } // namespace v8::internal
504 550
505 #endif // V8_TARGET_ARCH_X64 551 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698