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

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

Issue 24989003: Re-land "Add methods to enable configuration of ResourceConstraints based on limits derived at..." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Reland original CL. 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
103 int OS::ActivationFrameAlignment() { 145 int OS::ActivationFrameAlignment() {
104 #if V8_TARGET_ARCH_ARM 146 #if V8_TARGET_ARCH_ARM
105 // On EABI ARM targets this is required for fp correctness in the 147 // On EABI ARM targets this is required for fp correctness in the
106 // runtime system. 148 // runtime system.
107 return 8; 149 return 8;
108 #elif V8_TARGET_ARCH_MIPS 150 #elif V8_TARGET_ARCH_MIPS
109 return 8; 151 return 8;
110 #else 152 #else
111 // Otherwise we just assume 16 byte alignment, i.e.: 153 // Otherwise we just assume 16 byte alignment, i.e.:
112 // - With gcc 4.4 the tree vectorization optimizer can generate code 154 // - With gcc 4.4 the tree vectorization optimizer can generate code
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 771
730 void Thread::SetThreadLocal(LocalStorageKey key, void* value) { 772 void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
731 pthread_key_t pthread_key = LocalKeyToPthreadKey(key); 773 pthread_key_t pthread_key = LocalKeyToPthreadKey(key);
732 int result = pthread_setspecific(pthread_key, value); 774 int result = pthread_setspecific(pthread_key, value);
733 ASSERT_EQ(0, result); 775 ASSERT_EQ(0, result);
734 USE(result); 776 USE(result);
735 } 777 }
736 778
737 779
738 } } // namespace v8::internal 780 } } // 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