OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 | |
109 // If crankshaft is disabled, we can use libc's implementation to ensure | |
110 // consistency since fullcodegen's implementation always calls into runtime. | |
111 if (buffer == NULL || !V8::UseCrankshaft()) return &sqrt; | |
Sven Panne
2012/03/12 13:23:46
To guarantee consistency between runs with and wit
| |
112 | |
113 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | |
114 // xmm0: raw double input. | |
115 // Move double input into registers. | |
116 __ sqrtsd(xmm0, xmm0); | |
117 __ Ret(); | |
118 | |
119 CodeDesc desc; | |
120 masm.GetCode(&desc); | |
121 ASSERT(desc.reloc_size == 0); | |
122 | |
123 CPU::FlushICache(buffer, actual_size); | |
124 OS::ProtectCode(buffer, actual_size); | |
125 return FUNCTION_CAST<UnaryMathFunction>(buffer); | |
126 } | |
127 | |
128 | |
103 #ifdef _WIN64 | 129 #ifdef _WIN64 |
104 typedef double (*ModuloFunction)(double, double); | 130 typedef double (*ModuloFunction)(double, double); |
105 // Define custom fmod implementation. | 131 // Define custom fmod implementation. |
106 ModuloFunction CreateModuloFunction() { | 132 ModuloFunction CreateModuloFunction() { |
107 size_t actual_size; | 133 size_t actual_size; |
108 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 134 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
109 &actual_size, | 135 &actual_size, |
110 true)); | 136 true)); |
111 CHECK(buffer); | 137 CHECK(buffer); |
112 Assembler masm(NULL, buffer, static_cast<int>(actual_size)); | 138 Assembler masm(NULL, buffer, static_cast<int>(actual_size)); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 times_1, | 576 times_1, |
551 SeqAsciiString::kHeaderSize)); | 577 SeqAsciiString::kHeaderSize)); |
552 __ bind(&done); | 578 __ bind(&done); |
553 } | 579 } |
554 | 580 |
555 #undef __ | 581 #undef __ |
556 | 582 |
557 } } // namespace v8::internal | 583 } } // namespace v8::internal |
558 | 584 |
559 #endif // V8_TARGET_ARCH_X64 | 585 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |