@@ -955,7 +955,8 @@ llvm::Optional<uint64_t> SwiftLanguageRuntimeImpl::GetMemberVariableOffset(
955
955
offset = GetMemberVariableOffsetRemoteMirrors (instance_type, instance,
956
956
member_name, error);
957
957
#ifndef NDEBUG
958
- {
958
+ if (ModuleList::GetGlobalModuleListProperties ()
959
+ .GetSwiftValidateTypeSystem ()) {
959
960
// Convert to an AST type, if necessary.
960
961
if (auto ts = instance_type.GetTypeSystem ()
961
962
.dyn_cast_or_null <TypeSystemSwiftTypeRef>())
@@ -1990,35 +1991,39 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
1990
1991
#ifndef NDEBUG
1991
1992
// Dynamic type resolution in RemoteAST might pull in other Swift modules, so
1992
1993
// use the scratch context where such operations are legal and safe.
1993
- llvm::Optional<SwiftScratchContextReader> maybe_scratch_ctx =
1994
- in_value.GetSwiftScratchContext ();
1995
- if (!maybe_scratch_ctx)
1996
- return false ;
1997
- auto scratch_ctx = maybe_scratch_ctx->get ();
1998
- if (!scratch_ctx)
1999
- return false ;
2000
- SwiftASTContext *swift_ast_ctx = scratch_ctx->GetSwiftASTContext ();
2001
- if (!swift_ast_ctx)
2002
- return true ;
1994
+ if (ModuleList::GetGlobalModuleListProperties ()
1995
+ .GetSwiftValidateTypeSystem ()) {
1996
+ llvm::Optional<SwiftScratchContextReader> maybe_scratch_ctx =
1997
+ in_value.GetSwiftScratchContext ();
1998
+ if (!maybe_scratch_ctx)
1999
+ return false ;
2000
+ auto scratch_ctx = maybe_scratch_ctx->get ();
2001
+ if (!scratch_ctx)
2002
+ return false ;
2003
+ SwiftASTContext *swift_ast_ctx = scratch_ctx->GetSwiftASTContext ();
2004
+ if (!swift_ast_ctx)
2005
+ return true ;
2003
2006
2004
- auto &remote_ast = GetRemoteASTContext (*swift_ast_ctx);
2005
- auto remote_ast_metadata_address = remote_ast.getHeapMetadataForObject (
2006
- swift::remote::RemoteAddress (instance_ptr));
2007
- if (remote_ast_metadata_address) {
2008
- auto instance_type = remote_ast.getTypeForRemoteTypeMetadata (
2009
- remote_ast_metadata_address.getValue (),
2010
- /* skipArtificial=*/ true );
2011
- if (instance_type) {
2012
- auto ref_type = ToCompilerType (instance_type.getValue ());
2013
- ConstString a = ref_type.GetMangledTypeName ();
2014
- ConstString b = class_type_or_name.GetCompilerType ().GetMangledTypeName ();
2015
- if (a != b)
2016
- llvm::dbgs () << " RemoteAST and runtime diverge " << a << " != " << b
2017
- << " \n " ;
2018
- } else {
2019
- if (log) {
2020
- log->Printf (" could not get type metadata: %s\n " ,
2021
- instance_type.getFailure ().render ().c_str ());
2007
+ auto &remote_ast = GetRemoteASTContext (*swift_ast_ctx);
2008
+ auto remote_ast_metadata_address = remote_ast.getHeapMetadataForObject (
2009
+ swift::remote::RemoteAddress (instance_ptr));
2010
+ if (remote_ast_metadata_address) {
2011
+ auto instance_type = remote_ast.getTypeForRemoteTypeMetadata (
2012
+ remote_ast_metadata_address.getValue (),
2013
+ /* skipArtificial=*/ true );
2014
+ if (instance_type) {
2015
+ auto ref_type = ToCompilerType (instance_type.getValue ());
2016
+ ConstString a = ref_type.GetMangledTypeName ();
2017
+ ConstString b =
2018
+ class_type_or_name.GetCompilerType ().GetMangledTypeName ();
2019
+ if (a != b)
2020
+ llvm::dbgs () << " RemoteAST and runtime diverge " << a << " != " << b
2021
+ << " \n " ;
2022
+ } else {
2023
+ if (log) {
2024
+ log->Printf (" could not get type metadata: %s\n " ,
2025
+ instance_type.getFailure ().render ().c_str ());
2026
+ }
2022
2027
}
2023
2028
}
2024
2029
}
@@ -2212,18 +2217,22 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
2212
2217
address.SetRawAddress (out_address.getAddressData ());
2213
2218
2214
2219
#ifndef NDEBUG
2215
- auto reference_pair = remote_ast_impl (use_local_buffer, existential_address);
2216
- assert (pair.hasValue () >= reference_pair.hasValue () &&
2217
- " RemoteAST and runtime diverge" );
2218
-
2219
- if (reference_pair) {
2220
- CompilerType ref_type = std::get<CompilerType>(*reference_pair);
2221
- Address ref_address = std::get<Address>(*reference_pair);
2222
- ConstString a = class_type_or_name.GetCompilerType ().GetMangledTypeName ();
2223
- ConstString b = ref_type.GetMangledTypeName ();
2224
- if (a != b)
2225
- llvm::dbgs () << " RemoteAST and runtime diverge " << a << " != " << b
2226
- << " \n " ;
2220
+ if (ModuleList::GetGlobalModuleListProperties ()
2221
+ .GetSwiftValidateTypeSystem ()) {
2222
+ auto reference_pair =
2223
+ remote_ast_impl (use_local_buffer, existential_address);
2224
+ assert (pair.hasValue () >= reference_pair.hasValue () &&
2225
+ " RemoteAST and runtime diverge" );
2226
+
2227
+ if (reference_pair) {
2228
+ CompilerType ref_type = std::get<CompilerType>(*reference_pair);
2229
+ Address ref_address = std::get<Address>(*reference_pair);
2230
+ ConstString a = class_type_or_name.GetCompilerType ().GetMangledTypeName ();
2231
+ ConstString b = ref_type.GetMangledTypeName ();
2232
+ if (a != b)
2233
+ llvm::dbgs () << " RemoteAST and runtime diverge " << a << " != " << b
2234
+ << " \n " ;
2235
+ }
2227
2236
}
2228
2237
#endif
2229
2238
return true ;
0 commit comments