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

Side by Side Diff: src/ia32/codegen-ia32.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 12 matching lines...) Expand all
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 defined(V8_TARGET_ARCH_IA32) 30 #if defined(V8_TARGET_ARCH_IA32)
31 31
32 #include "codegen.h" 32 #include "codegen.h"
33 #include "heap.h"
33 #include "macro-assembler.h" 34 #include "macro-assembler.h"
34 35
35 namespace v8 { 36 namespace v8 {
36 namespace internal { 37 namespace internal {
37 38
38 39
39 // ------------------------------------------------------------------------- 40 // -------------------------------------------------------------------------
40 // Platform-specific RuntimeCallHelper functions. 41 // Platform-specific RuntimeCallHelper functions.
41 42
42 void StubRuntimeCallHelper::BeforeCall(MacroAssembler* masm) const { 43 void StubRuntimeCallHelper::BeforeCall(MacroAssembler* masm) const {
43 masm->EnterFrame(StackFrame::INTERNAL); 44 masm->EnterFrame(StackFrame::INTERNAL);
44 ASSERT(!masm->has_frame()); 45 ASSERT(!masm->has_frame());
45 masm->set_has_frame(true); 46 masm->set_has_frame(true);
46 } 47 }
47 48
48 49
49 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { 50 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const {
50 masm->LeaveFrame(StackFrame::INTERNAL); 51 masm->LeaveFrame(StackFrame::INTERNAL);
51 ASSERT(masm->has_frame()); 52 ASSERT(masm->has_frame());
52 masm->set_has_frame(false); 53 masm->set_has_frame(false);
53 } 54 }
54 55
55 56
56 #define __ masm. 57 #define __ masm.
57 58
59
60 TranscendentalFunction CreateTranscendentalFunction(
61 TranscendentalCache::Type type) {
62 size_t actual_size;
63 // Allocate buffer in executable space.
64 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
65 &actual_size,
66 true));
67 if (buffer == NULL) {
68 // Fallback to library function if function cannot be created.
69 switch (type) {
70 case TranscendentalCache::SIN: return &sin;
71 case TranscendentalCache::COS: return &cos;
72 case TranscendentalCache::TAN: return &tan;
73 case TranscendentalCache::LOG: return &log;
74 default: UNIMPLEMENTED();
75 }
76 }
77
78 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
79 // esp[1 * kPointerSize]: raw double input
80 // esp[0 * kPointerSize]: return address
81 // Move double input into registers.
82
83 __ push(ebx);
84 __ push(edx);
85 __ push(edi);
86 __ fld_d(Operand(esp, 4 * kPointerSize));
87 __ mov(ebx, Operand(esp, 4 * kPointerSize));
88 __ mov(edx, Operand(esp, 5 * kPointerSize));
Yang 2012/03/03 11:05:01 Had wrong stack offsets in the first version of th
89 TranscendentalCacheStub::GenerateOperation(&masm, type);
90 // The return value is expected to be on ST(0) of the FPU stack.
91 __ pop(edi);
92 __ pop(edx);
93 __ pop(ebx);
94 __ Ret();
95
96 CodeDesc desc;
97 masm.GetCode(&desc);
98 ASSERT(desc.reloc_size == 0);
99
100 CPU::FlushICache(buffer, actual_size);
101 OS::ProtectCode(buffer, actual_size);
102 return FUNCTION_CAST<TranscendentalFunction>(buffer);
103 }
104
105
58 static void MemCopyWrapper(void* dest, const void* src, size_t size) { 106 static void MemCopyWrapper(void* dest, const void* src, size_t size) {
59 memcpy(dest, src, size); 107 memcpy(dest, src, size);
60 } 108 }
61 109
62 110
63 OS::MemCopyFunction CreateMemCopyFunction() { 111 OS::MemCopyFunction CreateMemCopyFunction() {
64 size_t actual_size; 112 size_t actual_size;
65 // Allocate buffer in executable space. 113 // Allocate buffer in executable space.
66 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, 114 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
67 &actual_size, 115 &actual_size,
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 times_1, 705 times_1,
658 SeqAsciiString::kHeaderSize)); 706 SeqAsciiString::kHeaderSize));
659 __ bind(&done); 707 __ bind(&done);
660 } 708 }
661 709
662 #undef __ 710 #undef __
663 711
664 } } // namespace v8::internal 712 } } // namespace v8::internal
665 713
666 #endif // V8_TARGET_ARCH_IA32 714 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/lithium-ia32.cc » ('j') | src/x64/code-stubs-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698