Skip to content

Commit 53cd573

Browse files
committed
Auto merge of rust-lang#30660 - nagisa:rollup, r=steveklabnik
- Successful merges: rust-lang#30365, rust-lang#30565, rust-lang#30590, rust-lang#30630 - Failed merges:
2 parents 3b6a851 + 7448f48 commit 53cd573

File tree

20 files changed

+1402
-479
lines changed

20 files changed

+1402
-479
lines changed

mk/platform.mk

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,18 @@ define DEF_GOOD_VALGRIND
6464
ifeq ($(OSTYPE_$(1)),unknown-linux-gnu)
6565
GOOD_VALGRIND_$(1) = 1
6666
endif
67-
ifneq (,$(filter $(OSTYPE_$(1)),darwin freebsd))
68-
ifeq (HOST_$(1),x86_64)
67+
ifneq (,$(filter $(OSTYPE_$(1)),apple-darwin freebsd))
68+
ifeq ($(HOST_$(1)),x86_64)
6969
GOOD_VALGRIND_$(1) = 1
7070
endif
7171
endif
72+
ifdef GOOD_VALGRIND_$(t)
73+
$$(info cfg: have good valgrind for $(t))
74+
else
75+
$$(info cfg: no good valgrind for $(t))
76+
endif
7277
endef
7378
$(foreach t,$(CFG_TARGET),$(eval $(call DEF_GOOD_VALGRIND,$(t))))
74-
$(foreach t,$(CFG_TARGET),$(info cfg: good valgrind for $(t) is $(GOOD_VALGRIND_$(t))))
7579

7680
ifneq ($(findstring linux,$(CFG_OSTYPE)),)
7781
ifdef CFG_PERF

src/etc/apple-darwin.supp

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
{
22
osx-frameworks.rs-fails-otherwise-1
33
Memcheck:Leak
4-
match-leak-kinds: possible
4+
match-leak-kinds: definite,possible
55
fun:malloc
66
...
77
fun:__CFInitialize
8-
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
9-
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
10-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
11-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
12-
fun:_ZN11ImageLoader19processInitializersERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
13-
fun:_ZN11ImageLoader15runInitializersERKNS_11LinkContextERNS_21InitializerTimingListE
14-
fun:_ZN4dyld24initializeMainExecutableEv
8+
...
159
}
1610

1711
{
@@ -22,23 +16,17 @@
2216
...
2317
fun:__CFInitialize
2418
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
25-
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
26-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
27-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
28-
fun:_ZN11ImageLoader19processInitializersERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
2919
}
3020

3121
{
3222
osx-frameworks.rs-fails-otherwise-3
3323
Memcheck:Leak
3424
match-leak-kinds: possible
3525
fun:realloc
36-
fun:_ZL12realizeClassP10objc_class
37-
fun:_ZL12realizeClassP10objc_class
38-
fun:_ZN13list_array_ttIm15protocol_list_tE11attachListsEPKPS0_j
26+
...
3927
fun:_read_images
4028
fun:map_images_nolock
41-
fun:map_2_images
29+
...
4230
fun:_ZN4dyldL18notifyBatchPartialE17dyld_image_statesbPFPKcS0_jPK15dyld_image_infoE
4331
fun:_ZN4dyld36registerImageStateBatchChangeHandlerE17dyld_image_statesPFPKcS0_jPK15dyld_image_infoE
4432
fun:dyld_register_image_state_change_handler
@@ -49,7 +37,7 @@
4937
{
5038
osx-frameworks.rs-fails-otherwise-4
5139
Memcheck:Leak
52-
match-leak-kinds: possible
40+
match-leak-kinds: definite,possible
5341
fun:calloc
5442
...
5543
fun:__CFInitialize
@@ -61,45 +49,27 @@
6149
{
6250
osx-frameworks.rs-fails-otherwise-5
6351
Memcheck:Leak
64-
match-leak-kinds: definite
65-
fun:calloc
52+
match-leak-kinds: definite,possible
53+
fun:malloc_zone_malloc
6654
...
6755
fun:__CFInitialize
68-
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
69-
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
70-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
71-
}
72-
73-
{
74-
osx-frameworks.rs-fails-otherwise-6
75-
Memcheck:Leak
76-
match-leak-kinds: definite
77-
fun:malloc
78-
fun:strdup
79-
fun:_CFProcessPath
80-
fun:__CFInitialize
81-
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
82-
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
83-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
84-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
85-
fun:_ZN11ImageLoader19processInitializersERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
86-
fun:_ZN11ImageLoader15runInitializersERKNS_11LinkContextERNS_21InitializerTimingListE
87-
fun:_ZN4dyld24initializeMainExecutableEv
88-
fun:_ZN4dyld5_mainEPK12macho_headermiPPKcS5_S5_Pm
56+
...
8957
}
9058

9159
{
92-
osx-frameworks.rs-fails-otherwise-7
60+
fails-since-xcode-7.2
9361
Memcheck:Leak
94-
match-leak-kinds: definite
62+
match-leak-kinds: possible
9563
fun:malloc_zone_malloc
96-
...
97-
fun:__CFInitialize
98-
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
99-
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
100-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
101-
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
102-
fun:_ZN11ImageLoader19processInitializersERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
103-
fun:_ZN11ImageLoader15runInitializersERKNS_11LinkContextERNS_21InitializerTimingListE
104-
fun:_ZN4dyld24initializeMainExecutableEv
64+
fun:_objc_copyClassNamesForImage
65+
fun:_ZL9protocolsv
66+
fun:_Z9readClassP10objc_classbb
67+
fun:gc_init
68+
fun:_ZL33objc_initializeClassPair_internalP10objc_classPKcS0_S0_
69+
fun:layout_string_create
70+
fun:_ZL12realizeClassP10objc_class
71+
fun:_ZL22copySwiftV1MangledNamePKcb
72+
fun:_ZL22copySwiftV1MangledNamePKcb
73+
fun:_ZL22copySwiftV1MangledNamePKcb
74+
fun:_ZL22copySwiftV1MangledNamePKcb
10575
}

src/etc/x86.supp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
fun:tlv_finalize
1313
fun:_pthread_tsd_cleanup
1414
fun:_pthread_exit
15-
fun:_pthread_body
15+
...
1616
fun:_pthread_start
1717
fun:thread_start
1818
}
@@ -24,7 +24,7 @@
2424
fun:tlv_finalize
2525
fun:_pthread_tsd_cleanup
2626
fun:_pthread_exit
27-
fun:_pthread_body
27+
...
2828
fun:_pthread_start
2929
fun:thread_start
3030
}
@@ -36,7 +36,7 @@
3636
fun:tlv_finalize
3737
fun:_pthread_tsd_cleanup
3838
fun:_pthread_exit
39-
fun:_pthread_body
39+
...
4040
fun:_pthread_start
4141
fun:thread_start
4242
}
@@ -48,7 +48,7 @@
4848
fun:tlv_finalize
4949
fun:_pthread_tsd_cleanup
5050
fun:_pthread_exit
51-
fun:_pthread_body
51+
...
5252
fun:_pthread_start
5353
fun:thread_start
5454
}

src/librbml/leb128.rs

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[inline]
12+
pub fn write_to_vec(vec: &mut Vec<u8>, position: &mut usize, byte: u8)
13+
{
14+
if *position == vec.len() {
15+
vec.push(byte);
16+
} else {
17+
vec[*position] = byte;
18+
}
19+
20+
*position += 1;
21+
}
22+
23+
pub fn write_unsigned_leb128(out: &mut Vec<u8>,
24+
start_position: usize,
25+
mut value: u64)
26+
-> usize {
27+
let mut position = start_position;
28+
loop
29+
{
30+
let mut byte = (value & 0x7F) as u8;
31+
value >>= 7;
32+
if value != 0 {
33+
byte |= 0x80;
34+
}
35+
36+
write_to_vec(out, &mut position, byte);
37+
38+
if value == 0 {
39+
break;
40+
}
41+
}
42+
43+
return position - start_position;
44+
}
45+
46+
pub fn read_unsigned_leb128(data: &[u8],
47+
start_position: usize)
48+
-> (u64, usize) {
49+
let mut result = 0;
50+
let mut shift = 0;
51+
let mut position = start_position;
52+
loop {
53+
let byte = data[position];
54+
position += 1;
55+
result |= ((byte & 0x7F) as u64) << shift;
56+
if (byte & 0x80) == 0 {
57+
break;
58+
}
59+
shift += 7;
60+
}
61+
62+
(result, position - start_position)
63+
}
64+
65+
66+
pub fn write_signed_leb128(out: &mut Vec<u8>,
67+
start_position: usize,
68+
mut value: i64) -> usize {
69+
let mut position = start_position;
70+
71+
loop {
72+
let mut byte = (value as u8) & 0x7f;
73+
value >>= 7;
74+
let more = !((((value == 0 ) && ((byte & 0x40) == 0)) ||
75+
((value == -1) && ((byte & 0x40) != 0))));
76+
if more {
77+
byte |= 0x80; // Mark this byte to show that more bytes will follow.
78+
}
79+
80+
write_to_vec(out, &mut position, byte);
81+
82+
if !more {
83+
break;
84+
}
85+
}
86+
87+
return position - start_position;
88+
}
89+
90+
pub fn read_signed_leb128(data: &[u8],
91+
start_position: usize)
92+
-> (i64, usize) {
93+
let mut result = 0;
94+
let mut shift = 0;
95+
let mut position = start_position;
96+
let mut byte;
97+
98+
loop {
99+
byte = data[position];
100+
position += 1;
101+
result |= ((byte & 0x7F) as i64) << shift;
102+
shift += 7;
103+
104+
if (byte & 0x80) == 0 {
105+
break;
106+
}
107+
}
108+
109+
if (shift < 64) && ((byte & 0x40) != 0) {
110+
/* sign extend */
111+
result |= -(1i64 << shift);
112+
}
113+
114+
(result, position - start_position)
115+
}
116+
117+
#[test]
118+
fn test_unsigned_leb128() {
119+
let mut stream = Vec::with_capacity(10000);
120+
121+
for x in 0..62 {
122+
let pos = stream.len();
123+
let bytes_written = write_unsigned_leb128(&mut stream, pos, 3 << x);
124+
assert_eq!(stream.len(), pos + bytes_written);
125+
}
126+
127+
let mut position = 0;
128+
for x in 0..62 {
129+
let expected = 3 << x;
130+
let (actual, bytes_read) = read_unsigned_leb128(&stream, position);
131+
assert_eq!(expected, actual);
132+
position += bytes_read;
133+
}
134+
assert_eq!(stream.len(), position);
135+
}
136+
137+
#[test]
138+
fn test_signed_leb128() {
139+
let mut values = Vec::new();
140+
141+
let mut i = -500;
142+
while i < 500 {
143+
values.push(i * 123457i64);
144+
i += 1;
145+
}
146+
147+
let mut stream = Vec::new();
148+
149+
for &x in &values {
150+
let pos = stream.len();
151+
let bytes_written = write_signed_leb128(&mut stream, pos, x);
152+
assert_eq!(stream.len(), pos + bytes_written);
153+
}
154+
155+
let mut pos = 0;
156+
for &x in &values {
157+
let (value, bytes_read) = read_signed_leb128(&mut stream, pos);
158+
pos += bytes_read;
159+
assert_eq!(x, value);
160+
}
161+
assert_eq!(pos, stream.len());
162+
}

0 commit comments

Comments
 (0)