diff --git a/src/binding.cc b/src/binding.cc index baa8f40c..c1d3e40f 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -22,6 +22,11 @@ using namespace support; +template +constexpr size_t align_to(size_t size) { + return (size + sizeof(T) - 1) & ~(sizeof(T) - 1); +} + static_assert(sizeof(two_pointers_t) == sizeof(std::shared_ptr), "std::shared_ptr size mismatch"); @@ -40,7 +45,7 @@ static_assert(sizeof(v8::PromiseRejectMessage) == sizeof(size_t) * 3, static_assert(sizeof(v8::Locker) == sizeof(size_t) * 2, "Locker size mismatch"); -static_assert(sizeof(v8::ScriptCompiler::Source) <= sizeof(size_t) * 8, +static_assert(sizeof(v8::ScriptCompiler::Source) == align_to(sizeof(size_t) * 6 + sizeof(int) * 3), "Source size mismatch"); static_assert(sizeof(v8::FunctionCallbackInfo) == sizeof(size_t) * 3, diff --git a/src/script_compiler.rs b/src/script_compiler.rs index 6419f349..af39a06b 100644 --- a/src/script_compiler.rs +++ b/src/script_compiler.rs @@ -1,4 +1,5 @@ // Copyright 2019-2021 the Deno authors. All rights reserved. MIT license. +use std::os::raw::c_int; use std::{marker::PhantomData, mem::MaybeUninit}; use crate::Function; @@ -61,7 +62,17 @@ extern "C" { /// Source code which can then be compiled to a UnboundScript or Script. #[repr(C)] #[derive(Debug)] -pub struct Source([usize; 8]); +pub struct Source { + _source_string: usize, + _resource_name: usize, + _resource_line_offset: c_int, + _resource_column_offset: c_int, + _resource_options: c_int, + _source_map_url: usize, + _host_defined_options: usize, + _cached_data: usize, + _consume_cache_task: usize, +} /// Compilation data that the embedder can cache and pass back to speed up future /// compilations. The data is produced if the CompilerOptions passed to the compilation