Skip to content

Commit 5b9fe44

Browse files
committed
hacky flag for class resilience
1 parent b7de03f commit 5b9fe44

File tree

6 files changed

+23
-7
lines changed

6 files changed

+23
-7
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ namespace swift {
141141
/// \brief Enable experimental nested generic types feature.
142142
bool EnableExperimentalNestedGenericTypes = false;
143143

144+
/// \brief Staging flag for class resilience, which we do not want to enable
145+
/// fully until more code is in place, to allow the standard library to be
146+
/// tested with value type resilience only.
147+
bool EnableClassResilience = false;
148+
144149
/// Should we check the target OSs of serialized modules to see that they're
145150
/// new enough?
146151
bool EnableTargetOSChecking = true;

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ def enable_resilience : Flag<["-"], "enable-resilience">,
331331
HelpText<"Compile the module to export resilient interfaces for all "
332332
"public declarations by default">;
333333

334+
def enable_class_resilience : Flag<["-"], "enable-class-resilience">,
335+
HelpText<"Compile the module to export resilient interfaces for all "
336+
"public classes by default (doesn't work yet)">;
337+
334338
def group_info_path : Separate<["-"], "group-info-path">,
335339
HelpText<"The path to collect the group information of the compiled module">;
336340

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
787787
Opts.EnableExperimentalNestedGenericTypes |=
788788
Args.hasArg(OPT_enable_experimental_nested_generic_types);
789789

790+
Opts.EnableClassResilience |=
791+
Args.hasArg(OPT_enable_class_resilience);
792+
790793
Opts.DisableAvailabilityChecking |=
791794
Args.hasArg(OPT_disable_availability_checking);
792795
if (FrontendOpts.InputKind == InputFileKind::IFK_SIL)

lib/IRGen/ClassMetadataLayout.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ template <class Impl> class ClassMetadataLayout : public MetadataLayout<Impl> {
8888
// Skip superclass fields if superclass is resilient.
8989
// FIXME: Needs runtime support to ensure the field offset vector is
9090
// populated correctly.
91-
/*if (!IGM.isResilient(superclassDecl, ResilienceExpansion::Maximal)) {*/
91+
if (!IGM.Context.LangOpts.EnableClassResilience ||
92+
!IGM.isResilient(superclassDecl, ResilienceExpansion::Maximal)) {
9293
addClassMembers(superclassDecl, superclass);
93-
/*}*/
94+
}
9495
}
9596

9697
// Add a reference to the parent class, if applicable.

lib/IRGen/GenClass.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,12 @@ namespace {
245245
//
246246
// FIXME: We need to implement indirect field/vtable entry access
247247
// before we can enable this
248-
/* ClassHasFixedFieldCount = false; */
249-
addFieldsForClass(superclass, superclassType);
250-
NumInherited = Elements.size();
248+
if (IGM.Context.LangOpts.EnableClassResilience) {
249+
ClassHasFixedFieldCount = false;
250+
} else {
251+
addFieldsForClass(superclass, superclassType);
252+
NumInherited = Elements.size();
253+
}
251254

252255
ClassHasFixedSize = false;
253256

test/IRGen/class_resilience.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -I %S/../Inputs -enable-source-import -emit-ir -enable-resilience %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
2-
// RUN: %target-swift-frontend -I %S/../Inputs -enable-source-import -emit-ir -enable-resilience -O %s
1+
// RUN: %target-swift-frontend -I %S/../Inputs -enable-source-import -emit-ir -enable-resilience -enable-class-resilience %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
2+
// RUN: %target-swift-frontend -I %S/../Inputs -enable-source-import -emit-ir -enable-resilience -enable-class-resilience -O %s
33

44
// CHECK: %swift.type = type { [[INT:i32|i64]] }
55

0 commit comments

Comments
 (0)