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

Side by Side Diff: src/spaces.h

Issue 21087012: Simplify implementation of Mutex. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix unit test. Created 7 years, 4 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 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 }; 1437 };
1438 1438
1439 1439
1440 // The free list category holds a pointer to the top element and a pointer to 1440 // The free list category holds a pointer to the top element and a pointer to
1441 // the end element of the linked list of free memory blocks. 1441 // the end element of the linked list of free memory blocks.
1442 class FreeListCategory { 1442 class FreeListCategory {
1443 public: 1443 public:
1444 FreeListCategory() : 1444 FreeListCategory() :
1445 top_(NULL), 1445 top_(NULL),
1446 end_(NULL), 1446 end_(NULL),
1447 mutex_(OS::CreateMutex()),
1448 available_(0) {} 1447 available_(0) {}
1449 1448
1450 ~FreeListCategory() { 1449 ~FreeListCategory() {}
1451 delete mutex_;
1452 }
1453 1450
1454 intptr_t Concatenate(FreeListCategory* category); 1451 intptr_t Concatenate(FreeListCategory* category);
1455 1452
1456 void Reset(); 1453 void Reset();
1457 1454
1458 void Free(FreeListNode* node, int size_in_bytes); 1455 void Free(FreeListNode* node, int size_in_bytes);
1459 1456
1460 FreeListNode* PickNodeFromList(int *node_size); 1457 FreeListNode* PickNodeFromList(int *node_size);
1461 FreeListNode* PickNodeFromList(int size_in_bytes, int *node_size); 1458 FreeListNode* PickNodeFromList(int size_in_bytes, int *node_size);
1462 1459
1463 intptr_t EvictFreeListItemsInList(Page* p); 1460 intptr_t EvictFreeListItemsInList(Page* p);
1464 1461
1465 void RepairFreeList(Heap* heap); 1462 void RepairFreeList(Heap* heap);
1466 1463
1467 FreeListNode** GetTopAddress() { return &top_; } 1464 FreeListNode** GetTopAddress() { return &top_; }
1468 FreeListNode* top() const { return top_; } 1465 FreeListNode* top() const { return top_; }
1469 void set_top(FreeListNode* top) { top_ = top; } 1466 void set_top(FreeListNode* top) { top_ = top; }
1470 1467
1471 FreeListNode** GetEndAddress() { return &end_; } 1468 FreeListNode** GetEndAddress() { return &end_; }
1472 FreeListNode* end() const { return end_; } 1469 FreeListNode* end() const { return end_; }
1473 void set_end(FreeListNode* end) { end_ = end; } 1470 void set_end(FreeListNode* end) { end_ = end; }
1474 1471
1475 int* GetAvailableAddress() { return &available_; } 1472 int* GetAvailableAddress() { return &available_; }
1476 int available() const { return available_; } 1473 int available() const { return available_; }
1477 void set_available(int available) { available_ = available; } 1474 void set_available(int available) { available_ = available; }
1478 1475
1479 Mutex* mutex() { return mutex_; } 1476 Mutex* mutex() { return &mutex_; }
1480 1477
1481 #ifdef DEBUG 1478 #ifdef DEBUG
1482 intptr_t SumFreeList(); 1479 intptr_t SumFreeList();
1483 int FreeListLength(); 1480 int FreeListLength();
1484 #endif 1481 #endif
1485 1482
1486 private: 1483 private:
1487 FreeListNode* top_; 1484 FreeListNode* top_;
1488 FreeListNode* end_; 1485 FreeListNode* end_;
1489 Mutex* mutex_; 1486 Mutex mutex_;
1490 1487
1491 // Total available bytes in all blocks of this free list category. 1488 // Total available bytes in all blocks of this free list category.
1492 int available_; 1489 int available_;
1493 }; 1490 };
1494 1491
1495 1492
1496 // 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
1497 // 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
1498 // 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'
1499 // 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
2877 } 2874 }
2878 // Must be small, since an iteration is used for lookup. 2875 // Must be small, since an iteration is used for lookup.
2879 static const int kMaxComments = 64; 2876 static const int kMaxComments = 64;
2880 }; 2877 };
2881 #endif 2878 #endif
2882 2879
2883 2880
2884 } } // namespace v8::internal 2881 } } // namespace v8::internal
2885 2882
2886 #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