Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overloaded-box protocol changes #22086

Closed
wants to merge 10 commits into from

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Feb 8, 2015

This is a bootstrapping illustration of the new box prototype. The main point is to illustrate the fallout that occurs with the compiler type inference as it (nearly) stands today. (Note that much of that fallout has now landed in PR #23002.)

This PR is a revised version of PR #22006, building upon PR #22012 to remove much (but certainly not all) of the fallout observed there.

Now most of the fallout in this PR is from where box <expr> was being used in contexts that are implicitly coerced to Box<Trait>, which is not compatible with the new box protocol (at least, not yet), since the use of coercion there subverts the box-protocol's attempt to infer the appropriate boxed-type to create. (This is noted at this comment on the RFC.)

For now, I am usually getting around this by using Box::new(..);

  • it is worth noting that in HEAP { <expr> } can often fix such cases, but not always;
  • Box::new(<expr>) always works, though it may introduce an intermediate copy that could have been otherwise avoided.

see also rust-lang/rfcs#809 (which is now merged as of this (updated) writing).


oh, and

[breaking-change]

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix
Copy link
Member Author

pnkfelix commented Feb 8, 2015

(this isn't really up for review, so I removed the assignment to @nikomatsakis , who should nonetheless be cc'ed.)

@pnkfelix pnkfelix force-pushed the fsk-box-placer-take-3 branch 6 times, most recently from 23ea741 to 989515c Compare February 8, 2015 13:12
@pnkfelix
Copy link
Member Author

pnkfelix commented Feb 8, 2015

(is not quite right yet, I think I need to accommodate #21988 in some as yet unknown-to-me manner.)

@pnkfelix
Copy link
Member Author

pnkfelix commented Feb 8, 2015

(okay I figured out how to accommodate #21988)

@pnkfelix
Copy link
Member Author

cc #22181

@pnkfelix pnkfelix force-pushed the fsk-box-placer-take-3 branch 3 times, most recently from 3430c4d to 2ed35df Compare February 18, 2015 20:54
@pnkfelix pnkfelix force-pushed the fsk-box-placer-take-3 branch 3 times, most recently from 9bc1982 to c1d4f12 Compare March 2, 2015 08:01
@bors
Copy link
Contributor

bors commented Mar 2, 2015

☔ The latest upstream changes (presumably #22797) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Mar 2, 2015

☔ The latest upstream changes (presumably #22510) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Mar 3, 2015

☔ The latest upstream changes (presumably #22995) made this pull request unmergeable. Please resolve the merge conflicts.

@pnkfelix
Copy link
Member Author

pnkfelix commented Mar 6, 2015

@nikomatsakis (i'm mostly expecting a rubber stamp, though feel free to investigate as much as you like. Oh, and I guess I still owe you some performance and code size comparison data.)

@pnkfelix pnkfelix changed the title No checkin: overloaded-box protocol changes overloaded-box protocol changes Mar 6, 2015
@bors
Copy link
Contributor

bors commented Mar 6, 2015

☔ The latest upstream changes (presumably #22899) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

This looks good to me. I'd still like those measurements. ;)

UPDATE: r+, in case it wasn't clear

@pnkfelix
Copy link
Member Author

Some rough code size data:

configure --enable-optimize --disable-debug:

Baseline: 6048ba8
Post-runway Pre-protocol: b1ed6333100ac0a1bb46a3ed7aa378b3dfe61d92
Post-protocol: e8f64b6c72442d799df86ff35c8657efba1db44b

stage2 rlib name Baseline size Post-runway Pre-protocol size Post-protocol size Percent change over Baseline
libcore 16104350 16103898 16114376 (+0.062%)
liblibc 286482 286482 286482 (0%)
librand 830358 830352 830414 (+0.007%)
liballoc 2091636 2091656 2132392 (+1.949%)
libunicode 5738940 5738910 5739010 (+0.001%)
libcollections 6116590 6115800 6122776 (+0.101%)
libstd 15271254 15274376 15353768 (+0.540%)
librustc_bitflags 13024 13024 13024 (0%)
libflate 155512 155522 155580 (+0.044%)
libarena 163656 163672 163642 (-0.009%)
liblog 220018 221032 222908 (+1.314%)
libterm 838220 838218 849644 (+1.363%)
libserialize 3117002 3117662 3120722 (+0.119%)
libgetopts 658434 657510 659776 (+0.204%)
librbml 654998 655160 655440 (+0.067%)
libtest 1564224 1563860 1579410 (+0.971%)
libgraphviz 155552 155592 155226 (-0.210%)
libfmt_macros 223850 223756 223768 (-0.037%)
libsyntax 31197746 31204328 31303020 (+0.337%)
librustc_llvm 55250354 55250518 55255078 (+0.009%)
librustc_back 1915180 1913664 1920308 (+0.268%)
librustc 40072418 40072128 40018614 (-0.134%)
librustc_typeck 11407138 11409214 11413472 (+0.056%)
librustc_borrowck 2224886 2225584 2232206 (+0.329%)
librustc_resolve 2915826 2915516 2889206 (-0.913%)
librustc_trans 12489192 12492132 12372586 (-0.934%)
librustc_privacy 688020 687596 688842 (+0.119%)
librustc_lint 1398054 1398296 1405288 (+0.517%)
librustc_driver 5246754 5249698 5212736 (-0.648%)
librustdoc 13634096 13640610 13672884 (+0.284%)
total 232643764 232762598 (+0.051%)

Numbers gathered via invocation:

for f in $(ls -tr rust-placer/objdir-opt/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib/stamp.* ) ; do \
   F=$(basename $f | sed -e s/^stamp./lib/ ) ; \
  ( echo $F; \
    ( ls -l rust-plbase/objdir-opt/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib/$F-*.rlib && \
     ls -l rust-placer/objdir-opt/x86_64-apple-darwin/stage2/lib/rustlib/x86_64-apple-darwin/lib/$F-*.rlib )  | \
  cut -f 8 -d ' ' ) | xargs  ; done 

(and then manually feeding the data into some scheme code for calculating the percent-deltas)

@bors
Copy link
Contributor

bors commented Mar 12, 2015

☔ The latest upstream changes (presumably #23265) made this pull request unmergeable. Please resolve the merge conflicts.

…ed to Box.

Precursor for landing overloaded-`box`, since that will decouple the
`box` syntax from the exchange heap (and in fact will eliminate the
use of the two aforementioned lang items).

Instead, the new demonstration program shows a definition of the
`str_eq` lang item. (We do not have that many procedural lang-items to
choose from, which is a good sign for our efforts to decouple the
compiler from the runtime!)

(This previously used a demo of `panic_bounds_check`, but a `str_eq`
demonstration is both easier to code and arguably a more interesting
aspect of the language to discuss.)

Fix unsafe.md example.
See also issue 22405, which tracks going back to `box <expr>` if
possible in the future.

Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
…ck> }`.

Note that `box <expr>` itself remains unchanged.
update test/compile-fail/feature-gate-box-expr.rs to reflect new feature gates.

Part of what lands with Issue 22181.
Namely:

* Update run-pass/new-box-syntax
* Fix doc-embedded test for `alloc::boxed` to reflect new syntax.
* Fix test/debuginfo/box.rs to reflect new syntax.

Part of what lands with Issue 22181.
…t suite.

Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
@bors
Copy link
Contributor

bors commented Mar 13, 2015

☔ The latest upstream changes (presumably #23292) made this pull request unmergeable. Please resolve the merge conflicts.

@nikomatsakis
Copy link
Contributor

@pnkfelix should we close this PR or keep it open?

@pnkfelix
Copy link
Member Author

@nikomatsakis i guess i'll close it; I know where to find it when I get a chance to revive it (i.e. after I fix the ptr::write codegen issues.

@pnkfelix pnkfelix closed this Apr 25, 2015
bors added a commit that referenced this pull request Jun 3, 2015
Hack the move_val_init intrinsic to trans directly into the destination address.

This is to remove an intermediate (and unnecessary) alloca on the stack that one otherwise suffers when using this intrinsic.

This is part of the `box` protocol work; in particular, this is meant to address the `ptr::write` codegen issues alluded to at this comment: 

  #22086 (comment)

cc #22181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants