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

Side by Side Diff: src/spaces.h

Issue 23625003: Cleanup Mutex and related classes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 7 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/sampler.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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_SPACES_H_ 28 #ifndef V8_SPACES_H_
29 #define V8_SPACES_H_ 29 #define V8_SPACES_H_
30 30
31 #include "allocation.h" 31 #include "allocation.h"
32 #include "hashmap.h" 32 #include "hashmap.h"
33 #include "list.h" 33 #include "list.h"
34 #include "log.h" 34 #include "log.h"
35 #include "platform/mutex.h"
35 #include "v8utils.h" 36 #include "v8utils.h"
36 37
37 namespace v8 { 38 namespace v8 {
38 namespace internal { 39 namespace internal {
39 40
40 class Isolate; 41 class Isolate;
41 42
42 // ----------------------------------------------------------------------------- 43 // -----------------------------------------------------------------------------
43 // Heap structures: 44 // Heap structures:
44 // 45 //
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 }; 1439 };
1439 1440
1440 1441
1441 // The free list category holds a pointer to the top element and a pointer to 1442 // The free list category holds a pointer to the top element and a pointer to
1442 // the end element of the linked list of free memory blocks. 1443 // the end element of the linked list of free memory blocks.
1443 class FreeListCategory { 1444 class FreeListCategory {
1444 public: 1445 public:
1445 FreeListCategory() : 1446 FreeListCategory() :
1446 top_(NULL), 1447 top_(NULL),
1447 end_(NULL), 1448 end_(NULL),
1448 mutex_(OS::CreateMutex()),
1449 available_(0) {} 1449 available_(0) {}
1450 1450
1451 ~FreeListCategory() {
1452 delete mutex_;
1453 }
1454
1455 intptr_t Concatenate(FreeListCategory* category); 1451 intptr_t Concatenate(FreeListCategory* category);
1456 1452
1457 void Reset(); 1453 void Reset();
1458 1454
1459 void Free(FreeListNode* node, int size_in_bytes); 1455 void Free(FreeListNode* node, int size_in_bytes);
1460 1456
1461 FreeListNode* PickNodeFromList(int *node_size); 1457 FreeListNode* PickNodeFromList(int *node_size);
1462 FreeListNode* PickNodeFromList(int size_in_bytes, int *node_size); 1458 FreeListNode* PickNodeFromList(int size_in_bytes, int *node_size);
1463 1459
1464 intptr_t EvictFreeListItemsInList(Page* p); 1460 intptr_t EvictFreeListItemsInList(Page* p);
1465 1461
1466 void RepairFreeList(Heap* heap); 1462 void RepairFreeList(Heap* heap);
1467 1463
1468 FreeListNode** GetTopAddress() { return &top_; } 1464 FreeListNode** GetTopAddress() { return &top_; }
1469 FreeListNode* top() const { return top_; } 1465 FreeListNode* top() const { return top_; }
1470 void set_top(FreeListNode* top) { top_ = top; } 1466 void set_top(FreeListNode* top) { top_ = top; }
1471 1467
1472 FreeListNode** GetEndAddress() { return &end_; } 1468 FreeListNode** GetEndAddress() { return &end_; }
1473 FreeListNode* end() const { return end_; } 1469 FreeListNode* end() const { return end_; }
1474 void set_end(FreeListNode* end) { end_ = end; } 1470 void set_end(FreeListNode* end) { end_ = end; }
1475 1471
1476 int* GetAvailableAddress() { return &available_; } 1472 int* GetAvailableAddress() { return &available_; }
1477 int available() const { return available_; } 1473 int available() const { return available_; }
1478 void set_available(int available) { available_ = available; } 1474 void set_available(int available) { available_ = available; }
1479 1475
1480 Mutex* mutex() { return mutex_; } 1476 Mutex* mutex() { return &mutex_; }
1481 1477
1482 #ifdef DEBUG 1478 #ifdef DEBUG
1483 intptr_t SumFreeList(); 1479 intptr_t SumFreeList();
1484 int FreeListLength(); 1480 int FreeListLength();
1485 #endif 1481 #endif
1486 1482
1487 private: 1483 private:
1488 FreeListNode* top_; 1484 FreeListNode* top_;
1489 FreeListNode* end_; 1485 FreeListNode* end_;
1490 Mutex* mutex_; 1486 Mutex mutex_;
1491 1487
1492 // Total available bytes in all blocks of this free list category. 1488 // Total available bytes in all blocks of this free list category.
1493 int available_; 1489 int available_;
1494 }; 1490 };
1495 1491
1496 1492
1497 // The free list for the old space. The free list is organized in such a way 1493 // The free list for the old space. The free list is organized in such a way
1498 // as to encourage objects allocated around the same time to be near each 1494 // as to encourage objects allocated around the same time to be near each
1499 // other. The normal way to allocate is intended to be by bumping a 'top' 1495 // other. The normal way to allocate is intended to be by bumping a 'top'
1500 // pointer until it hits a 'limit' pointer. When the limit is hit we need to 1496 // pointer until it hits a 'limit' pointer. When the limit is hit we need to
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 } 2874 }
2879 // Must be small, since an iteration is used for lookup. 2875 // Must be small, since an iteration is used for lookup.
2880 static const int kMaxComments = 64; 2876 static const int kMaxComments = 64;
2881 }; 2877 };
2882 #endif 2878 #endif
2883 2879
2884 2880
2885 } } // namespace v8::internal 2881 } } // namespace v8::internal
2886 2882
2887 #endif // V8_SPACES_H_ 2883 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/sampler.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698