@@ -143,66 +143,46 @@ upcall_trace(char const *msg,
143
143
* Allocate an object in the exchange heap
144
144
*/
145
145
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)
164
146
struct s_exchange_malloc_args {
165
147
rust_task *task;
166
148
uintptr_t retval;
167
149
type_desc *td;
150
+ uintptr_t size;
168
151
};
169
152
170
153
extern " C" CDECL void
171
154
upcall_s_exchange_malloc (s_exchange_malloc_args *args) {
172
155
rust_task *task = args->task ;
173
156
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 ;
174
168
175
- args->retval = exchange_malloc (task, args-> td , args-> td -> size ) ;
169
+ args->retval = ( uintptr_t )header ;
176
170
}
177
171
178
172
extern " C" CDECL uintptr_t
179
- upcall_exchange_malloc (type_desc *td) {
173
+ upcall_exchange_malloc (type_desc *td, uintptr_t size ) {
180
174
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 };
182
176
UPCALL_SWITCH_STACK (task, &args, upcall_s_exchange_malloc);
183
177
return args.retval ;
184
178
}
185
179
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)
201
181
extern " C" CDECL uintptr_t
202
182
upcall_exchange_malloc_dyn (type_desc *td, uintptr_t size) {
203
183
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 );
206
186
return args.retval ;
207
187
}
208
188
@@ -229,69 +209,49 @@ upcall_exchange_free(void *ptr) {
229
209
* Allocate an object in the task-local heap.
230
210
*/
231
211
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)
253
212
struct s_malloc_args {
254
213
rust_task *task;
255
214
uintptr_t retval;
256
215
type_desc *td;
216
+ uintptr_t size;
257
217
};
258
218
259
219
extern " C" CDECL void
260
220
upcall_s_malloc (s_malloc_args *args) {
261
221
rust_task *task = args->task ;
262
222
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);
263
232
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;
265
239
}
266
240
267
241
extern " C" CDECL uintptr_t
268
- upcall_malloc (type_desc *td) {
242
+ upcall_malloc (type_desc *td, uintptr_t size ) {
269
243
rust_task *task = rust_get_current_task ();
270
- s_malloc_args args = {task, 0 , td};
244
+ s_malloc_args args = {task, 0 , td, size };
271
245
UPCALL_SWITCH_STACK (task, &args, upcall_s_malloc);
272
246
return args.retval ;
273
247
}
274
248
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)
290
250
extern " C" CDECL uintptr_t
291
251
upcall_malloc_dyn (type_desc *td, uintptr_t size) {
292
252
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 );
295
255
return args.retval ;
296
256
}
297
257
0 commit comments