Skip to content

Commit

Permalink
Add HeapSizeOf implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Aug 13, 2015
1 parent 9523854 commit 460082d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ git = "https://github.com/servo/mozjs"
libc = "*"
rustc-serialize = "*"
log = "*"
heapsize = "0.1.1"
16 changes: 15 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
extern crate libc;
#[macro_use]
extern crate log;
#[macro_use]
extern crate heapsize;
extern crate rustc_serialize as serialize;

pub mod jsapi;
Expand All @@ -23,11 +25,14 @@ pub mod rust;
pub mod glue;
pub mod jsval;

use jsapi::{JSContext, JSProtoKey};
use jsapi::{JSContext, JSProtoKey, Heap};
use jsval::JSVal;
use rust::GCMethods;

use libc::c_uint;

use heapsize::HeapSizeOf;

pub const default_heapsize: u32 = 32_u32 * 1024_u32 * 1024_u32;
pub const default_stacksize: usize = 8192;

Expand Down Expand Up @@ -91,3 +96,12 @@ pub unsafe fn JS_ARGV(_cx: *mut JSContext, vp: *mut JSVal) -> *mut JSVal {
pub unsafe fn JS_CALLEE(_cx: *mut JSContext, vp: *mut JSVal) -> JSVal {
*vp
}

// This is measured properly by the heap measurement implemented in SpiderMonkey.
impl<T: Copy + GCMethods<T>> HeapSizeOf for Heap<T> {
fn heap_size_of_children(&self) -> usize {
0
}
}
known_heap_size!(0, JSVal);

0 comments on commit 460082d

Please sign in to comment.