mirror of
https://github.com/swc-project/swc.git
synced 2024-10-04 20:28:43 +03:00
feat(es/plugin/runner): Add more traces for the plugin host (#5538)
This commit is contained in:
parent
6412279ddb
commit
d46418bb47
@ -159,6 +159,7 @@ impl RustPlugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "plugin", target_arch = "wasm32"))]
|
#[cfg(all(feature = "plugin", target_arch = "wasm32"))]
|
||||||
|
#[tracing::instrument(level = "info", skip_all)]
|
||||||
fn apply_inner(&mut self, n: Program) -> Result<Program, anyhow::Error> {
|
fn apply_inner(&mut self, n: Program) -> Result<Program, anyhow::Error> {
|
||||||
use std::{path::PathBuf, sync::Arc};
|
use std::{path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ impl PluginSerializedBytes {
|
|||||||
* Constructs an instance from already serialized byte
|
* Constructs an instance from already serialized byte
|
||||||
* slices.
|
* slices.
|
||||||
*/
|
*/
|
||||||
|
#[tracing::instrument(level = "info", skip_all)]
|
||||||
pub fn from_slice(bytes: &[u8]) -> PluginSerializedBytes {
|
pub fn from_slice(bytes: &[u8]) -> PluginSerializedBytes {
|
||||||
let mut field = rkyv::AlignedVec::new();
|
let mut field = rkyv::AlignedVec::new();
|
||||||
field.extend_from_slice(bytes);
|
field.extend_from_slice(bytes);
|
||||||
@ -54,6 +55,7 @@ impl PluginSerializedBytes {
|
|||||||
* This is sort of mimic TryFrom behavior, since we can't use generic
|
* This is sort of mimic TryFrom behavior, since we can't use generic
|
||||||
* to implement TryFrom trait
|
* to implement TryFrom trait
|
||||||
*/
|
*/
|
||||||
|
#[tracing::instrument(level = "info", skip_all)]
|
||||||
pub fn try_serialize<W>(t: &W) -> Result<Self, Error>
|
pub fn try_serialize<W>(t: &W) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
W: rkyv::Serialize<rkyv::ser::serializers::AllocSerializer<512>>,
|
W: rkyv::Serialize<rkyv::ser::serializers::AllocSerializer<512>>,
|
||||||
@ -74,6 +76,7 @@ impl PluginSerializedBytes {
|
|||||||
/*
|
/*
|
||||||
* Internal fn to constructs an instance from raw bytes ptr.
|
* Internal fn to constructs an instance from raw bytes ptr.
|
||||||
*/
|
*/
|
||||||
|
#[tracing::instrument(level = "info", skip_all)]
|
||||||
fn from_raw_ptr(
|
fn from_raw_ptr(
|
||||||
raw_allocated_ptr: *const u8,
|
raw_allocated_ptr: *const u8,
|
||||||
raw_allocated_ptr_len: usize,
|
raw_allocated_ptr_len: usize,
|
||||||
@ -92,6 +95,7 @@ impl PluginSerializedBytes {
|
|||||||
(self.field.as_ptr(), self.field.len())
|
(self.field.as_ptr(), self.field.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tracing::instrument(level = "info", skip_all)]
|
||||||
pub fn deserialize<W>(&self) -> Result<W, Error>
|
pub fn deserialize<W>(&self) -> Result<W, Error>
|
||||||
where
|
where
|
||||||
W: rkyv::Archive,
|
W: rkyv::Archive,
|
||||||
@ -113,6 +117,7 @@ impl PluginSerializedBytes {
|
|||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This is naturally unsafe by constructing bytes slice from raw ptr.
|
/// This is naturally unsafe by constructing bytes slice from raw ptr.
|
||||||
|
#[tracing::instrument(level = "info", skip_all)]
|
||||||
pub unsafe fn deserialize_from_ptr<W>(
|
pub unsafe fn deserialize_from_ptr<W>(
|
||||||
raw_allocated_ptr: *const u8,
|
raw_allocated_ptr: *const u8,
|
||||||
raw_allocated_ptr_len: i32,
|
raw_allocated_ptr_len: i32,
|
||||||
@ -136,6 +141,7 @@ where
|
|||||||
/// # Safety
|
/// # Safety
|
||||||
/// This is unsafe by construting bytes slice from raw ptr also deserialize
|
/// This is unsafe by construting bytes slice from raw ptr also deserialize
|
||||||
/// it without slice bound check.
|
/// it without slice bound check.
|
||||||
|
#[tracing::instrument(level = "info", skip_all)]
|
||||||
pub unsafe fn deserialize_from_ptr_into_fallible<W>(
|
pub unsafe fn deserialize_from_ptr_into_fallible<W>(
|
||||||
raw_allocated_ptr: *const u8,
|
raw_allocated_ptr: *const u8,
|
||||||
raw_allocated_ptr_len: i32,
|
raw_allocated_ptr_len: i32,
|
||||||
|
@ -88,6 +88,7 @@ impl TransformExecutor {
|
|||||||
|
|
||||||
/// Copy host's serialized bytes into guest (plugin)'s allocated memory.
|
/// Copy host's serialized bytes into guest (plugin)'s allocated memory.
|
||||||
/// Once transformation completes, host should free allocated memory.
|
/// Once transformation completes, host should free allocated memory.
|
||||||
|
#[tracing::instrument(level = "info", skip_all)]
|
||||||
fn write_bytes_into_guest(
|
fn write_bytes_into_guest(
|
||||||
&mut self,
|
&mut self,
|
||||||
serialized_bytes: &PluginSerializedBytes,
|
serialized_bytes: &PluginSerializedBytes,
|
||||||
|
Loading…
Reference in New Issue
Block a user