本文整理汇总了C++中JS_GC函数的典型用法代码示例。如果您正苦于以下问题:C++ JS_GC函数的具体用法?C++ JS_GC怎么用?C++ JS_GC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JS_GC函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PreWrap
static JSObject*
PreWrap(JSContext* cx, JS::HandleObject scope, JS::HandleObject obj,
JS::HandleObject objectPassedToWrap)
{
JS_GC(JS_GetRuntime(cx));
return obj;
}
开发者ID:ajkerrigan,项目名称:gecko-dev,代码行数:7,代码来源:testBug604087.cpp
示例2: shell_global_gc
/**
* shell_global_gc:
* @global: A #ShellGlobal
*
* Start a garbage collection process. For more information, see
* https://developer.mozilla.org/En/JS_GC
*/
void
shell_global_gc (ShellGlobal *global)
{
JSContext *context = gjs_context_get_native_context (global->js_context);
JS_GC (context);
}
开发者ID:MarkieMark,项目名称:gnome-shell,代码行数:14,代码来源:shell-global.c
示例3: gc
static JSBool
gc(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
{
JS_GC(cx);
*rval = JSVAL_VOID;
return JS_TRUE;
}
开发者ID:AvianFlu,项目名称:couchdb,代码行数:7,代码来源:sm170.c
示例4: JSCLASS_HAS_RESERVED_SLOTS
JSObject *newDelegate()
{
static const JSClass delegateClass = {
"delegate",
JSCLASS_GLOBAL_FLAGS | JSCLASS_HAS_RESERVED_SLOTS(1),
JS_PropertyStub,
JS_DeletePropertyStub,
JS_PropertyStub,
JS_StrictPropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
nullptr,
nullptr,
nullptr,
nullptr,
JS_GlobalObjectTraceHook
};
/* Create the global object. */
JS::CompartmentOptions options;
options.setVersion(JSVERSION_LATEST);
JS::RootedObject global(cx);
global = JS_NewGlobalObject(cx, &delegateClass, nullptr, JS::FireOnNewGlobalHook, options);
JS_SetReservedSlot(global, 0, JS::Int32Value(42));
/*
* Ensure the delegate is not in the nursery because for the purpose of this
* test we're going to put it in a private slot where it won't get updated.
*/
JS_GC(rt);
return global;
}
开发者ID:L2-D2,项目名称:gecko-dev,代码行数:34,代码来源:testWeakMap.cpp
示例5: gc
static JSBool
gc(JSContext* cx, uintN argc, jsval* vp)
{
JS_GC(cx);
JS_SET_RVAL(cx, vp, JSVAL_VOID);
return JS_TRUE;
}
开发者ID:draco2003,项目名称:bigcouch,代码行数:7,代码来源:sm180.c
示例6: NS_ASSERTION
void
nsXREDirProvider::DoShutdown()
{
if (mProfileNotified) {
nsCOMPtr<nsIObserverService> obsSvc =
mozilla::services::GetObserverService();
NS_ASSERTION(obsSvc, "No observer service?");
if (obsSvc) {
static const char16_t kShutdownPersist[] = MOZ_UTF16("shutdown-persist");
obsSvc->NotifyObservers(nullptr, "profile-change-net-teardown", kShutdownPersist);
obsSvc->NotifyObservers(nullptr, "profile-change-teardown", kShutdownPersist);
// Phase 2c: Now that things are torn down, force JS GC so that things which depend on
// resources which are about to go away in "profile-before-change" are destroyed first.
JSRuntime *rt = xpc::GetJSRuntime();
if (rt) {
JS_GC(rt);
}
// Phase 3: Notify observers of a profile change
obsSvc->NotifyObservers(nullptr, "profile-before-change", kShutdownPersist);
obsSvc->NotifyObservers(nullptr, "profile-before-change2", kShutdownPersist);
}
mProfileNotified = false;
}
}
开发者ID:ChaOSChriS,项目名称:gecko-dev,代码行数:27,代码来源:nsXREDirProvider.cpp
示例7: SameCompartmentWrap
static JSObject *
SameCompartmentWrap(JSContext *cx, JSObject *objArg)
{
JS::RootedObject obj(cx, objArg);
JS_GC(JS_GetRuntime(cx));
return obj;
}
开发者ID:periclesroalves,项目名称:jit-value-specialization,代码行数:7,代码来源:testBug604087.cpp
示例8: js_gc
static JSBool
js_gc(JSContext *cx, uintN argc, jsval *arglist)
{
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
jsval *argv=JS_ARGV(cx, arglist);
JSBool forced=JS_TRUE;
js_callback_t* cb;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((cb=(js_callback_t*)JS_GetPrivate(cx,obj))==NULL)
return(JS_FALSE);
if(argc)
JS_ValueToBoolean(cx,argv[0],&forced);
if(forced)
JS_GC(cx);
else
JS_MaybeGC(cx);
cb->gc_attempts++;
return(JS_TRUE);
}
开发者ID:mattzorzin,项目名称:synchronet,代码行数:25,代码来源:js_internal.c
示例9: root
JS_NEVER_INLINE bool
cls_testIsAboutToBeFinalized_bug528645::createAndTestRooted()
{
jsvalRoot root(cx);
/*
* Check various types of GC things against JS_IsAboutToBeFinalized.
* Make sure to include unit and numeric strings to the set.
*/
EVAL("var x = 1.1; "
"[''+x, 'a', '123456789', 'something'.substring(1), "
"{}, [], new Function('return 10;'), <xml/>];",
root.addr());
JSObject *array = JSVAL_TO_OBJECT(root.value());
JS_ASSERT(JS_IsArrayObject(cx, array));
JSBool ok = JS_GetArrayLength(cx, array, &checkPointersLength);
CHECK(ok);
checkPointers = (void **) malloc(sizeof(void *) * checkPointersLength);
CHECK(checkPointers);
checkPointersStaticStrings = 0;
for (jsuint i = 0; i != checkPointersLength; ++i) {
jsval v;
ok = JS_GetElement(cx, array, i, &v);
CHECK(ok);
JS_ASSERT(JSVAL_IS_GCTHING(v));
JS_ASSERT(!JSVAL_IS_NULL(v));
checkPointers[i] = JSVAL_TO_GCTHING(v);
if (JSString::isStatic(checkPointers[i]))
++checkPointersStaticStrings;
}
oldGCCallback = JS_SetGCCallback(cx, TestAboutToBeFinalizedCallback);
JS_GC(cx);
/*
* All GC things are rooted via the root holding the array containing them
* and TestAboutToBeFinalizedCallback must keep them as is.
*/
for (jsuint i = 0; i != checkPointersLength; ++i)
CHECK(checkPointers[i]);
/*
* Overwrite the registers and stack with new GC things to avoid false
* positives with the finalization test.
*/
EVAL("[]", root.addr());
array = JSVAL_TO_OBJECT(root.value());
JS_ASSERT(JS_IsArrayObject(cx, array));
jsuint tmp;
CHECK(JS_GetArrayLength(cx, array, &tmp));
CHECK(ok);
return true;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:60,代码来源:testIsAboutToBeFinalized.cpp
示例10: PreWrap
static void
PreWrap(JSContext* cx, JS::HandleObject scope, JS::HandleObject obj,
JS::HandleObject objectPassedToWrap,
JS::MutableHandleObject retObj)
{
JS_GC(cx);
retObj.set(obj);
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:8,代码来源:testBug604087.cpp
示例11: PreWrap
static JSObject *
PreWrap(JSContext *cx, JSObject *scopeArg, JSObject *objArg, unsigned flags)
{
JS::RootedObject scope(cx, scopeArg);
JS::RootedObject obj(cx, objArg);
JS_GC(JS_GetRuntime(cx));
return obj;
}
开发者ID:periclesroalves,项目名称:jit-value-specialization,代码行数:8,代码来源:testBug604087.cpp
示例12: EmptyTrapHandler
static JSTrapStatus
EmptyTrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
jsval closure)
{
JS_GC(JS_GetRuntime(cx));
if (JSVAL_IS_STRING(closure))
++emptyTrapCallCount;
return JSTRAP_CONTINUE;
}
开发者ID:marshall,项目名称:mozilla-central,代码行数:9,代码来源:testTrap.cpp
示例13: JS_DumpHeap
void ScriptInterface::DumpHeap()
{
#if MOZJS_DEBUG_ABI
JS_DumpHeap(GetJSRuntime(), stderr, NULL, JSTRACE_OBJECT, NULL, (size_t)-1, NULL);
#endif
fprintf(stderr, "# Bytes allocated: %u\n", JS_GetGCParameter(GetJSRuntime(), JSGC_BYTES));
JS_GC(GetJSRuntime());
fprintf(stderr, "# Bytes allocated after GC: %u\n", JS_GetGCParameter(GetJSRuntime(), JSGC_BYTES));
}
开发者ID:Rektosauros,项目名称:0ad,代码行数:9,代码来源:ScriptInterface.cpp
示例14: AfxGlobal_gc
static JSBool
AfxGlobal_gc(JSContext *cx, unsigned argc, JS::Value *vp)
{
JS::CallReceiver rec = JS::CallReceiverFromVp(vp);
JS_GC(g_JsRt);
rec.rval().set(JSVAL_VOID);
return JS_TRUE;
}
开发者ID:YaLTeR,项目名称:advancedfx,代码行数:10,代码来源:scripting.cpp
示例15: JS_SetContextThread
JsExecutionContext::~JsExecutionContext()
{
JS_SetContextThread(cx);
JS_GC(cx);
JS_BeginRequest(cx);
JS_ClearScope(cx, obj);
JS_EndRequest(cx);
JS_ClearContextThread(cx);
JS_DestroyContext(cx);
JS_DestroyRuntime(rt);
}
开发者ID:dyne,项目名称:FreeJ,代码行数:11,代码来源:jsparser.cpp
示例16: gjs_gc
static JSBool
gjs_gc(JSContext *context,
unsigned argc,
jsval *vp)
{
jsval *argv = JS_ARGV(cx, vp);
if (!gjs_parse_args(context, "gc", "", argc, argv))
return JS_FALSE;
JS_GC(JS_GetRuntime(context));
return JS_TRUE;
}
开发者ID:darkxst,项目名称:gjs-js188,代码行数:11,代码来源:system.c
示例17: vm_gc
/** Garbage Collector method for Javascript.
* One optional argument, boolean, whether or not to force the garbage collection.
*/
static JSBool vm_gc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
JSBool b;
if (argc == 0)
{
JS_GC(cx);
}
else
{
if (JS_ValueToBoolean(cx, argv[0], &b) == JS_FALSE)
return JS_FALSE;
if (b)
JS_GC(cx);
else
JS_MaybeGC(cx);
}
return JS_TRUE;
}
开发者ID:wesgarland,项目名称:gpsee,代码行数:24,代码来源:vm.c
示例18: begin_request
char *sm_eval(jaegermonkey_vm *vm, const char *filename, const char *code, int handle_retval) {
char *retval = NULL;
JSScript *script;
jsval result;
begin_request(vm);
script = JS_CompileScript(vm->context,
vm->global,
code, strlen(code),
filename, 1);
jaegermonkey_error *error = (jaegermonkey_error *) JS_GetContextPrivate(vm->context);
if (error == NULL) {
JS_ClearPendingException(vm->context);
JS_ExecuteScript(vm->context, vm->global, script, &result);
vm->invoke_count++;
error = (jaegermonkey_error *) JS_GetContextPrivate(vm->context);
if (error == NULL) {
if (handle_retval) {
if (JSVAL_IS_STRING(result)) {
JSString *str = JS_ValueToString(vm->context, result);
retval = copy_jsstring(str);
}
else if(strcmp(JS_GetStringBytes(JS_ValueToString(vm->context, result)), "undefined") == 0) {
retval = copy_string("{\"error\": \"Expression returned undefined\", \"lineno\": 0, \"source\": \"unknown\"}");
}
else {
retval = copy_string("{\"error\": \"non-JSON return value\", \"lineno\": 0, \"source\": \"unknown\"}");
}
}
JS_DestroyScript(vm->context, script);
}
else {
retval = error_to_json(error);
free_error(error);
JS_SetContextPrivate(vm->context, NULL);
}
}
else {
retval = error_to_json(error);
free_error(error);
JS_SetContextPrivate(vm->context, NULL);
}
if (vm->invoke_count > 200) {
JS_GC(vm->context);
vm->invoke_count = 0;
}
else {
JS_MaybeGC(vm->context);
}
end_request(vm);
return retval;
}
开发者ID:alepharchives,项目名称:erlang_js-jaegermonkey,代码行数:53,代码来源:jaegermonkey.c
示例19: assert
void TraceMonkeyValue::invalidate()
{
assert(isValid());
Logging::log(Logging::INFO, "Removing TM root for %s\r\n", debugName.c_str());
bool success = JS_RemoveRoot(TraceMonkeyEngine::context, &(this->value)); // Allow GCing (unless others use it)
assert(success);
JS_GC(TraceMonkeyEngine::context); // XXX For debugging purposes
ScriptValue::invalidate(); // call parent
}
开发者ID:Amplifying,项目名称:intensityengine,代码行数:13,代码来源:script_engine_tracemonkey.cpp
示例20: tryScript
bool tryScript(JS::HandleObject global, JSScript *scriptArg)
{
JS::RootedScript script(cx, scriptArg);
CHECK(script);
JS_GC(rt);
/* After a garbage collection, the script should still work. */
JS::RootedValue result(cx);
CHECK(JS_ExecuteScript(cx, global, script, result.address()));
return true;
}
开发者ID:PatMart,项目名称:gecko-dev,代码行数:13,代码来源:testScriptObject.cpp
注:本文中的JS_GC函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论