Skip to content

Commit

Permalink
Fix compilation for 32-bit targets (denoland#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
wg committed Aug 21, 2022
1 parent a9595da commit fa01b39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@

using namespace support;

template<typename T>
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<v8::BackingStore>),
"std::shared_ptr<v8::BackingStore> size mismatch");
Expand All @@ -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<size_t>(sizeof(size_t) * 6 + sizeof(int) * 3),
"Source size mismatch");

static_assert(sizeof(v8::FunctionCallbackInfo<v8::Value>) == sizeof(size_t) * 3,
Expand Down
13 changes: 12 additions & 1 deletion src/script_compiler.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fa01b39

Please sign in to comment.