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 25 matching lines...) Expand all Loading... |
36 #ifdef MINGW_HAS_SECURE_API | 36 #ifdef MINGW_HAS_SECURE_API |
37 #undef MINGW_HAS_SECURE_API | 37 #undef MINGW_HAS_SECURE_API |
38 #endif // MINGW_HAS_SECURE_API | 38 #endif // MINGW_HAS_SECURE_API |
39 #endif // __MINGW32__ | 39 #endif // __MINGW32__ |
40 | 40 |
41 #include "win32-headers.h" | 41 #include "win32-headers.h" |
42 | 42 |
43 #include "v8.h" | 43 #include "v8.h" |
44 | 44 |
45 #include "codegen.h" | 45 #include "codegen.h" |
| 46 #include "isolate-inl.h" |
46 #include "platform.h" | 47 #include "platform.h" |
47 #include "simulator.h" | 48 #include "simulator.h" |
48 #include "vm-state-inl.h" | 49 #include "vm-state-inl.h" |
49 | 50 |
50 #ifdef _MSC_VER | 51 #ifdef _MSC_VER |
51 | 52 |
52 // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually | 53 // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually |
53 // defined in strings.h. | 54 // defined in strings.h. |
54 int strncasecmp(const char* s1, const char* s2, int n) { | 55 int strncasecmp(const char* s1, const char* s2, int n) { |
55 return _strnicmp(s1, s2, n); | 56 return _strnicmp(s1, s2, n); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 --count; | 118 --count; |
118 } | 119 } |
119 } | 120 } |
120 CHECK_GT(dest_size, 0); | 121 CHECK_GT(dest_size, 0); |
121 *dest = 0; | 122 *dest = 0; |
122 return 0; | 123 return 0; |
123 } | 124 } |
124 | 125 |
125 #endif // __MINGW32__ | 126 #endif // __MINGW32__ |
126 | 127 |
127 // Generate a pseudo-random number in the range 0-2^31-1. Usually | |
128 // defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW. | |
129 int random() { | |
130 return rand(); | |
131 } | |
132 | |
133 | |
134 namespace v8 { | 128 namespace v8 { |
135 namespace internal { | 129 namespace internal { |
136 | 130 |
137 intptr_t OS::MaxVirtualMemory() { | 131 intptr_t OS::MaxVirtualMemory() { |
138 return 0; | 132 return 0; |
139 } | 133 } |
140 | 134 |
141 | 135 |
142 double ceiling(double x) { | 136 double ceiling(double x) { |
143 return ceil(x); | 137 return ceil(x); |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // Use a multiple of 64k to prevent committing unused memory. | 781 // Use a multiple of 64k to prevent committing unused memory. |
788 // Note: This does not guarantee RWX regions will be within the | 782 // Note: This does not guarantee RWX regions will be within the |
789 // range kAllocationRandomAddressMin to kAllocationRandomAddressMax | 783 // range kAllocationRandomAddressMin to kAllocationRandomAddressMax |
790 #ifdef V8_HOST_ARCH_64_BIT | 784 #ifdef V8_HOST_ARCH_64_BIT |
791 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000; | 785 static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000; |
792 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000; | 786 static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000; |
793 #else | 787 #else |
794 static const intptr_t kAllocationRandomAddressMin = 0x04000000; | 788 static const intptr_t kAllocationRandomAddressMin = 0x04000000; |
795 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000; | 789 static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000; |
796 #endif | 790 #endif |
797 uintptr_t address = (V8::RandomPrivate(isolate) << kPageSizeBits) | 791 uintptr_t address = |
798 | kAllocationRandomAddressMin; | 792 (isolate->random_number_generator()->NextInt() << kPageSizeBits) | |
| 793 kAllocationRandomAddressMin; |
799 address &= kAllocationRandomAddressMax; | 794 address &= kAllocationRandomAddressMax; |
800 return reinterpret_cast<void *>(address); | 795 return reinterpret_cast<void *>(address); |
801 } | 796 } |
802 return NULL; | 797 return NULL; |
803 } | 798 } |
804 | 799 |
805 | 800 |
806 static void* RandomizedVirtualAlloc(size_t size, int action, int protection) { | 801 static void* RandomizedVirtualAlloc(size_t size, int action, int protection) { |
807 LPVOID base = NULL; | 802 LPVOID base = NULL; |
808 | 803 |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 USE(result); | 1568 USE(result); |
1574 ASSERT(result); | 1569 ASSERT(result); |
1575 } | 1570 } |
1576 | 1571 |
1577 | 1572 |
1578 | 1573 |
1579 void Thread::YieldCPU() { | 1574 void Thread::YieldCPU() { |
1580 Sleep(0); | 1575 Sleep(0); |
1581 } | 1576 } |
1582 | 1577 |
1583 | |
1584 void OS::SetUp() { | |
1585 // Seed the random number generator. | |
1586 // Convert the current time to a 64-bit integer first, before converting it | |
1587 // to an unsigned. Going directly can cause an overflow and the seed to be | |
1588 // set to all ones. The seed will be identical for different instances that | |
1589 // call this setup code within the same millisecond. | |
1590 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | |
1591 srand(static_cast<unsigned int>(seed)); | |
1592 } | |
1593 | |
1594 } } // namespace v8::internal | 1578 } } // namespace v8::internal |
OLD | NEW |