Skip to content

Commit 894542d

Browse files
committed
---
yaml --- r: 13131 b: refs/heads/master c: 178c5cc h: refs/heads/master i: 13129: e77e812 13127: 7d35da1 v: v3
1 parent 2238686 commit 894542d

File tree

3 files changed

+45
-15
lines changed

3 files changed

+45
-15
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: c6a23cddfb66c97c5c5a5836a08c602ba2bb4f02
2+
refs/heads/master: 178c5cc4a394c7991321dfd349662051d2344cb6
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: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,31 +155,38 @@ upcall_trace(char const *msg,
155155
* Allocate an object in the exchange heap
156156
*/
157157

158-
struct s_exchange_malloc_args {
159-
uintptr_t retval;
160-
type_desc *td;
161-
};
162-
163-
extern "C" CDECL void
164-
upcall_s_exchange_malloc(s_exchange_malloc_args *args) {
165-
rust_task *task = rust_get_current_task();
166-
LOG_UPCALL_ENTRY(task);
158+
extern "C" CDECL uintptr_t
159+
exchange_malloc(rust_task *task, type_desc *td, uintptr_t size) {
167160

168-
LOG(task, mem, "upcall exchange malloc(0x%" PRIxPTR ")", args->td);
161+
LOG(task, mem, "upcall exchange malloc(0x%" PRIxPTR ")", td);
169162

170163
// Copied from boxed_region
171164
size_t header_size = sizeof(rust_opaque_box);
172-
size_t body_size = args->td->size;
173-
size_t body_align = args->td->align;
165+
size_t body_size = size;
166+
size_t body_align = td->align;
174167
size_t total_size = align_to(header_size, body_align) + body_size;
175168

176169
void *p = task->kernel->malloc(total_size, "exchange malloc");
177170
memset(p, '\0', total_size);
178171

179172
rust_opaque_box *header = static_cast<rust_opaque_box*>(p);
180-
header->td = args->td;
173+
header->td = td;
174+
175+
return (uintptr_t)header;
176+
}
177+
178+
struct s_exchange_malloc_args {
179+
uintptr_t retval;
180+
type_desc *td;
181+
};
182+
183+
extern "C" CDECL void
184+
upcall_s_exchange_malloc(s_exchange_malloc_args *args) {
185+
rust_task *task = rust_get_current_task();
186+
LOG_UPCALL_ENTRY(task);
181187

182-
args->retval = (uintptr_t)header;
188+
uintptr_t retval = exchange_malloc(task, args->td, args->td->size);
189+
args->retval = retval;
183190
}
184191

185192
extern "C" CDECL uintptr_t
@@ -189,6 +196,28 @@ upcall_exchange_malloc(type_desc *td) {
189196
return args.retval;
190197
}
191198

199+
struct s_exchange_malloc_dyn_args {
200+
uintptr_t retval;
201+
type_desc *td;
202+
uintptr_t size;
203+
};
204+
205+
extern "C" CDECL void
206+
upcall_s_exchange_malloc_dyn(s_exchange_malloc_dyn_args *args) {
207+
rust_task *task = rust_get_current_task();
208+
LOG_UPCALL_ENTRY(task);
209+
210+
uintptr_t retval = exchange_malloc(task, args->td, args->size);
211+
args->retval = retval;
212+
}
213+
214+
extern "C" CDECL uintptr_t
215+
upcall_exchange_malloc_dyn(type_desc *td, uintptr_t size) {
216+
s_exchange_malloc_dyn_args args = {0, td, size};
217+
UPCALL_SWITCH_STACK(&args, upcall_s_exchange_malloc_dyn);
218+
return args.retval;
219+
}
220+
192221
struct s_exchange_free_args {
193222
void *ptr;
194223
};

trunk/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ upcall_new_stack
8989
upcall_del_stack
9090
upcall_reset_stack_limit
9191
upcall_exchange_malloc
92+
upcall_exchange_malloc_dyn
9293
upcall_exchange_free
9394
rust_uv_loop_new
9495
rust_uv_loop_delete

0 commit comments

Comments
 (0)