From 96eb8463c0b354dd1d61bb022f00c918bba36d1c Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Mon, 21 Mar 2011 13:32:47 -0500 Subject: [PATCH] start adding support for V8 VM introspection functions. --- ext/v8/v8.cpp | 2 ++ ext/v8/v8_v8.cpp | 28 ++++++++++++++++++++++++++++ ext/v8/v8_v8.h | 6 ++++++ 3 files changed, 36 insertions(+) create mode 100644 ext/v8/v8_v8.cpp create mode 100644 ext/v8/v8_v8.h diff --git a/ext/v8/v8.cpp b/ext/v8/v8.cpp index 77455d1..fb564e1 100644 --- a/ext/v8/v8.cpp +++ b/ext/v8/v8.cpp @@ -14,6 +14,7 @@ #include "v8_exception.h" #include "v8_locker.h" #include "v8_debug.h" +#include "v8_v8.h" #include @@ -39,5 +40,6 @@ extern "C" { rr_init_v8_exception(); rr_init_v8_locker(); rr_init_v8_debug(); + rr_init_v8_v8(); } } diff --git a/ext/v8/v8_v8.cpp b/ext/v8/v8_v8.cpp new file mode 100644 index 0000000..ae6b5e1 --- /dev/null +++ b/ext/v8/v8_v8.cpp @@ -0,0 +1,28 @@ + +#include "rr.h" + +using namespace v8; + +namespace { + + VALUE IsDead(VALUE self) { + return rr_v82rb(V8::IsDead()); + } + + VALUE AdjustAmountOfExternalAllocatedMemory(VALUE self, VALUE bytes) { + V8::AdjustAmountOfExternalAllocatedMemory(NUM2INT(bytes)); + return Qnil; + } + + VALUE IdleNotification(VALUE self) { + return rr_v82rb(V8::IdleNotification()); + } +} + + +void rr_init_v8_v8() { + VALUE V8Module = rr_define_module("V8"); + rr_define_singleton_method(V8Module, "IsDead", IsDead, 0); + rr_define_singleton_method(V8Module, "AdjustAmountOfExternalAllocatedMemory", AdjustAmountOfExternalAllocatedMemory, 1); + rr_define_singleton_method(V8Module, "IdleNotification", IdleNotification, 0); +} diff --git a/ext/v8/v8_v8.h b/ext/v8/v8_v8.h new file mode 100644 index 0000000..2a89e3c --- /dev/null +++ b/ext/v8/v8_v8.h @@ -0,0 +1,6 @@ +#ifndef _RR_V8_V8_ +#define _RR_V8_V8_ + +void rr_init_v8_v8(); + +#endif \ No newline at end of file