Skip to content

Commit ff35f4c

Browse files
authored
---
yaml --- r: 261887 b: refs/heads/tensorflow c: 8664da6 h: refs/heads/master i: 261885: a5ff983 261883: 2eea84c 261879: dfa42f4 261871: d36e890 261855: d7f4460 261823: 9ce570d 261759: 3c26bf4 261631: 64688f3
1 parent f9b76c7 commit ff35f4c

File tree

130 files changed

+1321
-837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+1321
-837
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
818818
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
819819
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
820820
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
821-
refs/heads/tensorflow: dd08f6aa775b5069c155db0905d0f4d6a8fb95aa
821+
refs/heads/tensorflow: 8664da6d9d50e66820013b96bc6e2582935bc3fe
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
823823
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
824824
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/benchmark/single-source/ObjectiveCBridgingStubs.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public let ObjectiveCBridgingStubs = [
3737
BenchmarkInfo(name: "ObjectiveCBridgeStringRangeOfString", runFunction: run_ObjectiveCBridgeStringRangeOfString, tags: [.validation, .String, .bridging], setUpFunction: setup_StringBridgeBenchmark),
3838
BenchmarkInfo(name: "ObjectiveCBridgeStringHash", runFunction: run_ObjectiveCBridgeStringHash, tags: [.validation, .String, .bridging], setUpFunction: setup_StringBridgeBenchmark),
3939
BenchmarkInfo(name: "ObjectiveCBridgeStringUTF8String", runFunction: run_ObjectiveCBridgeStringUTF8String, tags: [.validation, .String, .bridging], setUpFunction: setup_StringBridgeBenchmark),
40+
BenchmarkInfo(name: "ObjectiveCBridgeStringCStringUsingEncoding", runFunction: run_ObjectiveCBridgeStringCStringUsingEncoding, tags: [.validation, .String, .bridging], setUpFunction: setup_StringBridgeBenchmark),
4041
]
4142

4243
var b:BridgeTester! = nil
@@ -387,6 +388,17 @@ public func run_ObjectiveCBridgeStringUTF8String(N: Int) {
387388
#endif
388389
}
389390

391+
@inline(never)
392+
public func run_ObjectiveCBridgeStringCStringUsingEncoding(N: Int) {
393+
#if _runtime(_ObjC)
394+
for _ in 0 ..< N {
395+
autoreleasepool {
396+
b.testCStringUsingEncoding()
397+
}
398+
}
399+
#endif
400+
}
401+
390402
@inline(never)
391403
public func setup_StringBridgeBenchmark() {
392404
#if _runtime(_ObjC)

branches/tensorflow/benchmark/utils/ObjectiveCTests/ObjectiveCTests.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
3838
- (void)testIsEqualToString2;
3939
- (void)testIsEqualToStringAllSwift;
4040
- (void)testUTF8String;
41+
- (void)testCStringUsingEncoding;
4142
- (void)testGetUTF8Contents;
4243
- (void)testGetASCIIContents;
4344
- (void)testRangeOfString;

branches/tensorflow/benchmark/utils/ObjectiveCTests/ObjectiveCTests.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,30 @@ - (void)testUTF8String {
249249
}
250250
}
251251

252+
- (void)testCStringUsingEncoding {
253+
for (NSString *str1 in bridgedStrings) {
254+
@autoreleasepool {
255+
for (int i = 0; i < 100; i++) {
256+
(void)[str1 cStringUsingEncoding: NSASCIIStringEncoding];
257+
}
258+
}
259+
}
260+
for (NSString *str1 in bridgedStrings) {
261+
@autoreleasepool {
262+
for (int i = 0; i < 100; i++) {
263+
(void)[str1 cStringUsingEncoding: NSUTF8StringEncoding];
264+
}
265+
}
266+
}
267+
for (NSString *str1 in bridgedStrings) {
268+
@autoreleasepool {
269+
for (int i = 0; i < 100; i++) {
270+
(void)[str1 cStringUsingEncoding: NSUnicodeStringEncoding];
271+
}
272+
}
273+
}
274+
}
275+
252276
- (void)testGetUTF8Contents {
253277
for (NSString *str1 in bridgedStrings) {
254278
for (int i = 0; i < 200; i++) {

branches/tensorflow/docs/ABI/Mangling.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ types where the metadata itself has unknown layout.)
183183
global ::= type label-list? 'D' // type mangling for the debugger with label list for function types.
184184
global ::= type 'TC' // continuation prototype (not actually used for real symbols)
185185
global ::= protocol-conformance entity 'TW' // protocol witness thunk
186-
global ::= protocol-conformance entity 'TS' // protocol self-conformance witness thunk
186+
global ::= entity 'TS' // protocol self-conformance witness thunk
187187
global ::= context identifier identifier 'TB' // property behavior initializer thunk (not used currently)
188188
global ::= context identifier identifier 'Tb' // property behavior setter thunk (not used currently)
189189
global ::= global specialization // function specialization

branches/tensorflow/include/swift/ABI/Metadata.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2083,10 +2083,10 @@ struct TargetTypeMetadataRecord {
20832083
const TargetTypeContextDescriptor<Runtime> *
20842084
getTypeContextDescriptor() const {
20852085
switch (getTypeKind()) {
2086-
case TypeReferenceKind::DirectNominalTypeDescriptor:
2086+
case TypeReferenceKind::DirectTypeDescriptor:
20872087
return DirectNominalTypeDescriptor.getPointer();
20882088

2089-
case TypeReferenceKind::IndirectNominalTypeDescriptor:
2089+
case TypeReferenceKind::IndirectTypeDescriptor:
20902090
return *IndirectNominalTypeDescriptor.getPointer();
20912091

20922092
// These types (and any others we might add to TypeReferenceKind
@@ -2172,14 +2172,14 @@ class RelativeTargetProtocolDescriptorPointer {
21722172
template <typename Runtime>
21732173
struct TargetTypeReference {
21742174
union {
2175-
/// A direct reference to a nominal type descriptor.
2176-
RelativeDirectPointer<TargetTypeContextDescriptor<Runtime>>
2177-
DirectNominalTypeDescriptor;
2175+
/// A direct reference to a TypeContextDescriptor or ProtocolDescriptor.
2176+
RelativeDirectPointer<TargetContextDescriptor<Runtime>>
2177+
DirectTypeDescriptor;
21782178

2179-
/// An indirect reference to a nominal type descriptor.
2179+
/// An indirect reference to a TypeContextDescriptor or ProtocolDescriptor.
21802180
RelativeDirectPointer<
2181-
ConstTargetMetadataPointer<Runtime, TargetTypeContextDescriptor>>
2182-
IndirectNominalTypeDescriptor;
2181+
ConstTargetMetadataPointer<Runtime, TargetContextDescriptor>>
2182+
IndirectTypeDescriptor;
21832183

21842184
/// An indirect reference to an Objective-C class.
21852185
RelativeDirectPointer<
@@ -2191,14 +2191,14 @@ struct TargetTypeReference {
21912191
DirectObjCClassName;
21922192
};
21932193

2194-
const TargetTypeContextDescriptor<Runtime> *
2195-
getTypeContextDescriptor(TypeReferenceKind kind) const {
2194+
const TargetContextDescriptor<Runtime> *
2195+
getTypeDescriptor(TypeReferenceKind kind) const {
21962196
switch (kind) {
2197-
case TypeReferenceKind::DirectNominalTypeDescriptor:
2198-
return DirectNominalTypeDescriptor;
2197+
case TypeReferenceKind::DirectTypeDescriptor:
2198+
return DirectTypeDescriptor;
21992199

2200-
case TypeReferenceKind::IndirectNominalTypeDescriptor:
2201-
return *IndirectNominalTypeDescriptor;
2200+
case TypeReferenceKind::IndirectTypeDescriptor:
2201+
return *IndirectTypeDescriptor;
22022202

22032203
case TypeReferenceKind::DirectObjCClassName:
22042204
case TypeReferenceKind::IndirectObjCClass:
@@ -2305,8 +2305,8 @@ struct TargetProtocolConformanceDescriptor final
23052305
return TypeRef.getIndirectObjCClass(getTypeKind());
23062306
}
23072307

2308-
const TargetTypeContextDescriptor<Runtime> *getTypeContextDescriptor() const {
2309-
return TypeRef.getTypeContextDescriptor(getTypeKind());
2308+
const TargetContextDescriptor<Runtime> *getTypeDescriptor() const {
2309+
return TypeRef.getTypeDescriptor(getTypeKind());
23102310
}
23112311

23122312
/// Retrieve the context of a retroactive conformance.

branches/tensorflow/include/swift/ABI/MetadataValues.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,12 @@ enum : unsigned {
380380
/// Kinds of type metadata/protocol conformance records.
381381
enum class TypeReferenceKind : unsigned {
382382
/// The conformance is for a nominal type referenced directly;
383-
/// getNominalTypeDescriptor() points to the nominal type descriptor.
384-
DirectNominalTypeDescriptor = 0x00,
383+
/// getTypeDescriptor() points to the type context descriptor.
384+
DirectTypeDescriptor = 0x00,
385385

386386
/// The conformance is for a nominal type referenced indirectly;
387-
/// getNominalTypeDescriptor() points to the nominal type descriptor.
388-
IndirectNominalTypeDescriptor = 0x01,
387+
/// getTypeDescriptor() points to the type context descriptor.
388+
IndirectTypeDescriptor = 0x01,
389389

390390
/// The conformance is for an Objective-C class that should be looked up
391391
/// by class name.
@@ -402,7 +402,7 @@ enum class TypeReferenceKind : unsigned {
402402

403403
// We only reserve three bits for this in the various places we store it.
404404

405-
First_Kind = DirectNominalTypeDescriptor,
405+
First_Kind = DirectTypeDescriptor,
406406
Last_Kind = IndirectObjCClass,
407407
};
408408

branches/tensorflow/include/swift/AST/DiagnosticsCommon.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ NOTE(profile_read_error,none,
9595
ERROR(generic_signature_not_minimal,none,
9696
"generic requirement '%0' is redundant in %1", (StringRef, StringRef))
9797

98+
WARNING(protocol_extension_redundant_requirement,none,
99+
"requirement of '%1' to '%2' is redundant in an extension of '%0'",
100+
(StringRef, StringRef, StringRef))
101+
98102
ERROR(attr_only_on_parameters, none,
99103
"'%0' may only be used on parameters", (StringRef))
100104

branches/tensorflow/include/swift/AST/ProtocolConformance.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,33 @@ class RootProtocolConformance : public ProtocolConformance {
364364
ConcreteDeclRef getWitnessDeclRef(ValueDecl *requirement,
365365
LazyResolver *resolver) const;
366366

367+
/// Apply the given function object to each value witness within this
368+
/// protocol conformance.
369+
///
370+
/// The function object should accept a \c ValueDecl* for the requirement
371+
/// followed by the \c Witness for the witness. Note that a generic
372+
/// witness will only be specialized if the conformance came from the current
373+
/// file.
374+
template<typename F>
375+
void forEachValueWitness(LazyResolver *resolver, F f) const {
376+
const ProtocolDecl *protocol = getProtocol();
377+
for (auto req : protocol->getMembers()) {
378+
auto valueReq = dyn_cast<ValueDecl>(req);
379+
if (!valueReq || isa<AssociatedTypeDecl>(valueReq) ||
380+
valueReq->isInvalid())
381+
continue;
382+
383+
if (!valueReq->isProtocolRequirement())
384+
continue;
385+
386+
// If we don't have and cannot resolve witnesses, skip it.
387+
if (!resolver && !hasWitness(valueReq))
388+
continue;
389+
390+
f(valueReq, getWitness(valueReq, resolver));
391+
}
392+
}
393+
367394
static bool classof(const ProtocolConformance *conformance) {
368395
return conformance->getKind() == ProtocolConformanceKind::Normal ||
369396
conformance->getKind() == ProtocolConformanceKind::Self;
@@ -639,33 +666,6 @@ class NormalProtocolConformance : public RootProtocolConformance,
639666
/// Set the witness for the given requirement.
640667
void setWitness(ValueDecl *requirement, Witness witness) const;
641668

642-
/// Apply the given function object to each value witness within this
643-
/// protocol conformance.
644-
///
645-
/// The function object should accept a \c ValueDecl* for the requirement
646-
/// followed by the \c Witness for the witness. Note that a generic
647-
/// witness will only be specialized if the conformance came from the current
648-
/// file.
649-
template<typename F>
650-
void forEachValueWitness(LazyResolver *resolver, F f) const {
651-
const ProtocolDecl *protocol = getProtocol();
652-
for (auto req : protocol->getMembers()) {
653-
auto valueReq = dyn_cast<ValueDecl>(req);
654-
if (!valueReq || isa<AssociatedTypeDecl>(valueReq) ||
655-
valueReq->isInvalid())
656-
continue;
657-
658-
if (!valueReq->isProtocolRequirement())
659-
continue;
660-
661-
// If we don't have and cannot resolve witnesses, skip it.
662-
if (!resolver && !hasWitness(valueReq))
663-
continue;
664-
665-
f(valueReq, getWitness(valueReq, resolver));
666-
}
667-
}
668-
669669
/// Retrieve the protocol conformances that satisfy the requirements of the
670670
/// protocol, which line up with the conformance constraints in the
671671
/// protocol's requirement signature.

branches/tensorflow/include/swift/IRGen/Linking.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ class LinkEntity {
676676
}
677677

678678
static LinkEntity forPropertyDescriptor(AbstractStorageDecl *decl) {
679+
assert(decl->exportsPropertyDescriptor());
679680
LinkEntity entity;
680681
entity.setForDecl(Kind::PropertyDescriptor, decl);
681682
return entity;

branches/tensorflow/include/swift/Remote/MetadataReader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ class MetadataReader {
790790
const MetadataFn &metadataFn,
791791
const ClassNameFn &classNameFn) {
792792
switch (refKind) {
793-
case TypeReferenceKind::IndirectNominalTypeDescriptor: {
793+
case TypeReferenceKind::IndirectTypeDescriptor: {
794794
StoredPointer descriptorAddress = 0;
795795
if (!Reader->readInteger(RemoteAddress(ref), &descriptorAddress))
796796
return None;
@@ -799,7 +799,7 @@ class MetadataReader {
799799
LLVM_FALLTHROUGH;
800800
}
801801

802-
case TypeReferenceKind::DirectNominalTypeDescriptor: {
802+
case TypeReferenceKind::DirectTypeDescriptor: {
803803
auto descriptor = readContextDescriptor(ref);
804804
if (!descriptor)
805805
return None;

branches/tensorflow/include/swift/SIL/SILLinkage.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ enum class SubclassScope : uint8_t {
118118
/// This class can only be subclassed in this module.
119119
Internal,
120120

121+
/// This class is resilient so even public methods cannot be directly
122+
/// referenced from outside the module.
123+
Resilient,
124+
121125
/// There is no class to subclass, or it is final.
122126
NotApplicable,
123127
};
@@ -250,6 +254,11 @@ inline SILLinkage effectiveLinkageForClassMember(SILLinkage linkage,
250254
return SILLinkage::Hidden;
251255
break;
252256

257+
case SubclassScope::Resilient:
258+
if (isAvailableExternally(linkage))
259+
return SILLinkage::HiddenExternal;
260+
return SILLinkage::Hidden;
261+
253262
case SubclassScope::NotApplicable:
254263
break;
255264
}

branches/tensorflow/lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ std::string ASTMangler::mangleWitnessThunk(
201201
beginMangling();
202202
// Concrete witness thunks get a special mangling.
203203
if (Conformance) {
204-
if (auto selfConformance = dyn_cast<SelfProtocolConformance>(Conformance)) {
205-
auto protocol = cast<SelfProtocolConformance>(Conformance)->getProtocol();
206-
appendProtocolName(protocol);
207-
} else {
204+
if (!isa<SelfProtocolConformance>(Conformance)) {
208205
appendProtocolConformance(Conformance);
209206
}
210207
}

branches/tensorflow/lib/AST/Decl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5335,6 +5335,9 @@ bool AbstractFunctionDecl::isObjCInstanceMethod() const {
53355335
}
53365336

53375337
static bool requiresNewVTableEntry(const AbstractFunctionDecl *decl) {
5338+
if (!isa<ClassDecl>(decl->getDeclContext()))
5339+
return true;
5340+
53385341
assert(isa<FuncDecl>(decl) || isa<ConstructorDecl>(decl));
53395342

53405343
// Final members are always be called directly.

branches/tensorflow/lib/Demangling/Remangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,7 @@ void Remangler::mangleProtocolRequirementsBaseDescriptor(Node *node) {
17201720
}
17211721

17221722
void Remangler::mangleProtocolSelfConformanceDescriptor(Node *node) {
1723-
mangleProtocol(node->getChild(0));
1723+
manglePureProtocol(node->getChild(0));
17241724
Buffer << "MS";
17251725
}
17261726

branches/tensorflow/lib/IRGen/GenDecl.cpp

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,22 +2530,30 @@ IRGenModule::getAddrOfLLVMVariableOrGOTEquivalent(LinkEntity entity,
25302530
}
25312531

25322532
static TypeEntityReference
2533-
getTypeContextDescriptorEntityReference(IRGenModule &IGM,
2534-
NominalTypeDecl *decl) {
2535-
// A reference to a concrete type.
2533+
getContextDescriptorEntityReference(IRGenModule &IGM, const LinkEntity &entity){
25362534
// TODO: consider using a symbolic reference (i.e. a symbol string
25372535
// to be looked up dynamically) for types defined outside the module.
2538-
auto kind = TypeReferenceKind::DirectNominalTypeDescriptor;
2539-
auto entity = LinkEntity::forNominalTypeDescriptor(decl);
2540-
2541-
IGM.IRGen.noteUseOfTypeContextDescriptor(decl, DontRequireMetadata);
25422536
auto ref = IGM.getAddrOfLLVMVariableOrGOTEquivalent(entity);
2537+
auto kind = ref.isIndirect()
2538+
? TypeReferenceKind::IndirectTypeDescriptor
2539+
: TypeReferenceKind::DirectTypeDescriptor;
2540+
return TypeEntityReference(kind, ref.getValue());
2541+
}
25432542

2544-
if (ref.isIndirect()) {
2545-
kind = TypeReferenceKind::IndirectNominalTypeDescriptor;
2546-
}
2543+
static TypeEntityReference
2544+
getTypeContextDescriptorEntityReference(IRGenModule &IGM,
2545+
NominalTypeDecl *decl) {
2546+
auto entity = LinkEntity::forNominalTypeDescriptor(decl);
2547+
IGM.IRGen.noteUseOfTypeContextDescriptor(decl, DontRequireMetadata);
2548+
return getContextDescriptorEntityReference(IGM, entity);
2549+
}
25472550

2548-
return TypeEntityReference(kind, ref.getValue());
2551+
static TypeEntityReference
2552+
getProtocolDescriptorEntityReference(IRGenModule &IGM, ProtocolDecl *protocol) {
2553+
assert(!protocol->isObjC() &&
2554+
"objc protocols don't have swift protocol descriptors");
2555+
auto entity = LinkEntity::forProtocolDescriptor(protocol);
2556+
return getContextDescriptorEntityReference(IGM, entity);
25492557
}
25502558

25512559
static TypeEntityReference
@@ -2577,6 +2585,11 @@ getRuntimeOnlyClassEntityReference(IRGenModule &IGM, ClassDecl *cls) {
25772585

25782586
TypeEntityReference
25792587
IRGenModule::getTypeEntityReference(NominalTypeDecl *decl) {
2588+
if (auto protocol = dyn_cast<ProtocolDecl>(decl)) {
2589+
assert(!protocol->isObjC() && "imported protocols not handled here");
2590+
return getProtocolDescriptorEntityReference(*this, protocol);
2591+
}
2592+
25802593
auto clas = dyn_cast<ClassDecl>(decl);
25812594
if (!clas) {
25822595
return getTypeContextDescriptorEntityReference(*this, decl);

0 commit comments

Comments
 (0)