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

Rollup of 12 pull requests #39565

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3ccb87a
liballoc_jemalloc: fix linking with system library
ishitatsuyuki Feb 3, 2017
458167e
Add `aarch64-unknown-freebsd` to the supported targets
dumbbell Jan 25, 2017
f6c6b31
`aarch64` CPU type is called `arm64` on FreeBSD
dumbbell Feb 3, 2017
5e41ec2
rename other than copy/remove
king6cong Feb 1, 2017
7de99cd
Merge remote tracking branch 'upstream/master'
ishitatsuyuki Feb 3, 2017
768f6a9
add and use rename_or_copy_remove fn that fallback to copy & remove
king6cong Feb 3, 2017
d14b268
libbacktrace: Fix uninitialized variable
petrochenkov Feb 3, 2017
34f444d
Extract libcore benchmarks to a separate folder
phungleson Feb 3, 2017
efeb42b
Use less syscalls in `FileDesc::set_{nonblocking,cloexec}`
tbu- Feb 4, 2017
3c16139
Don't use "unadjusted" ABI on non windows platforms
est31 Feb 2, 2017
5a21f42
run rustfmt for librustc/util/fs.rs
king6cong Feb 4, 2017
87ace0d
More snap cleanup
nagisa Feb 4, 2017
206ee20
Unignore stage0/1 i128 tests as well
nagisa Feb 4, 2017
768c6c0
Support a debug info API change for LLVM 4.0
Feb 4, 2017
112a5a0
ignore more gdb versions with buggy rust support
TimNN Feb 4, 2017
a884a6c
Slightly optimize slice::sort
Feb 4, 2017
fa457bf
Minor fix in the *_expensive benchmark
Feb 4, 2017
fc88683
prefer issue-${no}.rs to bug-${no}.rs test file names
zackmdavis Feb 5, 2017
de8df01
continue to prefer hyphens in test files named after issue numbers
zackmdavis Feb 5, 2017
1c26f8c
unify both existing test files for issue #32829
zackmdavis Feb 5, 2017
aba3835
Rollup merge of #39439 - king6cong:move, r=alexcrichton
frewsxcv Feb 5, 2017
4d9b5c1
Rollup merge of #39472 - est31:unadjusted_only_for_win, r=nagisa
frewsxcv Feb 5, 2017
3621ff4
Rollup merge of #39481 - ishitatsuyuki:master, r=alexcrichton
frewsxcv Feb 5, 2017
0e65bae
Rollup merge of #39491 - dumbbell:support-aarch64-unknown-freebsd, r=…
frewsxcv Feb 5, 2017
ec25d1a
Rollup merge of #39501 - phungleson:libcorebench, r=alexcrichton
frewsxcv Feb 5, 2017
0a86735
Rollup merge of #39509 - petrochenkov:rb2, r=alexcrichton
frewsxcv Feb 5, 2017
fcf1b0f
Rollup merge of #39514 - tbu-:pr_less_syscalls_fd, r=alexcrichton
frewsxcv Feb 5, 2017
e0f3512
Rollup merge of #39519 - nagisa:more-snap, r=alexcrichton
frewsxcv Feb 5, 2017
184b46d
Rollup merge of #39528 - dylanmckay:llvm-4.0-diglobalvar, r=alexcrichton
frewsxcv Feb 5, 2017
ec47f9d
Rollup merge of #39530 - TimNN:more-gdb, r=alexcrichton
frewsxcv Feb 5, 2017
78bf59b
Rollup merge of #39538 - stjepang:slightly-optimize-sort, r=alexcrichton
frewsxcv Feb 5, 2017
be95d13
Rollup merge of #39556 - zackmdavis:issue_kebab_2_electric_boogaloo, …
frewsxcv Feb 5, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ case $CFG_CPUTYPE in
CFG_OSTYPE="${CFG_OSTYPE}eabihf"
;;

aarch64)
aarch64 | arm64)
CFG_CPUTYPE=aarch64
;;

Expand Down
1 change: 1 addition & 0 deletions mk/cfg/aarch64-unknown-freebsd.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rustbuild-only target
2 changes: 2 additions & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ def build_triple(self):
ostype += 'eabihf'
elif cputype == 'aarch64':
cputype = 'aarch64'
elif cputype == 'arm64':
cputype = 'aarch64'
elif cputype == 'mips':
if sys.byteorder == 'big':
cputype = 'mips'
Expand Down
11 changes: 6 additions & 5 deletions src/liballoc_jemalloc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ fn main() {
return;
}

if target.contains("android") {
println!("cargo:rustc-link-lib=gcc");
} else if !target.contains("windows") && !target.contains("musl") {
println!("cargo:rustc-link-lib=pthread");
}

if let Some(jemalloc) = env::var_os("JEMALLOC_OVERRIDE") {
let jemalloc = PathBuf::from(jemalloc);
println!("cargo:rustc-link-search=native={}",
Expand All @@ -66,11 +72,6 @@ fn main() {
println!("cargo:rustc-link-lib=static=jemalloc_pic");
}
println!("cargo:rustc-link-search=native={}/lib", build_dir.display());
if target.contains("android") {
println!("cargo:rustc-link-lib=gcc");
} else if !target.contains("windows") && !target.contains("musl") {
println!("cargo:rustc-link-lib=pthread");
}
let src_dir = env::current_dir().unwrap().join("../jemalloc");
rerun_if_changed_anything_in_dir(&src_dir);
let timestamp = build_dir.join("rustbuild.timestamp");
Expand Down
4 changes: 3 additions & 1 deletion src/libbacktrace/pecoff.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,9 @@ coff_add (struct backtrace_state *state, int descriptor,
// against the upstream libbacktrace, that's what's going on.
uint32_t str_size;
off_t str_off;
struct backtrace_view syms_view;
// NOTE: upstream doesn't have `{0}`, this is a fix for Rust issue #39468.
// If syms_view is not initialized, then `free(syms_view.base)` may segfault later.
struct backtrace_view syms_view = {0};
off_t syms_off;
size_t syms_size;
int syms_view_valid;
Expand Down
68 changes: 36 additions & 32 deletions src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
#![cfg_attr(test, allow(unused_imports, dead_code))]

use alloc::boxed::Box;
use core::cmp::Ordering::{self, Greater};
use core::cmp::Ordering::{self, Less};
use core::mem::size_of;
use core::mem;
use core::ptr;
Expand Down Expand Up @@ -1089,7 +1089,7 @@ impl<T> [T] {
pub fn sort(&mut self)
where T: Ord
{
self.sort_by(|a, b| a.cmp(b))
merge_sort(self, |a, b| a.lt(b));
}

/// Sorts the slice using `f` to extract a key to compare elements by.
Expand Down Expand Up @@ -1119,7 +1119,7 @@ impl<T> [T] {
pub fn sort_by_key<B, F>(&mut self, mut f: F)
where F: FnMut(&T) -> B, B: Ord
{
self.sort_by(|a, b| f(a).cmp(&f(b)))
merge_sort(self, |a, b| f(a).lt(&f(b)));
}

/// Sorts the slice using `compare` to compare elements.
Expand Down Expand Up @@ -1149,10 +1149,10 @@ impl<T> [T] {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn sort_by<F>(&mut self, compare: F)
pub fn sort_by<F>(&mut self, mut compare: F)
where F: FnMut(&T, &T) -> Ordering
{
merge_sort(self, compare)
merge_sort(self, |a, b| compare(a, b) == Less);
}

/// Copies the elements from `src` into `self`.
Expand Down Expand Up @@ -1355,10 +1355,10 @@ impl<T: Clone> ToOwned for [T] {
/// Inserts `v[0]` into pre-sorted sequence `v[1..]` so that whole `v[..]` becomes sorted.
///
/// This is the integral subroutine of insertion sort.
fn insert_head<T, F>(v: &mut [T], compare: &mut F)
where F: FnMut(&T, &T) -> Ordering
fn insert_head<T, F>(v: &mut [T], is_less: &mut F)
where F: FnMut(&T, &T) -> bool
{
if v.len() >= 2 && compare(&v[0], &v[1]) == Greater {
if v.len() >= 2 && is_less(&v[1], &v[0]) {
unsafe {
// There are three ways to implement insertion here:
//
Expand All @@ -1381,12 +1381,12 @@ fn insert_head<T, F>(v: &mut [T], compare: &mut F)

// Intermediate state of the insertion process is always tracked by `hole`, which
// serves two purposes:
// 1. Protects integrity of `v` from panics in `compare`.
// 1. Protects integrity of `v` from panics in `is_less`.
// 2. Fills the remaining hole in `v` in the end.
//
// Panic safety:
//
// If `compare` panics at any point during the process, `hole` will get dropped and
// If `is_less` panics at any point during the process, `hole` will get dropped and
// fill the hole in `v` with `tmp`, thus ensuring that `v` still holds every object it
// initially held exactly once.
let mut hole = InsertionHole {
Expand All @@ -1396,7 +1396,7 @@ fn insert_head<T, F>(v: &mut [T], compare: &mut F)
ptr::copy_nonoverlapping(&v[1], &mut v[0], 1);

for i in 2..v.len() {
if compare(&tmp.value, &v[i]) != Greater {
if !is_less(&v[i], &tmp.value) {
break;
}
ptr::copy_nonoverlapping(&v[i], &mut v[i - 1], 1);
Expand Down Expand Up @@ -1432,8 +1432,8 @@ fn insert_head<T, F>(v: &mut [T], compare: &mut F)
///
/// The two slices must be non-empty and `mid` must be in bounds. Buffer `buf` must be long enough
/// to hold a copy of the shorter slice. Also, `T` must not be a zero-sized type.
unsafe fn merge<T, F>(v: &mut [T], mid: usize, buf: *mut T, compare: &mut F)
where F: FnMut(&T, &T) -> Ordering
unsafe fn merge<T, F>(v: &mut [T], mid: usize, buf: *mut T, is_less: &mut F)
where F: FnMut(&T, &T) -> bool
{
let len = v.len();
let v = v.as_mut_ptr();
Expand All @@ -1449,12 +1449,12 @@ unsafe fn merge<T, F>(v: &mut [T], mid: usize, buf: *mut T, compare: &mut F)
// hole in `v`.
//
// Intermediate state of the process is always tracked by `hole`, which serves two purposes:
// 1. Protects integrity of `v` from panics in `compare`.
// 1. Protects integrity of `v` from panics in `is_less`.
// 2. Fills the remaining hole in `v` if the longer run gets consumed first.
//
// Panic safety:
//
// If `compare` panics at any point during the process, `hole` will get dropped and fill the
// If `is_less` panics at any point during the process, `hole` will get dropped and fill the
// hole in `v` with the unconsumed range in `buf`, thus ensuring that `v` still holds every
// object it initially held exactly once.
let mut hole;
Expand All @@ -1476,7 +1476,7 @@ unsafe fn merge<T, F>(v: &mut [T], mid: usize, buf: *mut T, compare: &mut F)
while *left < hole.end && right < v_end {
// Consume the lesser side.
// If equal, prefer the left run to maintain stability.
let to_copy = if compare(&**left, &*right) == Greater {
let to_copy = if is_less(&*right, &**left) {
get_and_increment(&mut right)
} else {
get_and_increment(left)
Expand All @@ -1500,7 +1500,7 @@ unsafe fn merge<T, F>(v: &mut [T], mid: usize, buf: *mut T, compare: &mut F)
while v < *left && buf < *right {
// Consume the greater side.
// If equal, prefer the right run to maintain stability.
let to_copy = if compare(&*left.offset(-1), &*right.offset(-1)) == Greater {
let to_copy = if is_less(&*right.offset(-1), &*left.offset(-1)) {
decrement_and_get(left)
} else {
decrement_and_get(right)
Expand Down Expand Up @@ -1550,8 +1550,8 @@ unsafe fn merge<T, F>(v: &mut [T], mid: usize, buf: *mut T, compare: &mut F)
/// 2. for every `i` in `2..runs.len()`: `runs[i - 2].len > runs[i - 1].len + runs[i].len`
///
/// The invariants ensure that the total running time is `O(n log n)` worst-case.
fn merge_sort<T, F>(v: &mut [T], mut compare: F)
where F: FnMut(&T, &T) -> Ordering
fn merge_sort<T, F>(v: &mut [T], mut is_less: F)
where F: FnMut(&T, &T) -> bool
{
// Sorting has no meaningful behavior on zero-sized types.
if size_of::<T>() == 0 {
Expand All @@ -1565,7 +1565,7 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F)
//
// Short runs are extended using insertion sort to span at least `min_run` elements, in order
// to improve performance.
let (max_insertion, min_run) = if size_of::<T>() <= 16 {
let (max_insertion, min_run) = if size_of::<T>() <= 2 * mem::size_of::<usize>() {
(64, 32)
} else {
(32, 16)
Expand All @@ -1577,15 +1577,15 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F)
if len <= max_insertion {
if len >= 2 {
for i in (0..len-1).rev() {
insert_head(&mut v[i..], &mut compare);
insert_head(&mut v[i..], &mut is_less);
}
}
return;
}

// Allocate a buffer to use as scratch memory. We keep the length 0 so we can keep in it
// shallow copies of the contents of `v` without risking the dtors running on copies if
// `compare` panics. When merging two sorted runs, this buffer holds a copy of the shorter run,
// `is_less` panics. When merging two sorted runs, this buffer holds a copy of the shorter run,
// which will always have length at most `len / 2`.
let mut buf = Vec::with_capacity(len / 2);

Expand All @@ -1600,14 +1600,18 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F)
let mut start = end - 1;
if start > 0 {
start -= 1;
if compare(&v[start], &v[start + 1]) == Greater {
while start > 0 && compare(&v[start - 1], &v[start]) == Greater {
start -= 1;
}
v[start..end].reverse();
} else {
while start > 0 && compare(&v[start - 1], &v[start]) != Greater {
start -= 1;
unsafe {
if is_less(v.get_unchecked(start + 1), v.get_unchecked(start)) {
while start > 0 && is_less(v.get_unchecked(start),
v.get_unchecked(start - 1)) {
start -= 1;
}
v[start..end].reverse();
} else {
while start > 0 && !is_less(v.get_unchecked(start),
v.get_unchecked(start - 1)) {
start -= 1;
}
}
}
}
Expand All @@ -1616,7 +1620,7 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F)
// merge sort on short sequences, so this significantly improves performance.
while start > 0 && end - start < min_run {
start -= 1;
insert_head(&mut v[start..end], &mut compare);
insert_head(&mut v[start..end], &mut is_less);
}

// Push this run onto the stack.
Expand All @@ -1632,7 +1636,7 @@ fn merge_sort<T, F>(v: &mut [T], mut compare: F)
let right = runs[r];
unsafe {
merge(&mut v[left.start .. right.start + right.len], left.len, buf.as_mut_ptr(),
&mut compare);
&mut is_less);
}
runs[r] = Run {
start: left.start,
Expand Down
9 changes: 3 additions & 6 deletions src/libcollectionstest/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1429,18 +1429,15 @@ mod bench {
fn sort_large_random_expensive(b: &mut Bencher) {
let len = 10000;
b.iter(|| {
let mut v = gen_random(len);
let mut count = 0;
let cmp = move |a: &u64, b: &u64| {
v.sort_by(|a: &u64, b: &u64| {
count += 1;
if count % 1_000_000_000 == 0 {
panic!("should not happen");
}
(*a as f64).cos().partial_cmp(&(*b as f64).cos()).unwrap()
};

let mut v = gen_random(len);
v.sort_by(cmp);

});
black_box(count);
});
b.bytes = len as u64 * mem::size_of::<u64>() as u64;
Expand Down
12 changes: 5 additions & 7 deletions src/libcompiler_builtins/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,7 @@ pub mod reimpls {
const MD1 : u32 = MANTISSA_DIGITS + 1;
const MD2 : u32 = MANTISSA_DIGITS + 2;

// SNAP: replace this with !0u128
let negn :u128 = !0;
let negn = !0u128;

if sd > MANTISSA_DIGITS {
a = match sd {
Expand Down Expand Up @@ -579,8 +578,7 @@ pub mod reimpls {
const MD1 : u32 = MANTISSA_DIGITS + 1;
const MD2 : u32 = MANTISSA_DIGITS + 2;

// SNAP: replace this with !0u128
let negn :u128 = !0;
let negn = !0u128;

if sd > MANTISSA_DIGITS {
a = match sd {
Expand Down Expand Up @@ -652,17 +650,17 @@ pub mod reimpls {
}

#[export_name="__fixunssfti"]
pub extern "unadjusted" fn f32_as_u128(a: f32) -> u128 {
pub extern $unadj fn f32_as_u128(a: f32) -> u128 {
float_as_unsigned!(a, f32, u128)
}

#[export_name="__fixdfti"]
pub extern "unadjusted" fn f64_as_i128(a: f64) -> i128 {
pub extern $unadj fn f64_as_i128(a: f64) -> i128 {
float_as_signed!(a, f64, i128)
}

#[export_name="__fixsfti"]
pub extern "unadjusted" fn f32_as_i128(a: f32) -> i128 {
pub extern $unadj fn f32_as_i128(a: f32) -> i128 {
float_as_signed!(a, f32, i128)
}

Expand Down
7 changes: 3 additions & 4 deletions src/libcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bench = false
name = "coretest"
path = "../libcoretest/lib.rs"

# FIXME: need to extract benchmarks to a separate crate
#[[bench]]
#name = "coretest"
#path = "../libcoretest/lib.rs"
[[bench]]
name = "corebench"
path = "../libcore/bench/lib.rs"
22 changes: 22 additions & 0 deletions src/libcore/bench/any.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use core::any::*;
use test::{Bencher, black_box};

#[bench]
fn bench_downcast_ref(b: &mut Bencher) {
b.iter(|| {
let mut x = 0;
let mut y = &mut x as &mut Any;
black_box(&mut y);
black_box(y.downcast_ref::<isize>() == Some(&0));
});
}
11 changes: 11 additions & 0 deletions src/libcore/bench/hash/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

mod sip;
Loading