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_ARM | 7 #if V8_TARGET_ARCH_ARM |
8 | 8 |
9 #include "src/arm/simulator-arm.h" | 9 #include "src/arm/simulator-arm.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.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())->CallFPReturnsDouble( | 23 return Simulator::current(Isolate::Current())->CallFPReturnsDouble( |
24 fast_exp_arm_machine_code, x, 0); | 24 fast_exp_arm_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 DwVfpRegister input = d0; | 40 DwVfpRegister input = d0; |
40 DwVfpRegister result = d1; | 41 DwVfpRegister result = d1; |
41 DwVfpRegister double_scratch1 = d2; | 42 DwVfpRegister double_scratch1 = d2; |
42 DwVfpRegister double_scratch2 = d3; | 43 DwVfpRegister double_scratch2 = d3; |
(...skipping 16 matching lines...) Expand all Loading... |
59 } else { | 60 } else { |
60 __ vmov(r0, r1, result); | 61 __ vmov(r0, r1, result); |
61 } | 62 } |
62 __ Ret(); | 63 __ Ret(); |
63 } | 64 } |
64 | 65 |
65 CodeDesc desc; | 66 CodeDesc desc; |
66 masm.GetCode(&desc); | 67 masm.GetCode(&desc); |
67 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 68 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
68 | 69 |
69 CPU::FlushICache(buffer, actual_size); | 70 CpuFeatures::FlushICache(buffer, actual_size); |
70 OS::ProtectCode(buffer, actual_size); | 71 base::OS::ProtectCode(buffer, actual_size); |
71 | 72 |
72 #if !defined(USE_SIMULATOR) | 73 #if !defined(USE_SIMULATOR) |
73 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 74 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
74 #else | 75 #else |
75 fast_exp_arm_machine_code = buffer; | 76 fast_exp_arm_machine_code = buffer; |
76 return &fast_exp_simulator; | 77 return &fast_exp_simulator; |
77 #endif | 78 #endif |
78 } | 79 } |
79 | 80 |
80 #if defined(V8_HOST_ARCH_ARM) | 81 #if defined(V8_HOST_ARCH_ARM) |
81 MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { | 82 MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { |
82 #if defined(USE_SIMULATOR) | 83 #if defined(USE_SIMULATOR) |
83 return stub; | 84 return stub; |
84 #else | 85 #else |
85 if (!CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) return stub; | 86 if (!CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) return stub; |
86 size_t actual_size; | 87 size_t actual_size; |
87 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); | 88 byte* buffer = |
| 89 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
88 if (buffer == NULL) return stub; | 90 if (buffer == NULL) return stub; |
89 | 91 |
90 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 92 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
91 | 93 |
92 Register dest = r0; | 94 Register dest = r0; |
93 Register src = r1; | 95 Register src = r1; |
94 Register chars = r2; | 96 Register chars = r2; |
95 Register temp1 = r3; | 97 Register temp1 = r3; |
96 Label less_4; | 98 Label less_4; |
97 | 99 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 __ ldrh(temp1, MemOperand(src, 2, PostIndex), cs); | 220 __ ldrh(temp1, MemOperand(src, 2, PostIndex), cs); |
219 __ strh(temp1, MemOperand(dest, 2, PostIndex), cs); | 221 __ strh(temp1, MemOperand(dest, 2, PostIndex), cs); |
220 __ ldrb(temp1, MemOperand(src), ne); | 222 __ ldrb(temp1, MemOperand(src), ne); |
221 __ strb(temp1, MemOperand(dest), ne); | 223 __ strb(temp1, MemOperand(dest), ne); |
222 __ Ret(); | 224 __ Ret(); |
223 | 225 |
224 CodeDesc desc; | 226 CodeDesc desc; |
225 masm.GetCode(&desc); | 227 masm.GetCode(&desc); |
226 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 228 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
227 | 229 |
228 CPU::FlushICache(buffer, actual_size); | 230 CpuFeatures::FlushICache(buffer, actual_size); |
229 OS::ProtectCode(buffer, actual_size); | 231 base::OS::ProtectCode(buffer, actual_size); |
230 return FUNCTION_CAST<MemCopyUint8Function>(buffer); | 232 return FUNCTION_CAST<MemCopyUint8Function>(buffer); |
231 #endif | 233 #endif |
232 } | 234 } |
233 | 235 |
234 | 236 |
235 // Convert 8 to 16. The number of character to copy must be at least 8. | 237 // Convert 8 to 16. The number of character to copy must be at least 8. |
236 MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( | 238 MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( |
237 MemCopyUint16Uint8Function stub) { | 239 MemCopyUint16Uint8Function stub) { |
238 #if defined(USE_SIMULATOR) | 240 #if defined(USE_SIMULATOR) |
239 return stub; | 241 return stub; |
240 #else | 242 #else |
241 if (!CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) return stub; | 243 if (!CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) return stub; |
242 size_t actual_size; | 244 size_t actual_size; |
243 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); | 245 byte* buffer = |
| 246 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
244 if (buffer == NULL) return stub; | 247 if (buffer == NULL) return stub; |
245 | 248 |
246 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 249 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
247 | 250 |
248 Register dest = r0; | 251 Register dest = r0; |
249 Register src = r1; | 252 Register src = r1; |
250 Register chars = r2; | 253 Register chars = r2; |
251 if (CpuFeatures::IsSupported(NEON)) { | 254 if (CpuFeatures::IsSupported(NEON)) { |
252 Register temp = r3; | 255 Register temp = r3; |
253 Label loop; | 256 Label loop; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 __ str(temp3, MemOperand(dest, 4, PostIndex)); | 307 __ str(temp3, MemOperand(dest, 4, PostIndex)); |
305 __ bind(¬_two); | 308 __ bind(¬_two); |
306 __ ldrb(temp1, MemOperand(src), ne); | 309 __ ldrb(temp1, MemOperand(src), ne); |
307 __ strh(temp1, MemOperand(dest), ne); | 310 __ strh(temp1, MemOperand(dest), ne); |
308 __ Pop(pc, r4); | 311 __ Pop(pc, r4); |
309 } | 312 } |
310 | 313 |
311 CodeDesc desc; | 314 CodeDesc desc; |
312 masm.GetCode(&desc); | 315 masm.GetCode(&desc); |
313 | 316 |
314 CPU::FlushICache(buffer, actual_size); | 317 CpuFeatures::FlushICache(buffer, actual_size); |
315 OS::ProtectCode(buffer, actual_size); | 318 base::OS::ProtectCode(buffer, actual_size); |
316 | 319 |
317 return FUNCTION_CAST<MemCopyUint16Uint8Function>(buffer); | 320 return FUNCTION_CAST<MemCopyUint16Uint8Function>(buffer); |
318 #endif | 321 #endif |
319 } | 322 } |
320 #endif | 323 #endif |
321 | 324 |
322 UnaryMathFunction CreateSqrtFunction() { | 325 UnaryMathFunction CreateSqrtFunction() { |
323 #if defined(USE_SIMULATOR) | 326 #if defined(USE_SIMULATOR) |
324 return &std::sqrt; | 327 return &std::sqrt; |
325 #else | 328 #else |
326 size_t actual_size; | 329 size_t actual_size; |
327 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); | 330 byte* buffer = |
| 331 static_cast<byte*>(base::OS::Allocate(1 * KB, &actual_size, true)); |
328 if (buffer == NULL) return &std::sqrt; | 332 if (buffer == NULL) return &std::sqrt; |
329 | 333 |
330 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); | 334 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); |
331 | 335 |
332 __ MovFromFloatParameter(d0); | 336 __ MovFromFloatParameter(d0); |
333 __ vsqrt(d0, d0); | 337 __ vsqrt(d0, d0); |
334 __ MovToFloatResult(d0); | 338 __ MovToFloatResult(d0); |
335 __ Ret(); | 339 __ Ret(); |
336 | 340 |
337 CodeDesc desc; | 341 CodeDesc desc; |
338 masm.GetCode(&desc); | 342 masm.GetCode(&desc); |
339 ASSERT(!RelocInfo::RequiresRelocation(desc)); | 343 ASSERT(!RelocInfo::RequiresRelocation(desc)); |
340 | 344 |
341 CPU::FlushICache(buffer, actual_size); | 345 CpuFeatures::FlushICache(buffer, actual_size); |
342 OS::ProtectCode(buffer, actual_size); | 346 base::OS::ProtectCode(buffer, actual_size); |
343 return FUNCTION_CAST<UnaryMathFunction>(buffer); | 347 return FUNCTION_CAST<UnaryMathFunction>(buffer); |
344 #endif | 348 #endif |
345 } | 349 } |
346 | 350 |
347 #undef __ | 351 #undef __ |
348 | 352 |
349 | 353 |
350 // ------------------------------------------------------------------------- | 354 // ------------------------------------------------------------------------- |
351 // Platform-specific RuntimeCallHelper functions. | 355 // Platform-specific RuntimeCallHelper functions. |
352 | 356 |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 } | 871 } |
868 | 872 |
869 | 873 |
870 void Code::PatchPlatformCodeAge(Isolate* isolate, | 874 void Code::PatchPlatformCodeAge(Isolate* isolate, |
871 byte* sequence, | 875 byte* sequence, |
872 Code::Age age, | 876 Code::Age age, |
873 MarkingParity parity) { | 877 MarkingParity parity) { |
874 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); | 878 uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
875 if (age == kNoAgeCodeAge) { | 879 if (age == kNoAgeCodeAge) { |
876 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); | 880 isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
877 CPU::FlushICache(sequence, young_length); | 881 CpuFeatures::FlushICache(sequence, young_length); |
878 } else { | 882 } else { |
879 Code* stub = GetCodeAgeStub(isolate, age, parity); | 883 Code* stub = GetCodeAgeStub(isolate, age, parity); |
880 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); | 884 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); |
881 patcher.masm()->add(r0, pc, Operand(-8)); | 885 patcher.masm()->add(r0, pc, Operand(-8)); |
882 patcher.masm()->ldr(pc, MemOperand(pc, -4)); | 886 patcher.masm()->ldr(pc, MemOperand(pc, -4)); |
883 patcher.masm()->emit_code_stub_address(stub); | 887 patcher.masm()->emit_code_stub_address(stub); |
884 } | 888 } |
885 } | 889 } |
886 | 890 |
887 | 891 |
888 } } // namespace v8::internal | 892 } } // namespace v8::internal |
889 | 893 |
890 #endif // V8_TARGET_ARCH_ARM | 894 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |