Skip to content

Commit

Permalink
Delete unused existential value witnesses from the old existential
Browse files Browse the repository at this point in the history
implementation

And remove the SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS flag.
  • Loading branch information
aschwaighofer committed Jun 2, 2017
1 parent 032c18c commit ca63326
Show file tree
Hide file tree
Showing 56 changed files with 290 additions and 2,083 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,6 @@ option(SWIFT_STDLIB_ENABLE_RESILIENCE
"Build the standard libraries and overlays with resilience enabled; see docs/LibraryEvolution.rst"
FALSE)

option(SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS
"Build the runtime with a copy-on-write implementation for opaque existentials"
TRUE)

option(SWIFT_STDLIB_USE_NONATOMIC_RC
"Build the standard libraries and overlays with nonatomic reference count operations enabled"
FALSE)
Expand Down
4 changes: 0 additions & 4 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,6 @@ function(_add_swift_library_single target name)
endif()
endif()

if(SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS)
list(APPEND SWIFTLIB_SINGLE_C_COMPILE_FLAGS "-DSWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS=1")
endif()

if (SWIFT_COMPILER_VERSION)
is_darwin_based_sdk("${SWIFTLIB_SINGLE_SDK}" IS_DARWIN)
if(IS_DARWIN)
Expand Down
4 changes: 0 additions & 4 deletions cmake/modules/SwiftSource.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,6 @@ function(_compile_swift_files
list(APPEND swift_flags "-Xfrontend" "-assume-single-threaded")
endif()

if(SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS)
list(APPEND swift_flags "-Xfrontend" "-enable-cow-existentials")
endif()

if(SWIFT_STDLIB_ENABLE_SIL_OWNERSHIP AND SWIFTFILE_IS_STDLIB)
list(APPEND swift_flags "-Xfrontend" "-enable-sil-ownership")
endif()
Expand Down
7 changes: 0 additions & 7 deletions include/swift/AST/SILOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,6 @@ class SILOptions {
/// Assume that code will be executed in a single-threaded environment.
bool AssumeSingleThreaded = false;

/// Use the copy-on-write implementation for opaque existentials.
#ifdef SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS
bool UseCOWExistentials = true;
#else
bool UseCOWExistentials = false;
#endif

/// Indicates which sanitizer is turned on.
SanitizerKind Sanitize : 2;

Expand Down
54 changes: 4 additions & 50 deletions include/swift/IRGen/ValueWitness.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,41 +64,15 @@ namespace irgen {
/// This leaves us with 12 data operations, to which we add the
/// meta-operation 'sizeAndAlign' for a total of 13.
enum class ValueWitness : unsigned {
// destroyBuffer comes first because I expect it to be the most
// common operation (both by code size and occurrence), since it's
// the optimal way to destroy an individual local/temporary.
//
// Several other candidates that are likely to see use in
// existential code are then grouped together for cache-locality
// reasons.
// Candidates that are likely to see use in existential code are then grouped
// together for cache-locality reasons.

/// void (*destroyBuffer)(B *buffer, M *self);
///
/// Given a valid buffer which owns a valid object of this type,
/// destroy it. This can be decomposed as
/// self->destroy(self->projectBuffer(buffer), self);
/// self->deallocateBuffer(buffer), self);
DestroyBuffer,

/// T *(*initializeBufferWithCopyOfBuffer)(B *dest, B *src, M *self);
/// Given an invalid buffer, initialize it as a copy of the
/// object in the source buffer. This can be decomposed as:
/// initializeBufferWithCopy(dest, self->projectBuffer(src), self)
/// initializeWithCopy(self->allocateBuffer(dest, self), self->projectBuffer(src), self)
InitializeBufferWithCopyOfBuffer,

/// T *(*projectBuffer)(B *buffer, M *self);
///
/// Given an initialized fixed-size buffer, find its allocated
/// storage.
ProjectBuffer,

/// void (*deallocateBuffer)(B *buffer, M *self);
///
/// Given a buffer owning storage for an uninitialized object of this
/// type, deallocate the storage, putting the buffer in an invalid
/// state.
DeallocateBuffer, // likely along exception edges of initializers

/// void (*destroy)(T *object, witness_t *self);
///
/// Given a valid object of this type, destroy it, leaving it as an
Expand All @@ -107,12 +81,6 @@ enum class ValueWitness : unsigned {
/// struct, or tuple element.
Destroy,

/// T *(*initializeBufferWithCopy)(B *dest, T *src, M *self);
/// Given an invalid buffer, initialize it as a copy of the
/// source object. This can be decomposed as:
/// initializeWithCopy(self->allocateBuffer(dest, self), src, self)
InitializeBufferWithCopy,

/// T *(*initializeWithCopy)(T *dest, T *src, M *self);
///
/// Given an invalid object of this type, initialize it as a copy of
Expand All @@ -125,13 +93,6 @@ enum class ValueWitness : unsigned {
/// source object. Returns the dest object.
AssignWithCopy,

/// T *(*initializeBufferWithTake)(B *dest, T *src, M *self);
///
/// Given an invalid buffer, initialize it by taking the value
/// of the source object. The source object becomes invalid.
/// Returns the dest object.
InitializeBufferWithTake,

/// T *(*initializeWithTake)(T *dest, T *src, M *self);
///
/// Given an invalid object of this type, initialize it by taking
Expand All @@ -145,18 +106,11 @@ enum class ValueWitness : unsigned {
/// source object. The source object becomes invalid. Returns the
/// dest object.
AssignWithTake,

/// T *(*allocateBuffer)(B *buffer, M *self);
///
/// Given a buffer in an invalid state, make it the owner of storage
/// for an uninitialized object of this type. Return the address of
/// that object.
AllocateBuffer,

/// T *(*initializeBufferWithTakeOfBuffer)(B *dest, B *src, M *self);
/// Given an invalid buffer, initialize it by taking the value out of
/// the source buffer. This can be (inefficiently) decomposed as:
/// initializeBufferWithTake(dest, self->projectBuffer(src), self)
/// initializeWithTake(self->allocateBuffer(dest, self), self->projectBuffer(src), self)
/// deallocateBuffer(src, self)
InitializeBufferWithTakeOfBuffer,

Expand Down
4 changes: 0 additions & 4 deletions include/swift/Reflection/ReflectionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,12 @@ class ReflectionContext
if (!getReader().readInteger(ExistentialAddress, &BoxAddress))
return false;

#ifdef SWIFT_RUNTIME_ENABLE_COW_EXISTENTIALS
// Address = BoxAddress + (sizeof(HeapObject) + alignMask) & ~alignMask)
auto Alignment = InstanceTI->getAlignment();
auto StartOfValue = BoxAddress + getSizeOfHeapObject();
// Align.
StartOfValue += Alignment - StartOfValue % Alignment;
*OutInstanceAddress = RemoteAddress(StartOfValue);
#else
*OutInstanceAddress = RemoteAddress(BoxAddress);
#endif
}
return true;
}
Expand Down
79 changes: 0 additions & 79 deletions include/swift/Runtime/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,17 +311,6 @@ class ExtraInhabitantFlags {

namespace value_witness_types {

/// Given an initialized buffer, destroy its value and deallocate
/// the buffer. This can be decomposed as:
///
/// self->destroy(self->projectBuffer(buffer), self);
/// self->deallocateBuffer(buffer), self);
///
/// Preconditions:
/// 'buffer' is an initialized buffer
/// Postconditions:
/// 'buffer' is an unallocated buffer
typedef void destroyBuffer(ValueBuffer *buffer, const Metadata *self);

/// Given an unallocated buffer, initialize it as a copy of the
/// object in the source buffer. This can be decomposed as:
Expand All @@ -340,23 +329,6 @@ typedef OpaqueValue *initializeBufferWithCopyOfBuffer(ValueBuffer *dest,
ValueBuffer *src,
const Metadata *self);

/// Given an allocated or initialized buffer, derive a pointer to
/// the object.
///
/// Invariants:
/// 'buffer' is an allocated or initialized buffer
typedef OpaqueValue *projectBuffer(ValueBuffer *buffer,
const Metadata *self);

/// Given an allocated buffer, deallocate the object.
///
/// Preconditions:
/// 'buffer' is an allocated buffer
/// Postconditions:
/// 'buffer' is an unallocated buffer
typedef void deallocateBuffer(ValueBuffer *buffer,
const Metadata *self);

/// Given an initialized object, destroy it.
///
/// Preconditions:
Expand All @@ -366,21 +338,6 @@ typedef void deallocateBuffer(ValueBuffer *buffer,
typedef void destroy(OpaqueValue *object,
const Metadata *self);

/// Given an uninitialized buffer and an initialized object, allocate
/// storage in the buffer and copy the value there.
///
/// Returns the dest object.
///
/// Preconditions:
/// 'dest' is an uninitialized buffer
/// Postconditions:
/// 'dest' is an initialized buffer
/// Invariants:
/// 'src' is an initialized object
typedef OpaqueValue *initializeBufferWithCopy(ValueBuffer *dest,
OpaqueValue *src,
const Metadata *self);

/// Given an uninitialized object and an initialized object, copy
/// the value.
///
Expand Down Expand Up @@ -412,24 +369,6 @@ typedef OpaqueValue *assignWithCopy(OpaqueValue *dest,
OpaqueValue *src,
const Metadata *self);

/// Given an uninitialized buffer and an initialized object, move
/// the value from the object to the buffer, leaving the source object
/// uninitialized.
///
/// This operation does not need to be safe against 'dest' and 'src' aliasing.
///
/// Returns the dest object.
///
/// Preconditions:
/// 'dest' is an uninitialized buffer
/// 'src' is an initialized object
/// Postconditions:
/// 'dest' is an initialized buffer
/// 'src' is an uninitialized object
typedef OpaqueValue *initializeBufferWithTake(ValueBuffer *dest,
OpaqueValue *src,
const Metadata *self);

/// Given an uninitialized object and an initialized object, move
/// the value from one to the other, leaving the source object
/// uninitialized.
Expand Down Expand Up @@ -474,18 +413,6 @@ typedef OpaqueValue *assignWithTake(OpaqueValue *dest,
OpaqueValue *src,
const Metadata *self);

/// Given an uninitialized buffer, allocate an object.
///
/// Returns the uninitialized object.
///
/// Preconditions:
/// 'buffer' is an uninitialized buffer
/// Postconditions:
/// 'buffer' is an allocated buffer
typedef OpaqueValue *allocateBuffer(ValueBuffer *buffer,
const Metadata *self);


/// Given an unallocated buffer and an initialized buffer, move the
/// value from one buffer to the other, leaving the source buffer
/// unallocated.
Expand Down Expand Up @@ -646,18 +573,12 @@ OpaqueValue *swift_copyPOD(OpaqueValue *dest,
const Metadata *self);

#define FOR_ALL_FUNCTION_VALUE_WITNESSES(MACRO) \
MACRO(destroyBuffer) \
MACRO(initializeBufferWithCopyOfBuffer) \
MACRO(projectBuffer) \
MACRO(deallocateBuffer) \
MACRO(destroy) \
MACRO(initializeBufferWithCopy) \
MACRO(initializeWithCopy) \
MACRO(assignWithCopy) \
MACRO(initializeBufferWithTake) \
MACRO(initializeWithTake) \
MACRO(assignWithTake) \
MACRO(allocateBuffer) \
MACRO(initializeBufferWithTakeOfBuffer) \
MACRO(destroyArray) \
MACRO(initializeArrayWithCopy) \
Expand Down
4 changes: 0 additions & 4 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,10 +1420,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
parseExclusivityEnforcementOptions(A, Opts, Diags);
}

/// Should we use the copy-on-write implementation of opaque existentials.
/// FIXME: Use during bootstraping this feature. Remove later.
Opts.UseCOWExistentials |= Args.hasArg(OPT_enable_cow_existentials);

return false;
}

Expand Down
Loading

0 comments on commit ca63326

Please sign in to comment.