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

Side by Side Diff: src/spaces.h

Issue 151152: Create a separate space for global property cells (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 5 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/serialize.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 #ifdef DEBUG 1373 #ifdef DEBUG
1374 // Does this free list contain a free block located at the address of 'node'? 1374 // Does this free list contain a free block located at the address of 'node'?
1375 bool Contains(FreeListNode* node); 1375 bool Contains(FreeListNode* node);
1376 #endif 1376 #endif
1377 1377
1378 DISALLOW_COPY_AND_ASSIGN(OldSpaceFreeList); 1378 DISALLOW_COPY_AND_ASSIGN(OldSpaceFreeList);
1379 }; 1379 };
1380 1380
1381 1381
1382 // The free list for the map space. 1382 // The free list for the map space.
1383 class MapSpaceFreeList BASE_EMBEDDED { 1383 class FixedSizeFreeList BASE_EMBEDDED {
1384 public: 1384 public:
1385 explicit MapSpaceFreeList(AllocationSpace owner); 1385 FixedSizeFreeList(AllocationSpace owner, int object_size);
1386 1386
1387 // Clear the free list. 1387 // Clear the free list.
1388 void Reset(); 1388 void Reset();
1389 1389
1390 // Return the number of bytes available on the free list. 1390 // Return the number of bytes available on the free list.
1391 int available() { return available_; } 1391 int available() { return available_; }
1392 1392
1393 // Place a node on the free list. The block starting at 'start' (assumed to 1393 // Place a node on the free list. The block starting at 'start' (assumed to
1394 // have size Map::kSize) is placed on the free list. Bookkeeping 1394 // have size object_size_) is placed on the free list. Bookkeeping
1395 // information will be written to the block, ie, its contents will be 1395 // information will be written to the block, ie, its contents will be
1396 // destroyed. The start address should be word aligned. 1396 // destroyed. The start address should be word aligned.
1397 void Free(Address start); 1397 void Free(Address start);
1398 1398
1399 // Allocate a map-sized block from the free list. The block is unitialized. 1399 // Allocate a fixed sized block from the free list. The block is unitialized.
1400 // A failure is returned if no block is available. 1400 // A failure is returned if no block is available.
1401 Object* Allocate(); 1401 Object* Allocate();
1402 1402
1403 private: 1403 private:
1404 // Available bytes on the free list. 1404 // Available bytes on the free list.
1405 int available_; 1405 int available_;
1406 1406
1407 // The head of the free list. 1407 // The head of the free list.
1408 Address head_; 1408 Address head_;
1409 1409
1410 // The identity of the owning space, for building allocation Failure 1410 // The identity of the owning space, for building allocation Failure
1411 // objects. 1411 // objects.
1412 AllocationSpace owner_; 1412 AllocationSpace owner_;
1413 1413
1414 DISALLOW_COPY_AND_ASSIGN(MapSpaceFreeList); 1414 // The size of the objects in this space.
1415 int object_size_;
1416
1417 DISALLOW_COPY_AND_ASSIGN(FixedSizeFreeList);
1415 }; 1418 };
1416 1419
1417 1420
1418 // ----------------------------------------------------------------------------- 1421 // -----------------------------------------------------------------------------
1419 // Old object space (excluding map objects) 1422 // Old object space (excluding map objects)
1420 1423
1421 class OldSpace : public PagedSpace { 1424 class OldSpace : public PagedSpace {
1422 public: 1425 public:
1423 // Creates an old space object with a given maximum capacity. 1426 // Creates an old space object with a given maximum capacity.
1424 // The constructor does not allocate pages from OS. 1427 // The constructor does not allocate pages from OS.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 // During relocation, we keep a pointer to the most recently relocated 1487 // During relocation, we keep a pointer to the most recently relocated
1485 // object in order to know when to move to the next page. 1488 // object in order to know when to move to the next page.
1486 Address mc_end_of_relocation_; 1489 Address mc_end_of_relocation_;
1487 1490
1488 public: 1491 public:
1489 TRACK_MEMORY("OldSpace") 1492 TRACK_MEMORY("OldSpace")
1490 }; 1493 };
1491 1494
1492 1495
1493 // ----------------------------------------------------------------------------- 1496 // -----------------------------------------------------------------------------
1494 // Old space for all map objects 1497 // Old space for objects of a fixed size
1495 1498
1496 class MapSpace : public PagedSpace { 1499 class PagedSpaceForFixedSizedObjects : public PagedSpace {
1497 public: 1500 public:
1498 // Creates a map space object with a maximum capacity. 1501 PagedSpaceForFixedSizedObjects(int max_capacity, AllocationSpace id,
1499 explicit MapSpace(int max_capacity, AllocationSpace id) 1502 int object_size, const char* name)
1500 : PagedSpace(max_capacity, id, NOT_EXECUTABLE), free_list_(id) { } 1503 : PagedSpace(max_capacity, id, NOT_EXECUTABLE),
1504 object_size_(object_size),
1505 name_(name),
1506 free_list_(id, object_size),
1507 page_extra_(Page::kObjectAreaSize % object_size) { }
1501 1508
1502 // The top of allocation in a page in this space. Undefined if page is unused. 1509 // The top of allocation in a page in this space. Undefined if page is unused.
1503 virtual Address PageAllocationTop(Page* page) { 1510 virtual Address PageAllocationTop(Page* page) {
1504 return page == TopPageOf(allocation_info_) ? top() 1511 return page == TopPageOf(allocation_info_) ? top()
1505 : page->ObjectAreaEnd() - kPageExtra; 1512 : page->ObjectAreaEnd() - page_extra_;
1506 } 1513 }
1507 1514
1508 // Give a map-sized block of memory to the space's free list. 1515 // Give a fixed sized block of memory to the space's free list.
1509 void Free(Address start) { 1516 void Free(Address start) {
1510 free_list_.Free(start); 1517 free_list_.Free(start);
1511 accounting_stats_.DeallocateBytes(Map::kSize); 1518 accounting_stats_.DeallocateBytes(Map::kSize);
1512 } 1519 }
1513 1520
1514 // Given an index, returns the page address.
1515 Address PageAddress(int page_index) { return page_addresses_[page_index]; }
1516
1517 // Prepares for a mark-compact GC. 1521 // Prepares for a mark-compact GC.
1518 virtual void PrepareForMarkCompact(bool will_compact); 1522 virtual void PrepareForMarkCompact(bool will_compact);
1519 1523
1520 // Updates the allocation pointer to the relocation top after a mark-compact 1524 // Updates the allocation pointer to the relocation top after a mark-compact
1521 // collection. 1525 // collection.
1522 virtual void MCCommitRelocationInfo(); 1526 virtual void MCCommitRelocationInfo();
1523 1527
1524 #ifdef DEBUG 1528 #ifdef DEBUG
1525 // Verify integrity of this space. 1529 // Verify integrity of this space.
1526 virtual void Verify(); 1530 virtual void Verify();
1527 1531
1532 // Implement by subclasses to verify an actual object in the space.
1533 virtual void VerifyObject(HeapObject* obj) = 0;
1534
1528 // Reports statistic info of the space 1535 // Reports statistic info of the space
1529 void ReportStatistics(); 1536 void ReportStatistics();
1537
1530 // Dump the remembered sets in the space to stdout. 1538 // Dump the remembered sets in the space to stdout.
1531 void PrintRSet(); 1539 void PrintRSet();
1532 #endif 1540 #endif
1533 1541
1534 // Constants.
1535 static const int kMapPageIndexBits = 10;
1536 static const int kMaxMapPageIndex = (1 << kMapPageIndexBits) - 1;
1537
1538 static const int kPageExtra = Page::kObjectAreaSize % Map::kSize;
1539
1540 protected: 1542 protected:
1541 // Virtual function in the superclass. Slow path of AllocateRaw. 1543 // Virtual function in the superclass. Slow path of AllocateRaw.
1542 HeapObject* SlowAllocateRaw(int size_in_bytes); 1544 HeapObject* SlowAllocateRaw(int size_in_bytes);
1543 1545
1544 // Virtual function in the superclass. Allocate linearly at the start of 1546 // Virtual function in the superclass. Allocate linearly at the start of
1545 // the page after current_page (there is assumed to be one). 1547 // the page after current_page (there is assumed to be one).
1546 HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes); 1548 HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes);
1547 1549
1548 private: 1550 private:
1551 // The size of objects in this space.
1552 int object_size_;
1553
1554 // The name of this space.
1555 const char* name_;
1556
1549 // The space's free list. 1557 // The space's free list.
1550 MapSpaceFreeList free_list_; 1558 FixedSizeFreeList free_list_;
1551 1559
1560 // Bytes of each page that cannot be allocated.
1561 int page_extra_;
1562 };
1563
1564
1565 // -----------------------------------------------------------------------------
1566 // Old space for all map objects
1567
1568 class MapSpace : public PagedSpaceForFixedSizedObjects {
1569 public:
1570 // Creates a map space object with a maximum capacity.
1571 MapSpace(int max_capacity, AllocationSpace id)
1572 : PagedSpaceForFixedSizedObjects(max_capacity, id, Map::kSize, "map") { }
1573
1574 // Prepares for a mark-compact GC.
1575 virtual void PrepareForMarkCompact(bool will_compact);
1576
1577 // Given an index, returns the page address.
1578 Address PageAddress(int page_index) { return page_addresses_[page_index]; }
1579
1580 // Constants.
1581 static const int kMaxMapPageIndex = (1 << MapWord::kMapPageIndexBits) - 1;
1582
1583 protected:
1584 #ifdef DEBUG
1585 virtual void VerifyObject(HeapObject* obj);
1586 #endif
1587
1588 private:
1552 // An array of page start address in a map space. 1589 // An array of page start address in a map space.
1553 Address page_addresses_[kMaxMapPageIndex + 1]; 1590 Address page_addresses_[kMaxMapPageIndex + 1];
1554 1591
1555 public: 1592 public:
1556 TRACK_MEMORY("MapSpace") 1593 TRACK_MEMORY("MapSpace")
1557 }; 1594 };
1558 1595
1559 1596
1560 // ----------------------------------------------------------------------------- 1597 // -----------------------------------------------------------------------------
1598 // Old space for all global object property cell objects
1599
1600 class GlobalPropertyCellSpace : public PagedSpaceForFixedSizedObjects {
1601 public:
1602 // Creates a property cell space object with a maximum capacity.
1603 GlobalPropertyCellSpace(int max_capacity, AllocationSpace id)
1604 : PagedSpaceForFixedSizedObjects(max_capacity, id,
1605 JSGlobalPropertyCell::kSize, "cell") { }
1606
1607 protected:
1608 #ifdef DEBUG
1609 virtual void VerifyObject(HeapObject* obj);
1610 #endif
1611
1612 public:
1613 TRACK_MEMORY("MapSpace")
1614 };
1615
1616
1617 // -----------------------------------------------------------------------------
1561 // Large objects ( > Page::kMaxHeapObjectSize ) are allocated and managed by 1618 // Large objects ( > Page::kMaxHeapObjectSize ) are allocated and managed by
1562 // the large object space. A large object is allocated from OS heap with 1619 // the large object space. A large object is allocated from OS heap with
1563 // extra padding bytes (Page::kPageSize + Page::kObjectStartOffset). 1620 // extra padding bytes (Page::kPageSize + Page::kObjectStartOffset).
1564 // A large object always starts at Page::kObjectStartOffset to a page. 1621 // A large object always starts at Page::kObjectStartOffset to a page.
1565 // Large objects do not move during garbage collections. 1622 // Large objects do not move during garbage collections.
1566 1623
1567 // A LargeObjectChunk holds exactly one large object page with exactly one 1624 // A LargeObjectChunk holds exactly one large object page with exactly one
1568 // large object. 1625 // large object.
1569 class LargeObjectChunk { 1626 class LargeObjectChunk {
1570 public: 1627 public:
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 1787
1731 private: 1788 private:
1732 LargeObjectChunk* current_; 1789 LargeObjectChunk* current_;
1733 HeapObjectCallback size_func_; 1790 HeapObjectCallback size_func_;
1734 }; 1791 };
1735 1792
1736 1793
1737 } } // namespace v8::internal 1794 } } // namespace v8::internal
1738 1795
1739 #endif // V8_SPACES_H_ 1796 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/serialize.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698