Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { | |
|
Vitaly Repeshko
2011/03/30 10:17:19
Why does this have to be in platform files? It'd b
William Hesse
2011/03/30 11:26:44
It depends on whether it is an inline function or
Vitaly Repeshko
2011/03/30 12:25:01
I think creating v8utils.cc is a better solution.
| |
| 216 if (memcopy_function == NULL) { | |
| 217 ScopedLock lock(memcopy_function_mutex); | |
| 218 Isolate::EnsureDefaultIsolate(); | |
| 219 if (memcopy_function == NULL) { | |
| 220 memcopy_function = CreateMemCopyFunction(); | |
|
Vitaly Repeshko
2011/03/30 10:17:19
You need a memory barrier between function creatio
William Hesse
2011/03/30 11:26:44
Done.
William Hesse
2011/03/30 11:26:44
We end the function CreateMemCopyFunction() with a
Vitaly Repeshko
2011/03/30 12:25:01
Well, strictly speaking we need both CPU and compi
| |
| 221 } | |
| 222 } | |
| 223 (*memcopy_function)(dest, src, size); | |
| 224 #ifdef DEBUG | |
| 225 CHECK_EQ(0, memcmp(dest, src, size)); | |
| 226 #endif | |
| 227 } | |
| 228 #endif // V8_TARGET_ARCH_IA32 | |
| 229 | |
| 208 // ---------------------------------------------------------------------------- | 230 // ---------------------------------------------------------------------------- |
| 209 // POSIX string support. | 231 // POSIX string support. |
| 210 // | 232 // |
| 211 | 233 |
| 212 char* OS::StrChr(char* str, int c) { | 234 char* OS::StrChr(char* str, int c) { |
| 213 return strchr(str, c); | 235 return strchr(str, c); |
| 214 } | 236 } |
| 215 | 237 |
| 216 | 238 |
| 217 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { | 239 void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 return ntohl(value); | 412 return ntohl(value); |
| 391 } | 413 } |
| 392 | 414 |
| 393 | 415 |
| 394 Socket* OS::CreateSocket() { | 416 Socket* OS::CreateSocket() { |
| 395 return new POSIXSocket(); | 417 return new POSIXSocket(); |
| 396 } | 418 } |
| 397 | 419 |
| 398 | 420 |
| 399 } } // namespace v8::internal | 421 } } // namespace v8::internal |
| OLD | NEW |