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

Side by Side Diff: src/platform-posix.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/platform.h ('k') | src/platform-win32.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // If the length is zero, the assignment fails. 198 // If the length is zero, the assignment fails.
199 if (str.length() > 0) 199 if (str.length() > 0)
200 str[str.length() - 1] = '\0'; 200 str[str.length() - 1] = '\0';
201 return -1; 201 return -1;
202 } else { 202 } else {
203 return n; 203 return n;
204 } 204 }
205 } 205 }
206 206
207 207
208 #if defined(V8_TARGET_ARCH_IA32)
209 static OS::MemCopyFunction memcopy_function = NULL;
210 static Mutex* memcopy_function_mutex = OS::CreateMutex();
211 // Defined in codegen-ia32.cc.
212 OS::MemCopyFunction CreateMemCopyFunction();
213
214 // Copy memory area to disjoint memory area.
215 void OS::MemCopy(void* dest, const void* src, size_t size) {
216 if (memcopy_function == NULL) {
217 ScopedLock lock(memcopy_function_mutex);
218 Isolate::EnsureDefaultIsolate();
219 if (memcopy_function == NULL) {
220 Release_Store(reinterpret_cast<AtomicWord*>(&memcopy_function),
221 reinterpret_cast<AtomicWord>(CreateMemCopyFunction()));
222 }
223 }
224 (*memcopy_function)(dest, src, size);
225 #ifdef DEBUG
226 CHECK_EQ(0, memcmp(dest, src, size));
227 #endif
228 }
229 #endif // V8_TARGET_ARCH_IA32
230
208 // ---------------------------------------------------------------------------- 231 // ----------------------------------------------------------------------------
209 // POSIX string support. 232 // POSIX string support.
210 // 233 //
211 234
212 char* OS::StrChr(char* str, int c) { 235 char* OS::StrChr(char* str, int c) {
213 return strchr(str, c); 236 return strchr(str, c);
214 } 237 }
215 238
216 239
217 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { 240 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return ntohl(value); 413 return ntohl(value);
391 } 414 }
392 415
393 416
394 Socket* OS::CreateSocket() { 417 Socket* OS::CreateSocket() {
395 return new POSIXSocket(); 418 return new POSIXSocket();
396 } 419 }
397 420
398 421
399 } } // namespace v8::internal 422 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698