Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Side by Side Diff: src/arm/codegen-arm.cc

Issue 23641009: Refactor and cleanup VirtualMemory. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed nits. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8config.h ('k') | src/deoptimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 double fast_exp_simulator(double x) { 57 double fast_exp_simulator(double x) {
58 return Simulator::current(Isolate::Current())->CallFP( 58 return Simulator::current(Isolate::Current())->CallFP(
59 fast_exp_arm_machine_code, x, 0); 59 fast_exp_arm_machine_code, x, 0);
60 } 60 }
61 #endif 61 #endif
62 62
63 63
64 UnaryMathFunction CreateExpFunction() { 64 UnaryMathFunction CreateExpFunction() {
65 if (!FLAG_fast_math) return &exp; 65 if (!FLAG_fast_math) return &exp;
66 size_t actual_size; 66 size_t actual_size;
67 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); 67 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
68 1 * KB, &actual_size, VirtualMemory::EXECUTABLE));
68 if (buffer == NULL) return &exp; 69 if (buffer == NULL) return &exp;
69 ExternalReference::InitializeMathExpData(); 70 ExternalReference::InitializeMathExpData();
70 71
71 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); 72 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
72 73
73 { 74 {
74 DwVfpRegister input = d0; 75 DwVfpRegister input = d0;
75 DwVfpRegister result = d1; 76 DwVfpRegister result = d1;
76 DwVfpRegister double_scratch1 = d2; 77 DwVfpRegister double_scratch1 = d2;
77 DwVfpRegister double_scratch2 = d3; 78 DwVfpRegister double_scratch2 = d3;
(...skipping 17 matching lines...) Expand all
95 __ vmov(r0, r1, result); 96 __ vmov(r0, r1, result);
96 } 97 }
97 __ Ret(); 98 __ Ret();
98 } 99 }
99 100
100 CodeDesc desc; 101 CodeDesc desc;
101 masm.GetCode(&desc); 102 masm.GetCode(&desc);
102 ASSERT(!RelocInfo::RequiresRelocation(desc)); 103 ASSERT(!RelocInfo::RequiresRelocation(desc));
103 104
104 CPU::FlushICache(buffer, actual_size); 105 CPU::FlushICache(buffer, actual_size);
105 OS::ProtectCode(buffer, actual_size); 106 bool result = VirtualMemory::WriteProtectRegion(buffer, actual_size);
107 ASSERT(result);
108 USE(result);
106 109
107 #if !defined(USE_SIMULATOR) 110 #if !defined(USE_SIMULATOR)
108 return FUNCTION_CAST<UnaryMathFunction>(buffer); 111 return FUNCTION_CAST<UnaryMathFunction>(buffer);
109 #else 112 #else
110 fast_exp_arm_machine_code = buffer; 113 fast_exp_arm_machine_code = buffer;
111 return &fast_exp_simulator; 114 return &fast_exp_simulator;
112 #endif 115 #endif
113 } 116 }
114 117
115 #if defined(V8_HOST_ARCH_ARM) 118 #if defined(V8_HOST_ARCH_ARM)
116 OS::MemCopyUint8Function CreateMemCopyUint8Function( 119 OS::MemCopyUint8Function CreateMemCopyUint8Function(
117 OS::MemCopyUint8Function stub) { 120 OS::MemCopyUint8Function stub) {
118 #if defined(USE_SIMULATOR) 121 #if defined(USE_SIMULATOR)
119 return stub; 122 return stub;
120 #else 123 #else
121 if (Serializer::enabled() || !CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) { 124 if (Serializer::enabled() || !CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) {
122 return stub; 125 return stub;
123 } 126 }
124 size_t actual_size; 127 size_t actual_size;
125 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); 128 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
129 1 * KB, &actual_size, VirtualMemory::EXECUTABLE));
126 if (buffer == NULL) return stub; 130 if (buffer == NULL) return stub;
127 131
128 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); 132 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
129 133
130 Register dest = r0; 134 Register dest = r0;
131 Register src = r1; 135 Register src = r1;
132 Register chars = r2; 136 Register chars = r2;
133 Register temp1 = r3; 137 Register temp1 = r3;
134 Label less_4; 138 Label less_4;
135 139
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 __ strh(temp1, MemOperand(dest, 2, PostIndex), cs); 261 __ strh(temp1, MemOperand(dest, 2, PostIndex), cs);
258 __ ldrb(temp1, MemOperand(src), ne); 262 __ ldrb(temp1, MemOperand(src), ne);
259 __ strb(temp1, MemOperand(dest), ne); 263 __ strb(temp1, MemOperand(dest), ne);
260 __ Ret(); 264 __ Ret();
261 265
262 CodeDesc desc; 266 CodeDesc desc;
263 masm.GetCode(&desc); 267 masm.GetCode(&desc);
264 ASSERT(!RelocInfo::RequiresRelocation(desc)); 268 ASSERT(!RelocInfo::RequiresRelocation(desc));
265 269
266 CPU::FlushICache(buffer, actual_size); 270 CPU::FlushICache(buffer, actual_size);
267 OS::ProtectCode(buffer, actual_size); 271 bool result = VirtualMemory::WriteProtectRegion(buffer, actual_size);
272 ASSERT(result);
273 USE(result);
268 return FUNCTION_CAST<OS::MemCopyUint8Function>(buffer); 274 return FUNCTION_CAST<OS::MemCopyUint8Function>(buffer);
269 #endif 275 #endif
270 } 276 }
271 277
272 278
273 // Convert 8 to 16. The number of character to copy must be at least 8. 279 // Convert 8 to 16. The number of character to copy must be at least 8.
274 OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( 280 OS::MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function(
275 OS::MemCopyUint16Uint8Function stub) { 281 OS::MemCopyUint16Uint8Function stub) {
276 #if defined(USE_SIMULATOR) 282 #if defined(USE_SIMULATOR)
277 return stub; 283 return stub;
278 #else 284 #else
279 if (Serializer::enabled() || !CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) { 285 if (Serializer::enabled() || !CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) {
280 return stub; 286 return stub;
281 } 287 }
282 size_t actual_size; 288 size_t actual_size;
283 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); 289 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
290 1 * KB, &actual_size, VirtualMemory::EXECUTABLE));
284 if (buffer == NULL) return stub; 291 if (buffer == NULL) return stub;
285 292
286 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); 293 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
287 294
288 Register dest = r0; 295 Register dest = r0;
289 Register src = r1; 296 Register src = r1;
290 Register chars = r2; 297 Register chars = r2;
291 if (CpuFeatures::IsSupported(NEON)) { 298 if (CpuFeatures::IsSupported(NEON)) {
292 Register temp = r3; 299 Register temp = r3;
293 Label loop; 300 Label loop;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 __ bind(&not_two); 352 __ bind(&not_two);
346 __ ldrb(temp1, MemOperand(src), ne); 353 __ ldrb(temp1, MemOperand(src), ne);
347 __ strh(temp1, MemOperand(dest), ne); 354 __ strh(temp1, MemOperand(dest), ne);
348 __ Pop(pc, r4); 355 __ Pop(pc, r4);
349 } 356 }
350 357
351 CodeDesc desc; 358 CodeDesc desc;
352 masm.GetCode(&desc); 359 masm.GetCode(&desc);
353 360
354 CPU::FlushICache(buffer, actual_size); 361 CPU::FlushICache(buffer, actual_size);
355 OS::ProtectCode(buffer, actual_size); 362 bool result = VirtualMemory::WriteProtectRegion(buffer, actual_size);
363 ASSERT(result);
364 USE(result);
356 365
357 return FUNCTION_CAST<OS::MemCopyUint16Uint8Function>(buffer); 366 return FUNCTION_CAST<OS::MemCopyUint16Uint8Function>(buffer);
358 #endif 367 #endif
359 } 368 }
360 #endif 369 #endif
361 370
362 #undef __ 371 #undef __
363 372
364 373
365 UnaryMathFunction CreateSqrtFunction() { 374 UnaryMathFunction CreateSqrtFunction() {
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 patcher.masm()->add(r0, pc, Operand(-8)); 893 patcher.masm()->add(r0, pc, Operand(-8));
885 patcher.masm()->ldr(pc, MemOperand(pc, -4)); 894 patcher.masm()->ldr(pc, MemOperand(pc, -4));
886 patcher.masm()->dd(reinterpret_cast<uint32_t>(stub->instruction_start())); 895 patcher.masm()->dd(reinterpret_cast<uint32_t>(stub->instruction_start()));
887 } 896 }
888 } 897 }
889 898
890 899
891 } } // namespace v8::internal 900 } } // namespace v8::internal
892 901
893 #endif // V8_TARGET_ARCH_ARM 902 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « include/v8config.h ('k') | src/deoptimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698