Skip to content

Commit ba777cd

Browse files
committed
---
yaml --- r: 344639 b: refs/heads/master c: 233f864 h: refs/heads/master i: 344637: 94a336e 344635: dc1b11d 344631: 4dadcc5 344623: 01fcb9c 344607: 35f2bb3 344575: 14c44e4
1 parent 284dfde commit ba777cd

Some content is hidden

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

41 files changed

+355
-881
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e5b31c4e1ec5986ae9aadad6297b1eb62af29bf2
2+
refs/heads/master: 233f8645d1f8b82827278b2c8dfff902c2645765
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/cmake/modules/SwiftSource.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ function(_compile_swift_files
326326
set(sib_file "${module_base}.Onone.sib")
327327
set(sibopt_file "${module_base}.O.sib")
328328
set(sibgen_file "${module_base}.sibgen")
329+
list(APPEND swift_module_flags
330+
"-emit-module-source-info-path" "${source_info_file}")
329331

330332
if(SWIFT_ENABLE_MODULE_INTERFACES)
331333
set(interface_file "${module_base}.swiftinterface")
@@ -499,7 +501,6 @@ function(_compile_swift_files
499501
COMMAND
500502
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
501503
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}"
502-
"-emit-module-source-info-path" "${source_info_file}"
503504
${swift_flags} ${swift_module_flags} "@${file_path}"
504505
${command_touch_module_outputs}
505506
OUTPUT ${module_outputs}

trunk/include/swift/AST/Decl.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5689,8 +5689,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
56895689
/// Note that a true return value does not imply that the body was actually
56905690
/// parsed.
56915691
bool hasBody() const {
5692-
return getBodyKind() != BodyKind::None &&
5693-
getBodyKind() != BodyKind::Skipped;
5692+
return getBodyKind() != BodyKind::None;
56945693
}
56955694

56965695
/// Returns true if the text of this function's body can be retrieved either
@@ -5717,22 +5716,14 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57175716
/// Note that the body was skipped for this function. Function body
57185717
/// cannot be attached after this call.
57195718
void setBodySkipped(SourceRange bodyRange) {
5720-
// FIXME: Remove 'Parsed' from this once we can delay parsing function
5721-
// bodies. Right now -experimental-skip-non-inlinable-function-bodies
5722-
// requires being able to change the state from Parsed to Skipped,
5723-
// because we're still eagerly parsing function bodies.
5724-
assert(getBodyKind() == BodyKind::None ||
5725-
getBodyKind() == BodyKind::Unparsed ||
5726-
getBodyKind() == BodyKind::Parsed);
5727-
assert(bodyRange.isValid());
5719+
assert(getBodyKind() == BodyKind::None);
57285720
BodyRange = bodyRange;
57295721
setBodyKind(BodyKind::Skipped);
57305722
}
57315723

57325724
/// Note that parsing for the body was delayed.
57335725
void setBodyDelayed(SourceRange bodyRange) {
57345726
assert(getBodyKind() == BodyKind::None);
5735-
assert(bodyRange.isValid());
57365727
BodyRange = bodyRange;
57375728
setBodyKind(BodyKind::Unparsed);
57385729
}
@@ -5778,10 +5769,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57785769
return getBodyKind() == BodyKind::TypeChecked;
57795770
}
57805771

5781-
bool isBodySkipped() const {
5782-
return getBodyKind() == BodyKind::Skipped;
5783-
}
5784-
57855772
bool isMemberwiseInitializer() const {
57865773
return getBodyKind() == BodyKind::MemberwiseInitializer;
57875774
}

trunk/include/swift/AST/DeclContext.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,6 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
409409
const_cast<DeclContext *>(this)->getInnermostDeclarationDeclContext();
410410
}
411411

412-
/// Returns the innermost context that is an AbstractFunctionDecl whose
413-
/// body has been skipped.
414-
LLVM_READONLY
415-
DeclContext *getInnermostSkippedFunctionContext();
416-
const DeclContext *getInnermostSkippedFunctionContext() const {
417-
return
418-
const_cast<DeclContext *>(this)->getInnermostSkippedFunctionContext();
419-
}
420-
421412
/// Returns the semantic parent of this context. A context has a
422413
/// parent if and only if it is not a module context.
423414
DeclContext *getParent() const {

trunk/include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ ERROR(error_mode_cannot_emit_module_source_info,none,
128128
"this mode does not support emitting module source info files", ())
129129
ERROR(error_mode_cannot_emit_interface,none,
130130
"this mode does not support emitting module interface files", ())
131-
ERROR(cannot_emit_ir_skipping_function_bodies,none,
132-
"-experimental-skip-non-inlinable-function-bodies does not support "
133-
"emitting IR", ())
134131

135132
WARNING(emit_reference_dependencies_without_primary_file,none,
136133
"ignoring -emit-reference-dependencies (requires -primary-file)", ())

trunk/include/swift/AST/SILOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ class SILOptions {
7070
/// Whether to stop the optimization pipeline after serializing SIL.
7171
bool StopOptimizationAfterSerialization = false;
7272

73-
/// Whether to skip emitting non-inlinable function bodies.
74-
bool SkipNonInlinableFunctionBodies = false;
75-
7673
/// Optimization mode being used.
7774
OptimizationMode OptMode = OptimizationMode::NotSet;
7875

trunk/include/swift/Frontend/FrontendOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ class FrontendOptions {
180180
/// \sa swift::SharedTimer
181181
bool DebugTimeCompilation = false;
182182

183-
bool SkipNonInlinableFunctionBodies = false;
184-
185183
/// The path to which we should output statistics files.
186184
std::string StatsOutputDir;
187185

@@ -341,7 +339,6 @@ class FrontendOptions {
341339

342340
public:
343341
static bool doesActionGenerateSIL(ActionType);
344-
static bool doesActionGenerateIR(ActionType);
345342
static bool doesActionProduceOutput(ActionType);
346343
static bool doesActionProduceTextualOutput(ActionType);
347344
static bool needsProperModuleName(ActionType);

trunk/include/swift/Option/Options.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,6 @@ def stats_output_dir: Separate<["-"], "stats-output-dir">,
254254
def trace_stats_events: Flag<["-"], "trace-stats-events">,
255255
Flags<[FrontendOption, HelpHidden]>,
256256
HelpText<"Trace changes to stats in -stats-output-dir">;
257-
def experimental_skip_non_inlinable_function_bodies:
258-
Flag<["-"], "experimental-skip-non-inlinable-function-bodies">,
259-
Flags<[FrontendOption, HelpHidden]>,
260-
HelpText<"Skip type-checking and SIL generation for non-inlinable function bodies">;
261257
def profile_stats_events: Flag<["-"], "profile-stats-events">,
262258
Flags<[FrontendOption, HelpHidden]>,
263259
HelpText<"Profile changes to stats in -stats-output-dir">;

trunk/include/swift/Reflection/ReflectionContext.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ class ReflectionContext
107107
using typename super::StoredPointer;
108108

109109
explicit ReflectionContext(std::shared_ptr<MemoryReader> reader)
110-
: super(std::move(reader), *this)
111-
{}
110+
: super(std::move(reader)) {
111+
getBuilder().setMetadataReader(*this);
112+
}
112113

113114
ReflectionContext(const ReflectionContext &other) = delete;
114115
ReflectionContext &operator=(const ReflectionContext &other) = delete;

trunk/include/swift/Reflection/TypeRefBuilder.h

Lines changed: 86 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,6 @@ class ReflectionSection {
6565
size_t size() const {
6666
return Size;
6767
}
68-
69-
bool containsRemoteAddress(uint64_t remoteAddr,
70-
uint64_t size) const {
71-
return Start.getAddressData() <= remoteAddr
72-
&& remoteAddr + size <= Start.getAddressData() + Size;
73-
}
74-
75-
template<typename U>
76-
RemoteRef<U> getRemoteRef(uint64_t remoteAddr) const {
77-
assert(containsRemoteAddress(remoteAddr, sizeof(U)));
78-
auto localAddr = (uint64_t)(uintptr_t)Start.getLocalBuffer()
79-
+ (remoteAddr - Start.getAddressData());
80-
81-
return RemoteRef<U>(remoteAddr, (const U*)localAddr);
82-
}
8368
};
8469

8570
template<typename Self, typename Descriptor>
@@ -254,12 +239,17 @@ class TypeRefBuilder {
254239
using BuiltTypeDecl = Optional<std::string>;
255240
using BuiltProtocolDecl = Optional<std::pair<std::string, bool /*isObjC*/>>;
256241

242+
TypeRefBuilder();
243+
257244
TypeRefBuilder(const TypeRefBuilder &other) = delete;
258245
TypeRefBuilder &operator=(const TypeRefBuilder &other) = delete;
259246

260247
private:
261248
Demangle::Demangler Dem;
262249

250+
std::function<const TypeRef* (const void*, unsigned)>
251+
OpaqueUnderlyingTypeReader;
252+
263253
/// Makes sure dynamically allocated TypeRefs stick around for the life of
264254
/// this TypeRefBuilder and are automatically released.
265255
std::vector<std::unique_ptr<const TypeRef>> TypeRefPool;
@@ -565,66 +555,106 @@ class TypeRefBuilder {
565555
return ReflectionInfos;
566556
}
567557

568-
public:
569-
enum ForTesting_t { ForTesting };
570-
571-
// Only for testing. A TypeRefBuilder built this way will not be able to
572-
// decode records in remote memory.
573-
explicit TypeRefBuilder(ForTesting_t) : TC(*this) {}
574-
575558
private:
576559
std::vector<ReflectionInfo> ReflectionInfos;
577-
560+
561+
uint64_t getRemoteAddrOfTypeRefPointer(const void *pointer);
562+
563+
std::function<auto (SymbolicReferenceKind kind,
564+
Directness directness,
565+
int32_t offset, const void *base) -> Demangle::Node *>
566+
SymbolicReferenceResolver;
567+
578568
std::string normalizeReflectionName(RemoteRef<char> name);
579569
bool reflectionNameMatches(RemoteRef<char> reflectionName,
580570
StringRef searchName);
581571

582572
public:
583-
RemoteRef<char> readTypeRef(uint64_t remoteAddr);
584-
585573
template<typename Record, typename Field>
586574
RemoteRef<char> readTypeRef(RemoteRef<Record> record,
587575
const Field &field) {
588576
uint64_t remoteAddr = record.resolveRelativeFieldData(field);
577+
// TODO: This assumes the remote and local buffer addresses are contiguous,
578+
// which should not be a guarantee that MemoryReaders need to maintain.
579+
// Ultimately this should use the MemoryReader to read the string.
580+
auto localAddr = (uint64_t)(uintptr_t)record.getLocalBuffer()
581+
+ (int64_t)(remoteAddr - record.getAddressData());
582+
583+
// Skip the mangling prefix, if any.
584+
auto localPtr = (const char *)localAddr;
585+
if (localPtr[0] == '$' && localPtr[1] == 's') {
586+
remoteAddr += 2;
587+
localPtr += 2;
588+
}
589589

590-
return readTypeRef(remoteAddr);
590+
return RemoteRef<char>(remoteAddr, localPtr);
591591
}
592-
592+
593593
StringRef getTypeRefString(RemoteRef<char> record) {
594594
return Demangle::makeSymbolicMangledNameStringRef(record.getLocalBuffer());
595595
}
596596

597-
private:
598-
// These fields are captured from the MetadataReader template passed into the
599-
// TypeRefBuilder struct, to isolate its template-ness from the rest of
600-
// TypeRefBuilder.
601-
unsigned PointerSize;
602-
std::function<Demangle::Node * (RemoteRef<char>)>
603-
TypeRefDemangler;
604-
std::function<const TypeRef* (const void*, unsigned)>
605-
OpaqueUnderlyingTypeReader;
597+
Demangle::Node *demangleTypeRef(RemoteRef<char> string) {
598+
// TODO: Use the remote addr in the RemoteRef to resolve and read from
599+
// remote addresses in the resolver function.
600+
return Dem.demangleType(getTypeRefString(string),
601+
SymbolicReferenceResolver);
602+
}
606603

607-
public:
608604
template<typename Runtime>
609-
TypeRefBuilder(remote::MetadataReader<Runtime, TypeRefBuilder> &reader)
610-
: TC(*this),
611-
PointerSize(sizeof(typename Runtime::StoredPointer)),
612-
TypeRefDemangler(
613-
[this, &reader](RemoteRef<char> string) -> Demangle::Node * {
614-
return reader.demangle(string,
615-
remote::MangledNameKind::Type,
616-
Dem, /*useOpaqueTypeSymbolicReferences*/ true);
617-
}),
618-
OpaqueUnderlyingTypeReader(
619-
[&reader](const void *descriptor, unsigned ordinal) -> const TypeRef* {
620-
auto context = (typename Runtime::StoredPointer)descriptor;
621-
return reader.readUnderlyingTypeForOpaqueTypeDescriptor(context,
622-
ordinal);
623-
})
624-
{}
625-
626-
Demangle::Node *demangleTypeRef(RemoteRef<char> string) {
627-
return TypeRefDemangler(string);
605+
void setMetadataReader(
606+
remote::MetadataReader<Runtime, TypeRefBuilder> &reader) {
607+
// Have the TypeRefBuilder demangle symbolic references by reading their
608+
// demangling out of the referenced context descriptors in the target
609+
// process.
610+
SymbolicReferenceResolver =
611+
[this, &reader](SymbolicReferenceKind kind,
612+
Directness directness,
613+
int32_t offset, const void *base) -> Demangle::Node * {
614+
// Resolve the reference to a remote address.
615+
auto remoteAddress = getRemoteAddrOfTypeRefPointer(base);
616+
if (remoteAddress == 0)
617+
return nullptr;
618+
619+
auto address = remoteAddress + offset;
620+
if (directness == Directness::Indirect) {
621+
if (auto indirectAddress = reader.readPointerValue(address)) {
622+
address = *indirectAddress;
623+
} else {
624+
return nullptr;
625+
}
626+
}
627+
628+
switch (kind) {
629+
case Demangle::SymbolicReferenceKind::Context: {
630+
auto context = reader.readContextDescriptor(address);
631+
if (!context)
632+
return nullptr;
633+
// Try to preserve a reference to an OpaqueTypeDescriptor symbolically,
634+
// since we'd like to read out and resolve the type ref to the
635+
// underlying type if available.
636+
if (context->getKind() == ContextDescriptorKind::OpaqueType) {
637+
return Dem.createNode(
638+
Node::Kind::OpaqueTypeDescriptorSymbolicReference,
639+
context.getAddressData());
640+
}
641+
642+
return reader.buildContextMangling(context, Dem);
643+
}
644+
case Demangle::SymbolicReferenceKind::AccessorFunctionReference:
645+
// The symbolic reference points at a resolver function, but we can't
646+
// execute code in the target process to resolve it from here.
647+
return nullptr;
648+
}
649+
650+
return nullptr;
651+
};
652+
653+
OpaqueUnderlyingTypeReader =
654+
[&reader](const void *descriptor, unsigned ordinal) -> const TypeRef* {
655+
auto context = (typename Runtime::StoredPointer)descriptor;
656+
return reader.readUnderlyingTypeForOpaqueTypeDescriptor(context, ordinal);
657+
};
628658
}
629659

630660
TypeConverter &getTypeConverter() { return TC; }

0 commit comments

Comments
 (0)