mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 23:41:50 +00:00
b21d7c16f6
- Use the correct object when filtering in store barriers. Review URL: https://chromiumcodereview.appspot.com//10796075 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9797 260f80e4-7a28-3924-810f-c04153c831b5
80 lines
1.8 KiB
C++
80 lines
1.8 KiB
C++
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/store_buffer.h"
|
|
|
|
#include "platform/assert.h"
|
|
#include "vm/runtime_entry.h"
|
|
|
|
namespace dart {
|
|
|
|
DEFINE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, Isolate* isolate) {
|
|
isolate->store_buffer_block()->ProcessBuffer(isolate);
|
|
}
|
|
END_LEAF_RUNTIME_ENTRY
|
|
|
|
|
|
void StoreBufferBlock::ProcessBuffer() {
|
|
ProcessBuffer(Isolate::Current());
|
|
}
|
|
|
|
|
|
void StoreBufferBlock::ProcessBuffer(Isolate* isolate) {
|
|
StoreBuffer* buffer = isolate->store_buffer();
|
|
int32_t end = top_;
|
|
for (int32_t i = 0; i < end; i++) {
|
|
buffer->AddPointer(pointers_[i]);
|
|
}
|
|
top_ = 0; // Reset back to the beginning.
|
|
}
|
|
|
|
|
|
bool StoreBufferBlock::Contains(uword pointer) {
|
|
for (int32_t i = 0; i < top_; i++) {
|
|
if (pointers_[i] == pointer) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
StoreBuffer::~StoreBuffer() {
|
|
DedupSet* current = dedup_sets_;
|
|
dedup_sets_ = NULL;
|
|
while (current != NULL) {
|
|
DedupSet* next = current->next();
|
|
delete current;
|
|
current = next;
|
|
}
|
|
}
|
|
|
|
|
|
void StoreBuffer::Reset() {
|
|
DedupSet* current = DedupSets();
|
|
while (current != NULL) {
|
|
DedupSet* next = current->next();
|
|
delete current;
|
|
current = next;
|
|
}
|
|
}
|
|
|
|
|
|
void StoreBuffer::AddPointer(uword address) {
|
|
ASSERT(dedup_sets_ != NULL);
|
|
ASSERT(Isolate::Current()->heap()->OldContains(address));
|
|
if (!dedup_sets_->set()->Add(address)) {
|
|
// Add a new DedupSet. Schedule an interrupt if we have run over the max
|
|
// number of DedupSets.
|
|
dedup_sets_ = new DedupSet(dedup_sets_);
|
|
count_++;
|
|
// TODO(iposva): Fix magic number.
|
|
if (count_ > 100) {
|
|
Isolate::Current()->ScheduleInterrupts(Isolate::kStoreBufferInterrupt);
|
|
}
|
|
}
|
|
}
|
|
|
|
} // namespace dart
|