Skip to content

Commit

Permalink
Auto merge of #30660 - nagisa:rollup, r=steveklabnik
Browse files Browse the repository at this point in the history
- Successful merges: #30365, #30565, #30590, #30630
- Failed merges:
  • Loading branch information
bors committed Dec 31, 2015
2 parents 3b6a851 + 7448f48 commit 53cd573
Show file tree
Hide file tree
Showing 20 changed files with 1,402 additions and 479 deletions.
10 changes: 7 additions & 3 deletions mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ define DEF_GOOD_VALGRIND
ifeq ($(OSTYPE_$(1)),unknown-linux-gnu)
GOOD_VALGRIND_$(1) = 1
endif
ifneq (,$(filter $(OSTYPE_$(1)),darwin freebsd))
ifeq (HOST_$(1),x86_64)
ifneq (,$(filter $(OSTYPE_$(1)),apple-darwin freebsd))
ifeq ($(HOST_$(1)),x86_64)
GOOD_VALGRIND_$(1) = 1
endif
endif
ifdef GOOD_VALGRIND_$(t)
$$(info cfg: have good valgrind for $(t))
else
$$(info cfg: no good valgrind for $(t))
endif
endef
$(foreach t,$(CFG_TARGET),$(eval $(call DEF_GOOD_VALGRIND,$(t))))
$(foreach t,$(CFG_TARGET),$(info cfg: good valgrind for $(t) is $(GOOD_VALGRIND_$(t))))

ifneq ($(findstring linux,$(CFG_OSTYPE)),)
ifdef CFG_PERF
Expand Down
72 changes: 21 additions & 51 deletions src/etc/apple-darwin.supp
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
{
osx-frameworks.rs-fails-otherwise-1
Memcheck:Leak
match-leak-kinds: possible
match-leak-kinds: definite,possible
fun:malloc
...
fun:__CFInitialize
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader19processInitializersERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader15runInitializersERKNS_11LinkContextERNS_21InitializerTimingListE
fun:_ZN4dyld24initializeMainExecutableEv
...
}

{
Expand All @@ -22,23 +16,17 @@
...
fun:__CFInitialize
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader19processInitializersERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
}

{
osx-frameworks.rs-fails-otherwise-3
Memcheck:Leak
match-leak-kinds: possible
fun:realloc
fun:_ZL12realizeClassP10objc_class
fun:_ZL12realizeClassP10objc_class
fun:_ZN13list_array_ttIm15protocol_list_tE11attachListsEPKPS0_j
...
fun:_read_images
fun:map_images_nolock
fun:map_2_images
...
fun:_ZN4dyldL18notifyBatchPartialE17dyld_image_statesbPFPKcS0_jPK15dyld_image_infoE
fun:_ZN4dyld36registerImageStateBatchChangeHandlerE17dyld_image_statesPFPKcS0_jPK15dyld_image_infoE
fun:dyld_register_image_state_change_handler
Expand All @@ -49,7 +37,7 @@
{
osx-frameworks.rs-fails-otherwise-4
Memcheck:Leak
match-leak-kinds: possible
match-leak-kinds: definite,possible
fun:calloc
...
fun:__CFInitialize
Expand All @@ -61,45 +49,27 @@
{
osx-frameworks.rs-fails-otherwise-5
Memcheck:Leak
match-leak-kinds: definite
fun:calloc
match-leak-kinds: definite,possible
fun:malloc_zone_malloc
...
fun:__CFInitialize
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
}

{
osx-frameworks.rs-fails-otherwise-6
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:strdup
fun:_CFProcessPath
fun:__CFInitialize
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader19processInitializersERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader15runInitializersERKNS_11LinkContextERNS_21InitializerTimingListE
fun:_ZN4dyld24initializeMainExecutableEv
fun:_ZN4dyld5_mainEPK12macho_headermiPPKcS5_S5_Pm
...
}

{
osx-frameworks.rs-fails-otherwise-7
fails-since-xcode-7.2
Memcheck:Leak
match-leak-kinds: definite
match-leak-kinds: possible
fun:malloc_zone_malloc
...
fun:__CFInitialize
fun:_ZN16ImageLoaderMachO11doImageInitERKN11ImageLoader11LinkContextE
fun:_ZN16ImageLoaderMachO16doInitializationERKN11ImageLoader11LinkContextE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader19processInitializersERKNS_11LinkContextEjRNS_21InitializerTimingListERNS_15UninitedUpwardsE
fun:_ZN11ImageLoader15runInitializersERKNS_11LinkContextERNS_21InitializerTimingListE
fun:_ZN4dyld24initializeMainExecutableEv
fun:_objc_copyClassNamesForImage
fun:_ZL9protocolsv
fun:_Z9readClassP10objc_classbb
fun:gc_init
fun:_ZL33objc_initializeClassPair_internalP10objc_classPKcS0_S0_
fun:layout_string_create
fun:_ZL12realizeClassP10objc_class
fun:_ZL22copySwiftV1MangledNamePKcb
fun:_ZL22copySwiftV1MangledNamePKcb
fun:_ZL22copySwiftV1MangledNamePKcb
fun:_ZL22copySwiftV1MangledNamePKcb
}
8 changes: 4 additions & 4 deletions src/etc/x86.supp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
fun:tlv_finalize
fun:_pthread_tsd_cleanup
fun:_pthread_exit
fun:_pthread_body
...
fun:_pthread_start
fun:thread_start
}
Expand All @@ -24,7 +24,7 @@
fun:tlv_finalize
fun:_pthread_tsd_cleanup
fun:_pthread_exit
fun:_pthread_body
...
fun:_pthread_start
fun:thread_start
}
Expand All @@ -36,7 +36,7 @@
fun:tlv_finalize
fun:_pthread_tsd_cleanup
fun:_pthread_exit
fun:_pthread_body
...
fun:_pthread_start
fun:thread_start
}
Expand All @@ -48,7 +48,7 @@
fun:tlv_finalize
fun:_pthread_tsd_cleanup
fun:_pthread_exit
fun:_pthread_body
...
fun:_pthread_start
fun:thread_start
}
Expand Down
162 changes: 162 additions & 0 deletions src/librbml/leb128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// Copyright 2012-2015 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.

#[inline]
pub fn write_to_vec(vec: &mut Vec<u8>, position: &mut usize, byte: u8)
{
if *position == vec.len() {
vec.push(byte);
} else {
vec[*position] = byte;
}

*position += 1;
}

pub fn write_unsigned_leb128(out: &mut Vec<u8>,
start_position: usize,
mut value: u64)
-> usize {
let mut position = start_position;
loop
{
let mut byte = (value & 0x7F) as u8;
value >>= 7;
if value != 0 {
byte |= 0x80;
}

write_to_vec(out, &mut position, byte);

if value == 0 {
break;
}
}

return position - start_position;
}

pub fn read_unsigned_leb128(data: &[u8],
start_position: usize)
-> (u64, usize) {
let mut result = 0;
let mut shift = 0;
let mut position = start_position;
loop {
let byte = data[position];
position += 1;
result |= ((byte & 0x7F) as u64) << shift;
if (byte & 0x80) == 0 {
break;
}
shift += 7;
}

(result, position - start_position)
}


pub fn write_signed_leb128(out: &mut Vec<u8>,
start_position: usize,
mut value: i64) -> usize {
let mut position = start_position;

loop {
let mut byte = (value as u8) & 0x7f;
value >>= 7;
let more = !((((value == 0 ) && ((byte & 0x40) == 0)) ||
((value == -1) && ((byte & 0x40) != 0))));
if more {
byte |= 0x80; // Mark this byte to show that more bytes will follow.
}

write_to_vec(out, &mut position, byte);

if !more {
break;
}
}

return position - start_position;
}

pub fn read_signed_leb128(data: &[u8],
start_position: usize)
-> (i64, usize) {
let mut result = 0;
let mut shift = 0;
let mut position = start_position;
let mut byte;

loop {
byte = data[position];
position += 1;
result |= ((byte & 0x7F) as i64) << shift;
shift += 7;

if (byte & 0x80) == 0 {
break;
}
}

if (shift < 64) && ((byte & 0x40) != 0) {
/* sign extend */
result |= -(1i64 << shift);
}

(result, position - start_position)
}

#[test]
fn test_unsigned_leb128() {
let mut stream = Vec::with_capacity(10000);

for x in 0..62 {
let pos = stream.len();
let bytes_written = write_unsigned_leb128(&mut stream, pos, 3 << x);
assert_eq!(stream.len(), pos + bytes_written);
}

let mut position = 0;
for x in 0..62 {
let expected = 3 << x;
let (actual, bytes_read) = read_unsigned_leb128(&stream, position);
assert_eq!(expected, actual);
position += bytes_read;
}
assert_eq!(stream.len(), position);
}

#[test]
fn test_signed_leb128() {
let mut values = Vec::new();

let mut i = -500;
while i < 500 {
values.push(i * 123457i64);
i += 1;
}

let mut stream = Vec::new();

for &x in &values {
let pos = stream.len();
let bytes_written = write_signed_leb128(&mut stream, pos, x);
assert_eq!(stream.len(), pos + bytes_written);
}

let mut pos = 0;
for &x in &values {
let (value, bytes_read) = read_signed_leb128(&mut stream, pos);
pos += bytes_read;
assert_eq!(x, value);
}
assert_eq!(pos, stream.len());
}
Loading

0 comments on commit 53cd573

Please sign in to comment.