re-apply r26871: stdlib: Do the Array fast-path check with a single array property call.

Changes compared to the original version:
I fixed the 2 bugs and added a test for the so far undetected missing range check bug.
To keep the SIL simple (4 basic blocks for arr[x]) I extracted the slow path for getElement into a
non-inlinable function.
On the other hand I inlined _typeCheck into the slow-path function.
This speeds up NSArray accesses because now only a single objectAtIndex is required for both
type checking and element retrieving.

Update on performance: DeltaBlue is now only 12% better (and not 25%). I suspect this is because
now Arnold's tail duplication cannot detect the ObjC call in the slow path.



Swift SVN r26935
This commit is contained in:
Erik Eckstein
2015-04-03 06:48:25 +00:00
parent 283b08c511
commit 2f971c22cb
11 changed files with 156 additions and 127 deletions

View File

@@ -45,7 +45,7 @@ bool swift::ArraySemanticsCall::isValidSignature() {
// All other calls can be consider valid.
default: break;
case ArrayCallKind::kArrayPropsIsNative:
case ArrayCallKind::kArrayPropsNeedsTypeCheck: {
case ArrayCallKind::kArrayPropsIsNativeNoDTC: {
// @guaranteed/@owned Self
if (SemanticsCall->getNumArguments() != 1)
return false;
@@ -120,8 +120,8 @@ ArrayCallKind swift::ArraySemanticsCall::getKind() const {
auto Kind =
llvm::StringSwitch<ArrayCallKind>(F->getSemanticsString())
.Case("array.props.isNative", ArrayCallKind::kArrayPropsIsNative)
.Case("array.props.needsElementTypeCheck",
ArrayCallKind::kArrayPropsNeedsTypeCheck)
.Case("array.props.isNativeNoDTC",
ArrayCallKind::kArrayPropsIsNativeNoDTC)
.Case("array.init", ArrayCallKind::kArrayInit)
.Case("array.uninitialized", ArrayCallKind::kArrayUninitialized)
.Case("array.check_subscript", ArrayCallKind::kCheckSubscript)
@@ -211,7 +211,7 @@ bool swift::ArraySemanticsCall::canHoist(SILInstruction *InsertBefore,
case ArrayCallKind::kCheckIndex:
case ArrayCallKind::kArrayPropsIsNative:
case ArrayCallKind::kArrayPropsNeedsTypeCheck:
case ArrayCallKind::kArrayPropsIsNativeNoDTC:
case ArrayCallKind::kGetElementAddress:
return canHoistArrayArgument(SemanticsCall, getSelf(), InsertBefore, DT);
@@ -333,7 +333,7 @@ ApplyInst *swift::ArraySemanticsCall::hoistOrCopy(SILInstruction *InsertBefore,
auto Kind = getKind();
switch (Kind) {
case ArrayCallKind::kArrayPropsIsNative:
case ArrayCallKind::kArrayPropsNeedsTypeCheck: {
case ArrayCallKind::kArrayPropsIsNativeNoDTC: {
assert(SemanticsCall->getNumArguments() == 1 &&
"Expect 'self' parameter only");