This should help to optimize the range check in isValidSubscript to a single unsigned integer comparison.
But this is not done yet, because it also needs an optimization in llvm, which I'm currently working on.
Together with the llvm change there will be an performance improvement for array benchmarks, where the
range check cannot be hoisted out of a loop. E.g. ~ +30% on QuickSort.
Swift SVN r23583
It returns the argument and specifies that the value is not negative.
It has only an effect if the argument is a load or call.
The effect of this builtin is that for the load/call argument a positive range metadata is created in llvm ir.
I also added a public function _assumeNonNegative(x: Int) -> Int in the stdlib.
To be on the save side, I prefixed it with an underscore. But maybe it makes sense to make it available for all users.
Swift SVN r23582
This is just a basic implementation of each, with some questions
lingering about whether to do unicode normalization (and if so how),
but it gets things going.
Swift SVN r23572
This name is more consistent with the convention used throughout the
runtime: use underscores to separate the preconditions of partial
functions from the rest of their names.
Swift SVN r23505
the ARC optimizer does not handle loops well, and so can get blocked by
the presence of a loop over the range. Therefore, add a single-element
check for the common case where we're not slicing.
Swift SVN r23502
When there's static knowledge that no spare bits are to be set, it's
faster to use that knowledge. We need a proper builtin to let us drop
the reinterpretCasts.
Swift SVN r23465
Naturally, the fast path for things like Array<Int> has to be that no
masking is required to get at the buffer. Therefore, the state with no
spare bits set needs to be reserved for native objects. After the
change, an ObjC non-tagged pointer is stored with all spare bits set, and
native objects are stored with 0..<N bits set, where N is the number of
spare bits. ObjC tagged pointers are still stored verbatim.
Swift SVN r23430
Stop trafficking in optionals and using checked arithmetic; the
optimizer doesn't like that. Also drop a needless cast, fix up some
names, and accept a native 2nd argument. Only classes imported from
ObjC actually have non-native refcounting, and we don't really care
about enforcing that for the 2nd argument. It's just expected to be a
possibly-non-native class.
Swift SVN r23396
That this code is dead implies we are throwing away the knowledge that
we have a native buffer whenever we downcast an array. That'll be fixed
when the array buffer simplification goes in.
Swift SVN r23350
Renames swift_class_getInstanceSize to
swift_class_getInstancePositiveExtentSize to reflect that it is
the size of the object after the instance address point.
Swift SVN r23333
This is acting as a temporary work around until the more general
getTypeKind() is finalized from an API perspective.
The reason that removing this now instead of waiting makes sense is:
1. The previous way playgrounds was performing this check was using the runtime
c++ implementation of swift_isClassOrObjCExistential via @asmname. We
want to move away from the @asmname approach in general since it is
brittle since it leads to loose cupling of dependencies.
2. The @asmname version in playgrounds caused the deserializer to assert since
the c++ version of swift_isClassOrObjCExistential() does not match the signature
of the swift declaration of swift_isClassOrObjCExistential().
This allows us to avoid the aforementioned issues and make forward
progress on re-enabling the playground logger with optimization.
rdar://18841292
Swift SVN r23307
The interposed line directive comment "// #line ..." prevents Swift from
associating the doc comment with the declaration. Tested, this time,
and everything!
Swift SVN r23260
Fixes rdar://problem/17229052
Make it clear C_ARGV var is unsafe.
Made it impossible to set the argc/unsafeArgv outside of the stdlib.
Refactored tests to not use C_ARG{C,V}.
Made C_ARG{C,V} unavailable.
Swift SVN r23249
This adds an analysis to the compiler that identifies types that are may store
to memory on destruction.
It adds a compiler known protocol _DestructorSafeContainer that allows the
standard library to identify containers whose destructor's memory effects
depends strictly on the type parameters of the container.
Array<T> : _DestructorSafeContainer {} may not store to memory during
destruction if the bound T is a type that does not store to memory on
destruction.
This is needed to deduce that for example Array<Array<Int>> is does not store to
memory on destruction (e.g during a call to release).
rdar://18940376
Swift SVN r23242