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

Commit

Permalink
meta: merge node/master into node-chakracore/master
Browse files Browse the repository at this point in the history
Merge 92ba624 as of 2018-02-07
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Jimmy Thomson <[email protected]>
  • Loading branch information
chakrabot committed Feb 13, 2018
2 parents 6faf146 + 92ba624 commit a89631e
Show file tree
Hide file tree
Showing 41 changed files with 560 additions and 314 deletions.
2 changes: 1 addition & 1 deletion deps/chakrashim/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 6
#define V8_MINOR_VERSION 4
#define V8_BUILD_NUMBER 388
#define V8_PATCH_LEVEL 41
#define V8_PATCH_LEVEL 42

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 6
#define V8_MINOR_VERSION 4
#define V8_BUILD_NUMBER 388
#define V8_PATCH_LEVEL 41
#define V8_PATCH_LEVEL 42

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
9 changes: 9 additions & 0 deletions deps/v8/src/frames.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,15 @@ JSFunction* JavaScriptFrame::function() const {
return JSFunction::cast(function_slot_object());
}

Object* JavaScriptFrame::unchecked_function() const {
// During deoptimization of an optimized function, we may have yet to
// materialize some closures on the stack. The arguments marker object
// marks this case.
DCHECK(function_slot_object()->IsJSFunction() ||
isolate()->heap()->arguments_marker() == function_slot_object());
return function_slot_object();
}

Object* JavaScriptFrame::receiver() const { return GetParameter(-1); }

Object* JavaScriptFrame::context() const {
Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ class JavaScriptFrame : public StandardFrame {

// Accessors.
virtual JSFunction* function() const;
Object* unchecked_function() const;
Object* receiver() const override;
Object* context() const override;
Script* script() const override;
Expand Down
23 changes: 19 additions & 4 deletions deps/v8/src/profiler/sampling-heap-profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,21 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() {
std::vector<SharedFunctionInfo*> stack;
JavaScriptFrameIterator it(isolate_);
int frames_captured = 0;
bool found_arguments_marker_frames = false;
while (!it.done() && frames_captured < stack_depth_) {
JavaScriptFrame* frame = it.frame();
SharedFunctionInfo* shared = frame->function()->shared();
stack.push_back(shared);

frames_captured++;
// If we are materializing objects during deoptimization, inlined
// closures may not yet be materialized, and this includes the
// closure on the stack. Skip over any such frames (they'll be
// in the top frames of the stack). The allocations made in this
// sensitive moment belong to the formerly optimized frame anyway.
if (frame->unchecked_function()->IsJSFunction()) {
SharedFunctionInfo* shared = frame->function()->shared();
stack.push_back(shared);
frames_captured++;
} else {
found_arguments_marker_frames = true;
}
it.Advance();
}

Expand Down Expand Up @@ -209,6 +218,12 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() {
}
node = node->FindOrAddChildNode(name, script_id, shared->start_position());
}

if (found_arguments_marker_frames) {
node =
node->FindOrAddChildNode("(deopt)", v8::UnboundScript::kNoScriptId, 0);
}

return node;
}

Expand Down
48 changes: 47 additions & 1 deletion deps/v8/test/cctest/test-heap-profiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3083,7 +3083,7 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
// Suppress randomness to avoid flakiness in tests.
v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true;

// Grow new space unitl maximum capacity reached.
// Grow new space until maximum capacity reached.
while (!CcTest::heap()->new_space()->IsAtMaximumCapacity()) {
CcTest::heap()->new_space()->Grow();
}
Expand Down Expand Up @@ -3138,3 +3138,49 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {

CHECK_GE(count, 8000);
}

TEST(SamplingHeapProfilerSampleDuringDeopt) {
i::FLAG_allow_natives_syntax = true;

v8::HandleScope scope(v8::Isolate::GetCurrent());
LocalContext env;
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();

// Suppress randomness to avoid flakiness in tests.
v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true;

// Small sample interval to force each object to be sampled.
heap_profiler->StartSamplingHeapProfiler(i::kPointerSize);

// Lazy deopt from runtime call from inlined callback function.
const char* source =
"var b = "
" [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];"
"(function f() {"
" var result = 0;"
" var lazyDeopt = function(deopt) {"
" var callback = function(v,i,o) {"
" result += i;"
" if (i == 13 && deopt) {"
" %DeoptimizeNow();"
" }"
" return v;"
" };"
" b.map(callback);"
" };"
" lazyDeopt();"
" lazyDeopt();"
" %OptimizeFunctionOnNextCall(lazyDeopt);"
" lazyDeopt();"
" lazyDeopt(true);"
" lazyDeopt();"
"})();";

CompileRun(source);
// Should not crash.

std::unique_ptr<v8::AllocationProfile> profile(
heap_profiler->GetAllocationProfile());
CHECK(profile);
heap_profiler->StopSamplingHeapProfiler();
}
2 changes: 1 addition & 1 deletion doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module. This can be one of the following:
| `format` | Description |
| --- | --- |
| `"esm"` | Load a standard JavaScript module |
| `"commonjs"` | Load a node-style CommonJS module |
| `"cjs"` | Load a node-style CommonJS module |
| `"builtin"` | Load a node builtin CommonJS module |
| `"json"` | Load a JSON file |
| `"addon"` | Load a [C++ Addon][addons] |
Expand Down
25 changes: 12 additions & 13 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3548,7 +3548,7 @@ the error raised if the file is not accessible.
added: REPLACEME
-->

* `file` {string|Buffer|URL|[FileHandle][]} filename or `FileHandle`
* `file` {string|Buffer|URL|FileHandle} filename or `FileHandle`
* `data` {string|Buffer}
* `options` {Object|string}
* `encoding` {string|null} **Default:** `'utf8'`
Expand Down Expand Up @@ -3640,7 +3640,7 @@ fs.promises.copyFile('source.txt', 'destination.txt', COPYFILE_EXCL)
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* `mode` {integer}
* Returns: {Promise}

Expand All @@ -3652,7 +3652,7 @@ success.
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* `uid` {integer}
* `gid` {integer}
* Returns: {Promise}
Expand All @@ -3665,7 +3665,7 @@ the `Promise` with no arguments upon success.
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* Returns: {Promise}

Asynchronous fdatasync(2). The `Promise` is resolved with no arguments upon
Expand All @@ -3676,7 +3676,7 @@ success.
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* Returns: {Promise}

Retrieves the [`fs.Stats`][] for the given `filehandle`.
Expand All @@ -3686,7 +3686,7 @@ Retrieves the [`fs.Stats`][] for the given `filehandle`.
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* Returns: {Promise}

Asynchronous fsync(2). The `Promise` is resolved with no arguments upon
Expand All @@ -3697,7 +3697,7 @@ success.
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* `len` {integer} **Default:** `0`
* Returns: {Promise}

Expand Down Expand Up @@ -3746,7 +3746,7 @@ The last three bytes are null bytes ('\0'), to compensate the over-truncation.
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* `atime` {number|string|Date}
* `mtime` {number|string|Date}`
* Returns: {Promise}
Expand Down Expand Up @@ -3934,7 +3934,7 @@ files can be opened for writing with the `r+` flag. A call to
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* `buffer` {Buffer|Uint8Array}
* `offset` {integer}
* `length` {integer}
Expand Down Expand Up @@ -3981,7 +3981,7 @@ will be passed as `Buffer` objects.
added: REPLACEME
-->

* `path` {string|Buffer|URL|[FileHandle][]} filename or `FileHandle`
* `path` {string|Buffer|URL|FileHandle} filename or `FileHandle`
* `options` {Object|string}
* `encoding` {string|null} **Default:** `null`
* `flag` {string} **Default:** `'r'`
Expand Down Expand Up @@ -4147,7 +4147,7 @@ The `atime` and `mtime` arguments follow these rules:
added: REPLACEME
-->

* `filehandle` {[FileHandle][]}
* `filehandle` {FileHandle}
* `buffer` {Buffer|Uint8Array}
* `offset` {integer}
* `length` {integer}
Expand Down Expand Up @@ -4180,7 +4180,7 @@ the end of the file.
added: REPLACEME
-->

* `file` {string|Buffer|URL|[FileHandle][]} filename or `FileHandle`
* `file` {string|Buffer|URL|FileHandle} filename or `FileHandle`
* `data` {string|Buffer|Uint8Array}
* `options` {Object|string}
* `encoding` {string|null} **Default:** `'utf8'`
Expand Down Expand Up @@ -4469,7 +4469,6 @@ The following constants are meant for use with the [`fs.Stats`][] object's
[`util.promisify()`]: util.html#util_util_promisify_original
[Caveats]: #fs_caveats
[Common System Errors]: errors.html#errors_common_system_errors
[FileHandle]: #fs_class_filehandle
[FS Constants]: #fs_fs_constants_1
[MDN-Date]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date
[MDN-Number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type
Expand Down
1 change: 1 addition & 0 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ Found'`.
## http.createServer([options][, requestListener])
<!-- YAML
added: v0.1.13
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/15752
description: The `options` argument is supported now.
Expand Down
2 changes: 1 addition & 1 deletion doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ changes:
and the total frame length will *not* necessarily be aligned at 8 bytes.
* `peerMaxConcurrentStreams` {number} Sets the maximum number of concurrent
streams for the remote peer as if a SETTINGS frame had been received. Will
be overridden if the remote peer sets its own value for.
be overridden if the remote peer sets its own value for
`maxConcurrentStreams`. **Default:** `100`
* `selectPadding` {Function} When `options.paddingStrategy` is equal to
`http2.constants.PADDING_STRATEGY_CALLBACK`, provides the callback function
Expand Down
76 changes: 68 additions & 8 deletions doc/api/synopsis.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,58 @@ Please see the [Command Line Options][] document for information about
different options and ways to run scripts with Node.js.

## Example

An example of a [web server][] written with Node.js which responds with
`'Hello World'`:
`'Hello World!'`:

Commands displayed in this document are shown starting with `$` or `>`
to replicate how they would appear in a user's terminal.
Do not include the `$` and `>` character they are there to
indicate the start of each command.

There are many tutorials and examples that follow this
convention: `$` or `>` for commands run as a regular user, and `#`
for commands that should be executed as an administrator.

Lines that don’t start with `$` or `>` character are typically showing
the output of the previous command.

Firstly, make sure to have downloaded and installed Node.js.
See [this guide][] for further install information.

Now, create an empty project folder called `projects`, navigate into it:
Project folder can be named base on user's current project title but
this example will use `projects` as the project folder.

Linux and Mac:

```console
$ mkdir ~/projects
$ cd ~/projects
```

Windows CMD:

```console
> mkdir %USERPROFILE%\projects
> cd %USERPROFILE%\projects
```

Windows PowerShell:

```console
> mkdir $env:USERPROFILE\projects
> cd $env:USERPROFILE\projects
```

Next, create a new source file in the `projects`
folder and call it `hello-world.js`.

In Node.js it is considered good style to use
hyphens (`-`) or underscores (`_`) to separate
multiple words in filenames.

Open `hello-world.js` in any preferred text editor and
paste in the following content.

```js
const http = require('http');
Expand All @@ -22,23 +71,34 @@ const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
res.end('Hello World!\n');
});

server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
```

To run the server, put the code into a file called `example.js` and execute
it with Node.js:
Save the file, go back to the terminal window enter the following command:

```txt
$ node example.js
Server running at http://127.0.0.1:3000/
```console
$ node hello-world.js
```

An output like this should appear in the terminal to indicate Node.js
server is running:

```console
Server running at http://127.0.0.1:3000/
````

Now, open any preferred web browser and visit `http://127.0.0.1:3000`.

If the browser displays the string `Hello, world!`, that indicates
the server is working.

Many of the examples in the documentation can be run similarly.

[Command Line Options]: cli.html#cli_command_line_options
[web server]: http.html
[this guide]: https://nodejs.org/en/download/package-manager/
Loading

0 comments on commit a89631e

Please sign in to comment.