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

Side by Side Diff: src/spaces.h

Issue 7058009: Make InToSpace/InFromSpace use the page header. (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
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 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE.
379 IN_TO_SPACE, // All pages in new space has one of these two set.
379 NUM_MEMORY_CHUNK_FLAGS 380 NUM_MEMORY_CHUNK_FLAGS
380 }; 381 };
381 382
382 void SetFlag(int flag) { 383 void SetFlag(int flag) {
383 flags_ |= 1 << flag; 384 flags_ |= (1 << flag);
384 } 385 }
385 386
386 void ClearFlag(int flag) { 387 void ClearFlag(int flag) {
387 flags_ &= ~(1 << flag); 388 flags_ &= ~(1 << flag);
388 } 389 }
389 390
391 void SetFlagTo(int flag, bool value) {
392 if (value) {
393 SetFlag(flag);
394 } else {
395 ClearFlag(flag);
396 }
397 }
398
390 bool IsFlagSet(int flag) { 399 bool IsFlagSet(int flag) {
391 return (flags_ & (1 << flag)) != 0; 400 return (flags_ & (1 << flag)) != 0;
392 } 401 }
393 402
394 void CopyFlagsFrom(MemoryChunk* chunk) { 403 // Set or clear multiple flags at a time. The flags in the mask
395 flags_ = chunk->flags_; 404 // are set to the value in "flags", the rest retain the current value
405 // in flags_.
406 void SetFlags(intptr_t flags, intptr_t mask) {
407 flags_ = (flags_ & ~mask) | (flags & mask);
396 } 408 }
397 409
410 // Return all current flags.
411 intptr_t GetFlags() { return flags_; }
412
398 static const intptr_t kAlignment = (1 << kPageSizeBits); 413 static const intptr_t kAlignment = (1 << kPageSizeBits);
399 414
400 static const intptr_t kAlignmentMask = kAlignment - 1; 415 static const intptr_t kAlignmentMask = kAlignment - 1;
401 416
402 static const size_t kHeaderSize = kPointerSize + kPointerSize + kPointerSize + 417 static const size_t kHeaderSize = kPointerSize + kPointerSize + kPointerSize +
403 kPointerSize + kPointerSize + kPointerSize + kPointerSize + kPointerSize; 418 kPointerSize + kPointerSize + kPointerSize + kPointerSize + kPointerSize;
404 419
405 static const int kBodyOffset = 420 static const int kBodyOffset =
406 CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + Bitmap::kSize)); 421 CODE_POINTER_ALIGN(MAP_POINTER_ALIGN(kHeaderSize + Bitmap::kSize));
407 422
408 // The start offset of the object area in a page. Aligned to both maps and 423 // The start offset of the object area in a page. Aligned to both maps and
409 // code alignment to be suitable for both. Also aligned to 32 words because 424 // code alignment to be suitable for both. Also aligned to 32 words because
410 // the marking bitmap is arranged in 32 bit chunks. 425 // the marking bitmap is arranged in 32 bit chunks.
411 static const int kObjectStartAlignment = 32 * kPointerSize; 426 static const int kObjectStartAlignment = 32 * kPointerSize;
412 static const int kObjectStartOffset = kBodyOffset - 1 + 427 static const int kObjectStartOffset = kBodyOffset - 1 +
413 (kObjectStartAlignment - (kBodyOffset - 1) % kObjectStartAlignment); 428 (kObjectStartAlignment - (kBodyOffset - 1) % kObjectStartAlignment);
414 429
415 size_t size() const { return size_; } 430 size_t size() const { return size_; }
416 431
417 Executability executable() { 432 Executability executable() {
418 return IsFlagSet(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE; 433 return IsFlagSet(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE;
419 } 434 }
420 435
421 bool ContainsOnlyData() { 436 bool ContainsOnlyData() {
422 return IsFlagSet(CONTAINS_ONLY_DATA); 437 return IsFlagSet(CONTAINS_ONLY_DATA);
423 } 438 }
424 439
425 bool InNewSpace() { 440 bool InNewSpace() {
426 return IsFlagSet(IN_NEW_SPACE); 441 return (flags_ & ((1 << IN_FROM_SPACE) | (1 << IN_TO_SPACE))) != 0;
442 }
443
444 bool InToSpace() {
445 return IsFlagSet(IN_TO_SPACE);
446 }
447
448 bool InFromSpace() {
449 return IsFlagSet(IN_FROM_SPACE);
427 } 450 }
428 451
429 // --------------------------------------------------------------------- 452 // ---------------------------------------------------------------------
430 // Markbits support 453 // Markbits support
431 454
432 inline Bitmap* markbits() { 455 inline Bitmap* markbits() {
433 return Bitmap::FromAddress(address() + kHeaderSize); 456 return Bitmap::FromAddress(address() + kHeaderSize);
434 } 457 }
435 458
436 void PrintMarkbits() { markbits()->Print(); } 459 void PrintMarkbits() { markbits()->Print(); }
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 1461
1439 const char* name() { return name_; } 1462 const char* name() { return name_; }
1440 void set_name(const char* name) { name_ = name; } 1463 void set_name(const char* name) { name_ = name; }
1441 1464
1442 private: 1465 private:
1443 const char* name_; 1466 const char* name_;
1444 }; 1467 };
1445 #endif 1468 #endif
1446 1469
1447 1470
1471 enum SemiSpaceId {
1472 kFromSpace = 0,
1473 kToSpace = 1
1474 };
1475
1476
1448 class NewSpacePage : public MemoryChunk { 1477 class NewSpacePage : public MemoryChunk {
1449 public: 1478 public:
1479 // GC related flags copied from from-space to to-space when
1480 // flipping semispaces.
1481 static const intptr_t kCopyOnFlipFlagsMask =
1482 (1 << MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING) |
1483 (1 << MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING) |
1484 (1 << MemoryChunk::SCAN_ON_SCAVENGE);
1485
1450 inline NewSpacePage* next_page() const { 1486 inline NewSpacePage* next_page() const {
1451 return static_cast<NewSpacePage*>(next_chunk()); 1487 return static_cast<NewSpacePage*>(next_chunk());
1452 } 1488 }
1453 1489
1454 inline void set_next_page(NewSpacePage* page) { 1490 inline void set_next_page(NewSpacePage* page) {
1455 set_next_chunk(page); 1491 set_next_chunk(page);
1456 } 1492 }
1457 private: 1493 private:
1458 // Finds the NewSpacePage containg the given address. 1494 // Finds the NewSpacePage containg the given address.
1459 static NewSpacePage* FromAddress(Address address_in_page) { 1495 static NewSpacePage* FromAddress(Address address_in_page) {
1460 Address page_start = 1496 Address page_start =
1461 reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address_in_page) & 1497 reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address_in_page) &
1462 ~Page::kPageAlignmentMask); 1498 ~Page::kPageAlignmentMask);
1463 return reinterpret_cast<NewSpacePage*>(page_start); 1499 return reinterpret_cast<NewSpacePage*>(page_start);
1464 } 1500 }
1465 1501
1466 static NewSpacePage* Initialize(Heap* heap, Address start); 1502 static NewSpacePage* Initialize(Heap* heap,
1503 Address start,
1504 SemiSpaceId semispace);
1467 1505
1468 friend class SemiSpace; 1506 friend class SemiSpace;
1469 friend class SemiSpaceIterator; 1507 friend class SemiSpaceIterator;
1470 }; 1508 };
1471 1509
1472 1510
1473 // ----------------------------------------------------------------------------- 1511 // -----------------------------------------------------------------------------
1474 // SemiSpace in young generation 1512 // SemiSpace in young generation
1475 // 1513 //
1476 // A semispace is a contiguous chunk of memory holding page-like memory 1514 // A semispace is a contiguous chunk of memory holding page-like memory
1477 // chunks. The mark-compact collector uses the memory of the first page in 1515 // chunks. The mark-compact collector uses the memory of the first page in
1478 // the from space as a marking stack when tracing live objects. 1516 // the from space as a marking stack when tracing live objects.
1479 1517
1480 class SemiSpace : public Space { 1518 class SemiSpace : public Space {
1481 public: 1519 public:
1482 // Constructor. 1520 // Constructor.
1483 explicit SemiSpace(Heap* heap) : Space(heap, NEW_SPACE, NOT_EXECUTABLE) { 1521 SemiSpace(Heap* heap, SemiSpaceId semispace)
1484 start_ = NULL; 1522 : Space(heap, NEW_SPACE, NOT_EXECUTABLE),
1485 age_mark_ = NULL; 1523 start_(NULL),
1486 } 1524 age_mark_(NULL),
1525 id_(semispace) { }
1487 1526
1488 // Sets up the semispace using the given chunk. 1527 // Sets up the semispace using the given chunk.
1489 bool Setup(Address start, int initial_capacity, int maximum_capacity); 1528 bool Setup(Address start, int initial_capacity, int maximum_capacity);
1490 1529
1491 // Tear down the space. Heap memory was not allocated by the space, so it 1530 // Tear down the space. Heap memory was not allocated by the space, so it
1492 // is not deallocated here. 1531 // is not deallocated here.
1493 void TearDown(); 1532 void TearDown();
1494 1533
1495 // True if the space has been set up but not torn down. 1534 // True if the space has been set up but not torn down.
1496 bool HasBeenSetup() { return start_ != NULL; } 1535 bool HasBeenSetup() { return start_ != NULL; }
1497 1536
1498 // Grow the size of the semispace by committing extra virtual memory. 1537 // Grow the size of the semispace by committing extra virtual memory.
1499 // Assumes that the caller has checked that the semispace has not reached 1538 // Assumes that the caller has checked that the semispace has not reached
1500 // its maximum capacity (and thus there is space available in the reserved 1539 // its maximum capacity (and thus there is space available in the reserved
1501 // address range to grow). 1540 // address range to grow).
1502 bool Grow(); 1541 bool Grow();
1503 1542
1504 // Grow the semispace to the new capacity. The new capacity 1543 // Grow the semispace to the new capacity. The new capacity
1505 // requested must be larger than the current capacity. 1544 // requested must be larger than the current capacity.
1506 bool GrowTo(int new_capacity); 1545 bool GrowTo(int new_capacity);
1507 1546
1508 // Shrinks the semispace to the new capacity. The new capacity 1547 // Shrinks the semispace to the new capacity. The new capacity
1509 // requested must be more than the amount of used memory in the 1548 // requested must be more than the amount of used memory in the
1510 // semispace and less than the current capacity. 1549 // semispace and less than the current capacity.
1511 bool ShrinkTo(int new_capacity); 1550 bool ShrinkTo(int new_capacity);
1512 1551
1552 // Flips the semispace between being from-space and to-space.
1553 // Copies the flags into the masked positions on all pages in the space.
1554 void Flip(intptr_t flags, intptr_t flag_mask);
1555
1513 // Returns the start address of the space. 1556 // Returns the start address of the space.
1514 Address low() { 1557 Address low() {
1515 return NewSpacePage::FromAddress(start_)->body(); 1558 return NewSpacePage::FromAddress(start_)->body();
1516 } 1559 }
1517 1560
1518 // Returns one past the end address of the space. 1561 // Returns one past the end address of the space.
1519 Address high() { 1562 Address high() {
1520 // TODO(gc): Change when there is more than one page. 1563 // TODO(gc): Change when there is more than one page.
1521 return current_page_->body() + current_page_->body_size(); 1564 return current_page_->body() + current_page_->body_size();
1522 } 1565 }
1523 1566
1524 // Age mark accessors. 1567 // Age mark accessors.
1525 Address age_mark() { return age_mark_; } 1568 Address age_mark() { return age_mark_; }
1526 void set_age_mark(Address mark) { age_mark_ = mark; } 1569 void set_age_mark(Address mark) { age_mark_ = mark; }
1527 1570
1528 // True if the address is in the address range of this semispace (not
1529 // necessarily below the allocation pointer).
1530 bool Contains(Address a) {
1531 return (reinterpret_cast<uintptr_t>(a) & address_mask_)
1532 == reinterpret_cast<uintptr_t>(start_);
1533 }
1534
1535 // True if the object is a heap object in the address range of this
1536 // semispace (not necessarily below the allocation pointer).
1537 bool Contains(Object* o) {
1538 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
1539 }
1540
1541 // The offset of an address from the beginning of the space. 1571 // The offset of an address from the beginning of the space.
1542 int SpaceOffsetForAddress(Address addr) { 1572 int SpaceOffsetForAddress(Address addr) {
1543 return static_cast<int>(addr - low()); 1573 return static_cast<int>(addr - low());
1544 } 1574 }
1545 1575
1546 // If we don't have these here then SemiSpace will be abstract. However 1576 // If we don't have these here then SemiSpace will be abstract. However
1547 // they should never be called. 1577 // they should never be called.
1548 virtual intptr_t Size() { 1578 virtual intptr_t Size() {
1549 UNREACHABLE(); 1579 UNREACHABLE();
1550 return 0; 1580 return 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 Address start_; 1622 Address start_;
1593 // Used to govern object promotion during mark-compact collection. 1623 // Used to govern object promotion during mark-compact collection.
1594 Address age_mark_; 1624 Address age_mark_;
1595 1625
1596 // Masks and comparison values to test for containment in this semispace. 1626 // Masks and comparison values to test for containment in this semispace.
1597 uintptr_t address_mask_; 1627 uintptr_t address_mask_;
1598 uintptr_t object_mask_; 1628 uintptr_t object_mask_;
1599 uintptr_t object_expected_; 1629 uintptr_t object_expected_;
1600 1630
1601 bool committed_; 1631 bool committed_;
1632 SemiSpaceId id_;
1602 1633
1603 NewSpacePage* current_page_; 1634 NewSpacePage* current_page_;
1604 1635
1605 public: 1636 public:
1606 TRACK_MEMORY("SemiSpace") 1637 TRACK_MEMORY("SemiSpace")
1607 }; 1638 };
1608 1639
1609 1640
1610 // A SemiSpaceIterator is an ObjectIterator that iterates over the active 1641 // A SemiSpaceIterator is an ObjectIterator that iterates over the active
1611 // semispace of the heap's new space. It iterates over the objects in the 1642 // semispace of the heap's new space. It iterates over the objects in the
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1660 // The young generation space. 1691 // The young generation space.
1661 // 1692 //
1662 // The new space consists of a contiguous pair of semispaces. It simply 1693 // The new space consists of a contiguous pair of semispaces. It simply
1663 // forwards most functions to the appropriate semispace. 1694 // forwards most functions to the appropriate semispace.
1664 1695
1665 class NewSpace : public Space { 1696 class NewSpace : public Space {
1666 public: 1697 public:
1667 // Constructor. 1698 // Constructor.
1668 explicit NewSpace(Heap* heap) 1699 explicit NewSpace(Heap* heap)
1669 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), 1700 : Space(heap, NEW_SPACE, NOT_EXECUTABLE),
1670 to_space_(heap), 1701 to_space_(heap, kToSpace),
1671 from_space_(heap) {} 1702 from_space_(heap, kFromSpace) {}
1672 1703
1673 // Sets up the new space using the given chunk. 1704 // Sets up the new space using the given chunk.
1674 bool Setup(int max_semispace_size); 1705 bool Setup(int max_semispace_size);
1675 1706
1676 // Tears down the space. Heap memory was not allocated by the space, so it 1707 // Tears down the space. Heap memory was not allocated by the space, so it
1677 // is not deallocated here. 1708 // is not deallocated here.
1678 void TearDown(); 1709 void TearDown();
1679 1710
1680 // True if the space has been set up but not torn down. 1711 // True if the space has been set up but not torn down.
1681 bool HasBeenSetup() { 1712 bool HasBeenSetup() {
1682 return to_space_.HasBeenSetup() && from_space_.HasBeenSetup(); 1713 return to_space_.HasBeenSetup() && from_space_.HasBeenSetup();
1683 } 1714 }
1684 1715
1685 // Flip the pair of spaces. 1716 // Flip the pair of spaces.
1686 void Flip(); 1717 void Flip();
1687 1718
1688 // Grow the capacity of the semispaces. Assumes that they are not at 1719 // Grow the capacity of the semispaces. Assumes that they are not at
1689 // their maximum capacity. 1720 // their maximum capacity.
1690 void Grow(); 1721 void Grow();
1691 1722
1692 // Shrink the capacity of the semispaces. 1723 // Shrink the capacity of the semispaces.
1693 void Shrink(); 1724 void Shrink();
1694 1725
1695 // True if the address or object lies in the address range of either 1726 // True if the address or object lies in the address range of either
1696 // semispace (not necessarily below the allocation pointer). 1727 // semispace (not necessarily below the allocation pointer).
1697 bool Contains(Address a) { 1728 bool Contains(Address a) {
1729 // TODO(gc): Replace by PageContains when we stop passing
1730 // pointers to non-paged space.
1698 return (reinterpret_cast<uintptr_t>(a) & address_mask_) 1731 return (reinterpret_cast<uintptr_t>(a) & address_mask_)
1699 == reinterpret_cast<uintptr_t>(start_); 1732 == reinterpret_cast<uintptr_t>(start_);
1700 } 1733 }
1701 1734
1702 // True if the address or object lies on a NewSpacePage. 1735 // 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 1736 // 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. 1737 // page, it must be a pointer into the beginning of it.
1705 // TODO(gc): When every call to Contains is converted to PageContains, 1738 // TODO(gc): When every call to Contains is converted to PageContains,
1706 // remove Contains and rename PageContains to Contains. 1739 // remove Contains and rename PageContains to Contains.
1707 bool PageContains(Address a) { 1740 bool PageContains(Address a) {
1708 if ((reinterpret_cast<intptr_t>(a) & ~kHeapObjectTagMask) == 1741 MemoryChunk* page = MemoryChunk::FromAddress(a);
1709 static_cast<intptr_t>(0)) { 1742 // Tagged zero-page pointers are not real heap pointers.
1710 // Tagged zero-page pointers are not real heap pointers. 1743 // TODO(gc): Remove when we no longer have tagged zero-page
1711 // TODO(gc): Remove when we no longer have tagged zero-page 1744 // pointers intermingled with real heap object pointers.
1712 // pointers intermingled with real heap object pointers. 1745 if (!page->is_valid()) return false;
1713 return false; 1746 return page->InNewSpace();
1714 }
1715 return MemoryChunk::FromAddress(a)->InNewSpace();
1716 } 1747 }
1717 1748
1718 bool Contains(Object* o) { 1749 bool Contains(Object* o) {
1719 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
1720 }
1721
1722 bool PageContains(Object* o) {
1723 if (o->IsSmi()) return false; 1750 if (o->IsSmi()) return false;
1724 if ((reinterpret_cast<uintptr_t>(o) & ~kHeapObjectTagMask) == 1751 Address a = reinterpret_cast<Address>(o);
1725 static_cast<uintptr_t>(0)) { 1752 MemoryChunk* page = MemoryChunk::FromAddress(a);
1726 // Tagged zero-page pointers are not real heap pointers. 1753 if (!page->is_valid()) return false;
1727 // TODO(gc): Remove when we no longer have tagged zero-page 1754 return page->InNewSpace();
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 } 1755 }
1734 1756
1735 // Return the allocated bytes in the active semispace. 1757 // Return the allocated bytes in the active semispace.
1736 virtual intptr_t Size() { return static_cast<int>(top() - bottom()); } 1758 virtual intptr_t Size() { return static_cast<int>(top() - bottom()); }
1737 // The same, but returning an int. We have to have the one that returns 1759 // The same, but returning an int. We have to have the one that returns
1738 // intptr_t because it is inherited, but if we know we are dealing with the 1760 // intptr_t because it is inherited, but if we know we are dealing with the
1739 // new space, which can't get as big as the other spaces then this is useful: 1761 // new space, which can't get as big as the other spaces then this is useful:
1740 int SizeAsInt() { return static_cast<int>(Size()); } 1762 int SizeAsInt() { return static_cast<int>(Size()); }
1741 1763
1742 // Return the current capacity of a semispace. 1764 // Return the current capacity of a semispace.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 Address ToSpaceHigh() { return to_space_.high(); } 1847 Address ToSpaceHigh() { return to_space_.high(); }
1826 1848
1827 // Offsets from the beginning of the semispaces. 1849 // Offsets from the beginning of the semispaces.
1828 int ToSpaceOffsetForAddress(Address a) { 1850 int ToSpaceOffsetForAddress(Address a) {
1829 return to_space_.SpaceOffsetForAddress(a); 1851 return to_space_.SpaceOffsetForAddress(a);
1830 } 1852 }
1831 int FromSpaceOffsetForAddress(Address a) { 1853 int FromSpaceOffsetForAddress(Address a) {
1832 return from_space_.SpaceOffsetForAddress(a); 1854 return from_space_.SpaceOffsetForAddress(a);
1833 } 1855 }
1834 1856
1857 inline bool ToSpaceContains(Address address) {
1858 MemoryChunk* page = MemoryChunk::FromAddress(address);
1859 return page->is_valid() && page->InToSpace();
1860 }
1861
1862 inline bool FromSpaceContains(Address address) {
1863 MemoryChunk* page = MemoryChunk::FromAddress(address);
1864 return page->is_valid() && page->InFromSpace();
1865 }
1866
1835 // True if the object is a heap object in the address range of the 1867 // True if the object is a heap object in the address range of the
1836 // respective semispace (not necessarily below the allocation pointer of the 1868 // respective semispace (not necessarily below the allocation pointer of the
1837 // semispace). 1869 // semispace).
1838 bool ToSpaceContains(Object* o) { return to_space_.Contains(o); } 1870 bool ToSpaceContains(Object* o) {
1839 bool FromSpaceContains(Object* o) { return from_space_.Contains(o); } 1871 if (o->IsSmi()) return false;
1872 Address address = reinterpret_cast<Address>(o);
1873 return ToSpaceContains(address);
1874 }
1840 1875
1841 bool ToSpaceContains(Address a) { return to_space_.Contains(a); } 1876 bool FromSpaceContains(Object* o) {
1842 bool FromSpaceContains(Address a) { return from_space_.Contains(a); } 1877 if (o->IsSmi()) return false;
1878 Address address = reinterpret_cast<Address>(o);
1879 return FromSpaceContains(address);
1880 }
1843 1881
1844 virtual bool ReserveSpace(int bytes); 1882 virtual bool ReserveSpace(int bytes);
1845 1883
1846 // Resizes a sequential string which must be the most recent thing that was 1884 // Resizes a sequential string which must be the most recent thing that was
1847 // allocated in new space. 1885 // allocated in new space.
1848 template <typename StringType> 1886 template <typename StringType>
1849 inline void ShrinkStringAtAllocationBoundary(String* string, int len); 1887 inline void ShrinkStringAtAllocationBoundary(String* string, int len);
1850 1888
1851 #ifdef ENABLE_HEAP_PROTECTION 1889 #ifdef ENABLE_HEAP_PROTECTION
1852 // Protect/unprotect the space by marking it read-only/writable. 1890 // Protect/unprotect the space by marking it read-only/writable.
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 } 2326 }
2289 // Must be small, since an iteration is used for lookup. 2327 // Must be small, since an iteration is used for lookup.
2290 static const int kMaxComments = 64; 2328 static const int kMaxComments = 64;
2291 }; 2329 };
2292 #endif 2330 #endif
2293 2331
2294 2332
2295 } } // namespace v8::internal 2333 } } // namespace v8::internal
2296 2334
2297 #endif // V8_SPACES_H_ 2335 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32-inl.h ('k') | src/spaces.cc » ('j') | src/spaces.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698