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

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

Issue 6777007: Add thread-safety to creation of MemCopy and modulo functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add Release_Store to change. Created 9 years, 8 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 | « src/api.cc ('k') | src/platform.h » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 10156 matching lines...) Expand 10 before | Expand all | Expand 10 after
10167 #undef __ 10167 #undef __
10168 10168
10169 #define __ masm. 10169 #define __ masm.
10170 10170
10171 10171
10172 static void MemCopyWrapper(void* dest, const void* src, size_t size) { 10172 static void MemCopyWrapper(void* dest, const void* src, size_t size) {
10173 memcpy(dest, src, size); 10173 memcpy(dest, src, size);
10174 } 10174 }
10175 10175
10176 10176
10177 MemCopyFunction CreateMemCopyFunction() { 10177 OS::MemCopyFunction CreateMemCopyFunction() {
10178 HandleScope scope; 10178 HandleScope scope;
10179 MacroAssembler masm(NULL, 1 * KB); 10179 MacroAssembler masm(NULL, 1 * KB);
10180 10180
10181 // Generated code is put into a fixed, unmovable, buffer, and not into 10181 // Generated code is put into a fixed, unmovable, buffer, and not into
10182 // the V8 heap. We can't, and don't, refer to any relocatable addresses 10182 // the V8 heap. We can't, and don't, refer to any relocatable addresses
10183 // (e.g. the JavaScript nan-object). 10183 // (e.g. the JavaScript nan-object).
10184 10184
10185 // 32-bit C declaration function calls pass arguments on stack. 10185 // 32-bit C declaration function calls pass arguments on stack.
10186 10186
10187 // Stack layout: 10187 // Stack layout:
10188 // esp[12]: Third argument, size. 10188 // esp[12]: Third argument, size.
10189 // esp[8]: Second argument, source pointer. 10189 // esp[8]: Second argument, source pointer.
10190 // esp[4]: First argument, destination pointer. 10190 // esp[4]: First argument, destination pointer.
10191 // esp[0]: return address 10191 // esp[0]: return address
10192 10192
10193 const int kDestinationOffset = 1 * kPointerSize; 10193 const int kDestinationOffset = 1 * kPointerSize;
10194 const int kSourceOffset = 2 * kPointerSize; 10194 const int kSourceOffset = 2 * kPointerSize;
10195 const int kSizeOffset = 3 * kPointerSize; 10195 const int kSizeOffset = 3 * kPointerSize;
10196 10196
10197 int stack_offset = 0; // Update if we change the stack height. 10197 int stack_offset = 0; // Update if we change the stack height.
10198 10198
10199 if (FLAG_debug_code) { 10199 if (FLAG_debug_code) {
10200 __ cmp(Operand(esp, kSizeOffset + stack_offset), 10200 __ cmp(Operand(esp, kSizeOffset + stack_offset),
10201 Immediate(kMinComplexMemCopy)); 10201 Immediate(OS::kMinComplexMemCopy));
10202 Label ok; 10202 Label ok;
10203 __ j(greater_equal, &ok); 10203 __ j(greater_equal, &ok);
10204 __ int3(); 10204 __ int3();
10205 __ bind(&ok); 10205 __ bind(&ok);
10206 } 10206 }
10207 if (masm.isolate()->cpu_features()->IsSupported(SSE2)) { 10207 if (masm.isolate()->cpu_features()->IsSupported(SSE2)) {
10208 CpuFeatures::Scope enable(SSE2); 10208 CpuFeatures::Scope enable(SSE2);
10209 __ push(edi); 10209 __ push(edi);
10210 __ push(esi); 10210 __ push(esi);
10211 stack_offset += 2 * kPointerSize; 10211 stack_offset += 2 * kPointerSize;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
10370 CodeDesc desc; 10370 CodeDesc desc;
10371 masm.GetCode(&desc); 10371 masm.GetCode(&desc);
10372 ASSERT(desc.reloc_size == 0); 10372 ASSERT(desc.reloc_size == 0);
10373 10373
10374 // Copy the generated code into an executable chunk and return a pointer 10374 // Copy the generated code into an executable chunk and return a pointer
10375 // to the first instruction in it as a C++ function pointer. 10375 // to the first instruction in it as a C++ function pointer.
10376 LargeObjectChunk* chunk = LargeObjectChunk::New(desc.instr_size, EXECUTABLE); 10376 LargeObjectChunk* chunk = LargeObjectChunk::New(desc.instr_size, EXECUTABLE);
10377 if (chunk == NULL) return &MemCopyWrapper; 10377 if (chunk == NULL) return &MemCopyWrapper;
10378 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size); 10378 memcpy(chunk->GetStartAddress(), desc.buffer, desc.instr_size);
10379 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size); 10379 CPU::FlushICache(chunk->GetStartAddress(), desc.instr_size);
10380 return FUNCTION_CAST<MemCopyFunction>(chunk->GetStartAddress()); 10380 MemoryBarrier();
10381 return FUNCTION_CAST<OS::MemCopyFunction>(chunk->GetStartAddress());
10381 } 10382 }
10382 10383
10383 #undef __ 10384 #undef __
10384 10385
10385 } } // namespace v8::internal 10386 } } // namespace v8::internal
10386 10387
10387 #endif // V8_TARGET_ARCH_IA32 10388 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698