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 a4f44ac as of 2017-12-21
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Taylor Woll <tawoll@ntdev.microsoft.com>
  • Loading branch information
chakrabot committed Jan 19, 2018
2 parents f40894f + a4f44ac commit 4f7a00f
Show file tree
Hide file tree
Showing 35 changed files with 1,066 additions and 224 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.3',
'v8_embedder_string': '-node.4',

# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
Expand Down
19 changes: 19 additions & 0 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10172,6 +10172,25 @@ void debug::QueryObjects(v8::Local<v8::Context> v8_context,
predicate, objects);
}

void debug::GlobalLexicalScopeNames(
v8::Local<v8::Context> v8_context,
v8::PersistentValueVector<v8::String>* names) {
i::Handle<i::Context> context = Utils::OpenHandle(*v8_context);
i::Handle<i::ScriptContextTable> table(
context->global_object()->native_context()->script_context_table());
for (int i = 0; i < table->used(); i++) {
i::Handle<i::Context> context = i::ScriptContextTable::GetContext(table, i);
DCHECK(context->IsScriptContext());
i::Handle<i::ScopeInfo> scope_info(context->scope_info());
int local_count = scope_info->ContextLocalCount();
for (int j = 0; j < local_count; ++j) {
i::String* name = scope_info->ContextLocalName(j);
if (i::ScopeInfo::VariableIsSynthetic(name)) continue;
names->Append(Utils::ToLocal(handle(name)));
}
}
}

Local<String> CpuProfileNode::GetFunctionName() const {
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
i::Isolate* isolate = node->isolate();
Expand Down
3 changes: 3 additions & 0 deletions deps/v8/src/debug/debug-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ void QueryObjects(v8::Local<v8::Context> context,
QueryObjectPredicate* predicate,
v8::PersistentValueVector<v8::Object>* objects);

void GlobalLexicalScopeNames(v8::Local<v8::Context> context,
v8::PersistentValueVector<v8::String>* names);

} // namespace debug
} // namespace v8

Expand Down
11 changes: 11 additions & 0 deletions deps/v8/src/inspector/js_protocol.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,17 @@
{ "name": "objects", "$ref": "RemoteObject", "description": "Array with objects." }
],
"experimental": true
},
{
"name": "globalLexicalScopeNames",
"parameters": [
{ "name": "executionContextId", "$ref": "ExecutionContextId", "optional": true, "description": "Specifies in which execution context to lookup global scope variables." }
],
"returns": [
{ "name": "names", "type": "array", "items": { "type": "string" } }
],
"description": "Returns all let, const and class variables from global scope.",
"experimental": true
}
],
"events": [
Expand Down
21 changes: 21 additions & 0 deletions deps/v8/src/inspector/v8-runtime-agent-impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,27 @@ Response V8RuntimeAgentImpl::queryObjects(
resultArray, scope.objectGroupName(), false, false, objects);
}

Response V8RuntimeAgentImpl::globalLexicalScopeNames(
Maybe<int> executionContextId,
std::unique_ptr<protocol::Array<String16>>* outNames) {
int contextId = 0;
Response response = ensureContext(m_inspector, m_session->contextGroupId(),
std::move(executionContextId), &contextId);
if (!response.isSuccess()) return response;

InjectedScript::ContextScope scope(m_session, contextId);
response = scope.initialize();
if (!response.isSuccess()) return response;

v8::PersistentValueVector<v8::String> names(m_inspector->isolate());
v8::debug::GlobalLexicalScopeNames(scope.context(), &names);
*outNames = protocol::Array<String16>::create();
for (size_t i = 0; i < names.Size(); ++i) {
(*outNames)->addItem(toProtocolString(names.Get(i)));
}
return Response::OK();
}

void V8RuntimeAgentImpl::restore() {
if (!m_state->booleanProperty(V8RuntimeAgentImplState::runtimeEnabled, false))
return;
Expand Down
3 changes: 3 additions & 0 deletions deps/v8/src/inspector/v8-runtime-agent-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class V8RuntimeAgentImpl : public protocol::Runtime::Backend {
Response queryObjects(
const String16& prototypeObjectId,
std::unique_ptr<protocol::Runtime::RemoteObject>* objects) override;
Response globalLexicalScopeNames(
Maybe<int> executionContextId,
std::unique_ptr<protocol::Array<String16>>* outNames) override;

void reset();
void reportExecutionContextCreated(InspectedContext*);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Test for Runtime.globalLexicalScopeVariablesNames
Running 'let a = 1'
Values:
a = 1

Running 'let b = 2'
Values:
a = 1
b = 2

Running 'let b = 3'
Values:
a = 1
b = 2

Running 'const c = 4'
Values:
a = 1
b = 2
c = 4

Running 'var d = 5'
(should not be in list of scoped variables)
Values:
a = 1
b = 2
c = 4

Running 'class Foo{}'
Values:
a = 1
b = 2
c = 4
Foo =
{
className : Function
description : class Foo{}
objectId : <objectId>
type : function
}

Adding script with scope variables
Values:
a = 1
b = 2
c = 4
Foo =
{
className : Function
description : class Foo{}
objectId : <objectId>
type : function
}
e = 1
f = 2
g = 3
Boo =
{
className : Function
description : class Boo {}
objectId : <objectId>
type : function
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

let {session, contextGroup, Protocol} =
InspectorTest.start('Test for Runtime.globalLexicalScopeVariablesNames');

(async function test() {
InspectorTest.log('Running \'let a = 1\'');
Protocol.Runtime.evaluate({expression: 'let a = 1'});
await dumpGlobalScopeVariables();

InspectorTest.log('Running \'let b = 2\'');
Protocol.Runtime.evaluate({expression: 'let b = 2'});
await dumpGlobalScopeVariables();

InspectorTest.log('Running \'let b = 3\'');
Protocol.Runtime.evaluate({expression: 'let b = 3'});
await dumpGlobalScopeVariables();

InspectorTest.log('Running \'const c = 4\'');
Protocol.Runtime.evaluate({expression: 'const c = 4'});
await dumpGlobalScopeVariables();

InspectorTest.log('Running \'var d = 5\'');
InspectorTest.log('(should not be in list of scoped variables)');
Protocol.Runtime.evaluate({expression: 'var d = 5'});
await dumpGlobalScopeVariables();

InspectorTest.log('Running \'class Foo{}\'');
Protocol.Runtime.evaluate({expression: 'class Foo{}'});
await dumpGlobalScopeVariables();

InspectorTest.log('Adding script with scope variables');
contextGroup.addScript(`
let e = 1;
const f = 2;
const g = 3;
class Boo {};
`);
await dumpGlobalScopeVariables();
InspectorTest.completeTest();
})();

async function dumpGlobalScopeVariables() {
let {result:{names}} =
await Protocol.Runtime.globalLexicalScopeNames();
InspectorTest.log('Values:');
for (let name of names) {
let {result:{result}} = await Protocol.Runtime.evaluate({expression: name});
if (result.value) {
InspectorTest.log(`${name} = ${result.value}`);
} else {
InspectorTest.log(`${name} =`);
InspectorTest.logMessage(result);
}
}
InspectorTest.log('');
}
2 changes: 1 addition & 1 deletion deps/v8/test/inspector/runtime/runtime-restore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.v8
// found in the LICENSE file.

let {session, contextGroup, Protocol} = InspectorTest.start('Checks that Runtime agent correctly restore its state.');

Expand Down
26 changes: 23 additions & 3 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -711,18 +711,21 @@ instead of the `AssertionError`.
<!-- YAML
added: v0.1.21
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/REPLACEME
description: The `error` parameter can now be an object as well.
- version: v4.2.0
pr-url: https://github.com/nodejs/node/pull/3276
description: The `error` parameter can now be an arrow function.
-->
* `block` {Function}
* `error` {RegExp|Function}
* `error` {RegExp|Function|object}
* `message` {any}

Expects the function `block` to throw an error.

If specified, `error` can be a constructor, [`RegExp`][], or validation
function.
If specified, `error` can be a constructor, [`RegExp`][], a validation
function, or an object where each property will be tested for.

If specified, `message` will be the message provided by the `AssertionError` if
the block fails to throw.
Expand Down Expand Up @@ -768,6 +771,23 @@ assert.throws(
);
```

Custom error object / error instance:

```js
assert.throws(
() => {
const err = new TypeError('Wrong value');
err.code = 404;
throw err;
},
{
name: 'TypeError',
message: 'Wrong value'
// Note that only properties on the error object will be tested!
}
);
```

Note that `error` can not be a string. If a string is provided as the second
argument, then `error` is assumed to be omitted and the string will be used for
`message` instead. This can lead to easy-to-miss mistakes. Please read the
Expand Down
36 changes: 27 additions & 9 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,10 @@ changes:
* `callback` {Function}
* `err` {Error}

Asynchronous chmod(2). No arguments other than a possible exception are given
to the completion callback.
Asynchronously changes the permissions of a file. No arguments other than a
possible exception are given to the completion callback.

See also: chmod(2)

## fs.chmodSync(path, mode)
<!-- YAML
Expand All @@ -907,7 +909,10 @@ changes:
* `path` {string|Buffer|URL}
* `mode` {integer}

Synchronous chmod(2). Returns `undefined`.
Synchronously changes the permissions of a file. Returns `undefined`.
This is the synchronous version of [`fs.chmod()`][].

See also: chmod(2)

## fs.chown(path, uid, gid, callback)
<!-- YAML
Expand All @@ -929,8 +934,10 @@ changes:
* `callback` {Function}
* `err` {Error}

Asynchronous chown(2). No arguments other than a possible exception are given
to the completion callback.
Asynchronously changes owner and group of a file. No arguments other than a
possible exception are given to the completion callback.

See also: chown(2)

## fs.chownSync(path, uid, gid)
<!-- YAML
Expand All @@ -946,7 +953,10 @@ changes:
* `uid` {integer}
* `gid` {integer}

Synchronous chown(2). Returns `undefined`.
Synchronously changes owner and group of a file. Returns `undefined`.
This is the synchronous version of [`fs.chown()`][].

See also: chown(2)

## fs.close(fd, callback)
<!-- YAML
Expand Down Expand Up @@ -1733,8 +1743,10 @@ changes:
* `callback` {Function}
* `err` {Error}

Asynchronous mkdir(2). No arguments other than a possible exception are given
to the completion callback. `mode` defaults to `0o777`.
Asynchronously creates a directory. No arguments other than a possible exception
are given to the completion callback. `mode` defaults to `0o777`.

See also: mkdir(2)

## fs.mkdirSync(path[, mode])
<!-- YAML
Expand All @@ -1749,7 +1761,10 @@ changes:
* `path` {string|Buffer|URL}
* `mode` {integer} **Default:** `0o777`

Synchronous mkdir(2). Returns `undefined`.
Synchronously creates a directory. Returns `undefined`.
This is the synchronous version of [`fs.mkdir()`][].

See also: mkdir(2)

## fs.mkdtemp(prefix[, options], callback)
<!-- YAML
Expand Down Expand Up @@ -3331,10 +3346,13 @@ The following constants are meant for use with the [`fs.Stats`][] object's
[`fs.Stats`]: #fs_class_fs_stats
[`fs.access()`]: #fs_fs_access_path_mode_callback
[`fs.appendFile()`]: fs.html#fs_fs_appendfile_file_data_options_callback
[`fs.chmod()`]: #fs_fs_chmod_path_mode_callback
[`fs.chown()`]: #fs_fs_chown_path_uid_gid_callback
[`fs.exists()`]: fs.html#fs_fs_exists_path_callback
[`fs.fstat()`]: #fs_fs_fstat_fd_callback
[`fs.futimes()`]: #fs_fs_futimes_fd_atime_mtime_callback
[`fs.lstat()`]: #fs_fs_lstat_path_callback
[`fs.mkdir()`]: #fs_fs_mkdir_path_mode_callback
[`fs.mkdtemp()`]: #fs_fs_mkdtemp_prefix_options_callback
[`fs.open()`]: #fs_fs_open_path_flags_mode_callback
[`fs.read()`]: #fs_fs_read_fd_buffer_offset_length_position_callback
Expand Down
Loading

0 comments on commit 4f7a00f

Please sign in to comment.