mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
e14b3a86f0
Bug: b/70275153 Change-Id: I81b868b25428b39835935846ba2c9f9f67b3e84d Reviewed-on: https://dart-review.googlesource.com/33665 Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
31 lines
1 KiB
C++
31 lines
1 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/code_patcher.h"
|
|
#include "vm/cpu.h"
|
|
#include "vm/instructions.h"
|
|
#include "vm/object.h"
|
|
#include "vm/virtual_memory.h"
|
|
|
|
namespace dart {
|
|
|
|
DEFINE_FLAG(bool, write_protect_code, true, "Write protect jitted code");
|
|
|
|
WritableInstructionsScope::WritableInstructionsScope(uword address,
|
|
intptr_t size)
|
|
: address_(address), size_(size) {
|
|
if (FLAG_write_protect_code) {
|
|
VirtualMemory::Protect(reinterpret_cast<void*>(address), size,
|
|
VirtualMemory::kReadWrite);
|
|
}
|
|
}
|
|
|
|
WritableInstructionsScope::~WritableInstructionsScope() {
|
|
if (FLAG_write_protect_code) {
|
|
VirtualMemory::Protect(reinterpret_cast<void*>(address_), size_,
|
|
VirtualMemory::kReadExecute);
|
|
}
|
|
}
|
|
|
|
} // namespace dart
|