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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 // limit. | 95 // limit. |
96 | 96 |
97 intptr_t OS::MaxVirtualMemory() { | 97 intptr_t OS::MaxVirtualMemory() { |
98 struct rlimit limit; | 98 struct rlimit limit; |
99 int result = getrlimit(RLIMIT_DATA, &limit); | 99 int result = getrlimit(RLIMIT_DATA, &limit); |
100 if (result != 0) return 0; | 100 if (result != 0) return 0; |
101 return limit.rlim_cur; | 101 return limit.rlim_cur; |
102 } | 102 } |
103 | 103 |
104 | 104 |
105 uintptr_t OS::TotalPhysicalMemory() { | |
Benedikt Meurer
2013/09/24 13:47:15
Shouldn't this return an uint64_t? Otherwise this
rmcilroy
2013/09/24 14:39:23
You're right. For some reason I thought a uintptr
| |
106 #if V8_OS_MACOSX | |
107 int mib[2]; | |
108 mib[0] = CTL_HW; | |
109 mib[1] = HW_MEMSIZE; | |
110 int64_t size = 0; | |
111 size_t len = sizeof(size); | |
112 if (sysctl(mib, 2, &size, &len, NULL, 0) != 0) { | |
113 UNREACHABLE(); | |
114 return 0; | |
115 } | |
116 return static_cast<uintptr_t> size; | |
Benedikt Meurer
2013/09/24 13:47:15
This static_cast is missing parenthesis.
rmcilroy
2013/09/24 14:39:23
Done.
| |
117 #elif V8_OS_FREEBSD | |
118 int pages, page_size; | |
119 size_t size = sizeof(pages); | |
120 sysctlbyname("vm.stats.vm.v_page_count", &pages, &size, NULL, 0); | |
121 sysctlbyname("vm.stats.vm.v_page_size", &page_size, &size, NULL, 0); | |
122 if (pages == -1 || page_size == -1) { | |
123 UNREACHABLE(); | |
124 return 0; | |
125 } | |
126 return static_cast<uintptr_t>(pages) * page_size; | |
127 #elif V8_OS_CYGWIN | |
128 MEMORYSTATUS memory_info; | |
129 memory_info.dwLength = sizeof(memory_info); | |
130 if (!GlobalMemoryStatus(&memory_info)) { | |
131 UNREACHABLE(); | |
132 return 0; | |
133 } | |
134 return static_cast<uintptr_t>(memory_info.dwTotalPhys); | |
135 #else | |
136 intptr_t pages = sysconf(_SC_PHYS_PAGES); | |
137 intptr_t page_size = sysconf(_SC_PAGESIZE); | |
138 if (pages == -1 || page_size == -1) { | |
139 UNREACHABLE(); | |
140 return 0; | |
141 } | |
142 return static_cast<uintptr_t>(pages) * page_size; | |
143 #endif | |
144 } | |
145 | |
146 | |
105 int OS::ActivationFrameAlignment() { | 147 int OS::ActivationFrameAlignment() { |
106 #if V8_TARGET_ARCH_ARM | 148 #if V8_TARGET_ARCH_ARM |
107 // On EABI ARM targets this is required for fp correctness in the | 149 // On EABI ARM targets this is required for fp correctness in the |
108 // runtime system. | 150 // runtime system. |
109 return 8; | 151 return 8; |
110 #elif V8_TARGET_ARCH_MIPS | 152 #elif V8_TARGET_ARCH_MIPS |
111 return 8; | 153 return 8; |
112 #else | 154 #else |
113 // Otherwise we just assume 16 byte alignment, i.e.: | 155 // Otherwise we just assume 16 byte alignment, i.e.: |
114 // - With gcc 4.4 the tree vectorization optimizer can generate code | 156 // - With gcc 4.4 the tree vectorization optimizer can generate code |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
731 | 773 |
732 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { | 774 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { |
733 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); | 775 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); |
734 int result = pthread_setspecific(pthread_key, value); | 776 int result = pthread_setspecific(pthread_key, value); |
735 ASSERT_EQ(0, result); | 777 ASSERT_EQ(0, result); |
736 USE(result); | 778 USE(result); |
737 } | 779 } |
738 | 780 |
739 | 781 |
740 } } // namespace v8::internal | 782 } } // namespace v8::internal |
OLD | NEW |