Skip to content

Commit

Permalink
feat: enable pointer compression and 31bit smis (#21468)
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon committed Dec 13, 2019
1 parent 341df4a commit c535e00
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
6 changes: 0 additions & 6 deletions build/args/all.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ v8_promise_internal_field_count = 1
v8_typed_array_max_size_in_heap = 0
v8_embedder_string = "-electron.0"

# TODO: this breaks native modules. See e.g. https://www.github.com/nodejs/node/pull/30463
# We can probably enable this as long as we make sure node native modules
# also build with the relevant #defines (V8_COMPRESS_POINTERS etc.)
v8_enable_pointer_compression = false
v8_enable_31bit_smis_on_64bit_arch = false

# TODO: this breaks mksnapshot
v8_enable_snapshot_native_code_counters = false

Expand Down
1 change: 1 addition & 0 deletions patches/node/.patches
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ fix_don_t_use_node-controlled_preparestacktrace.patch
fix_remove_uses_of_node_use_v8_platform.patch
fix_call_initializecontextruntime_in_initializecontext.patch
refactor_transferrablemodule_is_deprecated_use_compiledwasmmodule.patch
enable_31_bit_smis_on_64bit_arch_and_ptr_compression.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Tue, 10 Dec 2019 15:02:21 -0800
Subject: enable 31 bit smis on 64bit arch and ptr compression

This aligns with the defaults set on the Chromium build. Without this, native
node modules will have different (wrong) ideas about how v8 structs are laid
out in memory on 64-bit machines, and will summarily fail to work.

diff --git a/common.gypi b/common.gypi
index 412f613e7cfcf563fa6a000b932723166ab567da..6e2ad757781f794333b3656ec05f6e48ade86d2e 100644
--- a/common.gypi
+++ b/common.gypi
@@ -75,6 +75,9 @@
# TODO(refack): make v8-perfetto happen
'v8_use_perfetto': 0,

+ 'v8_enable_pointer_compression%': 0,
+ 'v8_enable_31bit_smis_on_64bit_arch': 1,
+
##### end V8 defaults #####

# When building native modules using 'npm install' with the system npm,
@@ -152,6 +155,9 @@
['OS=="mac"', {
'clang%': 1,
}],
+ ['target_arch == "arm64" or target_arch == "x64"', {
+ 'v8_enable_pointer_compression': 1,
+ }],
],
},

@@ -375,6 +381,12 @@
}],
],
}],
+ ['v8_enable_pointer_compression == 1', {
+ 'defines': ['V8_COMPRESS_POINTERS'],
+ }],
+ ['v8_enable_pointer_compression == 1 or v8_enable_31bit_smis_on_64bit_arch == 1', {
+ 'defines': ['V8_31BIT_SMIS_ON_64BIT_ARCH'],
+ }],
['OS == "win"', {
'defines': [
'WIN32',

0 comments on commit c535e00

Please sign in to comment.