mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-24 15:19:31 -05:00
feat: expose CachedData::rejected (#1413)
This commit is contained in:
parent
9dd629e1c3
commit
083f43346c
2 changed files with 16 additions and 7 deletions
|
@ -118,6 +118,11 @@ impl<'a> CachedData<'a> {
|
|||
pub(crate) fn buffer_policy(&self) -> BufferPolicy {
|
||||
self.buffer_policy
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn rejected(&self) -> bool {
|
||||
self.rejected
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> std::ops::Deref for CachedData<'a> {
|
||||
|
@ -227,11 +232,11 @@ pub enum NoCacheReason {
|
|||
#[inline(always)]
|
||||
pub fn compile_module<'s>(
|
||||
scope: &mut HandleScope<'s>,
|
||||
source: Source,
|
||||
mut source: Source,
|
||||
) -> Option<Local<'s, Module>> {
|
||||
compile_module2(
|
||||
scope,
|
||||
source,
|
||||
&mut source,
|
||||
CompileOptions::NoCompileOptions,
|
||||
NoCacheReason::NoReason,
|
||||
)
|
||||
|
@ -241,7 +246,7 @@ pub fn compile_module<'s>(
|
|||
#[inline(always)]
|
||||
pub fn compile_module2<'s>(
|
||||
scope: &mut HandleScope<'s>,
|
||||
mut source: Source,
|
||||
source: &mut Source,
|
||||
options: CompileOptions,
|
||||
no_cache_reason: NoCacheReason,
|
||||
) -> Option<Local<'s, Module>> {
|
||||
|
@ -249,7 +254,7 @@ pub fn compile_module2<'s>(
|
|||
scope.cast_local(|sd| {
|
||||
v8__ScriptCompiler__CompileModule(
|
||||
sd.get_isolate_ptr(),
|
||||
&mut source,
|
||||
source,
|
||||
options,
|
||||
no_cache_reason,
|
||||
)
|
||||
|
|
|
@ -8670,7 +8670,7 @@ fn create_module<'s>(
|
|||
true,
|
||||
);
|
||||
let has_cache = code_cache.is_some();
|
||||
let source = match code_cache {
|
||||
let mut source = match code_cache {
|
||||
Some(x) => v8::script_compiler::Source::new_with_cached_data(
|
||||
source,
|
||||
Some(&script_origin),
|
||||
|
@ -8678,14 +8678,18 @@ fn create_module<'s>(
|
|||
),
|
||||
None => v8::script_compiler::Source::new(source, Some(&script_origin)),
|
||||
};
|
||||
assert_eq!(source.get_cached_data().is_some(), has_cache);
|
||||
let module = v8::script_compiler::compile_module2(
|
||||
scope,
|
||||
source,
|
||||
&mut source,
|
||||
options,
|
||||
v8::script_compiler::NoCacheReason::NoReason,
|
||||
)
|
||||
.unwrap();
|
||||
let code_cache = source.get_cached_data();
|
||||
assert_eq!(code_cache.is_some(), has_cache);
|
||||
if let Some(code_cache) = code_cache {
|
||||
assert!(!code_cache.rejected());
|
||||
}
|
||||
module
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue