Skip to content

Commit

Permalink
[vm/ffi] Remove simulator code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dcharkes authored and commit-bot@chromium.org committed Dec 7, 2019
1 parent 52dc769 commit bd8da47
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 65 deletions.
7 changes: 2 additions & 5 deletions runtime/vm/compiler/backend/il.h
Original file line number Diff line number Diff line change
Expand Up @@ -4562,15 +4562,13 @@ class FfiCallInstr : public Definition {
intptr_t deopt_id,
const Function& signature,
const ZoneGrowableArray<Representation>& arg_reps,
const ZoneGrowableArray<Location>& arg_locs,
const ZoneGrowableArray<HostLocation>* arg_host_locs = nullptr)
const ZoneGrowableArray<Location>& 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());
}
Expand Down Expand Up @@ -4619,7 +4617,6 @@ class FfiCallInstr : public Definition {
GrowableArray<Value*> inputs_;
const ZoneGrowableArray<Representation>& arg_representations_;
const ZoneGrowableArray<Location>& arg_locations_;
const ZoneGrowableArray<HostLocation>* arg_host_locations_;

DISALLOW_COPY_AND_ASSIGN(FfiCallInstr);
};
Expand Down
55 changes: 6 additions & 49 deletions runtime/vm/compiler/ffi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class CallingConventions>
ZoneGrowableArray<Representation>* ArgumentRepresentationsBase(
ZoneGrowableArray<Representation>* ArgumentRepresentations(
const Function& signature) {
intptr_t num_arguments = signature.num_fixed_parameters() - 1;
auto result = new ZoneGrowableArray<Representation>(num_arguments);
Expand All @@ -228,8 +227,7 @@ ZoneGrowableArray<Representation>* ArgumentRepresentationsBase(
return result;
}

template <class CallingConventions>
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) {
Expand Down Expand Up @@ -292,35 +290,9 @@ RawFunction* NativeCallbackFunction(const Function& c_signature,
return function.raw();
}

ZoneGrowableArray<Representation>* ArgumentRepresentations(
const Function& signature) {
return ArgumentRepresentationsBase<CallingConventions>(signature);
}

Representation ResultRepresentation(const Function& signature) {
return ResultRepresentationBase<CallingConventions>(signature);
}

#if defined(USING_SIMULATOR)

ZoneGrowableArray<Representation>* ArgumentHostRepresentations(
const Function& signature) {
return ArgumentRepresentationsBase<host::CallingConventions>(signature);
}

Representation ResultHostRepresentation(const Function& signature) {
return ResultRepresentationBase<host::CallingConventions>(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 CallingConventions,
class Location,
class Register,
class FpuRegister>
class ArgumentAllocator : public ValueObject {
public:
Location AllocateArgument(Representation rep) {
Expand Down Expand Up @@ -506,31 +478,21 @@ 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 <class CallingConventions,
class Location,
class Register,
class FpuRegister>
ZoneGrowableArray<Location>* ArgumentLocationsBase(

ZoneGrowableArray<Location>* ArgumentLocations(
const ZoneGrowableArray<Representation>& arg_reps) {
intptr_t num_arguments = arg_reps.length();
auto result = new ZoneGrowableArray<Location>(num_arguments);

// Loop through all arguments and assign a register or a stack location.
ArgumentAllocator<CallingConventions, Location, Register, FpuRegister>
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));
}
return result;
}

ZoneGrowableArray<Location>* ArgumentLocations(
const ZoneGrowableArray<Representation>& arg_reps) {
return ArgumentLocationsBase<dart::CallingConventions, Location,
dart::Register, dart::FpuRegister>(arg_reps);
}

Location ResultLocation(Representation result_rep) {
switch (result_rep) {
case kUnboxedFloat:
Expand Down Expand Up @@ -598,8 +560,7 @@ RawFunction* TrampolineFunction(const Function& dart_signature,
}

// Accounts for alignment, where some stack slots are used as padding.
template <class Location>
intptr_t TemplateNumStackSlots(const ZoneGrowableArray<Location>& locations) {
intptr_t NumStackSlots(const ZoneGrowableArray<Location>& locations) {
intptr_t num_arguments = locations.length();
intptr_t max_height_in_slots = 0;
for (intptr_t i = 0; i < num_arguments; i++) {
Expand All @@ -619,10 +580,6 @@ intptr_t TemplateNumStackSlots(const ZoneGrowableArray<Location>& locations) {
return max_height_in_slots;
}

intptr_t NumStackSlots(const ZoneGrowableArray<Location>& locations) {
return TemplateNumStackSlots(locations);
}

#endif // !defined(DART_PRECOMPILED_RUNTIME)

} // namespace ffi
Expand Down
10 changes: 4 additions & 6 deletions runtime/vm/compiler/frontend/kernel_to_il.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,11 @@ Fragment FlowGraphBuilder::InstanceCall(
Fragment FlowGraphBuilder::FfiCall(
const Function& signature,
const ZoneGrowableArray<Representation>& arg_reps,
const ZoneGrowableArray<Location>& arg_locs,
const ZoneGrowableArray<HostLocation>* arg_host_locs) {
const ZoneGrowableArray<Location>& 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());
Expand Down Expand Up @@ -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<HostLocation>* arg_host_locs = nullptr;
const auto& arg_locs = *compiler::ffi::ArgumentLocations(arg_reps);

BuildArgumentTypeChecks(TypeChecksToBuild::kCheckAllTypeParameterBounds,
Expand All @@ -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 =
Expand Down
8 changes: 3 additions & 5 deletions runtime/vm/compiler/frontend/kernel_to_il.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Representation>& arg_reps,
const ZoneGrowableArray<Location>& arg_locs,
const ZoneGrowableArray<HostLocation>* arg_host_locs = nullptr);
Fragment FfiCall(const Function& signature,
const ZoneGrowableArray<Representation>& arg_reps,
const ZoneGrowableArray<Location>& arg_locs);

Fragment RethrowException(TokenPosition position, int catch_try_index);
Fragment LoadLocal(LocalVariable* variable);
Expand Down

0 comments on commit bd8da47

Please sign in to comment.