Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src,buffer: allow heap-allocated typed arrays #26301

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,10 +1123,6 @@ def configure_v8(o):
o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8)
o['variables']['force_dynamic_crt'] = 1 if options.shared else 0
o['variables']['node_enable_d8'] = b(options.enable_d8)
# Unconditionally force typed arrays to allocate outside the v8 heap. This
# is to prevent memory pointers from being moved around that are returned by
# Buffer::Data().
o['variables']['v8_typed_array_max_size_in_heap'] = 0
if options.enable_d8:
o['variables']['test_isolation_mode'] = 'noop' # Needed by d8.gyp.
if options.without_bundled_v8 and options.enable_d8:
Expand Down
8 changes: 2 additions & 6 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,17 @@ let poolSize, poolOffset, allocPool;
const zeroFill = bindingZeroFill || [0];

function createUnsafeBuffer(size) {
return new FastBuffer(createUnsafeArrayBuffer(size));
}

function createUnsafeArrayBuffer(size) {
zeroFill[0] = 0;
try {
return new ArrayBuffer(size);
return new FastBuffer(size);
} finally {
zeroFill[0] = 1;
}
}

function createPool() {
poolSize = Buffer.poolSize;
allocPool = createUnsafeArrayBuffer(poolSize);
allocPool = createUnsafeBuffer(poolSize).buffer;
poolOffset = 0;
}
createPool();
Expand Down
Loading