Skip to content

Commit bd8da47

Browse files
dcharkescommit-bot@chromium.org
authored andcommitted
[vm/ffi] Remove simulator code
DBC is deprecated, and we're unlikely to implement simarm FFI support. Removing templating as suggested in https://dart-review.googlesource.com/c/sdk/+/124136/3/runtime/vm/compiler/ffi.cc Change-Id: I39753129739430093db3b53fb530829c6af936b1 Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-precomp-mac-release-simarm_x64-try,dart-sdk-linux-try,flutter-engine-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127466 Commit-Queue: Daco Harkes <dacoharkes@google.com> Auto-Submit: Daco Harkes <dacoharkes@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
1 parent 52dc769 commit bd8da47

File tree

4 files changed

+15
-65
lines changed

4 files changed

+15
-65
lines changed

runtime/vm/compiler/backend/il.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4562,15 +4562,13 @@ class FfiCallInstr : public Definition {
45624562
intptr_t deopt_id,
45634563
const Function& signature,
45644564
const ZoneGrowableArray<Representation>& arg_reps,
4565-
const ZoneGrowableArray<Location>& arg_locs,
4566-
const ZoneGrowableArray<HostLocation>* arg_host_locs = nullptr)
4565+
const ZoneGrowableArray<Location>& arg_locs)
45674566
: Definition(deopt_id),
45684567
zone_(zone),
45694568
signature_(signature),
45704569
inputs_(arg_reps.length() + 1),
45714570
arg_representations_(arg_reps),
4572-
arg_locations_(arg_locs),
4573-
arg_host_locations_(arg_host_locs) {
4571+
arg_locations_(arg_locs) {
45744572
inputs_.FillWith(nullptr, 0, arg_reps.length() + 1);
45754573
ASSERT(signature.IsZoneHandle());
45764574
}
@@ -4619,7 +4617,6 @@ class FfiCallInstr : public Definition {
46194617
GrowableArray<Value*> inputs_;
46204618
const ZoneGrowableArray<Representation>& arg_representations_;
46214619
const ZoneGrowableArray<Location>& arg_locations_;
4622-
const ZoneGrowableArray<HostLocation>* arg_host_locations_;
46234620

46244621
DISALLOW_COPY_AND_ASSIGN(FfiCallInstr);
46254622
};

runtime/vm/compiler/ffi.cc

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ bool NativeTypeIsPointer(const AbstractType& result_type) {
207207

208208
// Converts a Ffi [signature] to a list of Representations.
209209
// Note that this ignores first argument (receiver) which is dynamic.
210-
template <class CallingConventions>
211-
ZoneGrowableArray<Representation>* ArgumentRepresentationsBase(
210+
ZoneGrowableArray<Representation>* ArgumentRepresentations(
212211
const Function& signature) {
213212
intptr_t num_arguments = signature.num_fixed_parameters() - 1;
214213
auto result = new ZoneGrowableArray<Representation>(num_arguments);
@@ -228,8 +227,7 @@ ZoneGrowableArray<Representation>* ArgumentRepresentationsBase(
228227
return result;
229228
}
230229

231-
template <class CallingConventions>
232-
Representation ResultRepresentationBase(const Function& signature) {
230+
Representation ResultRepresentation(const Function& signature) {
233231
AbstractType& arg_type = AbstractType::Handle(signature.result_type());
234232
Representation rep = TypeRepresentation(arg_type.type_class_id());
235233
if (rep == kUnboxedFloat && CallingConventions::kAbiSoftFP) {
@@ -292,35 +290,9 @@ RawFunction* NativeCallbackFunction(const Function& c_signature,
292290
return function.raw();
293291
}
294292

295-
ZoneGrowableArray<Representation>* ArgumentRepresentations(
296-
const Function& signature) {
297-
return ArgumentRepresentationsBase<CallingConventions>(signature);
298-
}
299-
300-
Representation ResultRepresentation(const Function& signature) {
301-
return ResultRepresentationBase<CallingConventions>(signature);
302-
}
303-
304-
#if defined(USING_SIMULATOR)
305-
306-
ZoneGrowableArray<Representation>* ArgumentHostRepresentations(
307-
const Function& signature) {
308-
return ArgumentRepresentationsBase<host::CallingConventions>(signature);
309-
}
310-
311-
Representation ResultHostRepresentation(const Function& signature) {
312-
return ResultRepresentationBase<host::CallingConventions>(signature);
313-
}
314-
315-
#endif // defined(USING_SIMULATOR)
316-
317293
// Represents the state of a stack frame going into a call, between allocations
318294
// of argument locations. Acts like a register allocator but for arguments in
319295
// the native ABI.
320-
template <class CallingConventions,
321-
class Location,
322-
class Register,
323-
class FpuRegister>
324296
class ArgumentAllocator : public ValueObject {
325297
public:
326298
Location AllocateArgument(Representation rep) {
@@ -506,31 +478,21 @@ Location CallbackArgumentTranslator::TranslateArgument(Location arg) {
506478

507479
// Takes a list of argument representations, and converts it to a list of
508480
// argument locations based on calling convention.
509-
template <class CallingConventions,
510-
class Location,
511-
class Register,
512-
class FpuRegister>
513-
ZoneGrowableArray<Location>* ArgumentLocationsBase(
481+
482+
ZoneGrowableArray<Location>* ArgumentLocations(
514483
const ZoneGrowableArray<Representation>& arg_reps) {
515484
intptr_t num_arguments = arg_reps.length();
516485
auto result = new ZoneGrowableArray<Location>(num_arguments);
517486

518487
// Loop through all arguments and assign a register or a stack location.
519-
ArgumentAllocator<CallingConventions, Location, Register, FpuRegister>
520-
frame_state;
488+
ArgumentAllocator frame_state;
521489
for (intptr_t i = 0; i < num_arguments; i++) {
522490
Representation rep = arg_reps[i];
523491
result->Add(frame_state.AllocateArgument(rep));
524492
}
525493
return result;
526494
}
527495

528-
ZoneGrowableArray<Location>* ArgumentLocations(
529-
const ZoneGrowableArray<Representation>& arg_reps) {
530-
return ArgumentLocationsBase<dart::CallingConventions, Location,
531-
dart::Register, dart::FpuRegister>(arg_reps);
532-
}
533-
534496
Location ResultLocation(Representation result_rep) {
535497
switch (result_rep) {
536498
case kUnboxedFloat:
@@ -598,8 +560,7 @@ RawFunction* TrampolineFunction(const Function& dart_signature,
598560
}
599561

600562
// Accounts for alignment, where some stack slots are used as padding.
601-
template <class Location>
602-
intptr_t TemplateNumStackSlots(const ZoneGrowableArray<Location>& locations) {
563+
intptr_t NumStackSlots(const ZoneGrowableArray<Location>& locations) {
603564
intptr_t num_arguments = locations.length();
604565
intptr_t max_height_in_slots = 0;
605566
for (intptr_t i = 0; i < num_arguments; i++) {
@@ -619,10 +580,6 @@ intptr_t TemplateNumStackSlots(const ZoneGrowableArray<Location>& locations) {
619580
return max_height_in_slots;
620581
}
621582

622-
intptr_t NumStackSlots(const ZoneGrowableArray<Location>& locations) {
623-
return TemplateNumStackSlots(locations);
624-
}
625-
626583
#endif // !defined(DART_PRECOMPILED_RUNTIME)
627584

628585
} // namespace ffi

runtime/vm/compiler/frontend/kernel_to_il.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,11 @@ Fragment FlowGraphBuilder::InstanceCall(
369369
Fragment FlowGraphBuilder::FfiCall(
370370
const Function& signature,
371371
const ZoneGrowableArray<Representation>& arg_reps,
372-
const ZoneGrowableArray<Location>& arg_locs,
373-
const ZoneGrowableArray<HostLocation>* arg_host_locs) {
372+
const ZoneGrowableArray<Location>& arg_locs) {
374373
Fragment body;
375374

376-
FfiCallInstr* const call = new (Z) FfiCallInstr(
377-
Z, GetNextDeoptId(), signature, arg_reps, arg_locs, arg_host_locs);
375+
FfiCallInstr* const call =
376+
new (Z) FfiCallInstr(Z, GetNextDeoptId(), signature, arg_reps, arg_locs);
378377

379378
for (intptr_t i = call->InputCount() - 1; i >= 0; --i) {
380379
call->SetInputAt(i, Pop());
@@ -2977,7 +2976,6 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiNative(const Function& function) {
29772976

29782977
const Function& signature = Function::ZoneHandle(Z, function.FfiCSignature());
29792978
const auto& arg_reps = *compiler::ffi::ArgumentRepresentations(signature);
2980-
const ZoneGrowableArray<HostLocation>* arg_host_locs = nullptr;
29812979
const auto& arg_locs = *compiler::ffi::ArgumentLocations(arg_reps);
29822980

29832981
BuildArgumentTypeChecks(TypeChecksToBuild::kCheckAllTypeParameterBounds,
@@ -3000,7 +2998,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiNative(const Function& function) {
30002998
Z, Class::Handle(I->object_store()->ffi_pointer_class()))
30012999
->context_variables()[0]));
30023000
body += UnboxTruncate(kUnboxedFfiIntPtr);
3003-
body += FfiCall(signature, arg_reps, arg_locs, arg_host_locs);
3001+
body += FfiCall(signature, arg_reps, arg_locs);
30043002

30053003
ffi_type = signature.result_type();
30063004
const Representation from_rep =

runtime/vm/compiler/frontend/kernel_to_il.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ class FlowGraphBuilder : public BaseFlowGraphBuilder {
123123
bool use_unchecked_entry = false,
124124
const CallSiteAttributesMetadata* call_site_attrs = nullptr);
125125

126-
Fragment FfiCall(
127-
const Function& signature,
128-
const ZoneGrowableArray<Representation>& arg_reps,
129-
const ZoneGrowableArray<Location>& arg_locs,
130-
const ZoneGrowableArray<HostLocation>* arg_host_locs = nullptr);
126+
Fragment FfiCall(const Function& signature,
127+
const ZoneGrowableArray<Representation>& arg_reps,
128+
const ZoneGrowableArray<Location>& arg_locs);
131129

132130
Fragment RethrowException(TokenPosition position, int catch_try_index);
133131
Fragment LoadLocal(LocalVariable* variable);

0 commit comments

Comments
 (0)