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

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

Issue 20014005: Fix duplicated methods for POSIX platforms. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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-cygwin.cc ('k') | src/platform-linux.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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return -0.0; 73 return -0.0;
74 } else { 74 } else {
75 return ceil(x); 75 return ceil(x);
76 } 76 }
77 } 77 }
78 78
79 79
80 static Mutex* limit_mutex = NULL; 80 static Mutex* limit_mutex = NULL;
81 81
82 82
83 void OS::PostSetUp() {
84 POSIXPostSetUp();
85 }
86
87
88 uint64_t OS::CpuFeaturesImpliedByPlatform() { 83 uint64_t OS::CpuFeaturesImpliedByPlatform() {
89 return 0; // FreeBSD runs on anything. 84 return 0; // FreeBSD runs on anything.
90 } 85 }
91 86
92 87
93 int OS::ActivationFrameAlignment() { 88 int OS::ActivationFrameAlignment() {
94 // 16 byte alignment on FreeBSD 89 // 16 byte alignment on FreeBSD
95 return 16; 90 return 16;
96 } 91 }
97 92
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 Max(highest_ever_allocated, 127 Max(highest_ever_allocated,
133 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); 128 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size));
134 } 129 }
135 130
136 131
137 bool OS::IsOutsideAllocatedSpace(void* address) { 132 bool OS::IsOutsideAllocatedSpace(void* address) {
138 return address < lowest_ever_allocated || address >= highest_ever_allocated; 133 return address < lowest_ever_allocated || address >= highest_ever_allocated;
139 } 134 }
140 135
141 136
142 size_t OS::AllocateAlignment() {
143 return getpagesize();
144 }
145
146
147 void* OS::Allocate(const size_t requested, 137 void* OS::Allocate(const size_t requested,
148 size_t* allocated, 138 size_t* allocated,
149 bool executable) { 139 bool executable) {
150 const size_t msize = RoundUp(requested, getpagesize()); 140 const size_t msize = RoundUp(requested, getpagesize());
151 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); 141 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0);
152 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); 142 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0);
153 143
154 if (mbase == MAP_FAILED) { 144 if (mbase == MAP_FAILED) {
155 LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed")); 145 LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed"));
156 return NULL; 146 return NULL;
157 } 147 }
158 *allocated = msize; 148 *allocated = msize;
159 UpdateAllocatedSpaceLimits(mbase, msize); 149 UpdateAllocatedSpaceLimits(mbase, msize);
160 return mbase; 150 return mbase;
161 } 151 }
162 152
163 153
164 void OS::Free(void* buf, const size_t length) {
165 // TODO(1240712): munmap has a return value which is ignored here.
166 int result = munmap(buf, length);
167 USE(result);
168 ASSERT(result == 0);
169 }
170
171
172 void OS::Sleep(int milliseconds) {
173 unsigned int ms = static_cast<unsigned int>(milliseconds);
174 usleep(1000 * ms);
175 }
176
177
178 int OS::NumberOfCores() {
179 return sysconf(_SC_NPROCESSORS_ONLN);
180 }
181
182
183 void OS::Abort() {
184 // Redirect to std abort to signal abnormal program termination.
185 abort();
186 }
187
188
189 void OS::DebugBreak() {
190 #if (defined(__arm__) || defined(__thumb__))
191 asm("bkpt 0");
192 #else
193 asm("int $3");
194 #endif
195 }
196
197
198 void OS::DumpBacktrace() { 154 void OS::DumpBacktrace() {
199 POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace(); 155 POSIXBacktraceHelper<backtrace, backtrace_symbols>::DumpBacktrace();
200 } 156 }
201 157
202 158
203 class PosixMemoryMappedFile : public OS::MemoryMappedFile { 159 class PosixMemoryMappedFile : public OS::MemoryMappedFile {
204 public: 160 public:
205 PosixMemoryMappedFile(FILE* file, void* memory, int size) 161 PosixMemoryMappedFile(FILE* file, void* memory, int size)
206 : file_(file), memory_(memory), size_(size) { } 162 : file_(file), memory_(memory), size_(size) { }
207 virtual ~PosixMemoryMappedFile(); 163 virtual ~PosixMemoryMappedFile();
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 limit_mutex = CreateMutex(); 548 limit_mutex = CreateMutex();
593 } 549 }
594 550
595 551
596 void OS::TearDown() { 552 void OS::TearDown() {
597 delete limit_mutex; 553 delete limit_mutex;
598 } 554 }
599 555
600 556
601 } } // namespace v8::internal 557 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-cygwin.cc ('k') | src/platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698