Skip to content

Commit 0beba58

Browse files
committed
---
yaml --- r: 13608 b: refs/heads/master c: 393f739 h: refs/heads/master v: v3
1 parent 9707341 commit 0beba58

File tree

5 files changed

+49
-89
lines changed

5 files changed

+49
-89
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 9a2b60dfce3ababb59eac53b7da083d7bd087e1d
2+
refs/heads/master: 393f739990240914a6b147d6b642adc7ab9a939b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rt/rust_upcall.cpp

Lines changed: 39 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -143,66 +143,46 @@ upcall_trace(char const *msg,
143143
* Allocate an object in the exchange heap
144144
*/
145145

146-
extern "C" CDECL uintptr_t
147-
exchange_malloc(rust_task *task, type_desc *td, uintptr_t size) {
148-
149-
LOG(task, mem, "upcall exchange malloc(0x%" PRIxPTR ")", td);
150-
151-
size_t total_size = get_box_size(size, td->align);
152-
void *p = task->kernel->calloc(total_size, "exchange malloc");
153-
154-
rust_opaque_box *header = static_cast<rust_opaque_box*>(p);
155-
header->ref_count = -1; // This is not ref counted
156-
header->td = td;
157-
header->prev = 0;
158-
header->next = 0;
159-
160-
return (uintptr_t)header;
161-
}
162-
163-
// FIXME: remove after snapshot (6/13/12)
164146
struct s_exchange_malloc_args {
165147
rust_task *task;
166148
uintptr_t retval;
167149
type_desc *td;
150+
uintptr_t size;
168151
};
169152

170153
extern "C" CDECL void
171154
upcall_s_exchange_malloc(s_exchange_malloc_args *args) {
172155
rust_task *task = args->task;
173156
LOG_UPCALL_ENTRY(task);
157+
LOG(task, mem, "upcall exchange malloc(0x%" PRIxPTR ")", args->td);
158+
159+
size_t total_size = get_box_size(args->size, args->td->align);
160+
// FIXME--does this have to be calloc? (Issue #2682)
161+
void *p = task->kernel->calloc(total_size, "exchange malloc");
162+
163+
rust_opaque_box *header = static_cast<rust_opaque_box*>(p);
164+
header->ref_count = -1; // This is not ref counted
165+
header->td = args->td;
166+
header->prev = 0;
167+
header->next = 0;
174168

175-
args->retval = exchange_malloc(task, args->td, args->td->size);
169+
args->retval = (uintptr_t)header;
176170
}
177171

178172
extern "C" CDECL uintptr_t
179-
upcall_exchange_malloc(type_desc *td) {
173+
upcall_exchange_malloc(type_desc *td, uintptr_t size) {
180174
rust_task *task = rust_get_current_task();
181-
s_exchange_malloc_args args = {task, 0, td};
175+
s_exchange_malloc_args args = {task, 0, td, size};
182176
UPCALL_SWITCH_STACK(task, &args, upcall_s_exchange_malloc);
183177
return args.retval;
184178
}
185179

186-
struct s_exchange_malloc_dyn_args {
187-
rust_task *task;
188-
uintptr_t retval;
189-
type_desc *td;
190-
uintptr_t size;
191-
};
192-
193-
extern "C" CDECL void
194-
upcall_s_exchange_malloc_dyn(s_exchange_malloc_dyn_args *args) {
195-
rust_task *task = args->task;
196-
LOG_UPCALL_ENTRY(task);
197-
198-
args->retval = exchange_malloc(task, args->td, args->size);
199-
}
200-
180+
// FIXME: remove after snapshot (6/21/12)
201181
extern "C" CDECL uintptr_t
202182
upcall_exchange_malloc_dyn(type_desc *td, uintptr_t size) {
203183
rust_task *task = rust_get_current_task();
204-
s_exchange_malloc_dyn_args args = {task, 0, td, size};
205-
UPCALL_SWITCH_STACK(task, &args, upcall_s_exchange_malloc_dyn);
184+
s_exchange_malloc_args args = {task, 0, td, size};
185+
UPCALL_SWITCH_STACK(task, &args, upcall_s_exchange_malloc);
206186
return args.retval;
207187
}
208188

@@ -229,69 +209,49 @@ upcall_exchange_free(void *ptr) {
229209
* Allocate an object in the task-local heap.
230210
*/
231211

232-
extern "C" CDECL uintptr_t
233-
shared_malloc(rust_task *task, type_desc *td, uintptr_t size) {
234-
LOG(task, mem, "upcall malloc(0x%" PRIxPTR ")", td);
235-
236-
cc::maybe_cc(task);
237-
238-
// FIXME--does this have to be calloc?
239-
rust_opaque_box *box = task->boxed.calloc(td, size);
240-
void *body = box_body(box);
241-
242-
debug::maybe_track_origin(task, box);
243-
244-
LOG(task, mem,
245-
"upcall malloc(0x%" PRIxPTR ") = box 0x%" PRIxPTR
246-
" with body 0x%" PRIxPTR,
247-
td, (uintptr_t)box, (uintptr_t)body);
248-
249-
return (uintptr_t)box;
250-
}
251-
252-
// FIXME: remove after snapshot (6/13/12)
253212
struct s_malloc_args {
254213
rust_task *task;
255214
uintptr_t retval;
256215
type_desc *td;
216+
uintptr_t size;
257217
};
258218

259219
extern "C" CDECL void
260220
upcall_s_malloc(s_malloc_args *args) {
261221
rust_task *task = args->task;
262222
LOG_UPCALL_ENTRY(task);
223+
LOG(task, mem, "upcall malloc(0x%" PRIxPTR ")", args->td);
224+
225+
cc::maybe_cc(task);
226+
227+
// FIXME--does this have to be calloc? (Issue #2682)
228+
rust_opaque_box *box = task->boxed.calloc(args->td, args->size);
229+
void *body = box_body(box);
230+
231+
debug::maybe_track_origin(task, box);
263232

264-
args->retval = shared_malloc(task, args->td, args->td->size);
233+
LOG(task, mem,
234+
"upcall malloc(0x%" PRIxPTR ") = box 0x%" PRIxPTR
235+
" with body 0x%" PRIxPTR,
236+
args->td, (uintptr_t)box, (uintptr_t)body);
237+
238+
args->retval = (uintptr_t)box;
265239
}
266240

267241
extern "C" CDECL uintptr_t
268-
upcall_malloc(type_desc *td) {
242+
upcall_malloc(type_desc *td, uintptr_t size) {
269243
rust_task *task = rust_get_current_task();
270-
s_malloc_args args = {task, 0, td};
244+
s_malloc_args args = {task, 0, td, size};
271245
UPCALL_SWITCH_STACK(task, &args, upcall_s_malloc);
272246
return args.retval;
273247
}
274248

275-
struct s_malloc_dyn_args {
276-
rust_task *task;
277-
uintptr_t retval;
278-
type_desc *td;
279-
uintptr_t size;
280-
};
281-
282-
extern "C" CDECL void
283-
upcall_s_malloc_dyn(s_malloc_dyn_args *args) {
284-
rust_task *task = args->task;
285-
LOG_UPCALL_ENTRY(task);
286-
287-
args->retval = shared_malloc(task, args->td, args->size);
288-
}
289-
249+
// FIXME: remove after snapshot (6/21/12)
290250
extern "C" CDECL uintptr_t
291251
upcall_malloc_dyn(type_desc *td, uintptr_t size) {
292252
rust_task *task = rust_get_current_task();
293-
s_malloc_dyn_args args = {task, 0, td, size};
294-
UPCALL_SWITCH_STACK(task, &args, upcall_s_malloc_dyn);
253+
s_malloc_args args = {task, 0, td, size};
254+
UPCALL_SWITCH_STACK(task, &args, upcall_s_malloc);
295255
return args.retval;
296256
}
297257

trunk/src/rustc/back/upcall.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import lib::llvm::{type_names, ModuleRef, ValueRef, TypeRef};
1010
type upcalls =
1111
{_fail: ValueRef,
1212
trace: ValueRef,
13-
malloc_dyn: ValueRef,
13+
malloc: ValueRef,
1414
free: ValueRef,
15-
exchange_malloc_dyn: ValueRef,
15+
exchange_malloc: ValueRef,
1616
exchange_free: ValueRef,
1717
validate_box: ValueRef,
1818
mark: ValueRef,
@@ -55,14 +55,14 @@ fn declare_upcalls(targ_cfg: @session::config,
5555
trace: dv("trace", [T_ptr(T_i8()),
5656
T_ptr(T_i8()),
5757
int_t]),
58-
malloc_dyn:
59-
nothrow(d("malloc_dyn",
58+
malloc:
59+
nothrow(d("malloc",
6060
[T_ptr(tydesc_type), int_t],
6161
T_ptr(T_i8()))),
6262
free:
6363
nothrow(dv("free", [T_ptr(T_i8())])),
64-
exchange_malloc_dyn:
65-
nothrow(d("exchange_malloc_dyn",
64+
exchange_malloc:
65+
nothrow(d("exchange_malloc",
6666
[T_ptr(tydesc_type), int_t],
6767
T_ptr(T_i8()))),
6868
exchange_free:

trunk/src/rustc/middle/trans/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap,
356356
let ccx = bcx.ccx();
357357

358358
let (mk_fn, upcall) = alt heap {
359-
heap_shared { (ty::mk_imm_box, ccx.upcalls.malloc_dyn) }
359+
heap_shared { (ty::mk_imm_box, ccx.upcalls.malloc) }
360360
heap_exchange {
361-
(ty::mk_imm_uniq, ccx.upcalls.exchange_malloc_dyn )
361+
(ty::mk_imm_uniq, ccx.upcalls.exchange_malloc )
362362
}
363363
};
364364

trunk/src/rustc/middle/trans/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ fn make_opaque_cbox_take_glue(
545545
let sz = Add(bcx, sz, shape::llsize_of(ccx, T_box_header(ccx)));
546546

547547
// Allocate memory, update original ptr, and copy existing data
548-
let malloc = ccx.upcalls.exchange_malloc_dyn;
548+
let malloc = ccx.upcalls.exchange_malloc;
549549
let cbox_out = Call(bcx, malloc, [tydesc, sz]);
550550
let cbox_out = PointerCast(bcx, cbox_out, llopaquecboxty);
551551
call_memmove(bcx, cbox_out, cbox_in, sz);

0 commit comments

Comments
 (0)