| 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 UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { | |
| 61 size_t actual_size; | |
| 62 // Allocate buffer in executable space. | |
| 63 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, | |
| 64 &actual_size, | |
| 65 true)); | |
| 66 if (buffer == NULL) { | |
| 67 // Fallback to library function if function cannot be created. | |
| 68 switch (type) { | |
| 69 case TranscendentalCache::LOG: return &log; | |
| 70 default: UNIMPLEMENTED(); | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | |
| 75 // esp[1 * kPointerSize]: raw double input | |
| 76 // esp[0 * kPointerSize]: return address | |
| 77 // Move double input into registers. | |
| 78 | |
| 79 __ push(ebx); | |
| 80 __ push(edx); | |
| 81 __ push(edi); | |
| 82 __ fld_d(Operand(esp, 4 * kPointerSize)); | |
| 83 __ mov(ebx, Operand(esp, 4 * kPointerSize)); | |
| 84 __ mov(edx, Operand(esp, 5 * kPointerSize)); | |
| 85 TranscendentalCacheStub::GenerateOperation(&masm, type); | |
| 86 // The return value is expected to be on ST(0) of the FPU stack. | |
| 87 __ pop(edi); | |
| 88 __ pop(edx); | |
| 89 __ pop(ebx); | |
| 90 __ Ret(); | |
| 91 | |
| 92 CodeDesc desc; | |
| 93 masm.GetCode(&desc); | |
| 94 ASSERT(!RelocInfo::RequiresRelocation(desc)); | |
| 95 | |
| 96 CPU::FlushICache(buffer, actual_size); | |
| 97 OS::ProtectCode(buffer, actual_size); | |
| 98 return FUNCTION_CAST<UnaryMathFunction>(buffer); | |
| 99 } | |
| 100 | |
| 101 | |
| 102 UnaryMathFunction CreateExpFunction() { | 60 UnaryMathFunction CreateExpFunction() { |
| 103 if (!CpuFeatures::IsSupported(SSE2)) return &exp; | 61 if (!CpuFeatures::IsSupported(SSE2)) return &exp; |
| 104 if (!FLAG_fast_math) return &exp; | 62 if (!FLAG_fast_math) return &exp; |
| 105 size_t actual_size; | 63 size_t actual_size; |
| 106 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); | 64 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); |
| 107 if (buffer == NULL) return &exp; | 65 if (buffer == NULL) return &exp; |
| 108 ExternalReference::InitializeMathExpData(); | 66 ExternalReference::InitializeMathExpData(); |
| 109 | 67 |
| 110 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 68 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
| 111 // esp[1 * kPointerSize]: raw double input | 69 // esp[1 * kPointerSize]: raw double input |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1171 Code* stub = GetCodeAgeStub(isolate, age, parity); | 1129 Code* stub = GetCodeAgeStub(isolate, age, parity); |
| 1172 CodePatcher patcher(sequence, young_length); | 1130 CodePatcher patcher(sequence, young_length); |
| 1173 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 1131 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
| 1174 } | 1132 } |
| 1175 } | 1133 } |
| 1176 | 1134 |
| 1177 | 1135 |
| 1178 } } // namespace v8::internal | 1136 } } // namespace v8::internal |
| 1179 | 1137 |
| 1180 #endif // V8_TARGET_ARCH_IA32 | 1138 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |