Skip to content

Commit

Permalink
[vm] Enable multiple entry-points on ARM64.
Browse files Browse the repository at this point in the history
Adresses dart-lang#34162

Change-Id: I7126f8c9b470041aaa260255293327f67d64d1bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128063
Commit-Queue: Samir Jindel <[email protected]>
Reviewed-by: Martin Kustermann <[email protected]>
  • Loading branch information
sjindel-google authored and [email protected] committed Dec 19, 2019
1 parent 781a71c commit fb7e926
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
25 changes: 13 additions & 12 deletions assembler_arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -619,16 +619,14 @@ void Assembler::Branch(const Code& target,
br(TMP);
}

void Assembler::BranchPatchable(const Code& code) {
Branch(code, PP, ObjectPoolBuilderEntry::kPatchable);
}

void Assembler::BranchLink(const Code& target,
ObjectPoolBuilderEntry::Patchability patchable) {
ObjectPoolBuilderEntry::Patchability patchable,
CodeEntryKind entry_kind) {
const int32_t offset = target::ObjectPool::element_offset(
object_pool_builder().FindObject(ToObject(target), patchable));
LoadWordFromPoolOffset(CODE_REG, offset);
ldr(TMP, FieldAddress(CODE_REG, target::Code::entry_point_offset()));
ldr(TMP,
FieldAddress(CODE_REG, target::Code::entry_point_offset(entry_kind)));
blr(TMP);
}

Expand All @@ -638,11 +636,13 @@ void Assembler::BranchLinkToRuntime() {
}

void Assembler::BranchLinkWithEquivalence(const Code& target,
const Object& equivalence) {
const Object& equivalence,
CodeEntryKind entry_kind) {
const int32_t offset = target::ObjectPool::element_offset(
object_pool_builder().FindObject(ToObject(target), equivalence));
LoadWordFromPoolOffset(CODE_REG, offset);
ldr(TMP, FieldAddress(CODE_REG, target::Code::entry_point_offset()));
ldr(TMP,
FieldAddress(CODE_REG, target::Code::entry_point_offset(entry_kind)));
blr(TMP);
}

Expand Down Expand Up @@ -1514,18 +1514,19 @@ void Assembler::LeaveStubFrame() {
// R0 receiver, R5 ICData entries array
// Preserve R4 (ARGS_DESC_REG), not required today, but maybe later.
void Assembler::MonomorphicCheckedEntryJIT() {
ASSERT(has_single_entry_point_);
has_single_entry_point_ = false;
const bool saved_use_far_branches = use_far_branches();
set_use_far_branches(false);
const intptr_t start = CodeSize();

Label immediate, miss;
Bind(&miss);
ldr(IP0, Address(THR, target::Thread::monomorphic_miss_entry_offset()));
br(IP0);

Comment("MonomorphicCheckedEntry");
ASSERT(CodeSize() == target::Instructions::kMonomorphicEntryOffsetJIT);
ASSERT(CodeSize() - start ==
target::Instructions::kMonomorphicEntryOffsetJIT);

const intptr_t cid_offset = target::Array::element_offset(0);
const intptr_t count_offset = target::Array::element_offset(1);
Expand All @@ -1541,15 +1542,15 @@ void Assembler::MonomorphicCheckedEntryJIT() {
LoadImmediate(R4, 0); // GC-safe for OptimizeInvokedFunction.

// Fall through to unchecked entry.
ASSERT(CodeSize() == target::Instructions::kPolymorphicEntryOffsetJIT);
ASSERT(CodeSize() - start ==
target::Instructions::kPolymorphicEntryOffsetJIT);

set_use_far_branches(saved_use_far_branches);
}

// R0 receiver, R5 guarded cid as Smi.
// Preserve R4 (ARGS_DESC_REG), not required today, but maybe later.
void Assembler::MonomorphicCheckedEntryAOT() {
ASSERT(has_single_entry_point_);
has_single_entry_point_ = false;
bool saved_use_far_branches = use_far_branches();
set_use_far_branches(false);
Expand Down
20 changes: 12 additions & 8 deletions assembler_arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -1371,14 +1371,15 @@ class Assembler : public AssemblerBase {
Register pp,
ObjectPoolBuilderEntry::Patchability patchable =
ObjectPoolBuilderEntry::kNotPatchable);
void BranchPatchable(const Code& code);

void BranchLink(const Code& code,
ObjectPoolBuilderEntry::Patchability patchable =
ObjectPoolBuilderEntry::kNotPatchable);
ObjectPoolBuilderEntry::kNotPatchable,
CodeEntryKind entry_kind = CodeEntryKind::kNormal);

void BranchLinkPatchable(const Code& code) {
BranchLink(code, ObjectPoolBuilderEntry::kPatchable);
void BranchLinkPatchable(const Code& code,
CodeEntryKind entry_kind = CodeEntryKind::kNormal) {
BranchLink(code, ObjectPoolBuilderEntry::kPatchable, entry_kind);
}
void BranchLinkToRuntime();

Expand All @@ -1388,7 +1389,10 @@ class Assembler : public AssemblerBase {

// Emit a call that shares its object pool entries with other calls
// that have the same equivalence marker.
void BranchLinkWithEquivalence(const Code& code, const Object& equivalence);
void BranchLinkWithEquivalence(
const Code& code,
const Object& equivalence,
CodeEntryKind entry_kind = CodeEntryKind::kNormal);

void AddImmediate(Register dest, int64_t imm) {
AddImmediate(dest, dest, imm);
Expand Down Expand Up @@ -1675,9 +1679,9 @@ class Assembler : public AssemblerBase {
// Returns object data offset for address calculation; for heap objects also
// accounts for the tag.
static int32_t HeapDataOffset(bool is_external, intptr_t cid) {
return is_external ?
0 :
(target::Instance::DataOffsetFor(cid) - kHeapObjectTag);
return is_external
? 0
: (target::Instance::DataOffsetFor(cid) - kHeapObjectTag);
}

static int32_t EncodeImm26BranchOffset(int64_t imm, int32_t instr) {
Expand Down

0 comments on commit fb7e926

Please sign in to comment.