Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Mathias Buus <mathiasbuus@gmail.com> <m@ge.tt>
Mathias Pettersson <mape@mape.me>
Matt Lang <matt@mediasuite.co.nz>
Matt Reed <matthewreed26@gmail.com>
Matteo Collina <matteo.collina@gmail.com> <hello@matteocollina.com>
Matteo Collina <hello@matteocollina.com> <matteo.collina@gmail.com>
Matthew Lye <muddletoes@hotmail.com>
Matthew Turner <matty_t47@hotmail.com> <ramesius@users.noreply.github.com>
Matthias Bastian <dev@matthias-bastian.de> <piepmatz@users.noreply.github.com>
Expand Down
4 changes: 0 additions & 4 deletions doc/contributing/large-pull-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

## Overview

Large pull requests are difficult to review or sometimes impossible to review in the GitHub UI. They are likely to sit
for a long time without receiving adequate review, and when they do get reviewed,
the quality of that review is often lower due to reviewer fatigue. Contributors
should avoid creating large pull requests except in those cases where it is
Large pull requests are difficult to review or sometimes impossible to review
in the GitHub UI. They are likely to sit for a long time without receiving
adequate review, and when they do get reviewed, the quality of that review is
Expand Down
17 changes: 0 additions & 17 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,23 +1071,6 @@
[ 'node_use_lief=="true" and node_shared_lief=="true"', {
'defines': [ 'HAVE_LIEF=1' ],
}],
[ 'node_use_sqlite=="true"', {
'sources': [
'<@(node_sqlite_sources)',
],
}],
[ 'node_use_ffi=="true"', {
'sources': [
'<@(node_ffi_sources)',
],
'conditions': [
[ 'node_shared_ffi=="false"', {
'dependencies': [
'deps/libffi/libffi.gyp:libffi',
],
}],
],
}],
[ 'node_use_quic=="true"', {
'sources': [
'<@(node_quic_sources)',
Expand Down
16 changes: 14 additions & 2 deletions src/encoding_binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,20 @@ void BindingData::DecodeUTF8(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args); // list, flags

CHECK_GE(args.Length(), 1);
auto isShared = args[0]->IsSharedArrayBuffer();

if (!(args[0]->IsArrayBuffer() || args[0]->IsSharedArrayBuffer() ||
args[0]->IsArrayBufferView())) {
if (!(args[0]->IsArrayBuffer() || isShared || args[0]->IsArrayBufferView())) {
return node::THROW_ERR_INVALID_ARG_TYPE(
env->isolate(),
"The \"list\" argument must be an instance of SharedArrayBuffer, "
"ArrayBuffer or ArrayBufferView.");
}

if (args[0]->IsArrayBufferView()) {
Local<v8::ArrayBufferView> view = args[0].As<v8::ArrayBufferView>();
isShared = view->Buffer()->IsSharedArrayBuffer();
}

ArrayBufferViewContents<char> buffer(args[0]);

bool ignore_bom = args[1]->IsTrue();
Expand All @@ -435,6 +440,13 @@ void BindingData::DecodeUTF8(const FunctionCallbackInfo<Value>& args) {
const char* data = buffer.data();
size_t length = buffer.length();

std::unique_ptr<char[]> data_copy;
if (isShared && length != 0) {
data_copy = std::make_unique_for_overwrite<char[]>(length);
memcpy(data_copy.get(), data, length);
data = data_copy.get();
}

if (!ignore_bom && length >= 3) {
if (memcmp(data, "\xEF\xBB\xBF", 3) == 0) {
data += 3;
Expand Down
24 changes: 18 additions & 6 deletions src/node_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -567,19 +567,31 @@ void StringSlice(const FunctionCallbackInfo<Value>& args) {
THROW_AND_RETURN_UNLESS_BUFFER(env, args[0]);
ArrayBufferViewContents<char> buffer(args[0]);

if (buffer.length() == 0)
return args.GetReturnValue().SetEmptyString();
auto buffer_length = buffer.length();
const char* data_ptr = buffer.data();

Local<ArrayBufferView> view = args[0].As<ArrayBufferView>();

if (buffer_length == 0) return args.GetReturnValue().SetEmptyString();

size_t start = 0;
size_t end = 0;
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[1], 0, &start));
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[2], buffer.length(), &end));
if (end < start) end = start;
THROW_AND_RETURN_IF_OOB(Just(end <= buffer.length()));
THROW_AND_RETURN_IF_OOB(ParseArrayIndex(env, args[2], buffer_length, &end));
if (end <= start) return args.GetReturnValue().SetEmptyString();
THROW_AND_RETURN_IF_OOB(Just(end <= buffer_length));
size_t length = end - start;

std::unique_ptr<char[]> data_copy;
if (view->Buffer()->IsSharedArrayBuffer()) {
data_copy = std::make_unique_for_overwrite<char[]>(length);
memcpy(data_copy.get(), data_ptr + start, length);
data_ptr = data_copy.get();
start = 0;
}

Local<Value> ret;
if (StringBytes::Encode(isolate, buffer.data() + start, length, encoding)
if (StringBytes::Encode(isolate, data_ptr + start, length, encoding)
.ToLocal(&ret)) {
args.GetReturnValue().Set(ret);
}
Expand Down
16 changes: 15 additions & 1 deletion tools/nix/v8.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,24 @@ let
../../tools/icu/icutrim.py
../../tools/icu/no-op.cc
];
potentiallyAlreadyRemovedFiles =
# Files that are removed in the release tarball (see Makefile $(TARBALL) target)
[ (fileset.difference ../../deps/v8/test ../../deps/v8/test/torque) ]
++ (builtins.filter builtins.pathExists [
../../deps/v8/samples
../../deps/v8/tools/profviz
../../deps/v8/tools/run-tests.py
../../deps/v8/third_party/ittapi
]);
trackedFiles =
({
# This line is being modified by Makefile $(TARBALL) target, any change to it should be sync
fileset = fileset.intersection (fileset.gitTracked root) (fileset.unions files);
}).fileset;
in
fileset.toSource {
inherit root;
fileset = fileset.intersection (fileset.gitTracked root) (fileset.unions files);
fileset = fileset.difference trackedFiles (fileset.unions potentiallyAlreadyRemovedFiles);
};
v8Dir = "${src}/deps/v8";
in
Expand Down
Loading