Skip to content

Commit 5f8ef47

Browse files
committed
---
yaml --- r: 63270 b: refs/heads/snap-stage3 c: 9963013 h: refs/heads/master v: v3
1 parent a39cb21 commit 5f8ef47

38 files changed

+3041
-2798
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 00ff170e7ff22b47ed077474c0b763cd48fd9ffb
4+
refs/heads/snap-stage3: 996301331e2d8ac7611d15ca82cc3ebc1abb632d
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/rt.mk

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,6 @@ $$(LIBUV_LIB_$(1)_$(2)): $$(LIBUV_DEPS)
210210
V=$$(VERBOSE)
211211
endif
212212

213-
ifeq ($(OSTYPE_$(1)), linux-androideabi)
214-
$$(JEMALLOC_LIB_$(1)_$(2)):
215-
cd $$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/jemalloc; $(S)src/rt/jemalloc/configure \
216-
--disable-experimental --build=$(CFG_BUILD_TRIPLE) --host=$(1) --disable-tls \
217-
EXTRA_CFLAGS="$$(CFG_GCCISH_CFLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
218-
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS) $$(LIBUV_FLAGS_$$(HOST_$(1)))" \
219-
CC="$$(CC_$(1))" \
220-
CXX="$$(CXX_$(1))" \
221-
AR="$$(AR_$(1))"
222-
$$(Q)$$(MAKE) -C $$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/jemalloc
223-
else
224213
$$(JEMALLOC_LIB_$(1)_$(2)):
225214
cd $$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/jemalloc; $(S)src/rt/jemalloc/configure \
226215
--disable-experimental --build=$(CFG_BUILD_TRIPLE) --host=$(1) \
@@ -230,7 +219,6 @@ $$(JEMALLOC_LIB_$(1)_$(2)):
230219
CXX="$$(CXX_$(1))" \
231220
AR="$$(AR_$(1))"
232221
$$(Q)$$(MAKE) -C $$(CFG_BUILD_DIR)/rt/$(1)/stage$(2)/jemalloc
233-
endif
234222

235223

236224
# These could go in rt.mk or rustllvm.mk, they're needed for both.
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
// Copyright 2013 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+
/*!
12+
13+
Dynamic library facilities.
14+
15+
A simple wrapper over the platforms dynamic library facilities
16+
17+
*/
18+
use ptr;
19+
use cast;
20+
use path;
21+
use libc;
22+
use ops::*;
23+
use option::*;
24+
use result::*;
25+
26+
pub struct DynamicLibrary { priv handle: *libc::c_void }
27+
28+
impl Drop for DynamicLibrary {
29+
fn finalize(&self) {
30+
match do dl::check_for_errors_in {
31+
unsafe {
32+
dl::close(self.handle)
33+
}
34+
} {
35+
Ok(()) => { },
36+
Err(str) => fail!(str)
37+
}
38+
}
39+
}
40+
41+
impl DynamicLibrary {
42+
/// Lazily open a dynamic library. When passed None it gives a
43+
/// handle to the calling process
44+
pub fn open(filename: Option<&path::Path>) -> Result<DynamicLibrary, ~str> {
45+
let open_wrapper = |raw_ptr| {
46+
do dl::check_for_errors_in {
47+
unsafe {
48+
DynamicLibrary { handle: dl::open(raw_ptr) }
49+
}
50+
}
51+
};
52+
53+
match filename {
54+
Some(name) => do name.to_str().as_c_str |raw_name| {
55+
open_wrapper(raw_name)
56+
},
57+
None => open_wrapper(ptr::null())
58+
}
59+
}
60+
61+
/// Access the value at the symbol of the dynamic library
62+
pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<T, ~str> {
63+
// This function should have a lifetime constraint of 'self on
64+
// T but that feature is still unimplemented
65+
66+
do dl::check_for_errors_in {
67+
let symbol_value = do symbol.as_c_str |raw_string| {
68+
dl::symbol(self.handle, raw_string)
69+
};
70+
71+
cast::transmute(symbol_value)
72+
}
73+
}
74+
}
75+
76+
#[test]
77+
priv fn test_loading_cosine () {
78+
// The math library does not need to be loaded since it is already
79+
// statically linked in
80+
let libm = match DynamicLibrary::open(None) {
81+
Err (error) => fail!("Could not load self as module: %s", error),
82+
Ok (libm) => libm
83+
};
84+
85+
// Unfortunately due to issue #6194 it is not possible to call
86+
// this as a C function
87+
let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe {
88+
match libm.symbol("cos") {
89+
Err (error) => fail!("Could not load function cos: %s", error),
90+
Ok (cosine) => cosine
91+
}
92+
};
93+
94+
let argument = 0.0;
95+
let expected_result = 1.0;
96+
let result = cosine(argument);
97+
if result != expected_result {
98+
fail!("cos(%?) != %? but equaled %? instead", argument,
99+
expected_result, result)
100+
}
101+
}
102+
103+
#[cfg(target_os = "linux")]
104+
#[cfg(target_os = "android")]
105+
#[cfg(target_os = "macos")]
106+
#[cfg(target_os = "freebsd")]
107+
mod dl {
108+
use libc;
109+
use ptr;
110+
use str;
111+
use task;
112+
use result::*;
113+
114+
pub unsafe fn open(filename: *libc::c_char) -> *libc::c_void {
115+
dlopen(filename, Lazy as libc::c_int)
116+
}
117+
118+
pub fn check_for_errors_in<T>(f: &fn()->T) -> Result<T, ~str> {
119+
unsafe {
120+
do task::atomically {
121+
let _old_error = dlerror();
122+
123+
let result = f();
124+
125+
let last_error = dlerror();
126+
if ptr::null() == last_error {
127+
Ok(result)
128+
} else {
129+
Err(str::raw::from_c_str(last_error))
130+
}
131+
}
132+
}
133+
}
134+
135+
pub unsafe fn symbol(handle: *libc::c_void, symbol: *libc::c_char) -> *libc::c_void {
136+
dlsym(handle, symbol)
137+
}
138+
pub unsafe fn close(handle: *libc::c_void) {
139+
dlclose(handle); ()
140+
}
141+
142+
pub enum RTLD {
143+
Lazy = 1,
144+
Now = 2,
145+
Global = 256,
146+
Local = 0,
147+
}
148+
149+
#[link_name = "dl"]
150+
extern {
151+
fn dlopen(filename: *libc::c_char, flag: libc::c_int) -> *libc::c_void;
152+
fn dlerror() -> *libc::c_char;
153+
fn dlsym(handle: *libc::c_void, symbol: *libc::c_char) -> *libc::c_void;
154+
fn dlclose(handle: *libc::c_void) -> libc::c_int;
155+
}
156+
}
157+
158+
#[cfg(target_os = "win32")]
159+
mod dl {
160+
use os;
161+
use libc;
162+
use task;
163+
use result::*;
164+
165+
pub unsafe fn open(filename: *libc::c_char) -> *libc::c_void {
166+
LoadLibrary(filename)
167+
}
168+
169+
pub fn check_for_errors_in<T>(f: &fn()->T) -> Result<T, ~str> {
170+
unsafe {
171+
do task::atomically {
172+
SetLastError(0);
173+
174+
let result = f();
175+
176+
let error = os::errno();
177+
if 0 == error {
178+
Ok(result)
179+
} else {
180+
Err(fmt!("Error code %?", error))
181+
}
182+
}
183+
}
184+
}
185+
pub unsafe fn symbol(handle: *libc::c_void, symbol: *libc::c_char) -> *libc::c_void {
186+
GetProcAddress(handle, symbol)
187+
}
188+
pub unsafe fn close(handle: *libc::c_void) {
189+
FreeLibrary(handle); ()
190+
}
191+
192+
#[link_name = "kernel32"]
193+
extern "stdcall" {
194+
fn SetLastError(error: u32);
195+
fn LoadLibrary(name: *libc::c_char) -> *libc::c_void;
196+
fn GetProcAddress(handle: *libc::c_void, name: *libc::c_char) -> *libc::c_void;
197+
fn FreeLibrary(handle: *libc::c_void);
198+
}
199+
}

branches/snap-stage3/src/libstd/unstable/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ use prelude::*;
1717
use task;
1818

1919
pub mod at_exit;
20+
21+
// Currently only works for *NIXes
22+
#[cfg(target_os = "linux")]
23+
#[cfg(target_os = "android")]
24+
#[cfg(target_os = "macos")]
25+
#[cfg(target_os = "freebsd")]
26+
pub mod dynamic_lib;
27+
2028
pub mod global;
2129
pub mod finally;
2230
pub mod weak_task;

branches/snap-stage3/src/rt/jemalloc/ChangeLog

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ found in the git revision history:
66
http://www.canonware.com/cgi-bin/gitweb.cgi?p=jemalloc.git
77
git://canonware.com/jemalloc.git
88

9+
* 3.4.0 (June 2, 2013)
10+
11+
This version is essentially a small bugfix release, but the addition of
12+
aarch64 support requires that the minor version be incremented.
13+
14+
Bug fixes:
15+
- Fix race-triggered deadlocks in chunk_record(). These deadlocks were
16+
typically triggered by multiple threads concurrently deallocating huge
17+
objects.
18+
19+
New features:
20+
- Add support for the aarch64 architecture.
21+
922
* 3.3.1 (March 6, 2013)
1023

1124
This version fixes bugs that are typically encountered only when utilizing
@@ -15,7 +28,7 @@ found in the git revision history:
1528
- Fix a locking order bug that could cause deadlock during fork if heap
1629
profiling were enabled.
1730
- Fix a chunk recycling bug that could cause the allocator to lose track of
18-
whether a chunk was zeroed. On FreeBSD, NetBSD, and OS X, it could cause
31+
whether a chunk was zeroed. On FreeBSD, NetBSD, and OS X, it could cause
1932
corruption if allocating via sbrk(2) (unlikely unless running with the
2033
"dss:primary" option specified). This was completely harmless on Linux
2134
unless using mlockall(2) (and unlikely even then, unless the
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.1-0-g9ef9d9e8c271cdf14f664b871a8f98c827714784
1+
3.4.0-0-g0ed518e5dab789ad2171bb38977a8927e2a26775

branches/snap-stage3/src/rt/jemalloc/bin/pprof

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# Copyright (c) 1998-2007, Google Inc.
44
# All rights reserved.
5-
#
5+
#
66
# Redistribution and use in source and binary forms, with or without
77
# modification, are permitted provided that the following conditions are
88
# met:
9-
#
9+
#
1010
# * Redistributions of source code must retain the above copyright
1111
# notice, this list of conditions and the following disclaimer.
1212
# * Redistributions in binary form must reproduce the above
@@ -16,7 +16,7 @@
1616
# * Neither the name of Google Inc. nor the names of its
1717
# contributors may be used to endorse or promote products derived from
1818
# this software without specific prior written permission.
19-
#
19+
#
2020
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2121
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2222
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -1683,23 +1683,23 @@ sub PrintSource {
16831683
HtmlPrintNumber($c2),
16841684
UnparseAddress($offset, $e->[0]),
16851685
CleanDisassembly($e->[3]));
1686-
1686+
16871687
# Append the most specific source line associated with this instruction
16881688
if (length($dis) < 80) { $dis .= (' ' x (80 - length($dis))) };
16891689
$dis = HtmlEscape($dis);
16901690
my $f = $e->[5];
16911691
my $l = $e->[6];
16921692
if ($f ne $last_dis_filename) {
1693-
$dis .= sprintf("<span class=disasmloc>%s:%d</span>",
1693+
$dis .= sprintf("<span class=disasmloc>%s:%d</span>",
16941694
HtmlEscape(CleanFileName($f)), $l);
16951695
} elsif ($l ne $last_dis_linenum) {
16961696
# De-emphasize the unchanged file name portion
16971697
$dis .= sprintf("<span class=unimportant>%s</span>" .
1698-
"<span class=disasmloc>:%d</span>",
1698+
"<span class=disasmloc>:%d</span>",
16991699
HtmlEscape(CleanFileName($f)), $l);
17001700
} else {
17011701
# De-emphasize the entire location
1702-
$dis .= sprintf("<span class=unimportant>%s:%d</span>",
1702+
$dis .= sprintf("<span class=unimportant>%s:%d</span>",
17031703
HtmlEscape(CleanFileName($f)), $l);
17041704
}
17051705
$last_dis_filename = $f;
@@ -1788,8 +1788,8 @@ sub PrintSource {
17881788
if (defined($dis) && $dis ne '') {
17891789
$asm = "<span class=\"asm\">" . $dis . "</span>";
17901790
}
1791-
my $source_class = (($n1 + $n2 > 0)
1792-
? "livesrc"
1791+
my $source_class = (($n1 + $n2 > 0)
1792+
? "livesrc"
17931793
: (($asm ne "") ? "deadsrc" : "nop"));
17941794
printf $output (
17951795
"<span class=\"line\">%5d</span> " .
@@ -4723,7 +4723,7 @@ sub MapToSymbols {
47234723
}
47244724
}
47254725
}
4726-
4726+
47274727
# Prepend to accumulated symbols for pcstr
47284728
# (so that caller comes before callee)
47294729
my $sym = $symbols->{$pcstr};
@@ -4917,7 +4917,7 @@ sub ConfigureTool {
49174917
my $dirname = $`; # this is everything up to and including the last slash
49184918
if (-x "$dirname$tool") {
49194919
$path = "$dirname$tool";
4920-
} else {
4920+
} else {
49214921
$path = $tool;
49224922
}
49234923
}

branches/snap-stage3/src/rt/jemalloc/configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
2626
])
2727

2828
dnl JE_COMPILABLE(label, hcode, mcode, rvar)
29-
dnl
29+
dnl
3030
dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
3131
dnl cause failure.
3232
AC_DEFUN([JE_COMPILABLE],
@@ -232,7 +232,7 @@ CC_MM=1
232232
dnl Platform-specific settings. abi and RPATH can probably be determined
233233
dnl programmatically, but doing so is error-prone, which makes it generally
234234
dnl not worth the trouble.
235-
dnl
235+
dnl
236236
dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
237237
dnl definitions need to be seen before any headers are included, which is a pain
238238
dnl to make happen otherwise.
@@ -965,7 +965,7 @@ fi
965965

966966
dnl ============================================================================
967967
dnl jemalloc configuration.
968-
dnl
968+
dnl
969969

970970
dnl Set VERSION if source directory has an embedded git repository.
971971
if test -d "${srcroot}.git" ; then

0 commit comments

Comments
 (0)