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

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

Issue 9690010: Ensure consistency of Math.sqrt on Intel platforms. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed suggestions. 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 57
58 TranscendentalFunction CreateTranscendentalFunction( 58 UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) {
59 TranscendentalCache::Type type) {
60 size_t actual_size; 59 size_t actual_size;
61 // Allocate buffer in executable space. 60 // Allocate buffer in executable space.
62 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, 61 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
63 &actual_size, 62 &actual_size,
64 true)); 63 true));
65 if (buffer == NULL) { 64 if (buffer == NULL) {
66 // Fallback to library function if function cannot be created. 65 // Fallback to library function if function cannot be created.
67 switch (type) { 66 switch (type) {
68 case TranscendentalCache::SIN: return &sin; 67 case TranscendentalCache::SIN: return &sin;
69 case TranscendentalCache::COS: return &cos; 68 case TranscendentalCache::COS: return &cos;
(...skipping 19 matching lines...) Expand all
89 __ pop(rdi); 88 __ pop(rdi);
90 __ pop(rbx); 89 __ pop(rbx);
91 __ Ret(); 90 __ Ret();
92 91
93 CodeDesc desc; 92 CodeDesc desc;
94 masm.GetCode(&desc); 93 masm.GetCode(&desc);
95 ASSERT(desc.reloc_size == 0); 94 ASSERT(desc.reloc_size == 0);
96 95
97 CPU::FlushICache(buffer, actual_size); 96 CPU::FlushICache(buffer, actual_size);
98 OS::ProtectCode(buffer, actual_size); 97 OS::ProtectCode(buffer, actual_size);
99 return FUNCTION_CAST<TranscendentalFunction>(buffer); 98 return FUNCTION_CAST<UnaryMathFunction>(buffer);
100 } 99 }
101 100
102 101
102 UnaryMathFunction CreateSqrtFunction() {
103 size_t actual_size;
104 // Allocate buffer in executable space.
105 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB,
106 &actual_size,
107 true));
108 if (buffer == NULL) return &sqrt;
109
110 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
111 // xmm0: raw double input.
112 // Move double input into registers.
113 __ sqrtsd(xmm0, xmm0);
114 __ Ret();
115
116 CodeDesc desc;
117 masm.GetCode(&desc);
118 ASSERT(desc.reloc_size == 0);
119
120 CPU::FlushICache(buffer, actual_size);
121 OS::ProtectCode(buffer, actual_size);
122 return FUNCTION_CAST<UnaryMathFunction>(buffer);
123 }
124
125
103 #ifdef _WIN64 126 #ifdef _WIN64
104 typedef double (*ModuloFunction)(double, double); 127 typedef double (*ModuloFunction)(double, double);
105 // Define custom fmod implementation. 128 // Define custom fmod implementation.
106 ModuloFunction CreateModuloFunction() { 129 ModuloFunction CreateModuloFunction() {
107 size_t actual_size; 130 size_t actual_size;
108 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 131 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
109 &actual_size, 132 &actual_size,
110 true)); 133 true));
111 CHECK(buffer); 134 CHECK(buffer);
112 Assembler masm(NULL, buffer, static_cast<int>(actual_size)); 135 Assembler masm(NULL, buffer, static_cast<int>(actual_size));
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 times_1, 573 times_1,
551 SeqAsciiString::kHeaderSize)); 574 SeqAsciiString::kHeaderSize));
552 __ bind(&done); 575 __ bind(&done);
553 } 576 }
554 577
555 #undef __ 578 #undef __
556 579
557 } } // namespace v8::internal 580 } } // namespace v8::internal
558 581
559 #endif // V8_TARGET_ARCH_X64 582 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698