mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
do not trace pending parsers
This commit is contained in:
parent
581ade575e
commit
558a55c0b2
3 changed files with 11 additions and 7 deletions
|
@ -42,6 +42,7 @@ use crate::dom::htmlimageelement::SourceSet;
|
||||||
use crate::dom::htmlmediaelement::{HTMLMediaElementFetchContext, MediaFrameRenderer};
|
use crate::dom::htmlmediaelement::{HTMLMediaElementFetchContext, MediaFrameRenderer};
|
||||||
use crate::dom::identityhub::Identities;
|
use crate::dom::identityhub::Identities;
|
||||||
use crate::script_runtime::StreamConsumer;
|
use crate::script_runtime::StreamConsumer;
|
||||||
|
use crate::script_thread::IncompleteParserContexts;
|
||||||
use crate::task::TaskBox;
|
use crate::task::TaskBox;
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use canvas_traits::canvas::{
|
use canvas_traits::canvas::{
|
||||||
|
@ -183,6 +184,8 @@ pub unsafe trait JSTraceable {
|
||||||
|
|
||||||
unsafe_no_jsmanaged_fields!(Box<dyn TaskBox>, Box<dyn EventLoopWaker>);
|
unsafe_no_jsmanaged_fields!(Box<dyn TaskBox>, Box<dyn EventLoopWaker>);
|
||||||
|
|
||||||
|
unsafe_no_jsmanaged_fields!(IncompleteParserContexts);
|
||||||
|
|
||||||
unsafe_no_jsmanaged_fields!(MessagePortImpl);
|
unsafe_no_jsmanaged_fields!(MessagePortImpl);
|
||||||
unsafe_no_jsmanaged_fields!(MessagePortId);
|
unsafe_no_jsmanaged_fields!(MessagePortId);
|
||||||
unsafe_no_jsmanaged_fields!(MessagePortRouterId);
|
unsafe_no_jsmanaged_fields!(MessagePortRouterId);
|
||||||
|
|
|
@ -689,7 +689,6 @@ impl Tokenizer {
|
||||||
|
|
||||||
/// The context required for asynchronously fetching a document
|
/// The context required for asynchronously fetching a document
|
||||||
/// and parsing it progressively.
|
/// and parsing it progressively.
|
||||||
#[derive(JSTraceable)]
|
|
||||||
pub struct ParserContext {
|
pub struct ParserContext {
|
||||||
/// The parser that initiated the request.
|
/// The parser that initiated the request.
|
||||||
parser: Option<Trusted<ServoParser>>,
|
parser: Option<Trusted<ServoParser>>,
|
||||||
|
|
|
@ -500,7 +500,7 @@ impl<'a> Iterator for DocumentsIter<'a> {
|
||||||
// which can trigger GC, and so we can end up tracing the script
|
// which can trigger GC, and so we can end up tracing the script
|
||||||
// thread during parsing. For this reason, we don't trace the
|
// thread during parsing. For this reason, we don't trace the
|
||||||
// incomplete parser contexts during GC.
|
// incomplete parser contexts during GC.
|
||||||
type IncompleteParserContexts = Vec<(PipelineId, ParserContext)>;
|
pub struct IncompleteParserContexts(RefCell<Vec<(PipelineId, ParserContext)>>);
|
||||||
|
|
||||||
unsafe_no_jsmanaged_fields!(TaskQueue<MainThreadScriptMsg>);
|
unsafe_no_jsmanaged_fields!(TaskQueue<MainThreadScriptMsg>);
|
||||||
unsafe_no_jsmanaged_fields!(dyn BackgroundHangMonitorRegister);
|
unsafe_no_jsmanaged_fields!(dyn BackgroundHangMonitorRegister);
|
||||||
|
@ -518,7 +518,7 @@ pub struct ScriptThread {
|
||||||
/// A list of data pertaining to loads that have not yet received a network response
|
/// A list of data pertaining to loads that have not yet received a network response
|
||||||
incomplete_loads: DomRefCell<Vec<InProgressLoad>>,
|
incomplete_loads: DomRefCell<Vec<InProgressLoad>>,
|
||||||
/// A vector containing parser contexts which have not yet been fully processed
|
/// A vector containing parser contexts which have not yet been fully processed
|
||||||
incomplete_parser_contexts: RefCell<IncompleteParserContexts>,
|
incomplete_parser_contexts: IncompleteParserContexts,
|
||||||
/// Image cache for this script thread.
|
/// Image cache for this script thread.
|
||||||
image_cache: Arc<dyn ImageCache>,
|
image_cache: Arc<dyn ImageCache>,
|
||||||
/// A handle to the resource thread. This is an `Arc` to avoid running out of file descriptors if
|
/// A handle to the resource thread. This is an `Arc` to avoid running out of file descriptors if
|
||||||
|
@ -1257,7 +1257,7 @@ impl ScriptThread {
|
||||||
documents: DomRefCell::new(Documents::new()),
|
documents: DomRefCell::new(Documents::new()),
|
||||||
window_proxies: DomRefCell::new(HashMap::new()),
|
window_proxies: DomRefCell::new(HashMap::new()),
|
||||||
incomplete_loads: DomRefCell::new(vec![]),
|
incomplete_loads: DomRefCell::new(vec![]),
|
||||||
incomplete_parser_contexts: RefCell::new(vec![]),
|
incomplete_parser_contexts: IncompleteParserContexts(RefCell::new(vec![])),
|
||||||
|
|
||||||
image_cache: state.image_cache.clone(),
|
image_cache: state.image_cache.clone(),
|
||||||
image_cache_channel: image_cache_channel,
|
image_cache_channel: image_cache_channel,
|
||||||
|
@ -3686,6 +3686,7 @@ impl ScriptThread {
|
||||||
|
|
||||||
let context = ParserContext::new(id, load_data.url);
|
let context = ParserContext::new(id, load_data.url);
|
||||||
self.incomplete_parser_contexts
|
self.incomplete_parser_contexts
|
||||||
|
.0
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push((id, context));
|
.push((id, context));
|
||||||
|
|
||||||
|
@ -3712,7 +3713,7 @@ impl ScriptThread {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut incomplete_parser_contexts = self.incomplete_parser_contexts.borrow_mut();
|
let mut incomplete_parser_contexts = self.incomplete_parser_contexts.0.borrow_mut();
|
||||||
let parser = incomplete_parser_contexts
|
let parser = incomplete_parser_contexts
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|&&mut (pipeline_id, _)| pipeline_id == id);
|
.find(|&&mut (pipeline_id, _)| pipeline_id == id);
|
||||||
|
@ -3722,7 +3723,7 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_fetch_chunk(&self, id: PipelineId, chunk: Vec<u8>) {
|
fn handle_fetch_chunk(&self, id: PipelineId, chunk: Vec<u8>) {
|
||||||
let mut incomplete_parser_contexts = self.incomplete_parser_contexts.borrow_mut();
|
let mut incomplete_parser_contexts = self.incomplete_parser_contexts.0.borrow_mut();
|
||||||
let parser = incomplete_parser_contexts
|
let parser = incomplete_parser_contexts
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.find(|&&mut (pipeline_id, _)| pipeline_id == id);
|
.find(|&&mut (pipeline_id, _)| pipeline_id == id);
|
||||||
|
@ -3734,12 +3735,13 @@ impl ScriptThread {
|
||||||
fn handle_fetch_eof(&self, id: PipelineId, eof: Result<ResourceFetchTiming, NetworkError>) {
|
fn handle_fetch_eof(&self, id: PipelineId, eof: Result<ResourceFetchTiming, NetworkError>) {
|
||||||
let idx = self
|
let idx = self
|
||||||
.incomplete_parser_contexts
|
.incomplete_parser_contexts
|
||||||
|
.0
|
||||||
.borrow()
|
.borrow()
|
||||||
.iter()
|
.iter()
|
||||||
.position(|&(pipeline_id, _)| pipeline_id == id);
|
.position(|&(pipeline_id, _)| pipeline_id == id);
|
||||||
|
|
||||||
if let Some(idx) = idx {
|
if let Some(idx) = idx {
|
||||||
let (_, mut ctxt) = self.incomplete_parser_contexts.borrow_mut().remove(idx);
|
let (_, mut ctxt) = self.incomplete_parser_contexts.0.borrow_mut().remove(idx);
|
||||||
ctxt.process_response_eof(eof);
|
ctxt.process_response_eof(eof);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue