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

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: Missing renames added to patch. 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
« no previous file with comments | « src/platform-win32.cc ('k') | src/spaces.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 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() {
Vyacheslav Egorov (Chromium) 2011/09/14 12:46:51 reservation is a bit confusing name. UnderlyingMa
335 return &reservation_;
336 }
337
338 void initialize_reservation() {
339 reservation_.Reset();
Vyacheslav Egorov (Chromium) 2011/09/14 12:46:51 InitializeReservation
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 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 // The new space consists of a contiguous pair of semispaces. It simply 1943 // The new space consists of a contiguous pair of semispaces. It simply
1928 // forwards most functions to the appropriate semispace. 1944 // forwards most functions to the appropriate semispace.
1929 1945
1930 class NewSpace : public Space { 1946 class NewSpace : public Space {
1931 public: 1947 public:
1932 // Constructor. 1948 // Constructor.
1933 explicit NewSpace(Heap* heap) 1949 explicit NewSpace(Heap* heap)
1934 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), 1950 : Space(heap, NEW_SPACE, NOT_EXECUTABLE),
1935 to_space_(heap, kToSpace), 1951 to_space_(heap, kToSpace),
1936 from_space_(heap, kFromSpace), 1952 from_space_(heap, kFromSpace),
1953 reservation_(),
1937 inline_allocation_limit_step_(0) {} 1954 inline_allocation_limit_step_(0) {}
1938 1955
1939 // Sets up the new space using the given chunk. 1956 // Sets up the new space using the given chunk.
1940 bool Setup(int reserved_semispace_size_, int max_semispace_size); 1957 bool Setup(int reserved_semispace_size_, int max_semispace_size);
1941 1958
1942 // Tears down the space. Heap memory was not allocated by the space, so it 1959 // Tears down the space. Heap memory was not allocated by the space, so it
1943 // is not deallocated here. 1960 // is not deallocated here.
1944 void TearDown(); 1961 void TearDown();
1945 1962
1946 // True if the space has been set up but not torn down. 1963 // True if the space has been set up but not torn down.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 private: 2164 private:
2148 // Update allocation info to match the current to-space page. 2165 // Update allocation info to match the current to-space page.
2149 void UpdateAllocationInfo(); 2166 void UpdateAllocationInfo();
2150 2167
2151 Address chunk_base_; 2168 Address chunk_base_;
2152 uintptr_t chunk_size_; 2169 uintptr_t chunk_size_;
2153 2170
2154 // The semispaces. 2171 // The semispaces.
2155 SemiSpace to_space_; 2172 SemiSpace to_space_;
2156 SemiSpace from_space_; 2173 SemiSpace from_space_;
2174 VirtualMemory reservation_;
2157 int pages_used_; 2175 int pages_used_;
2158 2176
2159 // Start address and bit mask for containment testing. 2177 // Start address and bit mask for containment testing.
2160 Address start_; 2178 Address start_;
2161 uintptr_t address_mask_; 2179 uintptr_t address_mask_;
2162 uintptr_t object_mask_; 2180 uintptr_t object_mask_;
2163 uintptr_t object_expected_; 2181 uintptr_t object_expected_;
2164 2182
2165 // Allocation pointer and limit for normal allocation and allocation during 2183 // Allocation pointer and limit for normal allocation and allocation during
2166 // mark-compact collection. 2184 // mark-compact collection.
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2517 } 2535 }
2518 // Must be small, since an iteration is used for lookup. 2536 // Must be small, since an iteration is used for lookup.
2519 static const int kMaxComments = 64; 2537 static const int kMaxComments = 64;
2520 }; 2538 };
2521 #endif 2539 #endif
2522 2540
2523 2541
2524 } } // namespace v8::internal 2542 } } // namespace v8::internal
2525 2543
2526 #endif // V8_SPACES_H_ 2544 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/platform-win32.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698