mirror of
https://github.com/servo/servo.git
synced 2025-08-01 19:50:30 +01:00
Auto merge of #27420 - avr1254:master, r=jdm
Removed unnecessary conversion from UTF-8 to UTF-16 <!-- Please describe your changes on the following line: --> Changed Spidermonkey API calls to remove need for UTF-16 conversion. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #27331 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because they simply optimize existing code for speed. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
commit
582a7a7afa
2 changed files with 8 additions and 13 deletions
|
@ -43,10 +43,10 @@ use html5ever::{LocalName, Prefix};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use js::jsapi::{
|
use js::jsapi::{
|
||||||
CanCompileOffThread, CompileOffThread, FinishOffThreadScript, Heap, JSScript, OffThreadToken,
|
CanCompileOffThread, CompileOffThread1, FinishOffThreadScript, Heap, JSScript, OffThreadToken,
|
||||||
};
|
};
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use js::rust::{transform_u16_to_source_text, CompileOptionsWrapper};
|
use js::rust::{transform_str_to_source_text, CompileOptionsWrapper};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use net_traits::request::{
|
use net_traits::request::{
|
||||||
CorsSettings, CredentialsMode, Destination, ParserMetadata, RequestBuilder,
|
CorsSettings, CredentialsMode, Destination, ParserMetadata, RequestBuilder,
|
||||||
|
@ -77,7 +77,6 @@ pub struct OffThreadCompilationContext {
|
||||||
task_source: DOMManipulationTaskSource,
|
task_source: DOMManipulationTaskSource,
|
||||||
canceller: TaskCanceller,
|
canceller: TaskCanceller,
|
||||||
script_text: String,
|
script_text: String,
|
||||||
utf16_chars: Vec<u16>,
|
|
||||||
fetch_options: ScriptFetchOptions,
|
fetch_options: ScriptFetchOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +432,6 @@ impl FetchResponseListener for ClassicContext {
|
||||||
|
|
||||||
if can_compile_off_thread {
|
if can_compile_off_thread {
|
||||||
let source_string = source_text.to_string();
|
let source_string = source_text.to_string();
|
||||||
let source_text: Vec<u16> = source_text.encode_utf16().collect();
|
|
||||||
|
|
||||||
let context = Box::new(OffThreadCompilationContext {
|
let context = Box::new(OffThreadCompilationContext {
|
||||||
script_element: self.elem.clone(),
|
script_element: self.elem.clone(),
|
||||||
|
@ -443,15 +441,14 @@ impl FetchResponseListener for ClassicContext {
|
||||||
task_source: global.dom_manipulation_task_source(),
|
task_source: global.dom_manipulation_task_source(),
|
||||||
canceller: global.task_canceller(TaskSourceName::DOMManipulation),
|
canceller: global.task_canceller(TaskSourceName::DOMManipulation),
|
||||||
script_text: source_string,
|
script_text: source_string,
|
||||||
utf16_chars: source_text,
|
|
||||||
fetch_options: self.fetch_options.clone(),
|
fetch_options: self.fetch_options.clone(),
|
||||||
});
|
});
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
assert!(CompileOffThread(
|
assert!(CompileOffThread1(
|
||||||
*cx,
|
*cx,
|
||||||
options.ptr as *const _,
|
options.ptr as *const _,
|
||||||
&mut transform_u16_to_source_text(&context.utf16_chars) as *mut _,
|
&mut transform_str_to_source_text(&context.script_text) as *mut _,
|
||||||
Some(off_thread_compilation_callback),
|
Some(off_thread_compilation_callback),
|
||||||
Box::into_raw(context) as *mut c_void,
|
Box::into_raw(context) as *mut c_void,
|
||||||
));
|
));
|
||||||
|
|
|
@ -45,7 +45,7 @@ use js::jsapi::Handle as RawHandle;
|
||||||
use js::jsapi::HandleObject;
|
use js::jsapi::HandleObject;
|
||||||
use js::jsapi::HandleValue as RawHandleValue;
|
use js::jsapi::HandleValue as RawHandleValue;
|
||||||
use js::jsapi::Value;
|
use js::jsapi::Value;
|
||||||
use js::jsapi::{CompileModule, ExceptionStackBehavior, FinishDynamicModuleImport};
|
use js::jsapi::{CompileModuleDontInflate, ExceptionStackBehavior, FinishDynamicModuleImport};
|
||||||
use js::jsapi::{GetModuleResolveHook, JSRuntime, SetModuleResolveHook};
|
use js::jsapi::{GetModuleResolveHook, JSRuntime, SetModuleResolveHook};
|
||||||
use js::jsapi::{GetRequestedModules, SetModuleMetadataHook};
|
use js::jsapi::{GetRequestedModules, SetModuleMetadataHook};
|
||||||
use js::jsapi::{Heap, JSContext, JS_ClearPendingException, SetModulePrivate};
|
use js::jsapi::{Heap, JSContext, JS_ClearPendingException, SetModulePrivate};
|
||||||
|
@ -56,7 +56,7 @@ use js::jsapi::{SetModuleDynamicImportHook, SetScriptPrivateReferenceHooks};
|
||||||
use js::jsval::{JSVal, PrivateValue, UndefinedValue};
|
use js::jsval::{JSVal, PrivateValue, UndefinedValue};
|
||||||
use js::rust::jsapi_wrapped::{GetRequestedModuleSpecifier, JS_GetPendingException};
|
use js::rust::jsapi_wrapped::{GetRequestedModuleSpecifier, JS_GetPendingException};
|
||||||
use js::rust::jsapi_wrapped::{JS_GetArrayLength, JS_GetElement};
|
use js::rust::jsapi_wrapped::{JS_GetArrayLength, JS_GetElement};
|
||||||
use js::rust::transform_u16_to_source_text;
|
use js::rust::transform_str_to_source_text;
|
||||||
use js::rust::wrappers::JS_SetPendingException;
|
use js::rust::wrappers::JS_SetPendingException;
|
||||||
use js::rust::CompileOptionsWrapper;
|
use js::rust::CompileOptionsWrapper;
|
||||||
use js::rust::{Handle, HandleValue, IntoHandle};
|
use js::rust::{Handle, HandleValue, IntoHandle};
|
||||||
|
@ -420,8 +420,6 @@ impl ModuleTree {
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
options: ScriptFetchOptions,
|
options: ScriptFetchOptions,
|
||||||
) -> Result<ModuleObject, RethrowError> {
|
) -> Result<ModuleObject, RethrowError> {
|
||||||
let module: Vec<u16> = module_script_text.encode_utf16().collect();
|
|
||||||
|
|
||||||
let url_cstr = ffi::CString::new(url.as_str().as_bytes()).unwrap();
|
let url_cstr = ffi::CString::new(url.as_str().as_bytes()).unwrap();
|
||||||
|
|
||||||
let _ac = JSAutoRealm::new(*global.get_cx(), *global.reflector().get_jsobject());
|
let _ac = JSAutoRealm::new(*global.get_cx(), *global.reflector().get_jsobject());
|
||||||
|
@ -430,10 +428,10 @@ impl ModuleTree {
|
||||||
unsafe { CompileOptionsWrapper::new(*global.get_cx(), url_cstr.as_ptr(), 1) };
|
unsafe { CompileOptionsWrapper::new(*global.get_cx(), url_cstr.as_ptr(), 1) };
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
rooted!(in(*global.get_cx()) let mut module_script = CompileModule(
|
rooted!(in(*global.get_cx()) let mut module_script = CompileModuleDontInflate(
|
||||||
*global.get_cx(),
|
*global.get_cx(),
|
||||||
compile_options.ptr,
|
compile_options.ptr,
|
||||||
&mut transform_u16_to_source_text(&module),
|
&mut transform_str_to_source_text(&module_script_text),
|
||||||
));
|
));
|
||||||
|
|
||||||
if module_script.is_null() {
|
if module_script.is_null() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue