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

Side by Side Diff: src/platform.h

Issue 8139027: Version 3.6.5 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 9 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/parser.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } 294 }
295 static const int kMinComplexMemCopy = 256; 295 static const int kMinComplexMemCopy = 256;
296 #endif // V8_TARGET_ARCH_IA32 296 #endif // V8_TARGET_ARCH_IA32
297 297
298 private: 298 private:
299 static const int msPerSecond = 1000; 299 static const int msPerSecond = 1000;
300 300
301 DISALLOW_IMPLICIT_CONSTRUCTORS(OS); 301 DISALLOW_IMPLICIT_CONSTRUCTORS(OS);
302 }; 302 };
303 303
304 304 // Represents and controls an area of reserved memory.
305 // Control of the reserved memory can be assigned to another VirtualMemory
306 // object by assignment or copy-contructing. This removes the reserved memory
307 // from the original object.
305 class VirtualMemory { 308 class VirtualMemory {
306 public: 309 public:
310 // Empty VirtualMemory object, controlling no reserved memory.
311 VirtualMemory();
312
307 // Reserves virtual memory with size. 313 // Reserves virtual memory with size.
308 explicit VirtualMemory(size_t size); 314 explicit VirtualMemory(size_t size);
315
316 // Reserves virtual memory containing an area of the given size that
317 // is aligned per alignment. This may not be at the position returned
318 // by address().
319 VirtualMemory(size_t size, size_t alignment);
320
321 // Releases the reserved memory, if any, controlled by this VirtualMemory
322 // object.
309 ~VirtualMemory(); 323 ~VirtualMemory();
310 324
311 // Returns whether the memory has been reserved. 325 // Returns whether the memory has been reserved.
312 bool IsReserved(); 326 bool IsReserved();
313 327
328 // Initialize or resets an embedded VirtualMemory object.
329 void Reset();
330
314 // Returns the start address of the reserved memory. 331 // Returns the start address of the reserved memory.
332 // If the memory was reserved with an alignment, this address is not
333 // necessarily aligned. The user might need to round it up to a multiple of
334 // the alignment to get the start of the aligned block.
315 void* address() { 335 void* address() {
316 ASSERT(IsReserved()); 336 ASSERT(IsReserved());
317 return address_; 337 return address_;
318 } 338 }
319 339
320 // Returns the size of the reserved memory. 340 // Returns the size of the reserved memory. The returned value is only
341 // meaningful when IsReserved() returns true.
342 // If the memory was reserved with an alignment, this size may be larger
343 // than the requested size.
321 size_t size() { return size_; } 344 size_t size() { return size_; }
322 345
323 // Commits real memory. Returns whether the operation succeeded. 346 // Commits real memory. Returns whether the operation succeeded.
324 bool Commit(void* address, size_t size, bool is_executable); 347 bool Commit(void* address, size_t size, bool is_executable);
325 348
326 // Uncommit real memory. Returns whether the operation succeeded. 349 // Uncommit real memory. Returns whether the operation succeeded.
327 bool Uncommit(void* address, size_t size); 350 bool Uncommit(void* address, size_t size);
328 351
352 void Release() {
353 ASSERT(IsReserved());
354 // Notice: Order is important here. The VirtualMemory object might live
355 // inside the allocated region.
356 void* address = address_;
357 size_t size = size_;
358 Reset();
359 bool result = ReleaseRegion(address, size);
360 USE(result);
361 ASSERT(result);
362 }
363
364 // Assign control of the reserved region to a different VirtualMemory object.
365 // The old object is no longer functional (IsReserved() returns false).
366 void TakeControl(VirtualMemory* from) {
367 ASSERT(!IsReserved());
368 address_ = from->address_;
369 size_ = from->size_;
370 from->Reset();
371 }
372
373 static void* ReserveRegion(size_t size);
374
375 static bool CommitRegion(void* base, size_t size, bool is_executable);
376
377 static bool UncommitRegion(void* base, size_t size);
378
379 // Must be called with a base pointer that has been returned by ReserveRegion
380 // and the same size it was reserved with.
381 static bool ReleaseRegion(void* base, size_t size);
382
329 private: 383 private:
330 void* address_; // Start address of the virtual memory. 384 void* address_; // Start address of the virtual memory.
331 size_t size_; // Size of the virtual memory. 385 size_t size_; // Size of the virtual memory.
332 }; 386 };
333 387
388
334 // ---------------------------------------------------------------------------- 389 // ----------------------------------------------------------------------------
335 // Thread 390 // Thread
336 // 391 //
337 // Thread objects are used for creating and running threads. When the start() 392 // Thread objects are used for creating and running threads. When the start()
338 // method is called the new thread starts running the run() method in the new 393 // method is called the new thread starts running the run() method in the new
339 // thread. The Thread object should not be deallocated before the thread has 394 // thread. The Thread object should not be deallocated before the thread has
340 // terminated. 395 // terminated.
341 396
342 class Thread { 397 class Thread {
343 public: 398 public:
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 Atomic32 active_; 681 Atomic32 active_;
627 PlatformData* data_; // Platform specific data. 682 PlatformData* data_; // Platform specific data.
628 int samples_taken_; // Counts stack samples taken. 683 int samples_taken_; // Counts stack samples taken.
629 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); 684 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler);
630 }; 685 };
631 686
632 687
633 } } // namespace v8::internal 688 } } // namespace v8::internal
634 689
635 #endif // V8_PLATFORM_H_ 690 #endif // V8_PLATFORM_H_
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698