Skip to content

Commit 59576f5

Browse files
committed
---
yaml --- r: 85732 b: refs/heads/dist-snap c: 0a1baef h: refs/heads/master v: v3
1 parent d7b044c commit 59576f5

File tree

13 files changed

+100
-319
lines changed

13 files changed

+100
-319
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 7b5a91f4b346b99b4e9171eb8deb52d9bf2525ea
9+
refs/heads/dist-snap: 0a1baef4f57b4ac8558a65b7bd8dc787ebf54840
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/mk/rt.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ endif
6363
endif
6464

6565
RUNTIME_CXXS_$(1)_$(2) := \
66-
rt/sync/timer.cpp \
6766
rt/sync/lock_and_signal.cpp \
6867
rt/sync/rust_thread.cpp \
6968
rt/rust_builtin.cpp \
@@ -75,7 +74,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
7574
rt/rust_gc_metadata.cpp \
7675
rt/rust_util.cpp \
7776
rt/rust_log.cpp \
78-
rt/rust_exchange_alloc.cpp \
7977
rt/isaac/randport.cpp \
8078
rt/miniz.cpp \
8179
rt/rust_abi.cpp \

branches/dist-snap/src/libextra/time.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ pub struct Tm {
121121
}
122122

123123
pub fn empty_tm() -> Tm {
124+
// 64 is the max size of the timezone buffer allocated on windows
125+
// in rust_localtime. In glibc the max timezone size is supposedly 3.
126+
let zone = str::with_capacity(64);
124127
Tm {
125128
tm_sec: 0_i32,
126129
tm_min: 0_i32,
@@ -132,7 +135,7 @@ pub fn empty_tm() -> Tm {
132135
tm_yday: 0_i32,
133136
tm_isdst: 0_i32,
134137
tm_gmtoff: 0_i32,
135-
tm_zone: ~"",
138+
tm_zone: zone,
136139
tm_nsec: 0_i32,
137140
}
138141
}

branches/dist-snap/src/librustc/middle/trans/monomorphize.rs

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ use middle::trans::type_of;
2626
use middle::trans::type_use;
2727
use middle::trans::intrinsic;
2828
use middle::ty;
29+
use middle::ty::{FnSig};
2930
use middle::typeck;
3031
use util::ppaux::{Repr,ty_to_str};
3132

3233
use syntax::ast;
3334
use syntax::ast_map;
3435
use syntax::ast_map::path_name;
3536
use syntax::ast_util::local_def;
37+
use syntax::opt_vec;
38+
use syntax::abi::AbiSet;
3639

3740
pub fn monomorphic_fn(ccx: @mut CrateContext,
3841
fn_id: ast::def_id,
@@ -58,10 +61,17 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
5861
let _icx = push_ctxt("monomorphic_fn");
5962
let mut must_cast = false;
6063

64+
let do_normalize = |t: &ty::t| {
65+
match normalize_for_monomorphization(ccx.tcx, *t) {
66+
Some(t) => { must_cast = true; t }
67+
None => *t
68+
}
69+
};
70+
6171
let psubsts = @param_substs {
62-
tys: real_substs.tps.to_owned(),
72+
tys: real_substs.tps.map(|x| do_normalize(x)),
6373
vtables: vtables,
64-
self_ty: real_substs.self_ty.clone(),
74+
self_ty: real_substs.self_ty.map(|x| do_normalize(x)),
6575
self_vtables: self_vtables
6676
};
6777

@@ -295,6 +305,61 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
295305
(lldecl, must_cast)
296306
}
297307

308+
pub fn normalize_for_monomorphization(tcx: ty::ctxt,
309+
ty: ty::t) -> Option<ty::t> {
310+
// FIXME[mono] could do this recursively. is that worthwhile? (#2529)
311+
return match ty::get(ty).sty {
312+
ty::ty_box(*) => {
313+
Some(ty::mk_opaque_box(tcx))
314+
}
315+
ty::ty_bare_fn(_) => {
316+
Some(ty::mk_bare_fn(
317+
tcx,
318+
ty::BareFnTy {
319+
purity: ast::impure_fn,
320+
abis: AbiSet::Rust(),
321+
sig: FnSig {bound_lifetime_names: opt_vec::Empty,
322+
inputs: ~[],
323+
output: ty::mk_nil()}}))
324+
}
325+
ty::ty_closure(ref fty) => {
326+
Some(normalized_closure_ty(tcx, fty.sigil))
327+
}
328+
ty::ty_trait(_, _, ref store, _, _) => {
329+
let sigil = match *store {
330+
ty::UniqTraitStore => ast::OwnedSigil,
331+
ty::BoxTraitStore => ast::ManagedSigil,
332+
ty::RegionTraitStore(_) => ast::BorrowedSigil,
333+
};
334+
335+
// Traits have the same runtime representation as closures.
336+
Some(normalized_closure_ty(tcx, sigil))
337+
}
338+
ty::ty_ptr(_) => {
339+
Some(ty::mk_uint())
340+
}
341+
_ => {
342+
None
343+
}
344+
};
345+
346+
fn normalized_closure_ty(tcx: ty::ctxt,
347+
sigil: ast::Sigil) -> ty::t
348+
{
349+
ty::mk_closure(
350+
tcx,
351+
ty::ClosureTy {
352+
purity: ast::impure_fn,
353+
sigil: sigil,
354+
onceness: ast::Many,
355+
region: ty::re_static,
356+
bounds: ty::EmptyBuiltinBounds(),
357+
sig: ty::FnSig {bound_lifetime_names: opt_vec::Empty,
358+
inputs: ~[],
359+
output: ty::mk_nil()}})
360+
}
361+
}
362+
298363
pub fn make_mono_id(ccx: @mut CrateContext,
299364
item: ast::def_id,
300365
substs: &param_substs,

branches/dist-snap/src/libstd/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ fn test_repr() {
590590
exact_test(&(~"he\u10f3llo"), "~\"he\\u10f3llo\"");
591591

592592
exact_test(&(@10), "@10");
593-
exact_test(&(@mut 10), "@mut 10");
593+
exact_test(&(@mut 10), "@10"); // FIXME: #4210: incorrect
594594
exact_test(&((@mut 10, 2)), "(@mut 10, 2)");
595595
exact_test(&(~10), "~10");
596596
exact_test(&(&10), "&10");

branches/dist-snap/src/rt/rust_builtin.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
/* Foreign builtins. */
1212

1313
#include "rust_util.h"
14-
#include "sync/timer.h"
1514
#include "sync/rust_thread.h"
1615
#include "sync/lock_and_signal.h"
1716
#include "memory_region.h"
@@ -25,6 +24,7 @@
2524

2625
#ifdef __APPLE__
2726
#include <crt_externs.h>
27+
#include <mach/mach_time.h>
2828
#endif
2929

3030
#if !defined(__WIN32__)
@@ -242,10 +242,33 @@ get_time(int64_t *sec, int32_t *nsec) {
242242
}
243243
#endif
244244

245+
const uint64_t ns_per_s = 1000000000LL;
246+
245247
extern "C" CDECL void
246248
precise_time_ns(uint64_t *ns) {
247-
timer t;
248-
*ns = t.time_ns();
249+
250+
#ifdef __APPLE__
251+
uint64_t time = mach_absolute_time();
252+
mach_timebase_info_data_t info = {0, 0};
253+
if (info.denom == 0) {
254+
mach_timebase_info(&info);
255+
}
256+
uint64_t time_nano = time * (info.numer / info.denom);
257+
*ns = time_nano;
258+
#elif __WIN32__
259+
uint64_t ticks_per_s;
260+
QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_s);
261+
if (ticks_per_s == 0LL) {
262+
ticks_per_s = 1LL;
263+
}
264+
uint64_t ticks;
265+
QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
266+
*ns = ((ticks * ns_per_s) / ticks_per_s);
267+
#else
268+
timespec ts;
269+
clock_gettime(CLOCK_MONOTONIC, &ts);
270+
*ns = (ts.tv_sec * ns_per_s + ts.tv_nsec);
271+
#endif
249272
}
250273

251274
struct rust_tm {
@@ -292,7 +315,7 @@ void tm_to_rust_tm(tm* in_tm, rust_tm* out_tm, int32_t gmtoff,
292315

293316
if (zone != NULL) {
294317
size_t size = strlen(zone);
295-
reserve_vec_exact(&out_tm->tm_zone, size);
318+
assert(out_tm->tm_zone->alloc >= size);
296319
memcpy(out_tm->tm_zone->data, zone, size);
297320
out_tm->tm_zone->fill = size;
298321
}

branches/dist-snap/src/rt/rust_exchange_alloc.cpp

Lines changed: 0 additions & 35 deletions
This file was deleted.

branches/dist-snap/src/rt/rust_exchange_alloc.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

branches/dist-snap/src/rt/rust_test_helpers.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// Helper functions used only in tests
1212

1313
#include "rust_util.h"
14-
#include "sync/timer.h"
1514
#include "sync/rust_thread.h"
1615
#include "sync/lock_and_signal.h"
1716
#include "rust_abi.h"

branches/dist-snap/src/rt/rust_util.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#define RUST_UTIL_H
1313

1414
#include <limits.h>
15-
#include "rust_exchange_alloc.h"
1615
#include "rust_type.h"
1716

1817
extern struct type_desc str_body_tydesc;
@@ -57,16 +56,6 @@ vec_data(rust_vec *v) {
5756
return reinterpret_cast<T*>(v->data);
5857
}
5958

60-
inline void reserve_vec_exact(rust_vec** vpp,
61-
size_t size) {
62-
if (size > (*vpp)->alloc) {
63-
rust_exchange_alloc exchange_alloc;
64-
*vpp = (rust_vec*)exchange_alloc
65-
.realloc(*vpp, size + sizeof(rust_vec));
66-
(*vpp)->alloc = size;
67-
}
68-
}
69-
7059
typedef rust_vec rust_str;
7160

7261
inline size_t get_box_size(size_t body_size, size_t body_align) {

branches/dist-snap/src/rt/sync/timer.cpp

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)