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

Side by Side Diff: src/platform.h

Issue 53004: Add basic infrastructure for protecting V8's heap when leaving the VM... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 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
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // output. On platforms that has standard terminal output, the output 161 // output. On platforms that has standard terminal output, the output
162 // should go to stderr. 162 // should go to stderr.
163 static void PrintError(const char* format, ...); 163 static void PrintError(const char* format, ...);
164 static void VPrintError(const char* format, va_list args); 164 static void VPrintError(const char* format, va_list args);
165 165
166 // Allocate/Free memory used by JS heap. Pages are readable/writable, but 166 // Allocate/Free memory used by JS heap. Pages are readable/writable, but
167 // they are not guaranteed to be executable unless 'executable' is true. 167 // they are not guaranteed to be executable unless 'executable' is true.
168 // Returns the address of allocated memory, or NULL if failed. 168 // Returns the address of allocated memory, or NULL if failed.
169 static void* Allocate(const size_t requested, 169 static void* Allocate(const size_t requested,
170 size_t* allocated, 170 size_t* allocated,
171 bool executable); 171 bool is_executable);
172 static void Free(void* buf, const size_t length); 172 static void Free(void* address, const size_t size);
173 // Get the Alignment guaranteed by Allocate(). 173 // Get the Alignment guaranteed by Allocate().
174 static size_t AllocateAlignment(); 174 static size_t AllocateAlignment();
175 175
176 #ifdef ENABLE_HEAP_PROTECTION
177 // Protect/unprotect a block of memory by marking it read-only/writable.
178 static void Protect(void* address, size_t size);
179 static void Unprotect(void* address, size_t size, bool is_executable);
180 #endif
181
176 // Returns an indication of whether a pointer is in a space that 182 // Returns an indication of whether a pointer is in a space that
177 // has been allocated by Allocate(). This method may conservatively 183 // has been allocated by Allocate(). This method may conservatively
178 // always return false, but giving more accurate information may 184 // always return false, but giving more accurate information may
179 // improve the robustness of the stack dump code in the presence of 185 // improve the robustness of the stack dump code in the presence of
180 // heap corruption. 186 // heap corruption.
181 static bool IsOutsideAllocatedSpace(void* pointer); 187 static bool IsOutsideAllocatedSpace(void* pointer);
182 188
183 // Sleep for a number of milliseconds. 189 // Sleep for a number of milliseconds.
184 static void Sleep(const int milliseconds); 190 static void Sleep(const int milliseconds);
185 191
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 // Returns the start address of the reserved memory. 266 // Returns the start address of the reserved memory.
261 void* address() { 267 void* address() {
262 ASSERT(IsReserved()); 268 ASSERT(IsReserved());
263 return address_; 269 return address_;
264 }; 270 };
265 271
266 // Returns the size of the reserved memory. 272 // Returns the size of the reserved memory.
267 size_t size() { return size_; } 273 size_t size() { return size_; }
268 274
269 // Commits real memory. Returns whether the operation succeeded. 275 // Commits real memory. Returns whether the operation succeeded.
270 bool Commit(void* address, size_t size, bool executable); 276 bool Commit(void* address, size_t size, bool is_executable);
271 277
272 // Uncommit real memory. Returns whether the operation succeeded. 278 // Uncommit real memory. Returns whether the operation succeeded.
273 bool Uncommit(void* address, size_t size); 279 bool Uncommit(void* address, size_t size);
274 280
275 private: 281 private:
276 void* address_; // Start address of the virtual memory. 282 void* address_; // Start address of the virtual memory.
277 size_t size_; // Size of the virtual memory. 283 size_t size_; // Size of the virtual memory.
278 }; 284 };
279 285
280 286
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 bool active_; 516 bool active_;
511 PlatformData* data_; // Platform specific data. 517 PlatformData* data_; // Platform specific data.
512 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 518 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
513 }; 519 };
514 520
515 #endif // ENABLE_LOGGING_AND_PROFILING 521 #endif // ENABLE_LOGGING_AND_PROFILING
516 522
517 } } // namespace v8::internal 523 } } // namespace v8::internal
518 524
519 #endif // V8_PLATFORM_H_ 525 #endif // V8_PLATFORM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698