Commit Graph

665 Commits

Author SHA1 Message Date
Bob Wilson
7fb7c4f9d6 [master-next] Take 3 on adjusting to LLVM r335407 splitting Intrinsics.inc
There were only 2 places to update and I got them both wrong... We need
the IntrinsicImpl.inc file in both places. I've actually tested it this
time.
2018-06-25 23:18:56 -07:00
Bob Wilson
03d38f0d80 [master-next] Fix to use IntrinsicImpl.inc file for target data.
My previous adjustment for LLVM r335407 used IntrinsicEnums.inc in two
places, but the second one needs to use IntrinsicImpl.inc instead.
2018-06-25 16:39:43 -07:00
Bob Wilson
8b936177d1 [master-next] Use new IntrinsicEnums.inc file
LLVM r335407 split up the Intrinsics.inc file into separate files with
the enums and implementations. Change Swift to use the new file for the
enums.
2018-06-23 22:18:30 -07:00
Bob Wilson
65c6322c46 master-next: Rename LLVM's Intrinsics.gen to Intrinsics.inc to match r330843 2018-04-26 09:30:05 -07:00
Joe Groff
62771a0c9d stdlib: Add withUnsafeBytes(of:) and withUnsafePointer(to:) for immutable arguments.
Since the functions produce pointers with tightly-scoped lifetimes there's no formal reason these have to only work on `inout` things.  Now that arguments can be +0, we can even do this without copying values that we already have at +0.
2018-04-18 09:13:45 -07:00
Michael Gottesman
6350397ff2 [Exclusivity] Add builtins needed for dynamic enforcement of exclusivity.
This is chopped off from Devin Coughlin's PR so I can test the actual fix that should
make the rest of his commit work.

rdar://problem/31972680
2018-04-17 13:04:06 -07:00
Huon Wilson
e307e54098 [AST] Explicitly track things marked __owned. 2018-03-08 12:36:24 +11:00
Sho Ikeda
26d650292f [gardening] Use empty() over size() == 0 2018-03-05 14:43:13 +09:00
David Zarzycki
a0e5e419a2 [Perf] Improve dirty AST rebuild speed 2.56x on many-core machines
On many-core machines, the files that take the longest to compile are
build bottlenecks. With this change, we workaround clang scaling
problems compiling large llvm::StringSwitch expressions and bring the
"touch tools/swift/include/swift/AST/* ; time ninja swift" time down
from 1m43.24s down to 40.26s.

I've also benchmarked rebuilding Swift.o after this change. The before
and after seems to be deep in the noise.
2018-02-16 17:39:04 -05:00
Joe Shajrawi
6538d543f7 Builtins: add StringObjectOr and use it in the standard library 2018-02-13 11:12:55 +02:00
Joe Shajrawi
f732ea66ef Builtins: add ValueToBridgeObject instruction 2018-02-12 13:27:59 +02:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Chris Lattner
415cd50ba2 Reduce array abstraction on apple platforms dealing with literals (#13665)
* Reduce array abstraction on apple platforms dealing with literals

Part of the ongoing quest to reduce swift array literal abstraction
penalties: make the SIL optimizer able to eliminate bridging overhead
 when dealing with array literals.

Introduce a new classify_bridge_object SIL instruction to handle the
logic of extracting platform specific bits from a Builtin.BridgeObject
value that indicate whether it contains a ObjC tagged pointer object,
or a normal ObjC object. This allows the SIL optimizer to eliminate
these, which allows constant folding a ton of code. On the example
added to test/SILOptimizer/static_arrays.swift, this results in 4x
less SIL code, and also leads to a lot more commonality between linux
and apple platform codegen when passing an array literal.

This also introduces a couple of SIL combines for patterns that occur
in the array literal passing case.
2018-01-02 15:23:48 -08:00
John McCall
59e2ab4277 The callback to Builtin.once is a C function, not a Swift one.
If we want it to be a Swift function, we'll have to thunk in the
runtime when using a system implementaton like dispatch_once_f,
since the function pointer ABIs could be different, depending on
the target.  Dealing with that, or avoiding it on a per-target basis,
is more complexiity than a micro-optimization of the slow path of
this builtin could possibly be worth.
2017-12-16 02:22:13 -05:00
John McCall
7743be30f6 Add a "token" type to SIL to allow dependencies to be expressed without
allowing abstraction.
2017-11-13 04:03:21 -05:00
Slava Pestov
15fa6c8955 AST: Call setValidationStarted() on synthesized declarations
This avoids doing unnecessary work in validateDecl().
2017-10-22 20:05:00 -07:00
Doug Gregor
936a701b15 [AST] Stop uniquing canonical GSBs based on the module.
Now that the GenericSignatureBuilder is no longer sensitive to the input
module, stop uniquing the canonical GSBs based on that module. The main
win here is when deserializing a generic environment: we would end up 
creating a canonical GSB in the module we deserialized and another
canonical GSB in the module in which it is used.
2017-10-10 09:41:23 -07:00
Doug Gregor
ef542ffd8a [GSB] Eliminate the stored LookupConformanceFn to the GSB.
Implement a module-agnostic conformance lookup operation within the GSB
itself, so it does not need to be supplied by the code constructing the
generic signature builder. This makes the generic signature builder
(closer to) being module-agnostic.
2017-10-10 09:41:23 -07:00
Jordan Rose
b6c28b02d0 [SIL] Remove the builtins related to UnknownObject.
No functionality change; nothing is using them.
2017-10-02 09:05:31 -07:00
Doug Gregor
d93bed5ed1 [GSB] Move a well-formed GenericSignatureBuilder to be the canonical builder.
Once we compute a generic signature from a generic signature builder,
all queries involving that generic signature will go through a separate
(canonicalized) builder, and the original builder can no longer be used.
The canonicalization process then creates a new, effectively identical
generic signature builder. How silly.

Once we’ve computed the signature of a generic signature builder, “register”
it with the ASTContext, allowing us to move the existing generic signature
builder into place as the canonical generic signature builder. The builder
requires minimal patching but is otherwise fully usable.

Thanks to Slava Pestov for the idea!
2017-09-28 16:19:08 -07:00
Doug Gregor
0a1583fb87 [GSB] Tighten up interfaces for computing a generic signature.
Funnel all places where we create a generic signature builder to compute
the generic signature through a single entry point in the GSB
(`computeGenericSignature()`), and make `finalize` and `getGenericSignature`
private so no new uses crop up.

Tighten up the signature of `computeGenericSignature()` so it only works on
GSB rvalues, and ensure that all clients consider the GSB dead after that
point by clearing out the internal representation of the GSB.
2017-09-28 14:27:15 -07:00
Doug Gregor
8f5d8aa7f9 Revert "[GSB] Centralize, clean up, and cache nested type name lookup" 2017-09-25 13:43:10 -07:00
Doug Gregor
a048194041 [GSB] Tighten up interfaces for computing a generic signature.
Funnel all places where we create a generic signature builder to compute
the generic signature through a single entry point in the GSB
(`computeGenericSignature()`), and make `finalize` and `getGenericSignature`
private so no new uses crop up.

Tighten up the signature of `computeGenericSignature()` so it only works on
GSB rvalues, and ensure that all clients consider the GSB dead after that
point by clearing out the internal representation of the GSB.
2017-09-25 08:47:40 -07:00
Joe Shajrawi
00f44ce24a Revert "Create fewer generic signature builders" 2017-09-22 21:57:53 -07:00
Doug Gregor
eccdedaf97 Merge pull request #12062 from DougGregor/make-fewer-gsbs
Create fewer generic signature builders
2017-09-22 18:38:27 -07:00
Doug Gregor
76a532b3af [GSB] Move a well-formed GenericSignatureBuilder to be the canonical builder.
Once we compute a generic signature from a generic signature builder,
all queries involving that generic signature will go through a separate
(canonicalized) builder, and the original builder can no longer be used.
The canonicalization process then creates a new, effectively identical
generic signature builder. How silly.

Once we’ve computed the signature of a generic signature builder, “register”
it with the ASTContext, allowing us to move the existing generic signature
builder into place as the canonical generic signature builder. The builder
requires minimal patching but is otherwise fully usable.

Thanks to Slava Pestov for the idea!
2017-09-22 17:11:05 -07:00
Doug Gregor
115d81a327 [GSB] Tighten up interfaces for computing a generic signature.
Funnel all places where we create a generic signature builder to compute
the generic signature through a single entry point in the GSB
(`computeGenericSignature()`), and make `finalize` and `getGenericSignature`
private so no new uses crop up.

Tighten up the signature of `computeGenericSignature()` so it only works on
GSB rvalues, and ensure that all clients consider the GSB dead after that
point by clearing out the internal representation of the GSB.
2017-09-22 11:32:26 -07:00
Mark Lacey
c0c848d2b3 Add Builtin.type_join* family of functions.
These will be used for unit-testing the Type::join functionality in the
type checker. The result of the join is replaced during constraint
generation with the actual type.

There is currently no checking for whether the arguments can be used to
statically compute the value, so bad things will likely happen if
e.g. they are type variables. Once more of the basic functionality of
Type::join is working I'll make this a bit more bullet-proof in that
regard.

They include:
  // Compute the join of T and U and return the metatype of that type.
  Builtin.type_join<T, U, V>(_: T.Type, _: U.Type) -> V.Type

  // Compute the join of &T and U and return the metatype of that type.
  Builtin.type_join_inout<T, U, V>(_: inout T, _: U.Type) -> V.Type

  // Compute the join of T.Type and U.Type and return that type.
  Builtin.type_join_meta<T, U, V>(_: T.Type, _: U.Type) -> V.Type

I've added a couple simple tests to start off, based on what currently
works (aka doesn't cause an assert, crash, etc.).
2017-09-21 14:43:26 -07:00
Arnold Schwaighofer
8a85a9efd5 Use array copy runtime implementation instead of the array value witnesses
And add builtins for the added runtime functions (assign-take, assign-copy).

rdar://27412867
SR-3376
2017-09-12 12:43:26 -07:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Jordan Rose
5f30eac288 Excise "Accessibility" from the compiler (1/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the names of methods, fields, a few local
variables, and even a swift-ide-test flag. The full list is below.

accessibilityForDiagnostics -> accessLevelForDiagnostics
checkAccessibility -> checkAccess
checkGenericParamAccessibility -> checkGenericParamAccess
checkTypeAccessibility -> checkTypeAccess
checkWitnessAccessibility -> checkWitnessAccessibility
computeAccessibility -> computeAccessLevel
computeDefaultAccessibility -> computeDefaultAccessLevel
fixItAccessibility -> fixItAccess
getAccessibilityString -> getAccessLevelString
getAccessibilityStrictly -> getAccessLevelStrictly
getAccessibilityUID -> getAccessLevelUID
getActualAccessibility -> getActualAccessLevel
getDefaultAccessibility -> getDefaultAccessLevel
getMaxAccessibility -> getMaxAccessLevel
getOverridableAccessibility -> getOverridableAccessLevel
getRawStableAccessibility -> getRawStableAccessLevel
getSetterAccessibility -> getSetterFormalAccess
hasAccessibility -> hasAccess
hasDefaultAccessibility -> hasDefaultAccessLevel
inferAccessibility -> inferAccessLevel
inferDefaultAccessibility -> inferDefaultAccessLevel
inferSetterAccessibility -> inferSetterAccessLevel
overwriteAccessibility -> overwriteAccess
overwriteSetterAccessibility -> overwriteSetterAccess
printAccessibility -> printAccess
requiredAccessibilityForDiagnostics -> requiredAccessForDiagnostics
resolveAccessibility -> resolveAccessControl
setAccessibility -> setAccess
setSetterAccessibility -> setSetterAccess
setDefaultAndMaxAccessibility -> setDefaultAndMaxAccess
validateAccessibility -> validateAccessControl

Accessibility -> AccessLevel
AccessibilityFilter -> AccessFilter
IgnoreAccessibility -> IgnoreAccessControl
NL_IgnoreAccessibility -> NL_IgnoreAccessControl
PrintAccessibility -> PrintAccess
PrintInternalAccessibilityKeyword -> PrintInternalAccessKeyword
SetterAccessibility -> SetterAccessLevel

setterAccessibility -> setterAccess
storedPropertyAccessibility -> storedPropertyAccess

-print-accessibility -> -print-access
2017-08-28 11:11:57 -07:00
Slava Pestov
bf2ca1ab94 Sema/AST: Don't crash when stdlib declarations are missing
I don't have reduced test cases. The original test cases
were a series of frontend invocations in -parse-stdlib
mode.

While the original bugs seem to have been fixed, while
verifying I found a few places where we weren't checking
for null decls property in the ASTContext.

Probably not too useful to check this in, but I don't see it
causing any harm, either.
2017-08-06 00:43:23 -07:00
swift-ci
d9f0e3cedb Merge remote-tracking branch 'origin/master' into master-next 2017-07-19 13:28:52 -07:00
Robert Widmann
d019485e36 Address review comments 2017-07-19 12:38:23 -07:00
Robert Widmann
490ab65c7e Explicitly construct inout parameters in the builtin GSB 2017-07-19 09:49:32 -07:00
swift-ci
2dc84ee365 Merge remote-tracking branch 'origin/master' into master-next 2017-07-05 15:28:50 -07:00
Robert Widmann
4da853e7cb Rename Specifier::None to Specifier::Owned 2017-07-05 14:02:26 -07:00
swift-ci
5707eaf699 Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 20:09:34 -07:00
Robert Widmann
ac5594dabe Use a meaningful representation of parameter specifiers
In anticipation of future attributes, and perhaps the ability to
declare lvalues with specifiers other than 'let' and 'var', expand
the "isLet" bit into a more general "specifier" field.
2017-06-29 16:03:49 -07:00
Greg Parker
7b009eccde Merge remote-tracking branch 'origin/master' into master-next 2017-06-28 15:25:17 -07:00
Robert Widmann
777e1f9604 Miscellaneous cleanups for Parameters/Tuple Types
* Move IsInOut bit into the type parameter flags and
make sure to serialize it.

* Remove some unused constructors and accessors.
2017-06-21 10:17:43 -07:00
swift-ci
31f74c2888 Merge remote-tracking branch 'origin/master' into master-next 2017-05-17 09:29:03 -07:00
Joe Groff
c8a7a442ae Runtime: Include source location information in log messages about deprecated implicit Objective-C entry points.
Make it easier for migration by pinpointing exactly where to insert @objc to keep the entry points in Swift 4 mode. rdar://problem/32230003
2017-05-16 19:02:47 -07:00
swift-ci
d18cb7fa3b Merge remote-tracking branch 'origin/master' into master-next 2017-05-16 09:29:05 -07:00
Roman Levenstein
34ad596693 Merge pull request #9627 from swiftix/is-same-metatype-builtin
Add a new builtin called is_same_metatype for checking the equality between metatypes
2017-05-16 09:13:03 -07:00
swift-ci
96736f749d Merge remote-tracking branch 'origin/master' into master-next 2017-05-15 23:08:37 -07:00
Doug Gregor
fef69478f6 [GSB] Introduce computeGenericSignature() for generic signature creation.
The GenericSignatureBuilder requires `finalize()` to be called before a
generic signature can be retrieved with `getGenericSignature()`. Most of the former isn’t strictly needed unless you want a generic signature, and the 
latter is potentially expensive. `computeGenericSignature()` combines the two
operations together, since they are conceptually related. Update most of the
callers to the former two functions to use `computeGenericSignature()`.
2017-05-15 17:16:50 -07:00
Roman Levenstein
d522618bac Add a new builtin called is_same_metatype for checking the equality between metatypes
Having such a builtin makes it easier for the optimizer to reason about what is actually happening.
I plan to add later some optimizations which can optimize pieces of code dominated by such a check.
2017-05-15 16:21:09 -07:00
swift-ci
4ef7b46971 Merge remote-tracking branch 'origin/master' into master-next 2017-04-21 18:08:32 -07:00
Joe Groff
3d178be169 Merge pull request #8875 from jckarter/keypaths
Keypaths
2017-04-21 17:51:17 -07:00