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

Side by Side Diff: src/spaces.h

Issue 7865025: Move aligned allocation to the platform files. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Working on win32 too Created 9 years, 3 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 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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 324 }
325 } 325 }
326 326
327 void set_owner(Space* space) { 327 void set_owner(Space* space) {
328 ASSERT((reinterpret_cast<intptr_t>(space) & kFailureTagMask) == 0); 328 ASSERT((reinterpret_cast<intptr_t>(space) & kFailureTagMask) == 0);
329 owner_ = reinterpret_cast<Address>(space) + kFailureTag; 329 owner_ = reinterpret_cast<Address>(space) + kFailureTag;
330 ASSERT((reinterpret_cast<intptr_t>(owner_) & kFailureTagMask) == 330 ASSERT((reinterpret_cast<intptr_t>(owner_) & kFailureTagMask) ==
331 kFailureTag); 331 kFailureTag);
332 } 332 }
333 333
334 VirtualMemory* reservation() {
335 return &reservation_;
336 }
337
338 void initialize_reservation() {
339 reservation_.Reset();
340 }
341
342 void set_reservation(VirtualMemory* reservation) {
343 ASSERT_NOT_NULL(reservation);
344 reservation_.TakeControl(reservation);
345 }
346
334 bool scan_on_scavenge() { return IsFlagSet(SCAN_ON_SCAVENGE); } 347 bool scan_on_scavenge() { return IsFlagSet(SCAN_ON_SCAVENGE); }
335 void initialize_scan_on_scavenge(bool scan) { 348 void initialize_scan_on_scavenge(bool scan) {
336 if (scan) { 349 if (scan) {
337 SetFlag(SCAN_ON_SCAVENGE); 350 SetFlag(SCAN_ON_SCAVENGE);
338 } else { 351 } else {
339 ClearFlag(SCAN_ON_SCAVENGE); 352 ClearFlag(SCAN_ON_SCAVENGE);
340 } 353 }
341 } 354 }
342 inline void set_scan_on_scavenge(bool scan); 355 inline void set_scan_on_scavenge(bool scan);
343 356
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 MemoryChunk::FromAddress(address)->IncrementLiveBytes(by); 460 MemoryChunk::FromAddress(address)->IncrementLiveBytes(by);
448 } 461 }
449 462
450 static const intptr_t kAlignment = 463 static const intptr_t kAlignment =
451 (static_cast<uintptr_t>(1) << kPageSizeBits); 464 (static_cast<uintptr_t>(1) << kPageSizeBits);
452 465
453 static const intptr_t kAlignmentMask = kAlignment - 1; 466 static const intptr_t kAlignmentMask = kAlignment - 1;
454 467
455 static const intptr_t kLiveBytesOffset = 468 static const intptr_t kLiveBytesOffset =
456 kPointerSize + kPointerSize + kPointerSize + kPointerSize + 469 kPointerSize + kPointerSize + kPointerSize + kPointerSize +
457 kPointerSize + kPointerSize + kIntSize; 470 kPointerSize + kPointerSize + kPointerSize + kPointerSize +
471 kIntSize;
458 472
459 static const size_t kSlotsBufferOffset = kLiveBytesOffset + kIntSize; 473 static const size_t kSlotsBufferOffset = kLiveBytesOffset + kIntSize;
460 474
461 static const size_t kHeaderSize = kSlotsBufferOffset + kPointerSize; 475 static const size_t kHeaderSize = kSlotsBufferOffset + kPointerSize;
462 476
463 static const int kBodyOffset = 477 static const int kBodyOffset =
464 CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + Bitmap::kSize)); 478 CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + Bitmap::kSize));
465 479
466 // The start offset of the object area in a page. Aligned to both maps and 480 // The start offset of the object area in a page. Aligned to both maps and
467 // code alignment to be suitable for both. Also aligned to 32 words because 481 // code alignment to be suitable for both. Also aligned to 32 words because
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 ASSERT(slots_buffer_ == NULL); 560 ASSERT(slots_buffer_ == NULL);
547 ClearFlag(EVACUATION_CANDIDATE); 561 ClearFlag(EVACUATION_CANDIDATE);
548 } 562 }
549 563
550 564
551 protected: 565 protected:
552 MemoryChunk* next_chunk_; 566 MemoryChunk* next_chunk_;
553 MemoryChunk* prev_chunk_; 567 MemoryChunk* prev_chunk_;
554 size_t size_; 568 size_t size_;
555 intptr_t flags_; 569 intptr_t flags_;
570 // If the chunk needs to remember its memory reservation, it is stored here.
571 VirtualMemory reservation_;
556 // The identity of the owning space. This is tagged as a failure pointer, but 572 // The identity of the owning space. This is tagged as a failure pointer, but
557 // no failure can be in an object, so this can be distinguished from any entry 573 // no failure can be in an object, so this can be distinguished from any entry
558 // in a fixed array. 574 // in a fixed array.
559 Address owner_; 575 Address owner_;
560 Heap* heap_; 576 Heap* heap_;
561 // Used by the store buffer to keep track of which pages to mark scan-on- 577 // Used by the store buffer to keep track of which pages to mark scan-on-
562 // scavenge. 578 // scavenge.
563 int store_buffer_counter_; 579 int store_buffer_counter_;
564 // Count of bytes marked black on page. 580 // Count of bytes marked black on page.
565 int live_byte_count_; 581 int live_byte_count_;
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 894
879 #ifdef DEBUG 895 #ifdef DEBUG
880 // Reports statistic info of the space. 896 // Reports statistic info of the space.
881 void ReportStatistics(); 897 void ReportStatistics();
882 #endif 898 #endif
883 899
884 MemoryChunk* AllocateChunk(intptr_t body_size, 900 MemoryChunk* AllocateChunk(intptr_t body_size,
885 Executability executable, 901 Executability executable,
886 Space* space); 902 Space* space);
887 903
888 Address AllocateAlignedMemory(const size_t requested, 904 Address ReserveAlignedMemory(size_t requested,
905 size_t alignment,
906 VirtualMemory* controller);
907 Address AllocateAlignedMemory(size_t requested,
889 size_t alignment, 908 size_t alignment,
890 Executability executable, 909 Executability executable,
891 size_t* allocated_size); 910 VirtualMemory* controller);
892 911
893 Address ReserveAlignedMemory(const size_t requested, 912 void FreeMemory(VirtualMemory* reservation, Executability executable);
894 size_t alignment,
895 size_t* allocated_size);
896
897 void FreeMemory(Address addr, size_t size, Executability executable); 913 void FreeMemory(Address addr, size_t size, Executability executable);
898 914
899 // Commit a contiguous block of memory from the initial chunk. Assumes that 915 // Commit a contiguous block of memory from the initial chunk. Assumes that
900 // the address is not NULL, the size is greater than zero, and that the 916 // the address is not NULL, the size is greater than zero, and that the
901 // block is contained in the initial chunk. Returns true if it succeeded 917 // block is contained in the initial chunk. Returns true if it succeeded
902 // and false otherwise. 918 // and false otherwise.
903 bool CommitBlock(Address start, size_t size, Executability executable); 919 bool CommitBlock(Address start, size_t size, Executability executable);
904 920
905 // Uncommit a contiguous block of memory [start..(start+size)[. 921 // Uncommit a contiguous block of memory [start..(start+size)[.
906 // start is not NULL, the size is greater than zero, and the 922 // start is not NULL, the size is greater than zero, and the
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 // The new space consists of a contiguous pair of semispaces. It simply 1941 // The new space consists of a contiguous pair of semispaces. It simply
1926 // forwards most functions to the appropriate semispace. 1942 // forwards most functions to the appropriate semispace.
1927 1943
1928 class NewSpace : public Space { 1944 class NewSpace : public Space {
1929 public: 1945 public:
1930 // Constructor. 1946 // Constructor.
1931 explicit NewSpace(Heap* heap) 1947 explicit NewSpace(Heap* heap)
1932 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), 1948 : Space(heap, NEW_SPACE, NOT_EXECUTABLE),
1933 to_space_(heap, kToSpace), 1949 to_space_(heap, kToSpace),
1934 from_space_(heap, kFromSpace), 1950 from_space_(heap, kFromSpace),
1951 reservation_(),
1935 inline_allocation_limit_step_(0) {} 1952 inline_allocation_limit_step_(0) {}
1936 1953
1937 // Sets up the new space using the given chunk. 1954 // Sets up the new space using the given chunk.
1938 bool Setup(int reserved_semispace_size_, int max_semispace_size); 1955 bool Setup(int reserved_semispace_size_, int max_semispace_size);
1939 1956
1940 // Tears down the space. Heap memory was not allocated by the space, so it 1957 // Tears down the space. Heap memory was not allocated by the space, so it
1941 // is not deallocated here. 1958 // is not deallocated here.
1942 void TearDown(); 1959 void TearDown();
1943 1960
1944 // True if the space has been set up but not torn down. 1961 // True if the space has been set up but not torn down.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 private: 2162 private:
2146 // Update allocation info to match the current to-space page. 2163 // Update allocation info to match the current to-space page.
2147 void UpdateAllocationInfo(); 2164 void UpdateAllocationInfo();
2148 2165
2149 Address chunk_base_; 2166 Address chunk_base_;
2150 uintptr_t chunk_size_; 2167 uintptr_t chunk_size_;
2151 2168
2152 // The semispaces. 2169 // The semispaces.
2153 SemiSpace to_space_; 2170 SemiSpace to_space_;
2154 SemiSpace from_space_; 2171 SemiSpace from_space_;
2172 VirtualMemory reservation_;
2155 int pages_used_; 2173 int pages_used_;
2156 2174
2157 // Start address and bit mask for containment testing. 2175 // Start address and bit mask for containment testing.
2158 Address start_; 2176 Address start_;
2159 uintptr_t address_mask_; 2177 uintptr_t address_mask_;
2160 uintptr_t object_mask_; 2178 uintptr_t object_mask_;
2161 uintptr_t object_expected_; 2179 uintptr_t object_expected_;
2162 2180
2163 // Allocation pointer and limit for normal allocation and allocation during 2181 // Allocation pointer and limit for normal allocation and allocation during
2164 // mark-compact collection. 2182 // mark-compact collection.
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 } 2533 }
2516 // Must be small, since an iteration is used for lookup. 2534 // Must be small, since an iteration is used for lookup.
2517 static const int kMaxComments = 64; 2535 static const int kMaxComments = 64;
2518 }; 2536 };
2519 #endif 2537 #endif
2520 2538
2521 2539
2522 } } // namespace v8::internal 2540 } } // namespace v8::internal
2523 2541
2524 #endif // V8_SPACES_H_ 2542 #endif // V8_SPACES_H_
OLDNEW
« src/platform-win32.cc ('K') | « src/platform-win32.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698