mirror of
https://github.com/servo/servo.git
synced 2025-06-11 10:00:18 +00:00
Ignore the HTML parser's borrow flag in GC tracing
Adds some other dynamic checks in debug builds.
This commit is contained in:
parent
6ec0939a22
commit
49234484d6
5 changed files with 59 additions and 5 deletions
|
@ -60,6 +60,7 @@ use geom::point::Point2D;
|
|||
use js::jsapi::{JS_SetWrapObjectCallbacks, JS_SetGCZeal, JS_DEFAULT_ZEAL_FREQ, JS_GC};
|
||||
use js::jsapi::{JSContext, JSRuntime, JSTracer};
|
||||
use js::jsapi::{JS_SetGCParameter, JSGC_MAX_BYTES};
|
||||
use js::jsapi::{JS_SetGCCallback, JSGCStatus, JSGC_BEGIN, JSGC_END};
|
||||
use js::rust::{Cx, RtUtils};
|
||||
use js::rust::with_compartment;
|
||||
use js;
|
||||
|
@ -285,6 +286,16 @@ impl ScriptTaskFactory for ScriptTask {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn debug_gc_callback(rt: *mut JSRuntime, status: JSGCStatus) {
|
||||
js::rust::gc_callback(rt, status);
|
||||
|
||||
match status {
|
||||
JSGC_BEGIN => task_state::enter(task_state::InGC),
|
||||
JSGC_END => task_state::exit(task_state::InGC),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
impl ScriptTask {
|
||||
/// Creates a new script task.
|
||||
pub fn new(id: PipelineId,
|
||||
|
@ -376,6 +387,13 @@ impl ScriptTask {
|
|||
JS_SetGCZeal((*js_context).ptr, 0, JS_DEFAULT_ZEAL_FREQ);
|
||||
}
|
||||
|
||||
// Needed for debug assertions about whether GC is running.
|
||||
if !cfg!(ndebug) {
|
||||
unsafe {
|
||||
JS_SetGCCallback(js_runtime.ptr, Some(debug_gc_callback));
|
||||
}
|
||||
}
|
||||
|
||||
(js_runtime, js_context)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue