From bd8da4757e1944d451c558c00e92228ffac61704 Mon Sep 17 00:00:00 2001 From: Daco Harkes Date: Sat, 7 Dec 2019 17:10:45 +0000 Subject: [PATCH] [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 Auto-Submit: Daco Harkes Reviewed-by: Martin Kustermann --- runtime/vm/compiler/backend/il.h | 7 +-- runtime/vm/compiler/ffi.cc | 55 +++----------------- runtime/vm/compiler/frontend/kernel_to_il.cc | 10 ++-- runtime/vm/compiler/frontend/kernel_to_il.h | 8 ++- 4 files changed, 15 insertions(+), 65 deletions(-) diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h index b2d8e7c1f32b..748ea5aa5464 100644 --- a/runtime/vm/compiler/backend/il.h +++ b/runtime/vm/compiler/backend/il.h @@ -4562,15 +4562,13 @@ class FfiCallInstr : public Definition { intptr_t deopt_id, const Function& signature, const ZoneGrowableArray& arg_reps, - const ZoneGrowableArray& arg_locs, - const ZoneGrowableArray* arg_host_locs = nullptr) + const ZoneGrowableArray& arg_locs) : Definition(deopt_id), zone_(zone), signature_(signature), inputs_(arg_reps.length() + 1), arg_representations_(arg_reps), - arg_locations_(arg_locs), - arg_host_locations_(arg_host_locs) { + arg_locations_(arg_locs) { inputs_.FillWith(nullptr, 0, arg_reps.length() + 1); ASSERT(signature.IsZoneHandle()); } @@ -4619,7 +4617,6 @@ class FfiCallInstr : public Definition { GrowableArray inputs_; const ZoneGrowableArray& arg_representations_; const ZoneGrowableArray& arg_locations_; - const ZoneGrowableArray* arg_host_locations_; DISALLOW_COPY_AND_ASSIGN(FfiCallInstr); }; diff --git a/runtime/vm/compiler/ffi.cc b/runtime/vm/compiler/ffi.cc index 90af59dd934e..82e95df1c03c 100644 --- a/runtime/vm/compiler/ffi.cc +++ b/runtime/vm/compiler/ffi.cc @@ -207,8 +207,7 @@ bool NativeTypeIsPointer(const AbstractType& result_type) { // Converts a Ffi [signature] to a list of Representations. // Note that this ignores first argument (receiver) which is dynamic. -template -ZoneGrowableArray* ArgumentRepresentationsBase( +ZoneGrowableArray* ArgumentRepresentations( const Function& signature) { intptr_t num_arguments = signature.num_fixed_parameters() - 1; auto result = new ZoneGrowableArray(num_arguments); @@ -228,8 +227,7 @@ ZoneGrowableArray* ArgumentRepresentationsBase( return result; } -template -Representation ResultRepresentationBase(const Function& signature) { +Representation ResultRepresentation(const Function& signature) { AbstractType& arg_type = AbstractType::Handle(signature.result_type()); Representation rep = TypeRepresentation(arg_type.type_class_id()); if (rep == kUnboxedFloat && CallingConventions::kAbiSoftFP) { @@ -292,35 +290,9 @@ RawFunction* NativeCallbackFunction(const Function& c_signature, return function.raw(); } -ZoneGrowableArray* ArgumentRepresentations( - const Function& signature) { - return ArgumentRepresentationsBase(signature); -} - -Representation ResultRepresentation(const Function& signature) { - return ResultRepresentationBase(signature); -} - -#if defined(USING_SIMULATOR) - -ZoneGrowableArray* ArgumentHostRepresentations( - const Function& signature) { - return ArgumentRepresentationsBase(signature); -} - -Representation ResultHostRepresentation(const Function& signature) { - return ResultRepresentationBase(signature); -} - -#endif // defined(USING_SIMULATOR) - // Represents the state of a stack frame going into a call, between allocations // of argument locations. Acts like a register allocator but for arguments in // the native ABI. -template class ArgumentAllocator : public ValueObject { public: Location AllocateArgument(Representation rep) { @@ -506,18 +478,14 @@ Location CallbackArgumentTranslator::TranslateArgument(Location arg) { // Takes a list of argument representations, and converts it to a list of // argument locations based on calling convention. -template -ZoneGrowableArray* ArgumentLocationsBase( + +ZoneGrowableArray* ArgumentLocations( const ZoneGrowableArray& arg_reps) { intptr_t num_arguments = arg_reps.length(); auto result = new ZoneGrowableArray(num_arguments); // Loop through all arguments and assign a register or a stack location. - ArgumentAllocator - frame_state; + ArgumentAllocator frame_state; for (intptr_t i = 0; i < num_arguments; i++) { Representation rep = arg_reps[i]; result->Add(frame_state.AllocateArgument(rep)); @@ -525,12 +493,6 @@ ZoneGrowableArray* ArgumentLocationsBase( return result; } -ZoneGrowableArray* ArgumentLocations( - const ZoneGrowableArray& arg_reps) { - return ArgumentLocationsBase(arg_reps); -} - Location ResultLocation(Representation result_rep) { switch (result_rep) { case kUnboxedFloat: @@ -598,8 +560,7 @@ RawFunction* TrampolineFunction(const Function& dart_signature, } // Accounts for alignment, where some stack slots are used as padding. -template -intptr_t TemplateNumStackSlots(const ZoneGrowableArray& locations) { +intptr_t NumStackSlots(const ZoneGrowableArray& locations) { intptr_t num_arguments = locations.length(); intptr_t max_height_in_slots = 0; for (intptr_t i = 0; i < num_arguments; i++) { @@ -619,10 +580,6 @@ intptr_t TemplateNumStackSlots(const ZoneGrowableArray& locations) { return max_height_in_slots; } -intptr_t NumStackSlots(const ZoneGrowableArray& locations) { - return TemplateNumStackSlots(locations); -} - #endif // !defined(DART_PRECOMPILED_RUNTIME) } // namespace ffi diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc index f64d10c6de42..0fc435c28a8b 100644 --- a/runtime/vm/compiler/frontend/kernel_to_il.cc +++ b/runtime/vm/compiler/frontend/kernel_to_il.cc @@ -369,12 +369,11 @@ Fragment FlowGraphBuilder::InstanceCall( Fragment FlowGraphBuilder::FfiCall( const Function& signature, const ZoneGrowableArray& arg_reps, - const ZoneGrowableArray& arg_locs, - const ZoneGrowableArray* arg_host_locs) { + const ZoneGrowableArray& arg_locs) { Fragment body; - FfiCallInstr* const call = new (Z) FfiCallInstr( - Z, GetNextDeoptId(), signature, arg_reps, arg_locs, arg_host_locs); + FfiCallInstr* const call = + new (Z) FfiCallInstr(Z, GetNextDeoptId(), signature, arg_reps, arg_locs); for (intptr_t i = call->InputCount() - 1; i >= 0; --i) { call->SetInputAt(i, Pop()); @@ -2977,7 +2976,6 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiNative(const Function& function) { const Function& signature = Function::ZoneHandle(Z, function.FfiCSignature()); const auto& arg_reps = *compiler::ffi::ArgumentRepresentations(signature); - const ZoneGrowableArray* arg_host_locs = nullptr; const auto& arg_locs = *compiler::ffi::ArgumentLocations(arg_reps); BuildArgumentTypeChecks(TypeChecksToBuild::kCheckAllTypeParameterBounds, @@ -3000,7 +2998,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFfiNative(const Function& function) { Z, Class::Handle(I->object_store()->ffi_pointer_class())) ->context_variables()[0])); body += UnboxTruncate(kUnboxedFfiIntPtr); - body += FfiCall(signature, arg_reps, arg_locs, arg_host_locs); + body += FfiCall(signature, arg_reps, arg_locs); ffi_type = signature.result_type(); const Representation from_rep = diff --git a/runtime/vm/compiler/frontend/kernel_to_il.h b/runtime/vm/compiler/frontend/kernel_to_il.h index 29893dc00bd9..0584badcaaa8 100644 --- a/runtime/vm/compiler/frontend/kernel_to_il.h +++ b/runtime/vm/compiler/frontend/kernel_to_il.h @@ -123,11 +123,9 @@ class FlowGraphBuilder : public BaseFlowGraphBuilder { bool use_unchecked_entry = false, const CallSiteAttributesMetadata* call_site_attrs = nullptr); - Fragment FfiCall( - const Function& signature, - const ZoneGrowableArray& arg_reps, - const ZoneGrowableArray& arg_locs, - const ZoneGrowableArray* arg_host_locs = nullptr); + Fragment FfiCall(const Function& signature, + const ZoneGrowableArray& arg_reps, + const ZoneGrowableArray& arg_locs); Fragment RethrowException(TokenPosition position, int catch_try_index); Fragment LoadLocal(LocalVariable* variable);