Skip to content

Commit 2ebc636

Browse files
committed
Merge origin/master into upgrade-to-12x
Conflicts: graal-nodejs/ci.jsonnet graal-nodejs/test/graal/unit/value.js
2 parents b298f19 + 49d8237 commit 2ebc636

111 files changed

Lines changed: 4309 additions & 2662 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ This changelog summarizes major changes between GraalVM versions of the GraalVM
44
The main focus is on user-observable behavior of the engine.
55

66
## Version 19.3.0
7-
* Implemented [Promise.allSettled](https://github.com/tc39/proposal-promise-allSettled) proposal. It is available in ECMAScript 2020 mode (`--js.ecmascript-version=2020`).
7+
* Implemented the [Promise.allSettled](https://github.com/tc39/proposal-promise-allSettled) proposal. It is available in ECMAScript 2020 mode (`--js.ecmascript-version=2020`).
8+
* Implemented the [nullish coalescing](https://github.com/tc39/proposal-nullish-coalescing) proposal. It is available in ECMAScript 2020 mode (`--js.ecmascript-version=2020`).
89
* Updated ICU4J library to version 64.2.
910
* Updated ASM library to version 7.1.
1011
* Updated Node.js to version 10.16.3.

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local common = import 'common.jsonnet';
66
// Used to run fewer jobs
77
local debug = false,
88

9-
local overlay = '3a4bfbd8514c30b157c0a8eda6d28ffc670ec8d1',
9+
local overlay = 'd993a391ab5d364207355b7bfc635e6579f7c7dd',
1010

1111
local no_overlay = 'cb733e564850cd37b685fcef6f3c16b59802b22c',
1212

common.jsonnet

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
local labsjdk8 = {name: 'oraclejdk', version: '8u221-jvmci-19.3-b01', platformspecific: true},
2+
local labsjdk8 = {name: 'oraclejdk', version: '8u221-jvmci-19.3-b02', platformspecific: true},
33

44
local oraclejdk11 = {name : 'oraclejdk', version : "11.0.3+12", platformspecific: true},
55

@@ -49,7 +49,7 @@
4949
packages+: {
5050
'apache/ab': '==2.3',
5151
binutils: '==2.23.2',
52-
gcc: '==4.9.2',
52+
gcc: '==8.3.0',
5353
git: '>=1.8.3',
5454
maven: '==3.3.9',
5555
valgrind: '>=3.9.0',
@@ -71,6 +71,9 @@
7171

7272
linux_aarch64: common + {
7373
capabilities+: ['linux', 'aarch64'],
74+
packages+: {
75+
gcc: '==8.3.0',
76+
}
7477
},
7578

7679
darwin: common + {

docs/contributor/Testing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
GraalVM JavaScript publishes tests that can be used to verify the correctness of commits.
2+
A pull request against our codebase can only be accepted when all tests pass.
23

34
## Test engines
45
Test runners for different externally published test sets are provided.
@@ -15,8 +16,17 @@ $ mx testv8 gate
1516

1617
All test runners should result in 0 (unexpected) failures.
1718
Note that we maintain a blacklist of tests we know not to pass currently.
19+
A test not expected to pass typically means it tests a feature not yet supported by our engine.
1820
The tests runners suggest to automatically update those lists based on the tests results (add or remove known-to-fail tests from those lists).
1921

22+
You can run individual tests with this command:
23+
```
24+
$ mx test262 single=built-ins/Array/length.js
25+
```
26+
27+
This allows you to debug problems when working on the engine's codebase.
28+
Use `mx -d ...` to connect with a debugger to this process.
29+
2030
## Unit tests
2131
GraalVM JavaScript is also published with its own unit tests.
2232
To execute them use:

graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/Parser.java

Lines changed: 433 additions & 214 deletions
Large diffs are not rendered by default.

graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/ParserContext.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import java.util.Iterator;
4444
import java.util.NoSuchElementException;
4545

46-
import com.oracle.js.parser.ir.FunctionNode;
46+
import com.oracle.js.parser.ir.Scope;
4747
import com.oracle.js.parser.ir.Statement;
4848

4949
/**
@@ -205,22 +205,6 @@ public ParserContextLoopNode getContinueTo(final String labelName) {
205205
return getContinueTo();
206206
}
207207

208-
/**
209-
* Get the function body of a function node on the stack. This will trigger an assertion if node
210-
* isn't present
211-
*
212-
* @param functionNode function node
213-
* @return body of function node
214-
*/
215-
public ParserContextBlockNode getFunctionBody(final ParserContextFunctionNode functionNode) {
216-
for (int i = sp - 1; i >= 0; i--) {
217-
if (stack[i] == functionNode) {
218-
return (ParserContextBlockNode) stack[i + 1];
219-
}
220-
}
221-
throw new AssertionError(functionNode.getName() + " not on context stack");
222-
}
223-
224208
/**
225209
* Check the stack for a given label node by name
226210
*
@@ -318,13 +302,21 @@ public ParserContextFunctionNode getCurrentNonArrowFunction() {
318302
final Iterator<ParserContextFunctionNode> iter = getFunctions();
319303
while (iter.hasNext()) {
320304
final ParserContextFunctionNode fn = iter.next();
321-
if (fn.getKind() != FunctionNode.Kind.ARROW) {
305+
if (!fn.isArrow()) {
322306
return fn;
323307
}
324308
}
325309
return null;
326310
}
327311

312+
/**
313+
* Returns the innermost scope in the context.
314+
*/
315+
public Scope getCurrentScope() {
316+
NodeIterator<ParserContextScopableNode> iterator = new NodeIterator<>(ParserContextScopableNode.class);
317+
return iterator.hasNext() ? iterator.next().getScope() : null;
318+
}
319+
328320
private class NodeIterator<T extends ParserContextNode> implements Iterator<T> {
329321
private int index;
330322
private T next;

graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/ParserContextBaseNode.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ abstract class ParserContextBaseNode implements ParserContextNode {
5656

5757
private List<Statement> statements;
5858

59-
/**
60-
* Constructor
61-
*/
6259
ParserContextBaseNode() {
60+
this(0);
61+
}
62+
63+
ParserContextBaseNode(int flags) {
64+
this.flags = flags;
6365
this.statements = new ArrayList<>();
6466
}
6567

graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/ParserContextBlockNode.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,25 @@
4040
*/
4141
package com.oracle.js.parser;
4242

43+
import com.oracle.js.parser.ir.Scope;
44+
4345
/**
4446
* A ParserContextNode that represents a block that is currently being parsed
4547
*/
46-
class ParserContextBlockNode extends ParserContextBaseNode implements ParserContextBreakableNode {
48+
class ParserContextBlockNode extends ParserContextBaseNode implements ParserContextBreakableNode, ParserContextScopableNode {
4749

4850
private final long token;
51+
private Scope scope;
4952

5053
/**
5154
* Constructs a ParserContextBlockNode
5255
*
5356
* @param token The first token of the block
57+
* @param scope The block's scope.
5458
*/
55-
ParserContextBlockNode(final long token) {
59+
ParserContextBlockNode(final long token, Scope scope) {
5660
this.token = token;
61+
this.scope = scope;
5762
}
5863

5964
@Override
@@ -70,4 +75,13 @@ public long getToken() {
7075
return token;
7176
}
7277

78+
@Override
79+
public Scope getScope() {
80+
return scope;
81+
}
82+
83+
public void setScope(Scope scope) {
84+
this.scope = scope;
85+
}
86+
7387
}

graal-js/src/com.oracle.js.parser/src/com/oracle/js/parser/ParserContextFunctionNode.java

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
import com.oracle.js.parser.ir.IdentNode;
5353
import com.oracle.js.parser.ir.Module;
5454
import com.oracle.js.parser.ir.ParameterNode;
55+
import com.oracle.js.parser.ir.Scope;
56+
import com.oracle.js.parser.ir.Symbol;
5557
import com.oracle.js.parser.ir.VarNode;
5658

5759
/**
@@ -71,13 +73,14 @@ class ParserContextFunctionNode extends ParserContextBaseNode {
7173
/** Line number for function declaration */
7274
private final int line;
7375

74-
/** Function node kind, see FunctionNode.Kind */
75-
private final FunctionNode.Kind kind;
76+
private final Scope parentScope;
7677

7778
/** List of parameter identifiers (for simple and rest parameters). */
7879
private List<IdentNode> parameters;
7980
/** Optional parameter initialization block (replaces parameter list). */
8081
private ParserContextBlockNode parameterBlock;
82+
/** Function body block. */
83+
private ParserContextBlockNode bodyBlock;
8184

8285
/** Token for function start */
8386
private final long token;
@@ -103,19 +106,20 @@ class ParserContextFunctionNode extends ParserContextBaseNode {
103106
* @param name Internal name of the function
104107
* @param namespace Function's namespace
105108
* @param line The source line of the function
106-
* @param kind Function kind
107109
* @param parameters The parameters of the function
110+
* @param parentScope The parent scope
108111
*/
109-
ParserContextFunctionNode(final long token, final IdentNode ident, final String name, final Namespace namespace, final int line, final FunctionNode.Kind kind,
110-
final List<IdentNode> parameters, final int length) {
112+
ParserContextFunctionNode(final long token, final IdentNode ident, final String name, final Namespace namespace, final int line, final int flags,
113+
final List<IdentNode> parameters, final int length, Scope parentScope) {
114+
super(flags);
111115
this.ident = ident;
112116
this.namespace = namespace;
113117
this.line = line;
114-
this.kind = kind;
115118
this.name = name;
116119
this.parameters = parameters;
117120
this.token = token;
118121
this.length = length;
122+
this.parentScope = parentScope;
119123
this.parameterCount = parameters == null ? 0 : parameters.size();
120124
assert calculateLength(parameters) == length;
121125
}
@@ -182,13 +186,6 @@ public int getLineNumber() {
182186
return line;
183187
}
184188

185-
/**
186-
* @return The kind if function
187-
*/
188-
public FunctionNode.Kind getKind() {
189-
return kind;
190-
}
191-
192189
/**
193190
* Get parameters
194191
*
@@ -316,6 +313,7 @@ private boolean addParameterBinding(IdentNode bindingIdentifier) {
316313
parameterBoundNames = new HashSet<>();
317314
}
318315
if (parameterBoundNames.add(bindingIdentifier.getName())) {
316+
declareParameter(bindingIdentifier.getName());
319317
return true;
320318
} else {
321319
duplicateParameterBinding = bindingIdentifier;
@@ -343,6 +341,18 @@ public boolean isAsync() {
343341
return getFlag(FunctionNode.IS_ASYNC) != 0;
344342
}
345343

344+
public boolean isArrow() {
345+
return getFlag(FunctionNode.IS_ARROW) != 0;
346+
}
347+
348+
public boolean isGenerator() {
349+
return getFlag(FunctionNode.IS_GENERATOR) != 0;
350+
}
351+
352+
public boolean isScriptOrModule() {
353+
return getFlag(FunctionNode.IS_SCRIPT | FunctionNode.IS_MODULE) != 0;
354+
}
355+
346356
public ParserContextBlockNode getParameterBlock() {
347357
return parameterBlock;
348358
}
@@ -373,7 +383,8 @@ private void ensureParameterBlock() {
373383
}
374384

375385
private void initParameterBlock() {
376-
parameterBlock = new ParserContextBlockNode(token);
386+
assert bodyBlock == null; // parameter block must be created before body block
387+
parameterBlock = new ParserContextBlockNode(token, Scope.createParameter(parentScope));
377388
parameterBlock.setFlag(Block.IS_PARAMETER_BLOCK);
378389

379390
if (parameters != null) {
@@ -395,6 +406,37 @@ private void addParameterInit(IdentNode param, int index) {
395406
paramValue = new ParameterNode(paramToken, paramFinish, index);
396407
}
397408
parameterBlock.appendStatement(new VarNode(line, Token.recast(paramToken, TokenType.LET), paramFinish, param, paramValue, VarNode.IS_LET));
409+
declareParameter(param.getName());
410+
}
411+
412+
private void declareParameter(String parameterName) {
413+
if (parameterBlock != null) {
414+
// Parameters have a temporal dead zone (unless the parameter list is simple).
415+
parameterBlock.getScope().putSymbol(new Symbol(parameterName, Symbol.IS_LET | Symbol.IS_PARAM));
416+
}
417+
}
418+
419+
private void finalizeParameters() {
420+
if (parameterBlock == null) {
421+
if (parameters != null) {
422+
for (int i = 0; i < parameters.size(); i++) {
423+
IdentNode parameter = parameters.get(i);
424+
bodyBlock.getScope().putSymbol(new Symbol(parameter.getName(), Symbol.IS_VAR | Symbol.IS_PARAM));
425+
}
426+
}
427+
} else {
428+
parameterBlock.getScope().close();
429+
}
430+
}
431+
432+
public ParserContextBlockNode getBodyBlock() {
433+
return bodyBlock;
434+
}
435+
436+
public void setBodyBlock(ParserContextBlockNode bodyBlock) {
437+
assert this.bodyBlock == null;
438+
this.bodyBlock = bodyBlock;
439+
finalizeParameters();
398440
}
399441

400442
private static int calculateLength(final List<IdentNode> parameters) {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2019, 2019, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
package com.oracle.js.parser;
42+
43+
import com.oracle.js.parser.ir.Scope;
44+
45+
/**
46+
* An interface that is implemented by ParserContextNodes that have a {@link Scope}.
47+
*/
48+
interface ParserContextScopableNode extends ParserContextNode {
49+
Scope getScope();
50+
}

0 commit comments

Comments
 (0)