Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit df730ba

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge 0fb017d as of 2018-03-19 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
2 parents dd99ab2 + 0fb017d commit df730ba

28 files changed

+298
-168
lines changed

deps/chakrashim/include/v8-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 6
1212
#define V8_MINOR_VERSION 5
1313
#define V8_BUILD_NUMBER 254
14-
#define V8_PATCH_LEVEL 38
14+
#define V8_PATCH_LEVEL 40
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/include/v8-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 6
1212
#define V8_MINOR_VERSION 5
1313
#define V8_BUILD_NUMBER 254
14-
#define V8_PATCH_LEVEL 38
14+
#define V8_PATCH_LEVEL 40
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/wasm/wasm-code-manager.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,8 @@ void WasmCodeManager::FreeNativeModuleMemories(NativeModule* native_module) {
954954
Free(&vmem);
955955
DCHECK(!vmem.IsReserved());
956956
}
957+
native_module->owned_memory_.clear();
958+
957959
// No need to tell the GC anything if we're destroying the heap,
958960
// which we currently indicate by having the isolate_ as null
959961
if (isolate_ == nullptr) return;

deps/v8/tools/whitespace.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ The doubles heard this and started to unbox.
88
The Smi looked at them when a crazy v8-autoroll account showed up...
99
The autoroller bought a round of Himbeerbrause. Suddenly...
1010
The bartender starts to shake the bottles.......................
11-
.
12-
.

doc/api/errors.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -783,18 +783,6 @@ falsy value.
783783
An invalid symlink type was passed to the [`fs.symlink()`][] or
784784
[`fs.symlinkSync()`][] methods.
785785

786-
<a id="ERR_FS_WATCHER_ALREADY_STARTED"></a>
787-
### ERR_FS_WATCHER_ALREADY_STARTED
788-
789-
An attempt was made to start a watcher returned by `fs.watch()` that has
790-
already been started.
791-
792-
<a id="ERR_FS_WATCHER_NOT_STARTED"></a>
793-
### ERR_FS_WATCHER_NOT_STARTED
794-
795-
An attempt was made to initiate operations on a watcher returned by
796-
`fs.watch()` that has not yet been started.
797-
798786
<a id="ERR_HTTP_HEADERS_SENT"></a>
799787
### ERR_HTTP_HEADERS_SENT
800788

doc/api/stream.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,10 @@ print(fs.createReadStream('file')).catch(console.log);
12081208

12091209
If the loop terminates with a `break` or a `throw`, the stream will be
12101210
destroyed. In other terms, iterating over a stream will consume the stream
1211-
fully.
1211+
fully. The stream will be read in chunks of size equal to the `highWaterMark`
1212+
option. In the code example above, data will be in a single chunk if the file
1213+
has less then 64kb of data because no `highWaterMark` option is provided to
1214+
[`fs.createReadStream()`][].
12121215

12131216
### Duplex and Transform Streams
12141217

lib/fs.js

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ const fs = exports;
3636
const { Buffer } = require('buffer');
3737
const errors = require('internal/errors');
3838
const {
39-
ERR_FS_WATCHER_ALREADY_STARTED,
40-
ERR_FS_WATCHER_NOT_STARTED,
4139
ERR_INVALID_ARG_TYPE,
4240
ERR_INVALID_CALLBACK,
4341
ERR_OUT_OF_RANGE
@@ -1342,25 +1340,26 @@ util.inherits(FSWatcher, EventEmitter);
13421340

13431341
// FIXME(joyeecheung): this method is not documented.
13441342
// At the moment if filename is undefined, we
1345-
// 1. Throw an Error from C++ land if it's the first time .start() is called
1346-
// 2. Return silently from C++ land if .start() has already been called
1343+
// 1. Throw an Error if it's the first time .start() is called
1344+
// 2. Return silently if .start() has already been called
13471345
// on a valid filename and the wrap has been initialized
1346+
// This method is a noop if the watcher has already been started.
13481347
FSWatcher.prototype.start = function(filename,
13491348
persistent,
13501349
recursive,
13511350
encoding) {
13521351
lazyAssert()(this._handle instanceof FSEvent, 'handle must be a FSEvent');
13531352
if (this._handle.initialized) {
1354-
throw new ERR_FS_WATCHER_ALREADY_STARTED();
1353+
return;
13551354
}
13561355

13571356
filename = getPathFromURL(filename);
13581357
validatePath(filename, 'filename');
13591358

1360-
var err = this._handle.start(pathModule.toNamespacedPath(filename),
1361-
persistent,
1362-
recursive,
1363-
encoding);
1359+
const err = this._handle.start(pathModule.toNamespacedPath(filename),
1360+
persistent,
1361+
recursive,
1362+
encoding);
13641363
if (err) {
13651364
const error = errors.uvException({
13661365
errno: err,
@@ -1372,10 +1371,11 @@ FSWatcher.prototype.start = function(filename,
13721371
}
13731372
};
13741373

1374+
// This method is a noop if the watcher has not been started.
13751375
FSWatcher.prototype.close = function() {
13761376
lazyAssert()(this._handle instanceof FSEvent, 'handle must be a FSEvent');
13771377
if (!this._handle.initialized) {
1378-
throw new ERR_FS_WATCHER_NOT_STARTED();
1378+
return;
13791379
}
13801380
this._handle.close();
13811381
};
@@ -1449,18 +1449,43 @@ util.inherits(StatWatcher, EventEmitter);
14491449

14501450
// FIXME(joyeecheung): this method is not documented.
14511451
// At the moment if filename is undefined, we
1452-
// 1. Throw an Error from C++ land if it's the first time .start() is called
1453-
// 2. Return silently from C++ land if .start() has already been called
1452+
// 1. Throw an Error if it's the first time .start() is called
1453+
// 2. Return silently if .start() has already been called
14541454
// on a valid filename and the wrap has been initialized
1455+
// This method is a noop if the watcher has already been started.
14551456
StatWatcher.prototype.start = function(filename, persistent, interval) {
1457+
lazyAssert()(this._handle instanceof binding.StatWatcher,
1458+
'handle must be a StatWatcher');
1459+
if (this._handle.isActive) {
1460+
return;
1461+
}
1462+
14561463
filename = getPathFromURL(filename);
1457-
nullCheck(filename, 'filename');
1458-
this._handle.start(pathModule.toNamespacedPath(filename),
1459-
persistent, interval);
1464+
validatePath(filename, 'filename');
1465+
validateUint32(interval, 'interval');
1466+
const err = this._handle.start(pathModule.toNamespacedPath(filename),
1467+
persistent, interval);
1468+
if (err) {
1469+
const error = errors.uvException({
1470+
errno: err,
1471+
syscall: 'watch',
1472+
path: filename
1473+
});
1474+
error.filename = filename;
1475+
throw error;
1476+
}
14601477
};
14611478

1462-
1479+
// FIXME(joyeecheung): this method is not documented while there is
1480+
// another documented fs.unwatchFile(). The counterpart in
1481+
// FSWatcher is .close()
1482+
// This method is a noop if the watcher has not been started.
14631483
StatWatcher.prototype.stop = function() {
1484+
lazyAssert()(this._handle instanceof binding.StatWatcher,
1485+
'handle must be a StatWatcher');
1486+
if (!this._handle.isActive) {
1487+
return;
1488+
}
14641489
this._handle.stop();
14651490
};
14661491

lib/internal/errors.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,6 @@ E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value', Error);
654654
E('ERR_FS_INVALID_SYMLINK_TYPE',
655655
'Symlink type must be one of "dir", "file", or "junction". Received "%s"',
656656
Error); // Switch to TypeError. The current implementation does not seem right
657-
E('ERR_FS_WATCHER_ALREADY_STARTED',
658-
'The watcher has already been started', Error);
659-
E('ERR_FS_WATCHER_NOT_STARTED',
660-
'The watcher has not been started', Error);
661657
E('ERR_HTTP2_ALTSVC_INVALID_ORIGIN',
662658
'HTTP/2 ALTSVC frames require a valid origin', TypeError);
663659
E('ERR_HTTP2_ALTSVC_LENGTH',

src/node_file.cc

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,6 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
15381538

15391539
const auto enc = ParseEncoding(env->isolate(), args[3], UTF8);
15401540

1541-
std::unique_ptr<char[]> delete_on_return;
15421541
Local<Value> value = args[1];
15431542
char* buf = nullptr;
15441543
size_t len;
@@ -1566,24 +1565,42 @@ static void WriteString(const FunctionCallbackInfo<Value>& args) {
15661565
}
15671566
}
15681567

1569-
if (buf == nullptr) {
1568+
if (is_async) { // write(fd, string, pos, enc, req)
1569+
CHECK_NE(req_wrap, nullptr);
15701570
len = StringBytes::StorageSize(env->isolate(), value, enc);
1571-
buf = new char[len];
1572-
// SYNC_CALL returns on error. Make sure to always free the memory.
1573-
if (!is_async) delete_on_return.reset(buf);
1571+
FSReqBase::FSReqBuffer& stack_buffer =
1572+
req_wrap->Init("write", len, enc);
15741573
// StorageSize may return too large a char, so correct the actual length
15751574
// by the write size
1576-
len = StringBytes::Write(env->isolate(), buf, len, args[1], enc);
1577-
}
1578-
1579-
uv_buf_t uvbuf = uv_buf_init(buf, len);
1580-
1581-
if (is_async) { // write(fd, string, pos, enc, req)
1582-
AsyncCall(env, req_wrap, args, "write", UTF8, AfterInteger,
1583-
uv_fs_write, fd, &uvbuf, 1, pos);
1575+
len = StringBytes::Write(env->isolate(), *stack_buffer, len, args[1], enc);
1576+
stack_buffer.SetLengthAndZeroTerminate(len);
1577+
uv_buf_t uvbuf = uv_buf_init(*stack_buffer, len);
1578+
int err = uv_fs_write(env->event_loop(), req_wrap->req(),
1579+
fd, &uvbuf, 1, pos, AfterInteger);
1580+
req_wrap->Dispatched();
1581+
if (err < 0) {
1582+
uv_fs_t* uv_req = req_wrap->req();
1583+
uv_req->result = err;
1584+
uv_req->path = nullptr;
1585+
AfterInteger(uv_req); // after may delete req_wrap if there is an error
1586+
} else {
1587+
req_wrap->SetReturnValue(args);
1588+
}
15841589
} else { // write(fd, string, pos, enc, undefined, ctx)
15851590
CHECK_EQ(argc, 6);
15861591
fs_req_wrap req_wrap;
1592+
FSReqBase::FSReqBuffer stack_buffer;
1593+
if (buf == nullptr) {
1594+
len = StringBytes::StorageSize(env->isolate(), value, enc);
1595+
stack_buffer.AllocateSufficientStorage(len + 1);
1596+
// StorageSize may return too large a char, so correct the actual length
1597+
// by the write size
1598+
len = StringBytes::Write(env->isolate(), *stack_buffer,
1599+
len, args[1], enc);
1600+
stack_buffer.SetLengthAndZeroTerminate(len);
1601+
buf = *stack_buffer;
1602+
}
1603+
uv_buf_t uvbuf = uv_buf_init(buf, len);
15871604
int bytesWritten = SyncCall(env, args[5], &req_wrap, "write",
15881605
uv_fs_write, fd, &uvbuf, 1, pos);
15891606
args.GetReturnValue().Set(bytesWritten);

src/node_file.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ namespace fs {
2424

2525
class FSReqBase : public ReqWrap<uv_fs_t> {
2626
public:
27+
typedef MaybeStackBuffer<char, 64> FSReqBuffer;
28+
2729
FSReqBase(Environment* env, Local<Object> req, AsyncWrap::ProviderType type)
2830
: ReqWrap(env, req, type) {
2931
Wrap(object(), this);
@@ -34,9 +36,9 @@ class FSReqBase : public ReqWrap<uv_fs_t> {
3436
}
3537

3638
void Init(const char* syscall,
37-
const char* data = nullptr,
38-
size_t len = 0,
39-
enum encoding encoding = UTF8) {
39+
const char* data,
40+
size_t len,
41+
enum encoding encoding) {
4042
syscall_ = syscall;
4143
encoding_ = encoding;
4244

@@ -49,6 +51,16 @@ class FSReqBase : public ReqWrap<uv_fs_t> {
4951
}
5052
}
5153

54+
FSReqBuffer& Init(const char* syscall, size_t len,
55+
enum encoding encoding) {
56+
syscall_ = syscall;
57+
encoding_ = encoding;
58+
59+
buffer_.AllocateSufficientStorage(len + 1);
60+
has_data_ = false; // so that the data does not show up in error messages
61+
return buffer_;
62+
}
63+
5264
virtual void FillStatsArray(const uv_stat_t* stat) = 0;
5365
virtual void Reject(Local<Value> reject) = 0;
5466
virtual void Resolve(Local<Value> value) = 0;
@@ -68,7 +80,7 @@ class FSReqBase : public ReqWrap<uv_fs_t> {
6880

6981
// Typically, the content of buffer_ is something like a file name, so
7082
// something around 64 bytes should be enough.
71-
MaybeStackBuffer<char, 64> buffer_;
83+
FSReqBuffer buffer_;
7284

7385
DISALLOW_COPY_AND_ASSIGN(FSReqBase);
7486
};

0 commit comments

Comments
 (0)