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