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

Side by Side Diff: src/spaces.h

Issue 7029030: Use page header information to test for InNewSpace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 7 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return addr >= body() && addr < address() + size(); 368 return addr >= body() && addr < address() + size();
369 } 369 }
370 370
371 enum MemoryChunkFlags { 371 enum MemoryChunkFlags {
372 IS_EXECUTABLE, 372 IS_EXECUTABLE,
373 WAS_SWEPT_CONSERVATIVELY, 373 WAS_SWEPT_CONSERVATIVELY,
374 CONTAINS_ONLY_DATA, 374 CONTAINS_ONLY_DATA,
375 POINTERS_TO_HERE_ARE_INTERESTING, 375 POINTERS_TO_HERE_ARE_INTERESTING,
376 POINTERS_FROM_HERE_ARE_INTERESTING, 376 POINTERS_FROM_HERE_ARE_INTERESTING,
377 SCAN_ON_SCAVENGE, 377 SCAN_ON_SCAVENGE,
378 IN_NEW_SPACE,
378 NUM_MEMORY_CHUNK_FLAGS 379 NUM_MEMORY_CHUNK_FLAGS
379 }; 380 };
380 381
381 void SetFlag(int flag) { 382 void SetFlag(int flag) {
382 flags_ |= 1 << flag; 383 flags_ |= 1 << flag;
383 } 384 }
384 385
385 void ClearFlag(int flag) { 386 void ClearFlag(int flag) {
386 flags_ &= ~(1 << flag); 387 flags_ &= ~(1 << flag);
387 } 388 }
(...skipping 26 matching lines...) Expand all
414 size_t size() const { return size_; } 415 size_t size() const { return size_; }
415 416
416 Executability executable() { 417 Executability executable() {
417 return IsFlagSet(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE; 418 return IsFlagSet(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE;
418 } 419 }
419 420
420 bool ContainsOnlyData() { 421 bool ContainsOnlyData() {
421 return IsFlagSet(CONTAINS_ONLY_DATA); 422 return IsFlagSet(CONTAINS_ONLY_DATA);
422 } 423 }
423 424
425 bool InNewSpace() {
426 return IsFlagSet(IN_NEW_SPACE);
427 }
428
424 // --------------------------------------------------------------------- 429 // ---------------------------------------------------------------------
425 // Markbits support 430 // Markbits support
426 431
427 inline Bitmap* markbits() { 432 inline Bitmap* markbits() {
428 return Bitmap::FromAddress(address() + kHeaderSize); 433 return Bitmap::FromAddress(address() + kHeaderSize);
429 } 434 }
430 435
431 void PrintMarkbits() { markbits()->Print(); } 436 void PrintMarkbits() { markbits()->Print(); }
432 437
433 inline uint32_t AddressToMarkbitIndex(Address addr) { 438 inline uint32_t AddressToMarkbitIndex(Address addr) {
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 1687
1683 // Grow the capacity of the semispaces. Assumes that they are not at 1688 // Grow the capacity of the semispaces. Assumes that they are not at
1684 // their maximum capacity. 1689 // their maximum capacity.
1685 void Grow(); 1690 void Grow();
1686 1691
1687 // Shrink the capacity of the semispaces. 1692 // Shrink the capacity of the semispaces.
1688 void Shrink(); 1693 void Shrink();
1689 1694
1690 // True if the address or object lies in the address range of either 1695 // True if the address or object lies in the address range of either
1691 // semispace (not necessarily below the allocation pointer). 1696 // semispace (not necessarily below the allocation pointer).
1697 // Must be a pointer into a heap page, and if it's a large object
1698 // page, it must be a pointer into the beginning of it.
Erik Corry 2011/05/19 07:22:32 Comment should be moved down to the function to wh
Lasse Reichstein 2011/05/19 08:40:40 Moved.
1692 bool Contains(Address a) { 1699 bool Contains(Address a) {
1693 return (reinterpret_cast<uintptr_t>(a) & address_mask_) 1700 return (reinterpret_cast<uintptr_t>(a) & address_mask_)
1694 == reinterpret_cast<uintptr_t>(start_); 1701 == reinterpret_cast<uintptr_t>(start_);
1695 } 1702 }
1703
1704 bool PageContains(Address a) {
1705 if ((reinterpret_cast<intptr_t>(a) & ~kHeapObjectTagMask) ==
1706 static_cast<intptr_t>(0)) {
1707 // Tagged zero-page pointers are not real heap pointers.
1708 return false;
Erik Corry 2011/05/19 07:22:32 Can we add a TODO to remove this?
Lasse Reichstein 2011/05/19 08:40:40 Done.
1709 }
1710 return MemoryChunk::FromAddress(a)->InNewSpace();
1711 }
1712
1696 bool Contains(Object* o) { 1713 bool Contains(Object* o) {
1697 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; 1714 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
1698 } 1715 }
1699 1716
1717 bool PageContains(Object* o) {
1718 if (o->IsSmi()) return false;
1719 if ((reinterpret_cast<uintptr_t>(o) & ~kHeapObjectTagMask) ==
Erik Corry 2011/05/19 07:22:32 And this
Lasse Reichstein 2011/05/19 08:40:40 And done.
1720 static_cast<uintptr_t>(0)) {
1721 return false;
1722 }
1723 Address a = HeapObject::cast(o)->address();
1724 return MemoryChunk::FromAddress(a)->InNewSpace();
1725 }
1726
1700 // Return the allocated bytes in the active semispace. 1727 // Return the allocated bytes in the active semispace.
1701 virtual intptr_t Size() { return static_cast<int>(top() - bottom()); } 1728 virtual intptr_t Size() { return static_cast<int>(top() - bottom()); }
1702 // The same, but returning an int. We have to have the one that returns 1729 // The same, but returning an int. We have to have the one that returns
1703 // intptr_t because it is inherited, but if we know we are dealing with the 1730 // intptr_t because it is inherited, but if we know we are dealing with the
1704 // new space, which can't get as big as the other spaces then this is useful: 1731 // new space, which can't get as big as the other spaces then this is useful:
1705 int SizeAsInt() { return static_cast<int>(Size()); } 1732 int SizeAsInt() { return static_cast<int>(Size()); }
1706 1733
1707 // Return the current capacity of a semispace. 1734 // Return the current capacity of a semispace.
1708 intptr_t Capacity() { 1735 intptr_t Capacity() {
1709 ASSERT(to_space_.Capacity() == from_space_.Capacity()); 1736 ASSERT(to_space_.Capacity() == from_space_.Capacity());
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 } 2280 }
2254 // Must be small, since an iteration is used for lookup. 2281 // Must be small, since an iteration is used for lookup.
2255 static const int kMaxComments = 64; 2282 static const int kMaxComments = 64;
2256 }; 2283 };
2257 #endif 2284 #endif
2258 2285
2259 2286
2260 } } // namespace v8::internal 2287 } } // namespace v8::internal
2261 2288
2262 #endif // V8_SPACES_H_ 2289 #endif // V8_SPACES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698