28f8c96abe
If the --use-bare-instructions flag is enabled we will:
* Make call sites load the target directly from the pool (instead of
the code object) - this saves one instruction (and an indirect load)
* Ensure the object pool will have direct entry addresses by:
- Letting the clustered snapshot reader change any StubCode::UnlinkedCall()
in the object pool by it's monomorphic entry
- Change the code patcher to patch SwitchableCalls by writing the
monomorphic entry into the pool (instead of the code object)
Issue https://github.com/dart-lang/sdk/issues/33274
Change-Id: I4e41fc8e4461bde477cc559a6a4fccaaf3a350b5
Reviewed-on: https://dart-review.googlesource.com/c/86160
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
51 lines
1.7 KiB
C++
51 lines
1.7 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);
|
|
}
|
|
}
|
|
|
|
bool MatchesPattern(uword end, const int16_t* pattern, intptr_t size) {
|
|
// When breaking within generated code in GDB, it may overwrite individual
|
|
// instructions with trap instructions, which can cause this test to fail.
|
|
//
|
|
// Ignoring trap instructions would work well enough within GDB alone, but it
|
|
// doesn't work in RR, because the check for the trap instrution itself will
|
|
// cause replay to diverge from the original record.
|
|
if (FLAG_support_rr) return true;
|
|
|
|
uint8_t* bytes = reinterpret_cast<uint8_t*>(end - size);
|
|
for (intptr_t i = 0; i < size; i++) {
|
|
int16_t val = pattern[i];
|
|
if ((val >= 0) && (val != bytes[i])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} // namespace dart
|