mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:49:43 +00:00
[vm/perf] Fix JITDUMP integration.
* Use 3-arg variant of open() to fix compilation on GCC and also to ensure that created file is readable/writable by all users. * Avoid changing protection on code pages emitted into VM isolate heap: this allows to profile stubs. Change-Id: I2b621596405ad78f54a63cfebde7a1af9fa15911 Reviewed-on: https://dart-review.googlesource.com/57263 Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
This commit is contained in:
parent
9d9eff44c9
commit
03cb46a229
|
@ -29,6 +29,8 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
DEFINE_FLAG(bool, write_protect_vm_isolate, true, "Write protect vm_isolate.");
|
||||
|
||||
Heap::Heap(Isolate* isolate,
|
||||
intptr_t max_new_gen_semi_words,
|
||||
intptr_t max_old_gen_words,
|
||||
|
@ -878,12 +880,16 @@ NoHeapGrowthControlScope::~NoHeapGrowthControlScope() {
|
|||
|
||||
WritableVMIsolateScope::WritableVMIsolateScope(Thread* thread)
|
||||
: StackResource(thread) {
|
||||
Dart::vm_isolate()->heap()->WriteProtect(false);
|
||||
if (FLAG_write_protect_vm_isolate) {
|
||||
Dart::vm_isolate()->heap()->WriteProtect(false);
|
||||
}
|
||||
}
|
||||
|
||||
WritableVMIsolateScope::~WritableVMIsolateScope() {
|
||||
ASSERT(Dart::vm_isolate()->heap()->UsedInWords(Heap::kNew) == 0);
|
||||
Dart::vm_isolate()->heap()->WriteProtect(true);
|
||||
if (FLAG_write_protect_vm_isolate) {
|
||||
Dart::vm_isolate()->heap()->WriteProtect(true);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -45,6 +45,7 @@ DEFINE_FLAG(bool,
|
|||
"Generate jitdump file to use with perf-inject");
|
||||
|
||||
DECLARE_FLAG(bool, write_protect_code);
|
||||
DECLARE_FLAG(bool, write_protect_vm_isolate);
|
||||
|
||||
// Linux CodeObservers.
|
||||
|
||||
|
@ -122,7 +123,7 @@ class JitDumpCodeObserver : public CodeObserver {
|
|||
: out_file_(nullptr), mapped_(nullptr), mapped_size_(0), code_id_(0) {
|
||||
const intptr_t pid = getpid();
|
||||
char* const filename = OS::SCreate(nullptr, "/tmp/jit-%" Pd ".dump", pid);
|
||||
const int fd = open(filename, O_CREAT | O_TRUNC | O_RDWR);
|
||||
const int fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, 0666);
|
||||
free(filename);
|
||||
|
||||
if (fd == -1) {
|
||||
|
@ -155,9 +156,11 @@ class JitDumpCodeObserver : public CodeObserver {
|
|||
// writing all JIT generated code out.
|
||||
setvbuf(out_file_, nullptr, _IOFBF, 2 * MB);
|
||||
|
||||
// Disable code write protection, constant flickering of page attributes
|
||||
// Disable code write protection and vm isolate write protection, because
|
||||
// calling mprotect on the pages filled with JIT generated code objects
|
||||
// confuses perf.
|
||||
FLAG_write_protect_code = false;
|
||||
FLAG_write_protect_vm_isolate = false;
|
||||
|
||||
// Write JITDUMP header.
|
||||
WriteHeader();
|
||||
|
|
Loading…
Reference in a new issue