mirror of
https://github.com/denoland/rusty_v8.git
synced 2025-01-12 17:09:28 -05:00
Fix some issues with v8::StartupData (#178)
This commit is contained in:
parent
2d77996467
commit
e0b8f2d02c
3 changed files with 10 additions and 7 deletions
|
@ -397,9 +397,12 @@ impl CreateParams {
|
||||||
/// - Compression of the startup blob might be useful, but needs to
|
/// - Compression of the startup blob might be useful, but needs to
|
||||||
/// handled entirely on the embedders' side.
|
/// handled entirely on the embedders' side.
|
||||||
/// - The call will abort if the data is invalid.
|
/// - The call will abort if the data is invalid.
|
||||||
pub fn set_snapshot_blob(&mut self, snapshot_blob: &mut StartupData) {
|
pub fn set_snapshot_blob(&mut self, snapshot_blob: &StartupData) {
|
||||||
unsafe {
|
unsafe {
|
||||||
v8__Isolate__CreateParams__SET__snapshot_blob(self, snapshot_blob)
|
v8__Isolate__CreateParams__SET__snapshot_blob(
|
||||||
|
self,
|
||||||
|
snapshot_blob as *const _ as *mut StartupData,
|
||||||
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub struct StartupData<'a> {
|
||||||
impl<'a> StartupData<'a> {
|
impl<'a> StartupData<'a> {
|
||||||
pub fn new<D>(data: &'a D) -> Self
|
pub fn new<D>(data: &'a D) -> Self
|
||||||
where
|
where
|
||||||
D: Borrow<[u8]>,
|
D: Borrow<[u8]> + ?Sized,
|
||||||
{
|
{
|
||||||
let data = data.borrow();
|
let data = data.borrow();
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -1494,7 +1494,7 @@ fn snapshot_creator() {
|
||||||
let g = setup();
|
let g = setup();
|
||||||
// First we create the snapshot, there is a single global variable 'a' set to
|
// First we create the snapshot, there is a single global variable 'a' set to
|
||||||
// the value 3.
|
// the value 3.
|
||||||
let mut startup_data = {
|
let startup_data = {
|
||||||
let mut snapshot_creator = v8::SnapshotCreator::new(None);
|
let mut snapshot_creator = v8::SnapshotCreator::new(None);
|
||||||
let isolate = snapshot_creator.get_isolate();
|
let isolate = snapshot_creator.get_isolate();
|
||||||
let mut locker = v8::Locker::new(&isolate);
|
let mut locker = v8::Locker::new(&isolate);
|
||||||
|
@ -1524,7 +1524,7 @@ fn snapshot_creator() {
|
||||||
{
|
{
|
||||||
let mut params = v8::Isolate::create_params();
|
let mut params = v8::Isolate::create_params();
|
||||||
params.set_array_buffer_allocator(v8::new_default_allocator());
|
params.set_array_buffer_allocator(v8::new_default_allocator());
|
||||||
params.set_snapshot_blob(&mut startup_data);
|
params.set_snapshot_blob(&startup_data);
|
||||||
let isolate = v8::Isolate::new(params);
|
let isolate = v8::Isolate::new(params);
|
||||||
let mut locker = v8::Locker::new(&isolate);
|
let mut locker = v8::Locker::new(&isolate);
|
||||||
{
|
{
|
||||||
|
@ -1560,7 +1560,7 @@ fn external_references() {
|
||||||
let g = setup();
|
let g = setup();
|
||||||
// First we create the snapshot, there is a single global variable 'a' set to
|
// First we create the snapshot, there is a single global variable 'a' set to
|
||||||
// the value 3.
|
// the value 3.
|
||||||
let mut startup_data = {
|
let startup_data = {
|
||||||
let mut snapshot_creator =
|
let mut snapshot_creator =
|
||||||
v8::SnapshotCreator::new(Some(&EXTERNAL_REFERENCES));
|
v8::SnapshotCreator::new(Some(&EXTERNAL_REFERENCES));
|
||||||
let isolate = snapshot_creator.get_isolate();
|
let isolate = snapshot_creator.get_isolate();
|
||||||
|
@ -1595,7 +1595,7 @@ fn external_references() {
|
||||||
{
|
{
|
||||||
let mut params = v8::Isolate::create_params();
|
let mut params = v8::Isolate::create_params();
|
||||||
params.set_array_buffer_allocator(v8::new_default_allocator());
|
params.set_array_buffer_allocator(v8::new_default_allocator());
|
||||||
params.set_snapshot_blob(&mut startup_data);
|
params.set_snapshot_blob(&startup_data);
|
||||||
params.set_external_references(&EXTERNAL_REFERENCES);
|
params.set_external_references(&EXTERNAL_REFERENCES);
|
||||||
let isolate = v8::Isolate::new(params);
|
let isolate = v8::Isolate::new(params);
|
||||||
let mut locker = v8::Locker::new(&isolate);
|
let mut locker = v8::Locker::new(&isolate);
|
||||||
|
|
Loading…
Reference in a new issue