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

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: Addressed review comments. 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
« no previous file with comments | « src/runtime.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 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 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
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).
1692 bool Contains(Address a) { 1697 bool Contains(Address a) {
1693 return (reinterpret_cast<uintptr_t>(a) & address_mask_) 1698 return (reinterpret_cast<uintptr_t>(a) & address_mask_)
1694 == reinterpret_cast<uintptr_t>(start_); 1699 == reinterpret_cast<uintptr_t>(start_);
1695 } 1700 }
1701
1702 // True if the address or object lies on a NewSpacePage.
1703 // Must be a pointer into a heap page, and if it's a large object
1704 // page, it must be a pointer into the beginning of it.
1705 // TODO(gc): When every call to Contains is converted to PageContains,
1706 // remove Contains and rename PageContains to Contains.
1707 bool PageContains(Address a) {
1708 if ((reinterpret_cast<intptr_t>(a) & ~kHeapObjectTagMask) ==
1709 static_cast<intptr_t>(0)) {
1710 // Tagged zero-page pointers are not real heap pointers.
1711 // TODO(gc): Remove when we no longer have tagged zero-page
1712 // pointers intermingled with real heap object pointers.
1713 return false;
1714 }
1715 return MemoryChunk::FromAddress(a)->InNewSpace();
1716 }
1717
1696 bool Contains(Object* o) { 1718 bool Contains(Object* o) {
1697 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; 1719 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
1698 } 1720 }
1699 1721
1722 bool PageContains(Object* o) {
1723 if (o->IsSmi()) return false;
1724 if ((reinterpret_cast<uintptr_t>(o) & ~kHeapObjectTagMask) ==
1725 static_cast<uintptr_t>(0)) {
1726 // Tagged zero-page pointers are not real heap pointers.
1727 // TODO(gc): Remove when we no longer have tagged zero-page
1728 // pointers intermingled with real heap object pointers.
1729 return false;
1730 }
1731 Address a = HeapObject::cast(o)->address();
1732 return MemoryChunk::FromAddress(a)->InNewSpace();
1733 }
1734
1700 // Return the allocated bytes in the active semispace. 1735 // Return the allocated bytes in the active semispace.
1701 virtual intptr_t Size() { return static_cast<int>(top() - bottom()); } 1736 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 1737 // 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 1738 // 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: 1739 // new space, which can't get as big as the other spaces then this is useful:
1705 int SizeAsInt() { return static_cast<int>(Size()); } 1740 int SizeAsInt() { return static_cast<int>(Size()); }
1706 1741
1707 // Return the current capacity of a semispace. 1742 // Return the current capacity of a semispace.
1708 intptr_t Capacity() { 1743 intptr_t Capacity() {
1709 ASSERT(to_space_.Capacity() == from_space_.Capacity()); 1744 ASSERT(to_space_.Capacity() == from_space_.Capacity());
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 } 2288 }
2254 // Must be small, since an iteration is used for lookup. 2289 // Must be small, since an iteration is used for lookup.
2255 static const int kMaxComments = 64; 2290 static const int kMaxComments = 64;
2256 }; 2291 };
2257 #endif 2292 #endif
2258 2293
2259 2294
2260 } } // namespace v8::internal 2295 } } // namespace v8::internal
2261 2296
2262 #endif // V8_SPACES_H_ 2297 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698