about summary refs log tree commit diff
path: root/src/librustc/middle/trans/inline.rs
AgeCommit message (Collapse)AuthorLines
2014-11-18Move trans, back, driver, and back into a new crate, rustc_trans. Reduces ↵Niko Matsakis-197/+0
memory usage significantly and opens opportunities for more parallel compilation.
2014-11-17Fix fallout from coercion removalNick Cameron-1/+1
2014-11-06Fallout from collection conventionsAlexis Beingessner-1/+1
2014-10-09rustc: Add `const` globals to the languageAlex Crichton-16/+1
This change is an implementation of [RFC 69][rfc] which adds a third kind of global to the language, `const`. This global is most similar to what the old `static` was, and if you're unsure about what to use then you should use a `const`. The semantics of these three kinds of globals are: * A `const` does not represent a memory location, but only a value. Constants are translated as rvalues, which means that their values are directly inlined at usage location (similar to a #define in C/C++). Constant values are, well, constant, and can not be modified. Any "modification" is actually a modification to a local value on the stack rather than the actual constant itself. Almost all values are allowed inside constants, whether they have interior mutability or not. There are a few minor restrictions listed in the RFC, but they should in general not come up too often. * A `static` now always represents a memory location (unconditionally). Any references to the same `static` are actually a reference to the same memory location. Only values whose types ascribe to `Sync` are allowed in a `static`. This restriction is in place because many threads may access a `static` concurrently. Lifting this restriction (and allowing unsafe access) is a future extension not implemented at this time. * A `static mut` continues to always represent a memory location. All references to a `static mut` continue to be `unsafe`. This is a large breaking change, and many programs will need to be updated accordingly. A summary of the breaking changes is: * Statics may no longer be used in patterns. Statics now always represent a memory location, which can sometimes be modified. To fix code, repurpose the matched-on-`static` to a `const`. static FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } change this code to: const FOO: uint = 4; match n { FOO => { /* ... */ } _ => { /* ... */ } } * Statics may no longer refer to other statics by value. Due to statics being able to change at runtime, allowing them to reference one another could possibly lead to confusing semantics. If you are in this situation, use a constant initializer instead. Note, however, that statics may reference other statics by address, however. * Statics may no longer be used in constant expressions, such as array lengths. This is due to the same restrictions as listed above. Use a `const` instead. [breaking-change] [rfc]: https://github.com/rust-lang/rfcs/pull/246
2014-09-17librustc: Implement associated types behind a feature gate.Patrick Walton-0/+6
The implementation essentially desugars during type collection and AST type conversion time into the parameter scheme we have now. Only fully qualified names--e.g. `<T as Foo>::Bar`--are supported.
2014-09-14rustc: fix fallout from using ptr::P.Eduard Burtescu-14/+19
2014-09-06rustc: Refactor middle::trans::inlinePiotr Czarnecki-7/+23
2014-09-05translate into multiple llvm contextsStuart Pernsteiner-18/+47
Rotate between compilation units while translating. The "worker threads" commit added support for multiple compilation units, but only translated into one, leaving the rest empty. With this commit, `trans` rotates between various compilation units while translating, using a simple stragtegy: upon entering a module, switch to translating into whichever compilation unit currently contains the fewest LLVM instructions. Most of the actual changes here involve getting symbol linkage right, so that items translated into different compilation units will link together properly at the end.
2014-09-05make CrateContext fields privateStuart Pernsteiner-14/+14
2014-08-14librustc: Stop assuming that implementations and traits only containPatrick Walton-18/+33
methods. This paves the way to associated items by introducing an extra level of abstraction ("impl-or-trait item") between traits/implementations and methods. This new abstraction is encoded in the metadata and used throughout the compiler where appropriate. There are no functional changes; this is purely a refactoring.
2014-08-12Revert "avoid redundant translation of items during monomorphization"Stuart Pernsteiner-1/+1
This reverts commit f97f65f7b70e455c1c3e72e620120c9f1a96d89a. Conflicts: src/librustc/middle/trans/base.rs src/librustc/middle/trans/foreign.rs src/librustc/middle/trans/monomorphize.rs
2014-07-30avoid redundant translation of items during monomorphizationStuart Pernsteiner-1/+1
2014-07-15change to new trait style for method field refsJohn Clements-4/+3
Per @pnkfelix 's suggestion, using a trait to make these field accesses more readable (and vastly more similar to the original code. oops fix new ast_map fix
2014-07-14rustc_llvm: Remove the inner llvm moduleBrian Anderson-1/+1
This makes it much saner for clients to use the library since they don't have to worry about shadowing one llvm with another.
2014-07-13refactor Method definition to make space for macrosJohn Clements-2/+3
This change propagates to many locations, but because of the Macro Exterminator (or, more properly, the invariant that it protects), macro invocations can't occur downstream of expansion. This means that in librustc and librustdoc, extracting the desired field can simply assume that it can't be a macro invocation. Functions in ast_util abstract over this check.
2014-06-17librustc: Make addresses of immutable statics insignificant unlessPatrick Walton-4/+5
`#[inline(never)]` is used. Closes #8958. This can break some code that relied on the addresses of statics being distinct; add `#[inline(never)]` to the affected statics. [breaking-change]
2014-06-13Introduce VecPerParamSpace and use it to represent sets of types andNiko Matsakis-8/+8
parameters This involves numerous substeps: 1. Treat Self same as any other parameter. 2. No longer compute offsets for method parameters. 3. Store all generic types (both trait/impl and method) with a method, eliminating odd discrepancies. 4. Stop doing unspeakable things to static methods and instead just use the natural types, now that we can easily add the type parameters from trait into the method's polytype. 5. No doubt some more. It was hard to separate these into distinct commits. Fixes #13564
2014-06-11rustc: Move the AST from @T to Gc<T>Alex Crichton-3/+3
2014-06-06Stop passing around Option<&substs> in trans and just pass &substs, making ↵Niko Matsakis-1/+2
the code more regular
2014-04-24Pre-step towards issue #12624 and others: Introduce ExprUseVisitor, remove theNiko Matsakis-1/+1
moves computation. ExprUseVisitor is a visitor that walks the AST for a function and calls a delegate to inform it where borrows, copies, and moves occur. In this patch, I rewrite the gather_loans visitor to use ExprUseVisitor, but in future patches, I think we could rewrite regionck, check_loans, and possibly other passes to use it as well. This would refactor the repeated code between those places that tries to determine where copies/moves/etc occur.
2014-03-22rustc: Fix fallout of removing get()Alex Crichton-45/+23
2014-03-17De-@ move maps and rework parts of trans.Eduard Burtescu-6/+6
2014-03-17De-@ trans contexts.Eduard Burtescu-1/+1
2014-03-17De-@ Session usage.Eduard Burtescu-3/+3
2014-03-01librustc: Fix errors arising from the automated `~[T]` conversionPatrick Walton-1/+1
2014-02-14Refactored ast_map and friends, mainly to have Paths without storing them.Eduard Burtescu-8/+2
2014-02-02rustc: remove use of @[].Huon Wilson-1/+1
2014-01-27Demote self to an (almost) regular argument and remove the env param.Eduard Burtescu-20/+1
Fixes #10667 and closes #10259.
2014-01-15Issue #3511 - Rationalize temporary lifetimes.Niko Matsakis-1/+0
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way.
2014-01-11Use the right type for self in methods and remove obsoleted items.Eduard Burtescu-7/+4
Fixes #7411, #10615.
2014-01-09libsyntax: Renamed types, traits and enum variants to CamelCase.Eduard Burtescu-13/+12
2013-12-26librustc: De-`@mut` `n_inlines` in the statsPatrick Walton-2/+3
2013-12-26librustc: De-`@mut` the crate contextPatrick Walton-1/+1
2013-12-26librustc: De-`@mut` the `external` and `external_srcs` fields ofPatrick Walton-24/+49
`CrateContext`
2013-12-01Box Block, fn_decl, variant and Ty in the AST, as they were inflating ↵Eduard Burtescu-2/+2
critical enum sizes.
2013-11-28Register new snapshotsAlex Crichton-1/+1
2013-10-22libsyntax/librustc: Allow specifying mut on by-value self.Luqman Aden-1/+1
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-2/+2
Who doesn't like a massive renaming?
2013-10-01librustc: Inline cross-crate tuple struct constructorsPatrick Walton-1/+10
2013-09-30rustc: Remove usage of fmt!Alex Crichton-2/+2
2013-09-17Prevent a rare linkage issue with an xcrate staticAlex Crichton-1/+7
If a static is flagged as address_insignificant, then for LLVM to actually perform the relevant optimization it must have an internal linkage type. What this means, though, is that the static will not be available to other crates. Hence, if you have a generic function with an inner static, it will fail to link when built as a library because other crates will attempt to use the inner static externally. This gets around the issue by inlining the static into the metadata. The same relevant optimization is then applied separately in the external crate. What this ends up meaning is that all statics tagged with #[address_insignificant] will appear at most once per crate (by value), but they could appear in multiple crates. This should be the last blocker for using format! ...
2013-09-16Resume inlining globals across cratesAlex Crichton-1/+22
In #8185 cross-crate condition handlers were fixed by ensuring that globals didn't start appearing in different crates with different addressed. An unfortunate side effect of that pull request is that constants weren't inlined across crates (uint::bits is unknown to everything but libstd). This commit fixes this inlining by using the `available_eternally` linkage provided by LLVM. It partially reverts #8185, and then adds support for this linkage type. The main caveat is that not all statics could be inlined into other crates. Before this patch, all statics were considered "inlineable items", but an unfortunate side effect of how we deal with `&static` and `&[static]` means that these two cases cannot be inlined across crates. The translation of constants was modified to propogate this condition of whether a constant should be considered inlineable into other crates. Closes #9036
2013-09-03Modernized a few more types in syntax::astMarvin Löbel-2/+2
2013-08-03remove obsolete `foreach` keywordDaniel Micay-1/+1
this has been replaced by `for`
2013-08-01migrate many `for` loops to `foreach`Daniel Micay-1/+1
2013-07-17librustc: Remove all uses of "copy".Patrick Walton-2/+1
2013-07-11Drop a now unnecessary argument from maybe_instantiate_inline.Michael Sullivan-9/+5
2013-07-11Get cross crate static default methods working. Closes #7569.Michael Sullivan-1/+1
2013-06-30auto merge of #7468 : cmr/rust/great_renaming, r=pcwaltonbors-2/+1
2013-06-29Avoid double indirection for the "self" arg in methodsBjörn Steinbrink-3/+3
Currently we pass all "self" arguments by reference, for the pointer variants this means that we end up with double indirection which causes a unnecessary performance hit. The fix itself is pretty straight-forward and just means that "self" needs to be handled like any other argument, except for by-value "self" which still needs to be passed by reference. This is because non-pointer types can't just be stuffed into the environment slot which is used to pass "self". What made things tricky is that there was also a bug in the typechecker where the method map entries are created. For type impls, that stored the base type instead of the actual self-type in the method map, e.g. Foo instead of &Foo for &self. That worked with pass-by-reference, but fails with pass-by-value which needs the real type. Code that makes use of methods seems to be about 10% faster with this change. Also, build times are reduced by about 4%. Fixes #4355, #4402, #5280, #4406 and #7285