Skip to content
Snippets Groups Projects
Commit 4e7d587a authored by deuce's avatar deuce
Browse files

Add a get_size() global command which returns the stored size of an object.

parent 329a03a3
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@
/* SpiderMonkey: */
#include <jsapi.h>
#include <jsdbgapi.h>
#define MAX_ANSI_SEQ 16
#define MAX_ANSI_PARAMS 8
......@@ -3487,6 +3488,18 @@ js_list_named_queues(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
static JSBool js_getsize(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
JSObject* tmp_obj=JSVAL_TO_OBJECT(argv[0]);
if(!tmp_obj)
return(JS_FALSE);
JS_SET_RVAL(cx, arglist, DOUBLE_TO_JSVAL(JS_GetObjectTotalSize(cx, tmp_obj)));
return(JS_TRUE);
}
static JSBool
js_flags_str(JSContext *cx, uintN argc, jsval *arglist)
{
......@@ -3833,6 +3846,10 @@ static jsSyncMethodSpec js_global_functions[] = {
"(returns number OR string) - (added in v3.13)")
,313
},
{"get_size", js_getsize, 1, JSTYPE_NUMBER, JSDOCSTR("[number]")
,JSDOCSTR("Gets the size in bytes the object uses in memory (forces GC) ")
,314
},
{0}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment