@@ -5,22 +5,48 @@ import priv::{chan_from_global_ptr, weaken_task};
5
5
import comm:: { Port , Chan , select2, listen} ;
6
6
import task:: TaskBuilder ;
7
7
import either:: { Left , Right } ;
8
+ import send_map:: linear;
8
9
9
10
#[ abi = "cdecl" ]
10
11
extern mod rustrt {
11
12
fn rust_global_memory_watcher_chan_ptr ( ) -> * libc:: uintptr_t ;
12
13
}
13
14
14
15
enum Msg {
15
- ReportAllocation ( Task , libc:: uintptr_t , * libc:: c_char )
16
+ ReportAllocation ( Task , libc:: uintptr_t , * libc :: c_char , * libc:: c_char )
16
17
}
17
18
19
+ type MemoryWatcherKey = ( int , libc:: uintptr_t , libc:: uintptr_t ) ;
20
+
18
21
fn global_memory_watcher_spawner ( msg_po : comm:: Port < Msg > )
19
22
{
20
23
let msg_received = msg_po. recv ( ) ;
21
- let ( task_enum_received, size_allocated, td_value) = match msg_received {
22
- ReportAllocation ( t, s, c) => ( t, s, c)
24
+ let ( task_enum_received, size_allocated, td_value, address_allocation ) = match msg_received {
25
+ ReportAllocation ( t, s, c, a ) => ( t, s, c, a )
23
26
} ;
27
+
28
+ let mut hm_index: linear:: LinearMap < int , @mut linear:: LinearMap < libc:: uintptr_t , MemoryWatcherKey > > = linear:: LinearMap ( ) ;
29
+
30
+ loop {
31
+ match msg_po. recv ( ) {
32
+ ReportAllocation ( t, s, c, a) => {
33
+ let Metrics_value : MemoryWatcherKey = ( * ( t) , s, ( c as libc:: uintptr_t ) ) ;
34
+ let test1: int = ( * t) ;
35
+ let val1 = hm_index. find ( & test1) ;
36
+ match val1 {
37
+ Some ( T ) => {
38
+ let hm_task_LinearMap: @mut linear:: LinearMap < libc:: uintptr_t , MemoryWatcherKey > = T ;
39
+ hm_task_LinearMap. insert ( ( a as libc:: uintptr_t ) , Metrics_value ) ;
40
+ }
41
+ None => {
42
+ let hm_task: @mut linear:: LinearMap < libc:: uintptr_t , MemoryWatcherKey > = @mut linear:: LinearMap ( ) ;
43
+ hm_task. insert ( ( a as libc:: uintptr_t ) , Metrics_value ) ;
44
+ hm_index. insert ( * ( t) , hm_task) ;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
24
50
25
51
let remote_task_id = * ( task_enum_received) ;
26
52
0 commit comments