mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 00:20:56 +00:00
b6b054e3f1
Allocates hidden extra memory after VirtualMemory, and verified writes are duplicated at a fixed offset. This CL only adds the helper. Next steps: 1. Use Reserve when reserving semi-spaces and heap pages. 2. Use Write for storing pointers (+ offset in generated code). 3. Use Accept for GC-related object lifecycle. 4. Call Verify regularly. 5. Fix failures (= places where we forget/ignore write barriers). Review URL: https://codereview.chromium.org//641243004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41399 260f80e4-7a28-3924-810f-c04153c831b5
37 lines
1.3 KiB
C++
37 lines
1.3 KiB
C++
// Copyright (c) 2014, 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/verified_memory.h"
|
|
|
|
namespace dart {
|
|
|
|
#if defined(DEBUG)
|
|
|
|
DEFINE_FLAG(bool, verified_mem, false,
|
|
"Enable write-barrier verification mode (slow, DEBUG only).");
|
|
DEFINE_FLAG(int, verified_mem_max_reserve_mb, (kWordSize <= 4) ? 16 : 32,
|
|
"When verified_mem is true, largest supported reservation (MB).");
|
|
|
|
|
|
VirtualMemory* VerifiedMemory::ReserveInternal(intptr_t size) {
|
|
if (size > offset()) {
|
|
FATAL1("Requested reservation of %" Pd " bytes exceeds the limit. "
|
|
"Use --verified_mem_max_reserve_mb to increase it.", size);
|
|
}
|
|
VirtualMemory* result = VirtualMemory::Reserve(size + offset());
|
|
if (result != NULL) {
|
|
// Commit the offset part of the reservation (writable, not executable).
|
|
result->Commit(result->start() + offset(), size, /* executable = */ false);
|
|
// Truncate without unmapping, so that the returned object looks like
|
|
// a normal 'size' bytes reservation (but VirtualMemory will correctly
|
|
// unmap the entire original reservation on destruction).
|
|
result->Truncate(size, /* try_unmap = */ false);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
#endif // DEBUG
|
|
|
|
} // namespace dart
|