Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: src/platform-posix.cc

Issue 24269003: Add methods to enable configuration of ResourceConstraints based on limits derived at runtime. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: /s/uintptr_t/uint64_t Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 uint64_t OS::TotalPhysicalMemory() {
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<uint64_t>(size);
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<uint64_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<uint64_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<uint64_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
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
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698