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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 double fast_exp_simulator(double x) { | 22 double fast_exp_simulator(double x) { |
23 return Simulator::current(Isolate::Current())->CallFP( | 23 return Simulator::current(Isolate::Current())->CallFP( |
24 fast_exp_mips_machine_code, x, 0); | 24 fast_exp_mips_machine_code, x, 0); |
25 } | 25 } |
26 #endif | 26 #endif |
27 | 27 |
28 | 28 |
29 UnaryMathFunction CreateExpFunction() { | 29 UnaryMathFunction CreateExpFunction() { |
30 if (!FLAG_fast_math) return &std::exp; | 30 if (!FLAG_fast_math) return &std::exp; |
31 size_t actual_size; | 31 size_t actual_size; |
32 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); | 32 byte* buffer = |
| 33 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
33 if (buffer == NULL) return &std::exp; | 34 if (buffer == NULL) return &std::exp; |
34 ExternalReference::InitializeMathExpData(); | 35 ExternalReference::InitializeMathExpData(); |
35 | 36 |
36 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 37 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
37 | 38 |
38 { | 39 { |
39 DoubleRegister input = f12; | 40 DoubleRegister input = f12; |
40 DoubleRegister result = f0; | 41 DoubleRegister result = f0; |
41 DoubleRegister double_scratch1 = f4; | 42 DoubleRegister double_scratch1 = f4; |
42 DoubleRegister double_scratch2 = f6; | 43 DoubleRegister double_scratch2 = f6; |
43 Register temp1 = t0; | 44 Register temp1 = t0; |
44 Register temp2 = t1; | 45 Register temp2 = t1; |
45 Register temp3 = t2; | 46 Register temp3 = t2; |
46 | 47 |
47 __ MovFromFloatParameter(input); | 48 __ MovFromFloatParameter(input); |
48 __ Push(temp3, temp2, temp1); | 49 __ Push(temp3, temp2, temp1); |
49 MathExpGenerator::EmitMathExp( | 50 MathExpGenerator::EmitMathExp( |
50 &masm, input, result, double_scratch1, double_scratch2, | 51 &masm, input, result, double_scratch1, double_scratch2, |
51 temp1, temp2, temp3); | 52 temp1, temp2, temp3); |
52 __ Pop(temp3, temp2, temp1); | 53 __ Pop(temp3, temp2, temp1); |
53 __ MovToFloatResult(result); | 54 __ MovToFloatResult(result); |
54 __ Ret(); | 55 __ Ret(); |
55 } | 56 } |
56 | 57 |
57 CodeDesc desc; | 58 CodeDesc desc; |
58 masm.GetCode(&desc); | 59 masm.GetCode(&desc); |
59 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 60 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
60 | 61 |
61 CPU::FlushICache(buffer, actual_size); | 62 CpuFeatures::FlushICache(buffer, actual_size); |
62 OS::ProtectCode(buffer, actual_size); | 63 base::OS::ProtectCode(buffer, actual_size); |
63 | 64 |
64 #if !defined(USE_SIMULATOR) | 65 #if !defined(USE_SIMULATOR) |
65 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 66 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
66 #else | 67 #else |
67 fast_exp_mips_machine_code = buffer; | 68 fast_exp_mips_machine_code = buffer; |
68 return &fast_exp_simulator; | 69 return &fast_exp_simulator; |
69 #endif | 70 #endif |
70 } | 71 } |
71 | 72 |
72 | 73 |
73 #if defined(V8_HOST_ARCH_MIPS) | 74 #if defined(V8_HOST_ARCH_MIPS) |
74 MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { | 75 MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { |
75 #if defined(USE_SIMULATOR) | 76 #if defined(USE_SIMULATOR) |
76 return stub; | 77 return stub; |
77 #else | 78 #else |
78 size_t actual_size; | 79 size_t actual_size; |
79 byte* buffer = static_cast<byte*>(OS::Allocate(3 * KB, &actual_size, true)); | 80 byte* buffer = |
| 81 static_cast<byte*>(base::OS::Allocate(3 * KB, &actual_size, true)); |
80 if (buffer == NULL) return stub; | 82 if (buffer == NULL) return stub; |
81 | 83 |
82 // This code assumes that cache lines are 32 bytes and if the cache line is | 84 // This code assumes that cache lines are 32 bytes and if the cache line is |
83 // larger it will not work correctly. | 85 // larger it will not work correctly. |
84 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 86 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
85 | 87 |
86 { | 88 { |
87 Label lastb, unaligned, aligned, chkw, | 89 Label lastb, unaligned, aligned, chkw, |
88 loop16w, chk1w, wordCopy_loop, skip_pref, lastbloop, | 90 loop16w, chk1w, wordCopy_loop, skip_pref, lastbloop, |
89 leave, ua_chk16w, ua_loop16w, ua_skip_pref, ua_chkw, | 91 leave, ua_chk16w, ua_loop16w, ua_skip_pref, ua_chkw, |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 __ bne(a0, a3, &ua_smallCopy_loop); | 589 __ bne(a0, a3, &ua_smallCopy_loop); |
588 __ sb(v1, MemOperand(a0, -1)); // In delay slot. | 590 __ sb(v1, MemOperand(a0, -1)); // In delay slot. |
589 | 591 |
590 __ jr(ra); | 592 __ jr(ra); |
591 __ nop(); | 593 __ nop(); |
592 } | 594 } |
593 CodeDesc desc; | 595 CodeDesc desc; |
594 masm.GetCode(&desc); | 596 masm.GetCode(&desc); |
595 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 597 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
596 | 598 |
597 CPU::FlushICache(buffer, actual_size); | 599 CpuFeatures::FlushICache(buffer, actual_size); |
598 OS::ProtectCode(buffer, actual_size); | 600 base::OS::ProtectCode(buffer, actual_size); |
599 return FUNCTION_CAST<MemCopyUint8Function>(buffer); | 601 return FUNCTION_CAST<MemCopyUint8Function>(buffer); |
600 #endif | 602 #endif |
601 } | 603 } |
602 #endif | 604 #endif |
603 | 605 |
604 UnaryMathFunction CreateSqrtFunction() { | 606 UnaryMathFunction CreateSqrtFunction() { |
605 #if defined(USE_SIMULATOR) | 607 #if defined(USE_SIMULATOR) |
606 return &std::sqrt; | 608 return &std::sqrt; |
607 #else | 609 #else |
608 size_t actual_size; | 610 size_t actual_size; |
609 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); | 611 byte* buffer = |
| 612 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
610 if (buffer == NULL) return &std::sqrt; | 613 if (buffer == NULL) return &std::sqrt; |
611 | 614 |
612 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 615 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
613 | 616 |
614 __ MovFromFloatParameter(f12); | 617 __ MovFromFloatParameter(f12); |
615 __ sqrt_d(f0, f12); | 618 __ sqrt_d(f0, f12); |
616 __ MovToFloatResult(f0); | 619 __ MovToFloatResult(f0); |
617 __ Ret(); | 620 __ Ret(); |
618 | 621 |
619 CodeDesc desc; | 622 CodeDesc desc; |
620 masm.GetCode(&desc); | 623 masm.GetCode(&desc); |
621 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 624 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
622 | 625 |
623 CPU::FlushICache(buffer, actual_size); | 626 CpuFeatures::FlushICache(buffer, actual_size); |
624 OS::ProtectCode(buffer, actual_size); | 627 base::OS::ProtectCode(buffer, actual_size); |
625 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 628 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
626 #endif | 629 #endif |
627 } | 630 } |
628 | 631 |
629 #undef __ | 632 #undef __ |
630 | 633 |
631 | 634 |
632 // ------------------------------------------------------------------------- | 635 // ------------------------------------------------------------------------- |
633 // Platform-specific RuntimeCallHelper functions. | 636 // Platform-specific RuntimeCallHelper functions. |
634 | 637 |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 } | 1171 } |
1169 | 1172 |
1170 | 1173 |
1171 void Code::PatchPlatformCodeAge(Isolate* isolate, | 1174 void Code::PatchPlatformCodeAge(Isolate* isolate, |
1172 byte* sequence, | 1175 byte* sequence, |
1173 Code::Age age, | 1176 Code::Age age, |
1174 MarkingParity parity) { | 1177 MarkingParity parity) { |
1175 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); | 1178 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
1176 if (age == kNoAgeCodeAge) { | 1179 if (age == kNoAgeCodeAge) { |
1177 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); | 1180 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
1178 CPU::FlushICache(sequence, young_length); | 1181 CpuFeatures::FlushICache(sequence, young_length); |
1179 } else { | 1182 } else { |
1180 Code* stub = GetCodeAgeStub(isolate, age, parity); | 1183 Code* stub = GetCodeAgeStub(isolate, age, parity); |
1181 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); | 1184 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); |
1182 // Mark this code sequence for FindPlatformCodeAgeSequence(). | 1185 // Mark this code sequence for FindPlatformCodeAgeSequence(). |
1183 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); | 1186 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); |
1184 // Load the stub address to t9 and call it, | 1187 // Load the stub address to t9 and call it, |
1185 // GetCodeAgeAndParity() extracts the stub address from this instruction. | 1188 // GetCodeAgeAndParity() extracts the stub address from this instruction. |
1186 patcher.masm()->li( | 1189 patcher.masm()->li( |
1187 t9, | 1190 t9, |
1188 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), | 1191 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), |
1189 CONSTANT_SIZE); | 1192 CONSTANT_SIZE); |
1190 patcher.masm()->nop(); // Prevent jalr to jal optimization. | 1193 patcher.masm()->nop(); // Prevent jalr to jal optimization. |
1191 patcher.masm()->jalr(t9, a0); | 1194 patcher.masm()->jalr(t9, a0); |
1192 patcher.masm()->nop(); // Branch delay slot nop. | 1195 patcher.masm()->nop(); // Branch delay slot nop. |
1193 patcher.masm()->nop(); // Pad the empty space. | 1196 patcher.masm()->nop(); // Pad the empty space. |
1194 } | 1197 } |
1195 } | 1198 } |
1196 | 1199 |
1197 | 1200 |
1198 #undef __ | 1201 #undef __ |
1199 | 1202 |
1200 } } // namespace v8::internal | 1203 } } // namespace v8::internal |
1201 | 1204 |
1202 #endif // V8_TARGET_ARCH_MIPS | 1205 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |