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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { | 50 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { |
51 masm->LeaveFrame(StackFrame::INTERNAL); | 51 masm->LeaveFrame(StackFrame::INTERNAL); |
52 ASSERT(masm->has_frame()); | 52 ASSERT(masm->has_frame()); |
53 masm->set_has_frame(false); | 53 masm->set_has_frame(false); |
54 } | 54 } |
55 | 55 |
56 | 56 |
57 #define __ masm. | 57 #define __ masm. |
58 | 58 |
59 | 59 |
60 TranscendentalFunction CreateTranscendentalFunction( | 60 UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { |
61 TranscendentalCache::Type type) { | |
62 size_t actual_size; | 61 size_t actual_size; |
63 // Allocate buffer in executable space. | 62 // Allocate buffer in executable space. |
64 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, | 63 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, |
65 &actual_size, | 64 &actual_size, |
66 true)); | 65 true)); |
67 if (buffer == NULL) { | 66 if (buffer == NULL) { |
68 // Fallback to library function if function cannot be created. | 67 // Fallback to library function if function cannot be created. |
69 switch (type) { | 68 switch (type) { |
70 case TranscendentalCache::SIN: return &sin; | 69 case TranscendentalCache::SIN: return &sin; |
71 case TranscendentalCache::COS: return &cos; | 70 case TranscendentalCache::COS: return &cos; |
(...skipping 20 matching lines...) Expand all Loading... | |
92 __ pop(edx); | 91 __ pop(edx); |
93 __ pop(ebx); | 92 __ pop(ebx); |
94 __ Ret(); | 93 __ Ret(); |
95 | 94 |
96 CodeDesc desc; | 95 CodeDesc desc; |
97 masm.GetCode(&desc); | 96 masm.GetCode(&desc); |
98 ASSERT(desc.reloc_size == 0); | 97 ASSERT(desc.reloc_size == 0); |
99 | 98 |
100 CPU::FlushICache(buffer, actual_size); | 99 CPU::FlushICache(buffer, actual_size); |
101 OS::ProtectCode(buffer, actual_size); | 100 OS::ProtectCode(buffer, actual_size); |
102 return FUNCTION_CAST<TranscendentalFunction>(buffer); | 101 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
103 } | 102 } |
104 | 103 |
105 | 104 |
105 UnaryMathFunction CreateSqrtFunction() { | |
106 size_t actual_size; | |
107 // Allocate buffer in executable space. | |
108 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, | |
109 &actual_size, | |
110 true)); | |
111 | |
112 // If crankshaft is disabled, we can use libc's implementation to ensure | |
113 // consistency since fullcodegen's implementation always calls into runtime. | |
114 if (buffer == NULL || !V8::UseCrankshaft()) return &sqrt; | |
Sven Panne
2012/03/12 13:23:46
Using !CpuFeatures::IsSupported(SSE2) here would g
| |
115 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | |
116 // esp[1 * kPointerSize]: raw double input | |
117 // esp[0 * kPointerSize]: return address | |
118 // Move double input into registers. | |
119 | |
120 // Crankshaft cannot be enabled without SSE2. | |
121 ASSERT(CpuFeatures::IsSupported(SSE2)); | |
122 { | |
123 CpuFeatures::Scope use_sse2(SSE2); | |
124 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); | |
125 __ sqrtsd(xmm0, xmm0); | |
126 __ movdbl(Operand(esp, 1 * kPointerSize), xmm0); | |
127 // Load result into floating point register as return value. | |
128 __ fld_d(Operand(esp, 1 * kPointerSize)); | |
129 __ Ret(); | |
130 } | |
131 | |
132 CodeDesc desc; | |
133 masm.GetCode(&desc); | |
134 ASSERT(desc.reloc_size == 0); | |
135 | |
136 CPU::FlushICache(buffer, actual_size); | |
137 OS::ProtectCode(buffer, actual_size); | |
138 return FUNCTION_CAST<UnaryMathFunction>(buffer); | |
139 } | |
140 | |
141 | |
106 static void MemCopyWrapper(void* dest, const void* src, size_t size) { | 142 static void MemCopyWrapper(void* dest, const void* src, size_t size) { |
107 memcpy(dest, src, size); | 143 memcpy(dest, src, size); |
108 } | 144 } |
109 | 145 |
110 | 146 |
111 OS::MemCopyFunction CreateMemCopyFunction() { | 147 OS::MemCopyFunction CreateMemCopyFunction() { |
112 size_t actual_size; | 148 size_t actual_size; |
113 // Allocate buffer in executable space. | 149 // Allocate buffer in executable space. |
114 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, | 150 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, |
115 &actual_size, | 151 &actual_size, |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
705 times_1, | 741 times_1, |
706 SeqAsciiString::kHeaderSize)); | 742 SeqAsciiString::kHeaderSize)); |
707 __ bind(&done); | 743 __ bind(&done); |
708 } | 744 } |
709 | 745 |
710 #undef __ | 746 #undef __ |
711 | 747 |
712 } } // namespace v8::internal | 748 } } // namespace v8::internal |
713 | 749 |
714 #endif // V8_TARGET_ARCH_IA32 | 750 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |