Commit graph

14 commits

Author SHA1 Message Date
Manish Goregaokar
a876a5adcf
Rollup merge of #73378 - matthewjasper:arena-not-special, r=oli-obk
Remove use of specialization from librustc_arena

This reworks the macro so that specialization, `transmute` and `#[marker]` are not used.

r? @oli-obk
2020-06-20 14:45:00 -07:00
Tomasz Miąsko
f488dfc2b6 Use alloc::Layout in DroplessArena API 2020-06-18 01:19:04 +02:00
Matthew Jasper
1b92d592b5 Explain unused macro param 2020-06-16 19:29:53 +01:00
Dylan DPC
c65f39dac4
Rollup merge of #73237 - tmiasko:arena, r=nnethercote
Check for overflow in DroplessArena and align returned memory

* Check for overflow when calculating the slice start & end position.
* Align the pointer obtained from the allocator, ensuring that it
  satisfies user requested alignment (the allocator is only asked for
  layout compatible with u8 slice).
* Remove an incorrect assertion from DroplessArena::align.
* Avoid forming references to an uninitialized memory in DroplessArena.

Helps with #73007, #72624.
2020-06-16 15:08:35 +02:00
Matthew Jasper
2ea386424f Remove use of specialization from librustc_arena 2020-06-15 18:04:43 +01:00
Ralf Jung
eef9356e39
Rollup merge of #72707 - matthewjasper:rustc_min_spec, r=oli-obk
Use min_specialization in the remaining rustc crates

This adds a lot of `transmute` calls to replace the unsound uses of specialization.
It's ugly, but at least it's honest about what's going on.

cc #71420, @RalfJung
2020-06-15 12:00:58 +02:00
Tomasz Miąsko
1f0895162b Avoid forming references to an uninitialized memory in DroplessArena
Return a pointer from `alloc_raw` instead of a slice. There is no
practical use for slice as a return type and changing it to a pointer
avoids forming references to an uninitialized memory.
2020-06-15 10:02:06 +02:00
Tomasz Miąsko
c0c3327ade Check for overflow in DroplessArena and return aligned pointer
* Check for overflow when calculating the slice start & end position.
* Align the pointer obtained from the allocator, ensuring that it
  satisfies user requested alignment (the allocator is only asked for
  layout compatible with u8 slice).
* Remove an incorrect assertion from DroplessArena::align.
2020-06-15 09:56:34 +02:00
Matthew Jasper
88ea7e5234 Use min_specialization in the remaining rustc crates 2020-06-10 09:05:52 +01:00
Nicholas Nethercote
c9cbe7e7eb Rename some identifiers in RawVec and libarena.
- Use `len` more consistently for the number of elements in a vector,
  because that's the usual name.
- Use `additional` more consistently for the number of elements we want
  to add, because that's what `Vec::reserve()` uses.
- Use `cap` consistently rather than `capacity`.
- Plus a few other tweaks.

This increases consistency and conciseness.
2020-06-09 07:55:35 +10:00
Nicholas Nethercote
7145b87751 Remove the reserve_in_place calls in {Typed,Dropless}Arena::grow.
They are pointless. No reasonable allocator will be able to satisfy a
`reserve_in_place` request that *doubles* the size of an allocation when
dealing with allocations that are 4 KiB and larger.

Just to be sure, I confirmed on Linux that the `reserve_in_place` calls
never succeed.

(Note however that the `reserve_in_place` call for `DroplessArena::grow`
did occasionally succeed prior to the off-by-one fix in the previous
commit, because we would sometimes do a `reserve_in_place` request for
the chunk's current size, which would trivially succeed!)
2020-06-09 07:55:34 +10:00
Nicholas Nethercote
5ceff6b96a Fix off-by-one error in DroplessArena::alloc_raw.
This causes unnecessary calls to `grow` when the allocation would fit
exactly in the remaining space.
2020-06-09 07:55:34 +10:00
Vadim Petrochenkov
11d951492c Make things build again 2020-06-02 20:38:24 +03:00
Vadim Petrochenkov
47197d69ab Rename directories for some compiler crates from libx to librustc_x
libarena -> librustc_arena
libfmt_macros -> librustc_parse_format
libgraphviz -> librustc_graphviz
libserialize -> librustc_serialize
2020-06-02 19:53:33 +03:00