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...) 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...) 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 // If SSE2 is not available, we can use libc's implementation to ensure | |
112 // consistency since code by fullcodegen's calls into runtime in that case. | |
113 if (buffer == NULL || !CpuFeatures::IsSupported(SSE2)) return &sqrt; | |
114 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | |
115 // esp[1 * kPointerSize]: raw double input | |
116 // esp[0 * kPointerSize]: return address | |
117 // Move double input into registers. | |
118 | |
119 // Crankshaft cannot be enabled without SSE2. | |
120 ASSERT(CpuFeatures::IsSupported(SSE2)); | |
Sven Panne
2012/03/12 14:50:20
I think we can safely remove this assertion.
| |
121 { | |
122 CpuFeatures::Scope use_sse2(SSE2); | |
123 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); | |
124 __ sqrtsd(xmm0, xmm0); | |
125 __ movdbl(Operand(esp, 1 * kPointerSize), xmm0); | |
126 // Load result into floating point register as return value. | |
127 __ fld_d(Operand(esp, 1 * kPointerSize)); | |
128 __ Ret(); | |
129 } | |
130 | |
131 CodeDesc desc; | |
132 masm.GetCode(&desc); | |
133 ASSERT(desc.reloc_size == 0); | |
134 | |
135 CPU::FlushICache(buffer, actual_size); | |
136 OS::ProtectCode(buffer, actual_size); | |
137 return FUNCTION_CAST<UnaryMathFunction>(buffer); | |
138 } | |
139 | |
140 | |
106 static void MemCopyWrapper(void* dest, const void* src, size_t size) { | 141 static void MemCopyWrapper(void* dest, const void* src, size_t size) { |
107 memcpy(dest, src, size); | 142 memcpy(dest, src, size); |
108 } | 143 } |
109 | 144 |
110 | 145 |
111 OS::MemCopyFunction CreateMemCopyFunction() { | 146 OS::MemCopyFunction CreateMemCopyFunction() { |
112 size_t actual_size; | 147 size_t actual_size; |
113 // Allocate buffer in executable space. | 148 // Allocate buffer in executable space. |
114 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, | 149 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, |
115 &actual_size, | 150 &actual_size, |
(...skipping 589 matching lines...) Loading... | |
705 times_1, | 740 times_1, |
706 SeqAsciiString::kHeaderSize)); | 741 SeqAsciiString::kHeaderSize)); |
707 __ bind(&done); | 742 __ bind(&done); |
708 } | 743 } |
709 | 744 |
710 #undef __ | 745 #undef __ |
711 | 746 |
712 } } // namespace v8::internal | 747 } } // namespace v8::internal |
713 | 748 |
714 #endif // V8_TARGET_ARCH_IA32 | 749 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |