| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/ia32/codegen-ia32.h" | 5 #include "src/ia32/codegen-ia32.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 8 | 8 |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 __ pop(eax); | 58 __ pop(eax); |
| 59 __ movsd(Operand(esp, 1 * kPointerSize), result); | 59 __ movsd(Operand(esp, 1 * kPointerSize), result); |
| 60 __ fld_d(Operand(esp, 1 * kPointerSize)); | 60 __ fld_d(Operand(esp, 1 * kPointerSize)); |
| 61 __ Ret(); | 61 __ Ret(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 CodeDesc desc; | 64 CodeDesc desc; |
| 65 masm.GetCode(&desc); | 65 masm.GetCode(&desc); |
| 66 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 66 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
| 67 | 67 |
| 68 CpuFeatures::FlushICache(buffer, actual_size); | 68 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); |
| 69 base::OS::ProtectCode(buffer, actual_size); | 69 base::OS::ProtectCode(buffer, actual_size); |
| 70 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 70 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
| 71 } | 71 } |
| 72 | 72 |
| 73 | 73 |
| 74 UnaryMathFunction CreateSqrtFunction() { | 74 UnaryMathFunction CreateSqrtFunction() { |
| 75 size_t actual_size; | 75 size_t actual_size; |
| 76 // Allocate buffer in executable space. | 76 // Allocate buffer in executable space. |
| 77 byte* buffer = | 77 byte* buffer = |
| 78 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); | 78 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
| 79 if (buffer == NULL) return &std::sqrt; | 79 if (buffer == NULL) return &std::sqrt; |
| 80 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 80 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
| 81 // esp[1 * kPointerSize]: raw double input | 81 // esp[1 * kPointerSize]: raw double input |
| 82 // esp[0 * kPointerSize]: return address | 82 // esp[0 * kPointerSize]: return address |
| 83 // Move double input into registers. | 83 // Move double input into registers. |
| 84 { | 84 { |
| 85 __ movsd(xmm0, Operand(esp, 1 * kPointerSize)); | 85 __ movsd(xmm0, Operand(esp, 1 * kPointerSize)); |
| 86 __ sqrtsd(xmm0, xmm0); | 86 __ sqrtsd(xmm0, xmm0); |
| 87 __ movsd(Operand(esp, 1 * kPointerSize), xmm0); | 87 __ movsd(Operand(esp, 1 * kPointerSize), xmm0); |
| 88 // Load result into floating point register as return value. | 88 // Load result into floating point register as return value. |
| 89 __ fld_d(Operand(esp, 1 * kPointerSize)); | 89 __ fld_d(Operand(esp, 1 * kPointerSize)); |
| 90 __ Ret(); | 90 __ Ret(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 CodeDesc desc; | 93 CodeDesc desc; |
| 94 masm.GetCode(&desc); | 94 masm.GetCode(&desc); |
| 95 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 95 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
| 96 | 96 |
| 97 CpuFeatures::FlushICache(buffer, actual_size); | 97 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); |
| 98 base::OS::ProtectCode(buffer, actual_size); | 98 base::OS::ProtectCode(buffer, actual_size); |
| 99 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 99 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 |
| 103 // Helper functions for CreateMemMoveFunction. | 103 // Helper functions for CreateMemMoveFunction. |
| 104 #undef __ | 104 #undef __ |
| 105 #define __ ACCESS_MASM(masm) | 105 #define __ ACCESS_MASM(masm) |
| 106 | 106 |
| 107 enum Direction { FORWARD, BACKWARD }; | 107 enum Direction { FORWARD, BACKWARD }; |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 __ mov(eax, Operand(count, times_4, conv.address(&small_handlers))); | 498 __ mov(eax, Operand(count, times_4, conv.address(&small_handlers))); |
| 499 __ jmp(eax); | 499 __ jmp(eax); |
| 500 } | 500 } |
| 501 | 501 |
| 502 __ bind(&pop_and_return); | 502 __ bind(&pop_and_return); |
| 503 MemMoveEmitPopAndReturn(&masm); | 503 MemMoveEmitPopAndReturn(&masm); |
| 504 | 504 |
| 505 CodeDesc desc; | 505 CodeDesc desc; |
| 506 masm.GetCode(&desc); | 506 masm.GetCode(&desc); |
| 507 DCHECK(!RelocInfo::RequiresRelocation(desc)); | 507 DCHECK(!RelocInfo::RequiresRelocation(desc)); |
| 508 CpuFeatures::FlushICache(buffer, actual_size); | 508 Assembler::FlushICacheWithoutIsolate(buffer, actual_size); |
| 509 base::OS::ProtectCode(buffer, actual_size); | 509 base::OS::ProtectCode(buffer, actual_size); |
| 510 // TODO(jkummerow): It would be nice to register this code creation event | 510 // TODO(jkummerow): It would be nice to register this code creation event |
| 511 // with the PROFILE / GDBJIT system. | 511 // with the PROFILE / GDBJIT system. |
| 512 return FUNCTION_CAST<MemMoveFunction>(buffer); | 512 return FUNCTION_CAST<MemMoveFunction>(buffer); |
| 513 } | 513 } |
| 514 | 514 |
| 515 | 515 |
| 516 #undef __ | 516 #undef __ |
| 517 | 517 |
| 518 // ------------------------------------------------------------------------- | 518 // ------------------------------------------------------------------------- |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 } | 1025 } |
| 1026 | 1026 |
| 1027 | 1027 |
| 1028 void Code::PatchPlatformCodeAge(Isolate* isolate, | 1028 void Code::PatchPlatformCodeAge(Isolate* isolate, |
| 1029 byte* sequence, | 1029 byte* sequence, |
| 1030 Code::Age age, | 1030 Code::Age age, |
| 1031 MarkingParity parity) { | 1031 MarkingParity parity) { |
| 1032 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); | 1032 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
| 1033 if (age == kNoAgeCodeAge) { | 1033 if (age == kNoAgeCodeAge) { |
| 1034 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); | 1034 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
| 1035 CpuFeatures::FlushICache(sequence, young_length); | 1035 Assembler::FlushICache(isolate, sequence, young_length); |
| 1036 } else { | 1036 } else { |
| 1037 Code* stub = GetCodeAgeStub(isolate, age, parity); | 1037 Code* stub = GetCodeAgeStub(isolate, age, parity); |
| 1038 CodePatcher patcher(sequence, young_length); | 1038 CodePatcher patcher(sequence, young_length); |
| 1039 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); | 1039 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); |
| 1040 } | 1040 } |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 | 1043 |
| 1044 } // namespace internal | 1044 } // namespace internal |
| 1045 } // namespace v8 | 1045 } // namespace v8 |
| 1046 | 1046 |
| 1047 #endif // V8_TARGET_ARCH_IA32 | 1047 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |