Skip to content

Commit f134164

Browse files
sjindel-googlecommit-bot@chromium.org
authored andcommitted
[vm] Enable multiple entry-points on ARM64.
Adresses #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]>
1 parent 302184f commit f134164

File tree

7 files changed

+99
-49
lines changed

7 files changed

+99
-49
lines changed

runtime/tests/vm/vm.status

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ cc/Service_Profile: SkipByDesign
225225
[ $compiler == dartkb ]
226226
dart/generic_field_invocation_test: SkipByDesign # KBC interpreters do not support --no_lazy_dispatchers
227227

228-
[ $builder_tag == bytecode_interpreter || $hot_reload || $hot_reload_rollback || $arch != arm && $arch != simarm && $arch != x64 || $compiler != dartk && $compiler != dartkp && $compiler != dartkb ]
228+
[ $builder_tag == bytecode_interpreter || $hot_reload || $hot_reload_rollback || $arch != arm && $arch != simarm && $arch != x64 && $arch != simarm64 && $arch != arm64 || $compiler != dartk && $compiler != dartkp && $compiler != dartkb ]
229229
dart/entrypoints/*: SkipByDesign # These tests are for compiler optimizations and very sensitive to when functions are optimized, so they are disabled on hotreload and optcounter bots.
230230

231231
[ $builder_tag == crossword || $builder_tag == crossword_ast || $compiler != dartkp || $system != linux && $system != macos && $system != windows ]

runtime/vm/compiler/assembler/assembler_arm64.cc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -619,16 +619,14 @@ void Assembler::Branch(const Code& target,
619619
br(TMP);
620620
}
621621

622-
void Assembler::BranchPatchable(const Code& code) {
623-
Branch(code, PP, ObjectPoolBuilderEntry::kPatchable);
624-
}
625-
626622
void Assembler::BranchLink(const Code& target,
627-
ObjectPoolBuilderEntry::Patchability patchable) {
623+
ObjectPoolBuilderEntry::Patchability patchable,
624+
CodeEntryKind entry_kind) {
628625
const int32_t offset = target::ObjectPool::element_offset(
629626
object_pool_builder().FindObject(ToObject(target), patchable));
630627
LoadWordFromPoolOffset(CODE_REG, offset);
631-
ldr(TMP, FieldAddress(CODE_REG, target::Code::entry_point_offset()));
628+
ldr(TMP,
629+
FieldAddress(CODE_REG, target::Code::entry_point_offset(entry_kind)));
632630
blr(TMP);
633631
}
634632

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

640638
void Assembler::BranchLinkWithEquivalence(const Code& target,
641-
const Object& equivalence) {
639+
const Object& equivalence,
640+
CodeEntryKind entry_kind) {
642641
const int32_t offset = target::ObjectPool::element_offset(
643642
object_pool_builder().FindObject(ToObject(target), equivalence));
644643
LoadWordFromPoolOffset(CODE_REG, offset);
645-
ldr(TMP, FieldAddress(CODE_REG, target::Code::entry_point_offset()));
644+
ldr(TMP,
645+
FieldAddress(CODE_REG, target::Code::entry_point_offset(entry_kind)));
646646
blr(TMP);
647647
}
648648

@@ -1514,18 +1514,19 @@ void Assembler::LeaveStubFrame() {
15141514
// R0 receiver, R5 ICData entries array
15151515
// Preserve R4 (ARGS_DESC_REG), not required today, but maybe later.
15161516
void Assembler::MonomorphicCheckedEntryJIT() {
1517-
ASSERT(has_single_entry_point_);
15181517
has_single_entry_point_ = false;
15191518
const bool saved_use_far_branches = use_far_branches();
15201519
set_use_far_branches(false);
1520+
const intptr_t start = CodeSize();
15211521

15221522
Label immediate, miss;
15231523
Bind(&miss);
15241524
ldr(IP0, Address(THR, target::Thread::monomorphic_miss_entry_offset()));
15251525
br(IP0);
15261526

15271527
Comment("MonomorphicCheckedEntry");
1528-
ASSERT(CodeSize() == target::Instructions::kMonomorphicEntryOffsetJIT);
1528+
ASSERT(CodeSize() - start ==
1529+
target::Instructions::kMonomorphicEntryOffsetJIT);
15291530

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

15431544
// Fall through to unchecked entry.
1544-
ASSERT(CodeSize() == target::Instructions::kPolymorphicEntryOffsetJIT);
1545+
ASSERT(CodeSize() - start ==
1546+
target::Instructions::kPolymorphicEntryOffsetJIT);
15451547

15461548
set_use_far_branches(saved_use_far_branches);
15471549
}
15481550

15491551
// R0 receiver, R5 guarded cid as Smi.
15501552
// Preserve R4 (ARGS_DESC_REG), not required today, but maybe later.
15511553
void Assembler::MonomorphicCheckedEntryAOT() {
1552-
ASSERT(has_single_entry_point_);
15531554
has_single_entry_point_ = false;
15541555
bool saved_use_far_branches = use_far_branches();
15551556
set_use_far_branches(false);

runtime/vm/compiler/assembler/assembler_arm64.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,14 +1371,15 @@ class Assembler : public AssemblerBase {
13711371
Register pp,
13721372
ObjectPoolBuilderEntry::Patchability patchable =
13731373
ObjectPoolBuilderEntry::kNotPatchable);
1374-
void BranchPatchable(const Code& code);
13751374

13761375
void BranchLink(const Code& code,
13771376
ObjectPoolBuilderEntry::Patchability patchable =
1378-
ObjectPoolBuilderEntry::kNotPatchable);
1377+
ObjectPoolBuilderEntry::kNotPatchable,
1378+
CodeEntryKind entry_kind = CodeEntryKind::kNormal);
13791379

1380-
void BranchLinkPatchable(const Code& code) {
1381-
BranchLink(code, ObjectPoolBuilderEntry::kPatchable);
1380+
void BranchLinkPatchable(const Code& code,
1381+
CodeEntryKind entry_kind = CodeEntryKind::kNormal) {
1382+
BranchLink(code, ObjectPoolBuilderEntry::kPatchable, entry_kind);
13821383
}
13831384
void BranchLinkToRuntime();
13841385

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

13891390
// Emit a call that shares its object pool entries with other calls
13901391
// that have the same equivalence marker.
1391-
void BranchLinkWithEquivalence(const Code& code, const Object& equivalence);
1392+
void BranchLinkWithEquivalence(
1393+
const Code& code,
1394+
const Object& equivalence,
1395+
CodeEntryKind entry_kind = CodeEntryKind::kNormal);
13921396

13931397
void AddImmediate(Register dest, int64_t imm) {
13941398
AddImmediate(dest, dest, imm);
@@ -1675,9 +1679,9 @@ class Assembler : public AssemblerBase {
16751679
// Returns object data offset for address calculation; for heap objects also
16761680
// accounts for the tag.
16771681
static int32_t HeapDataOffset(bool is_external, intptr_t cid) {
1678-
return is_external ?
1679-
0 :
1680-
(target::Instance::DataOffsetFor(cid) - kHeapObjectTag);
1682+
return is_external
1683+
? 0
1684+
: (target::Instance::DataOffsetFor(cid) - kHeapObjectTag);
16811685
}
16821686

16831687
static int32_t EncodeImm26BranchOffset(int64_t imm, int32_t instr) {

runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id,
967967
RawPcDescriptors::Kind kind,
968968
LocationSummary* locs,
969969
Code::EntryKind entry_kind) {
970-
// TODO(sjindel/entrypoints): Support multiple entrypoints on ARM64.
971-
__ BranchLinkPatchable(stub);
970+
__ BranchLinkPatchable(stub, entry_kind);
972971
EmitCallsiteMetadata(token_pos, deopt_id, kind, locs);
973972
}
974973

@@ -978,7 +977,6 @@ void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id,
978977
LocationSummary* locs,
979978
const Function& target,
980979
Code::EntryKind entry_kind) {
981-
// TODO(sjindel/entrypoints): Support multiple entrypoints on ARM64.
982980
if (FLAG_precompiled_mode && FLAG_use_bare_instructions) {
983981
AddPcRelativeCallTarget(target, entry_kind);
984982
__ GenerateUnRelocatedPcRelativeCall();
@@ -990,7 +988,7 @@ void FlowGraphCompiler::GenerateStaticDartCall(intptr_t deopt_id,
990988
// instead.
991989
ASSERT(is_optimizing());
992990
const auto& stub = StubCode::CallStaticFunction();
993-
__ BranchLinkWithEquivalence(stub, target);
991+
__ BranchLinkWithEquivalence(stub, target, entry_kind);
994992
EmitCallsiteMetadata(token_pos, deopt_id, kind, locs);
995993
AddStaticCallTarget(target, entry_kind);
996994
}
@@ -1026,7 +1024,6 @@ void FlowGraphCompiler::EmitOptimizedInstanceCall(const Code& stub,
10261024
TokenPosition token_pos,
10271025
LocationSummary* locs,
10281026
Code::EntryKind entry_kind) {
1029-
// TODO(sjindel/entrypoints): Support multiple entrypoints on ARM64.
10301027
ASSERT(Array::Handle(zone(), ic_data.arguments_descriptor()).Length() > 0);
10311028
// Each ICData propagated from unoptimized to optimized code contains the
10321029
// function that corresponds to the Dart function of that IC call. Due
@@ -1038,7 +1035,8 @@ void FlowGraphCompiler::EmitOptimizedInstanceCall(const Code& stub,
10381035
__ LoadObject(R6, parsed_function().function());
10391036
__ LoadFromOffset(R0, SP, (ic_data.CountWithoutTypeArgs() - 1) * kWordSize);
10401037
__ LoadUniqueObject(R5, ic_data);
1041-
GenerateDartCall(deopt_id, token_pos, stub, RawPcDescriptors::kIcCall, locs);
1038+
GenerateDartCall(deopt_id, token_pos, stub, RawPcDescriptors::kIcCall, locs,
1039+
entry_kind);
10421040
__ Drop(ic_data.CountWithTypeArgs());
10431041
}
10441042

@@ -1122,7 +1120,6 @@ void FlowGraphCompiler::EmitInstanceCallAOT(const ICData& ic_data,
11221120
TokenPosition token_pos,
11231121
LocationSummary* locs,
11241122
Code::EntryKind entry_kind) {
1125-
// TODO(34162): Support multiple entry-points on ARM64.
11261123
ASSERT(ic_data.NumArgsTested() == 1);
11271124
const Code& initial_stub = StubCode::UnlinkedCall();
11281125
const UnlinkedCall& data =
@@ -1147,9 +1144,13 @@ void FlowGraphCompiler::EmitInstanceCallAOT(const ICData& ic_data,
11471144
} else {
11481145
__ LoadDoubleWordFromPoolOffset(R5, CODE_REG,
11491146
ObjectPool::element_offset(data_index));
1150-
__ ldr(LR, compiler::FieldAddress(
1151-
CODE_REG,
1152-
Code::entry_point_offset(Code::EntryKind::kMonomorphic)));
1147+
const intptr_t entry_point_offset =
1148+
entry_kind == Code::EntryKind::kNormal
1149+
? compiler::target::Code::entry_point_offset(
1150+
Code::EntryKind::kMonomorphic)
1151+
: compiler::target::Code::entry_point_offset(
1152+
Code::EntryKind::kMonomorphicUnchecked);
1153+
__ ldr(LR, compiler::FieldAddress(CODE_REG, entry_point_offset));
11531154
}
11541155
__ blr(LR);
11551156

@@ -1164,12 +1165,11 @@ void FlowGraphCompiler::EmitUnoptimizedStaticCall(intptr_t count_with_type_args,
11641165
LocationSummary* locs,
11651166
const ICData& ic_data,
11661167
Code::EntryKind entry_kind) {
1167-
// TODO(34162): Support multiple entry-points on ARM64.
11681168
const Code& stub =
11691169
StubCode::UnoptimizedStaticCallEntry(ic_data.NumArgsTested());
11701170
__ LoadObject(R5, ic_data);
11711171
GenerateDartCall(deopt_id, token_pos, stub,
1172-
RawPcDescriptors::kUnoptStaticCall, locs);
1172+
RawPcDescriptors::kUnoptStaticCall, locs, entry_kind);
11731173
__ Drop(count_with_type_args);
11741174
}
11751175

@@ -1181,7 +1181,6 @@ void FlowGraphCompiler::EmitOptimizedStaticCall(
11811181
TokenPosition token_pos,
11821182
LocationSummary* locs,
11831183
Code::EntryKind entry_kind) {
1184-
// TODO(sjindel/entrypoints): Support multiple entrypoints on ARM64.
11851184
ASSERT(!function.IsClosureFunction());
11861185
if (function.HasOptionalParameters() || function.IsGeneric()) {
11871186
__ LoadObject(R4, arguments_descriptor);
@@ -1193,7 +1192,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall(
11931192
// Do not use the code from the function, but let the code be patched so that
11941193
// we can record the outgoing edges to other code.
11951194
GenerateStaticDartCall(deopt_id, token_pos, RawPcDescriptors::kOther, locs,
1196-
function);
1195+
function, entry_kind);
11971196
__ Drop(count_with_type_args);
11981197
}
11991198

runtime/vm/compiler/backend/il_arm64.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
265265
// R0: Function.
266266
ASSERT(locs()->in(0).reg() == R0);
267267
__ LoadFieldFromOffset(CODE_REG, R0, Function::code_offset());
268-
__ LoadFieldFromOffset(R2, R0, Function::entry_point_offset());
268+
__ LoadFieldFromOffset(
269+
R2, CODE_REG, compiler::target::Code::entry_point_offset(entry_kind()));
269270

270271
// R2: instructions.
271272
// R5: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value).

0 commit comments

Comments
 (0)