@@ -21,8 +21,6 @@ use rt::env;
21
21
use rt:: global_heap;
22
22
use rt:: local:: Local ;
23
23
use rt:: task:: Task ;
24
- #[ cfg( stage0) ]
25
- use unstable:: intrinsics:: TyDesc ;
26
24
use unstable:: raw;
27
25
use vec:: ImmutableVector ;
28
26
@@ -61,29 +59,6 @@ impl LocalHeap {
61
59
}
62
60
63
61
#[ inline]
64
- #[ cfg( stage0) ]
65
- pub fn alloc ( & mut self , td : * TyDesc , size : uint ) -> * mut Box {
66
- let total_size = global_heap:: get_box_size ( size, unsafe { ( * td) . align } ) ;
67
- let alloc = self . memory_region . malloc ( total_size) ;
68
- {
69
- // Make sure that we can't use `mybox` outside of this scope
70
- let mybox: & mut Box = unsafe { cast:: transmute ( alloc) } ;
71
- // Clear out this box, and move it to the front of the live
72
- // allocations list
73
- mybox. type_desc = td;
74
- mybox. ref_count = 1 ;
75
- mybox. prev = ptr:: mut_null ( ) ;
76
- mybox. next = self . live_allocs ;
77
- if !self . live_allocs . is_null ( ) {
78
- unsafe { ( * self . live_allocs ) . prev = alloc; }
79
- }
80
- self . live_allocs = alloc;
81
- }
82
- return alloc;
83
- }
84
-
85
- #[ inline]
86
- #[ cfg( not( stage0) ) ]
87
62
pub fn alloc ( & mut self , drop_glue : fn ( * mut u8 ) , size : uint , align : uint ) -> * mut Box {
88
63
let total_size = global_heap:: get_box_size ( size, align) ;
89
64
let alloc = self . memory_region . malloc ( total_size) ;
@@ -126,41 +101,6 @@ impl LocalHeap {
126
101
}
127
102
128
103
#[ inline]
129
- #[ cfg( stage0) ]
130
- pub fn free ( & mut self , alloc : * mut Box ) {
131
- {
132
- // Make sure that we can't use `mybox` outside of this scope
133
- let mybox: & mut Box = unsafe { cast:: transmute ( alloc) } ;
134
- assert ! ( !mybox. type_desc. is_null( ) ) ;
135
-
136
- // Unlink it from the linked list
137
- if !mybox. prev . is_null ( ) {
138
- unsafe { ( * mybox. prev ) . next = mybox. next ; }
139
- }
140
- if !mybox. next . is_null ( ) {
141
- unsafe { ( * mybox. next ) . prev = mybox. prev ; }
142
- }
143
- if self . live_allocs == alloc {
144
- self . live_allocs = mybox. next ;
145
- }
146
-
147
- // Destroy the box memory-wise
148
- if self . poison_on_free {
149
- unsafe {
150
- let ptr: * mut u8 = cast:: transmute ( & mybox. data ) ;
151
- ptr:: set_memory ( ptr, 0xab , ( * mybox. type_desc ) . size ) ;
152
- }
153
- }
154
- mybox. prev = ptr:: mut_null ( ) ;
155
- mybox. next = ptr:: mut_null ( ) ;
156
- mybox. type_desc = ptr:: null ( ) ;
157
- }
158
-
159
- self . memory_region . free ( alloc) ;
160
- }
161
-
162
- #[ inline]
163
- #[ cfg( not( stage0) ) ]
164
104
pub fn free ( & mut self , alloc : * mut Box ) {
165
105
{
166
106
// Make sure that we can't use `mybox` outside of this scope
@@ -339,20 +279,6 @@ impl Drop for MemoryRegion {
339
279
}
340
280
341
281
#[ inline]
342
- #[ cfg( stage0) ]
343
- pub unsafe fn local_malloc ( td : * u8 , size : uint ) -> * u8 {
344
- // FIXME: Unsafe borrow for speed. Lame.
345
- let task: Option < * mut Task > = Local :: try_unsafe_borrow ( ) ;
346
- match task {
347
- Some ( task) => {
348
- ( * task) . heap . alloc ( td as * TyDesc , size) as * u8
349
- }
350
- None => rtabort ! ( "local malloc outside of task" )
351
- }
352
- }
353
-
354
- #[ inline]
355
- #[ cfg( not( stage0) ) ]
356
282
pub unsafe fn local_malloc ( drop_glue : fn ( * mut u8 ) , size : uint , align : uint ) -> * u8 {
357
283
// FIXME: Unsafe borrow for speed. Lame.
358
284
let task: Option < * mut Task > = Local :: try_unsafe_borrow ( ) ;
0 commit comments