According the Spidermonkey's User Guide
https://developer.mozilla.org/En/SpiderMonkey/JSAPI_User_Guide
... a jsval by itself does not protect its referent from the garbage collector...
My understanding of this statement is that if we create a JSString by, say, JS_NewStringCopyZ(), the value returned can be gc'ed at anytime. e.g.
JSString *str=JS_NewStringCopyZ(cx, "hello world");
JS_GC(cx);
//..now my "hello world" JSString is gone
So how do we prevent the str above from being gc'ed? I notice there is a JS_EnterLocalRootScope () function that I can call at the start of my JSNative function. Unfortunately, it is now deprecated. Then what should be the proper way to prevent gc?