Skip to content

Fix layering violation I introduced by putting _EmptyBoxStorage into the stubs library #10373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions stdlib/public/SwiftShims/GlobalObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ struct _SwiftHashingSecretKey _swift_stdlib_Hashing_secretKey;
SWIFT_RUNTIME_STDLIB_INTERFACE
__swift_uint64_t _swift_stdlib_HashingDetail_fixedSeedOverride;

struct _SwiftEmptyBoxStorage {
struct HeapObject header;
};

SWIFT_RUNTIME_STDLIB_INTERFACE
struct _SwiftEmptyBoxStorage _EmptyBoxStorage;

#ifdef __cplusplus

static_assert(std::is_pod<_SwiftEmptyArrayStorage>::value,
Expand Down
18 changes: 18 additions & 0 deletions stdlib/public/runtime/HeapObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ OpaqueValue *swift::swift_projectBox(HeapObject *o) {
return metadata->project(o);
}

namespace { // Begin anonymous namespace.

struct _SwiftEmptyBoxStorage {
HeapObject header;
};

swift::HeapLocalVariableMetadata _emptyBoxStorageMetadata;

/// The singleton empty box storage object.
_SwiftEmptyBoxStorage _EmptyBoxStorage = {
// HeapObject header;
{
&_emptyBoxStorageMetadata,
}
};

} // End anonymous namespace.

HeapObject *swift::swift_allocEmptyBox() {
auto heapObject = reinterpret_cast<HeapObject*>(&_EmptyBoxStorage);
SWIFT_RT_ENTRY_CALL(swift_retain)(heapObject);
Expand Down
11 changes: 0 additions & 11 deletions stdlib/public/stubs/GlobalObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,6 @@ void swift::_swift_instantiateInertHeapObject(void *address,
::new (address) HeapObject{metadata};
}

swift::HeapLocalVariableMetadata _emptyBoxStorageMetadata;

/// The signleton empty box storage object.
swift::_SwiftEmptyBoxStorage swift::_EmptyBoxStorage = {
// HeapObject header;
{
&_emptyBoxStorageMetadata,
}
};


namespace llvm { namespace hashing { namespace detail {
// An extern variable expected by LLVM's hashing templates. We don't link any
// LLVM libs into the runtime, so define this here.
Expand Down