NaCl runtime fixes
[mono.git] / mono / profiler / decode.c
index d045ceea4b8f467f71886040d9163ed4d3196274..1383ae90b27e10fb2f9434cd9e856184a82fd5d3 100644 (file)
 #define HASH_SIZE 9371
 #define SMALL_HASH_SIZE 31
 
+#if defined(__native_client__) || defined(__native_client_codegen__)
+volatile int __nacl_thread_suspension_needed = 0;
+void __nacl_suspend_thread_if_needed() {}
+#endif
+
 static int debug = 0;
 static int collect_traces = 0;
 static int show_traces = 0;
@@ -1287,6 +1292,7 @@ static int gc_resizes;
 typedef struct {
        uint64_t created;
        uint64_t destroyed;
+       uint64_t live;
        uint64_t max_live;
        TraceDesc traces;
 } HandleInfo;
@@ -1582,10 +1588,11 @@ decode_buffer (ProfContext *ctx)
                                if (htype > 3)
                                        return 0;
                                handle_info [htype].created++;
+                               handle_info [htype].live++;
                                add_trace_thread (thread, &handle_info [htype].traces, 1);
                                /* FIXME: we don't take into account timing here */
-                               if (handle_info [htype].created > handle_info [htype].max_live)
-                                       handle_info [htype].max_live = handle_info [htype].created;
+                               if (handle_info [htype].live > handle_info [htype].max_live)
+                                       handle_info [htype].max_live = handle_info [htype].live;
                                if (num_tracked_objects)
                                        track_handle (OBJ_ADDR (objdiff), htype, handle);
                                if (debug)
@@ -1595,7 +1602,8 @@ decode_buffer (ProfContext *ctx)
                                uint32_t handle = decode_uleb128 (p, &p);
                                if (htype > 3)
                                        return 0;
-                               handle_info [htype].created--;
+                               handle_info [htype].destroyed ++;
+                               handle_info [htype].live--;
                                if (debug)
                                        fprintf (outfile, "handle (%s) %u destroyed\n", get_handle_name (htype), handle);
                        }