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

Side by Side Diff: src/heap/slot-set.h

Issue 2360233002: [heap] Only insert new slot set entries. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_SLOT_SET_H 5 #ifndef V8_SLOT_SET_H
6 #define V8_SLOT_SET_H 6 #define V8_SLOT_SET_H
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/base/atomic-utils.h" 9 #include "src/base/atomic-utils.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 30 matching lines...) Expand all
41 // This method should only be called on the main thread because concurrent 41 // This method should only be called on the main thread because concurrent
42 // allocation of the bucket is not thread-safe. 42 // allocation of the bucket is not thread-safe.
43 void Insert(int slot_offset) { 43 void Insert(int slot_offset) {
44 int bucket_index, cell_index, bit_index; 44 int bucket_index, cell_index, bit_index;
45 SlotToIndices(slot_offset, &bucket_index, &cell_index, &bit_index); 45 SlotToIndices(slot_offset, &bucket_index, &cell_index, &bit_index);
46 base::AtomicValue<uint32_t>* current_bucket = bucket[bucket_index].Value(); 46 base::AtomicValue<uint32_t>* current_bucket = bucket[bucket_index].Value();
47 if (current_bucket == nullptr) { 47 if (current_bucket == nullptr) {
48 current_bucket = AllocateBucket(); 48 current_bucket = AllocateBucket();
49 bucket[bucket_index].SetValue(current_bucket); 49 bucket[bucket_index].SetValue(current_bucket);
50 } 50 }
51 current_bucket[cell_index].SetBit(bit_index); 51 if (!(current_bucket[cell_index].Value() & (1u << bit_index))) {
52 current_bucket[cell_index].SetBit(bit_index);
53 }
52 } 54 }
53 55
54 // The slot offset specifies a slot at address page_start_ + slot_offset. 56 // The slot offset specifies a slot at address page_start_ + slot_offset.
55 void Remove(int slot_offset) { 57 void Remove(int slot_offset) {
56 int bucket_index, cell_index, bit_index; 58 int bucket_index, cell_index, bit_index;
57 SlotToIndices(slot_offset, &bucket_index, &cell_index, &bit_index); 59 SlotToIndices(slot_offset, &bucket_index, &cell_index, &bit_index);
58 base::AtomicValue<uint32_t>* current_bucket = bucket[bucket_index].Value(); 60 base::AtomicValue<uint32_t>* current_bucket = bucket[bucket_index].Value();
59 if (current_bucket != nullptr) { 61 if (current_bucket != nullptr) {
60 uint32_t cell = current_bucket[cell_index].Value(); 62 uint32_t cell = current_bucket[cell_index].Value();
61 if (cell) { 63 if (cell) {
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 }; 412 };
411 413
412 Address page_start_; 414 Address page_start_;
413 base::AtomicValue<Chunk*> chunk_; 415 base::AtomicValue<Chunk*> chunk_;
414 }; 416 };
415 417
416 } // namespace internal 418 } // namespace internal
417 } // namespace v8 419 } // namespace v8
418 420
419 #endif // V8_SLOT_SET_H 421 #endif // V8_SLOT_SET_H
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698