mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user