| OLD | NEW |
| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 | 142 |
| 143 double ceiling(double x) { | 143 double ceiling(double x) { |
| 144 return ceil(x); | 144 return ceil(x); |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 static Mutex* limit_mutex = NULL; | 148 static Mutex* limit_mutex = NULL; |
| 149 | 149 |
| 150 #if defined(V8_TARGET_ARCH_IA32) | 150 #if defined(V8_TARGET_ARCH_IA32) |
| 151 static OS::MemCopyFunction memcopy_function = NULL; | 151 static void MemMoveWrapper(void* dest, const void* src, size_t size) { |
| 152 memmove(dest, src, size); |
| 153 } |
| 154 |
| 155 // Initialize to library version so we can call this at any time during startup. |
| 156 static OS::MemMoveFunction memmove_function = &MemMoveWrapper; |
| 157 |
| 152 // Defined in codegen-ia32.cc. | 158 // Defined in codegen-ia32.cc. |
| 153 OS::MemCopyFunction CreateMemCopyFunction(); | 159 OS::MemMoveFunction CreateMemMoveFunction(); |
| 154 | 160 |
| 155 // Copy memory area to disjoint memory area. | 161 // Copy memory area to disjoint memory area. |
| 156 void OS::MemCopy(void* dest, const void* src, size_t size) { | 162 void OS::MemMove(void* dest, const void* src, size_t size) { |
| 157 // Note: here we rely on dependent reads being ordered. This is true | 163 // Note: here we rely on dependent reads being ordered. This is true |
| 158 // on all architectures we currently support. | 164 // on all architectures we currently support. |
| 159 (*memcopy_function)(dest, src, size); | 165 (*memmove_function)(dest, src, size); |
| 160 #ifdef DEBUG | |
| 161 CHECK_EQ(0, memcmp(dest, src, size)); | |
| 162 #endif | |
| 163 } | 166 } |
| 167 |
| 164 #endif // V8_TARGET_ARCH_IA32 | 168 #endif // V8_TARGET_ARCH_IA32 |
| 165 | 169 |
| 166 #ifdef _WIN64 | 170 #ifdef _WIN64 |
| 167 typedef double (*ModuloFunction)(double, double); | 171 typedef double (*ModuloFunction)(double, double); |
| 168 static ModuloFunction modulo_function = NULL; | 172 static ModuloFunction modulo_function = NULL; |
| 169 // Defined in codegen-x64.cc. | 173 // Defined in codegen-x64.cc. |
| 170 ModuloFunction CreateModuloFunction(); | 174 ModuloFunction CreateModuloFunction(); |
| 171 | 175 |
| 172 void init_modulo_function() { | 176 void init_modulo_function() { |
| 173 modulo_function = CreateModuloFunction(); | 177 modulo_function = CreateModuloFunction(); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 // saving is in effect at the given time. | 573 // saving is in effect at the given time. |
| 570 return InDST() ? dst_tz_name_ : std_tz_name_; | 574 return InDST() ? dst_tz_name_ : std_tz_name_; |
| 571 } | 575 } |
| 572 | 576 |
| 573 | 577 |
| 574 void OS::PostSetUp() { | 578 void OS::PostSetUp() { |
| 575 // Math functions depend on CPU features therefore they are initialized after | 579 // Math functions depend on CPU features therefore they are initialized after |
| 576 // CPU. | 580 // CPU. |
| 577 MathSetup(); | 581 MathSetup(); |
| 578 #if defined(V8_TARGET_ARCH_IA32) | 582 #if defined(V8_TARGET_ARCH_IA32) |
| 579 memcopy_function = CreateMemCopyFunction(); | 583 OS::MemMoveFunction generated_memmove = CreateMemMoveFunction(); |
| 584 if (generated_memmove != NULL) { |
| 585 memmove_function = generated_memmove; |
| 586 } |
| 580 #endif | 587 #endif |
| 581 } | 588 } |
| 582 | 589 |
| 583 | 590 |
| 584 // Returns the accumulated user time for thread. | 591 // Returns the accumulated user time for thread. |
| 585 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { | 592 int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) { |
| 586 FILETIME dummy; | 593 FILETIME dummy; |
| 587 uint64_t usertime; | 594 uint64_t usertime; |
| 588 | 595 |
| 589 // Get the amount of time that the thread has executed in user mode. | 596 // Get the amount of time that the thread has executed in user mode. |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 // Open a physical file | 1062 // Open a physical file |
| 1056 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, | 1063 HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, |
| 1057 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL); | 1064 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL); |
| 1058 if (file == NULL) return NULL; | 1065 if (file == NULL) return NULL; |
| 1059 // Create a file mapping for the physical file | 1066 // Create a file mapping for the physical file |
| 1060 HANDLE file_mapping = CreateFileMapping(file, NULL, | 1067 HANDLE file_mapping = CreateFileMapping(file, NULL, |
| 1061 PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL); | 1068 PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL); |
| 1062 if (file_mapping == NULL) return NULL; | 1069 if (file_mapping == NULL) return NULL; |
| 1063 // Map a view of the file into memory | 1070 // Map a view of the file into memory |
| 1064 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size); | 1071 void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size); |
| 1065 if (memory) memmove(memory, initial, size); | 1072 if (memory) OS::MemMove(memory, initial, size); |
| 1066 return new Win32MemoryMappedFile(file, file_mapping, memory, size); | 1073 return new Win32MemoryMappedFile(file, file_mapping, memory, size); |
| 1067 } | 1074 } |
| 1068 | 1075 |
| 1069 | 1076 |
| 1070 Win32MemoryMappedFile::~Win32MemoryMappedFile() { | 1077 Win32MemoryMappedFile::~Win32MemoryMappedFile() { |
| 1071 if (memory_ != NULL) | 1078 if (memory_ != NULL) |
| 1072 UnmapViewOfFile(memory_); | 1079 UnmapViewOfFile(memory_); |
| 1073 CloseHandle(file_mapping_); | 1080 CloseHandle(file_mapping_); |
| 1074 CloseHandle(file_); | 1081 CloseHandle(file_); |
| 1075 } | 1082 } |
| (...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 | 2182 |
| 2176 | 2183 |
| 2177 void Sampler::Stop() { | 2184 void Sampler::Stop() { |
| 2178 ASSERT(IsActive()); | 2185 ASSERT(IsActive()); |
| 2179 SamplerThread::RemoveActiveSampler(this); | 2186 SamplerThread::RemoveActiveSampler(this); |
| 2180 SetActive(false); | 2187 SetActive(false); |
| 2181 } | 2188 } |
| 2182 | 2189 |
| 2183 | 2190 |
| 2184 } } // namespace v8::internal | 2191 } } // namespace v8::internal |
| OLD | NEW |