1
0
Fork 0
mirror of https://github.com/rubyjs/therubyracer synced 2023-03-27 23:21:42 -04:00
therubyracer/ext/v8/heap.cc
2012-06-12 12:03:55 -05:00

39 lines
No EOL
1.3 KiB
C++

#include "rr.h"
#if !defined(SIZET2NUM)
# if SIZEOF_SIZE_T == SIZEOF_LONG
# define SIZET2NUM(n) ULONG2NUM(n)
# else
# define SIZET2NUM(n) ULL2NUM(n)
# endif
#endif /* ! defined(SIZET2NUM) */
namespace rr {
void HeapStatistics::Init() {
ClassBuilder("HeapStatistics").
defineSingletonMethod("new", &initialize).
defineMethod("total_heap_size", &total_heap_size).
defineMethod("total_heap_size_executable", &total_heap_size_executable).
defineMethod("used_heap_size", &used_heap_size).
defineMethod("heap_size_limit", &heap_size_limit).
store(&Class);
}
VALUE HeapStatistics::initialize(VALUE self) {
return HeapStatistics(new v8::HeapStatistics());
}
VALUE HeapStatistics::total_heap_size(VALUE self) {
return SIZET2NUM(HeapStatistics(self)->total_heap_size());
}
VALUE HeapStatistics::total_heap_size_executable(VALUE self) {
return SIZET2NUM(HeapStatistics(self)->total_heap_size_executable());
}
VALUE HeapStatistics::used_heap_size(VALUE self) {
return SIZET2NUM(HeapStatistics(self)->used_heap_size());
}
VALUE HeapStatistics::heap_size_limit(VALUE self) {
return SIZET2NUM(HeapStatistics(self)->heap_size_limit());
}
template <> void Pointer<v8::HeapStatistics>::unwrap(VALUE value) {
Data_Get_Struct(value, class v8::HeapStatistics, pointer);
}
}