mirror of
https://github.com/openjdk/jdk.git
synced 2026-06-01 00:02:37 +00:00
8015961: Several small code-gardening fixes
Reviewed-by: lagergren, sundar
This commit is contained in:
parent
c5540744e7
commit
03ee3a979c
@ -32,7 +32,6 @@ import static jdk.nashorn.internal.codegen.CompilerConstants.THIS;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.nashorn.internal.ir.BaseNode;
|
||||
import jdk.nashorn.internal.ir.BinaryNode;
|
||||
import jdk.nashorn.internal.ir.Block;
|
||||
@ -258,7 +257,7 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> {
|
||||
return throwNode;
|
||||
}
|
||||
|
||||
private static Node ensureUniqueNamesIn(final LexicalContext lc, final Node node) {
|
||||
private static Node ensureUniqueNamesIn(final Node node) {
|
||||
return node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
|
||||
@Override
|
||||
public Node leaveFunctionNode(final FunctionNode functionNode) {
|
||||
@ -273,10 +272,10 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> {
|
||||
});
|
||||
}
|
||||
|
||||
private static List<Statement> copyFinally(final LexicalContext lc, final Block finallyBody) {
|
||||
private static List<Statement> copyFinally(final Block finallyBody) {
|
||||
final List<Statement> newStatements = new ArrayList<>();
|
||||
for (final Statement statement : finallyBody.getStatements()) {
|
||||
newStatements.add((Statement)ensureUniqueNamesIn(lc, statement));
|
||||
newStatements.add((Statement)ensureUniqueNamesIn(statement));
|
||||
if (statement.hasTerminalFlags()) {
|
||||
return newStatements;
|
||||
}
|
||||
@ -340,7 +339,7 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> {
|
||||
@Override
|
||||
public Node leaveThrowNode(final ThrowNode throwNode) {
|
||||
if (rethrows.contains(throwNode)) {
|
||||
final List<Statement> newStatements = copyFinally(lc, finallyBody);
|
||||
final List<Statement> newStatements = copyFinally(finallyBody);
|
||||
if (!isTerminal(newStatements)) {
|
||||
newStatements.add(throwNode);
|
||||
}
|
||||
@ -374,7 +373,7 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> {
|
||||
resultNode = null;
|
||||
}
|
||||
|
||||
newStatements.addAll(copyFinally(lc, finallyBody));
|
||||
newStatements.addAll(copyFinally(finallyBody));
|
||||
if (!isTerminal(newStatements)) {
|
||||
newStatements.add(expr == null ? returnNode : returnNode.setExpression(resultNode));
|
||||
}
|
||||
@ -384,7 +383,7 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> {
|
||||
|
||||
private Node copy(final Statement endpoint, final Node targetNode) {
|
||||
if (!insideTry.contains(targetNode)) {
|
||||
final List<Statement> newStatements = copyFinally(lc, finallyBody);
|
||||
final List<Statement> newStatements = copyFinally(finallyBody);
|
||||
if (!isTerminal(newStatements)) {
|
||||
newStatements.add(endpoint);
|
||||
}
|
||||
@ -550,7 +549,7 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> {
|
||||
final FunctionNode currentFunction = lc.getCurrentFunction();
|
||||
return callNode.setEvalArgs(
|
||||
new CallNode.EvalArgs(
|
||||
ensureUniqueNamesIn(lc, args.get(0)).accept(this),
|
||||
ensureUniqueNamesIn(args.get(0)).accept(this),
|
||||
compilerConstant(THIS),
|
||||
evalLocation(callee),
|
||||
currentFunction.isStrict()));
|
||||
|
||||
@ -41,10 +41,10 @@ import jdk.nashorn.internal.codegen.CompilerConstants.Call;
|
||||
import jdk.nashorn.internal.codegen.types.Type;
|
||||
import jdk.nashorn.internal.ir.RuntimeNode;
|
||||
import jdk.nashorn.internal.ir.RuntimeNode.Request;
|
||||
import jdk.nashorn.internal.runtime.ScriptRuntime;
|
||||
import jdk.nashorn.internal.runtime.linker.Bootstrap;
|
||||
import jdk.nashorn.internal.lookup.Lookup;
|
||||
import jdk.nashorn.internal.lookup.MethodHandleFactory;
|
||||
import jdk.nashorn.internal.runtime.ScriptRuntime;
|
||||
import jdk.nashorn.internal.runtime.linker.Bootstrap;
|
||||
|
||||
/**
|
||||
* Optimistic call site that assumes its Object arguments to be of a boxed type.
|
||||
@ -333,6 +333,7 @@ public final class RuntimeCallSite extends MutableCallSite {
|
||||
*
|
||||
* Do not call directly
|
||||
*
|
||||
* @param name current name (with type) of runtime call at the call site
|
||||
* @return next wider specialization method for this RuntimeCallSite
|
||||
*/
|
||||
public MethodHandle next(final String name) {
|
||||
|
||||
@ -30,7 +30,6 @@ import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jdk.nashorn.internal.codegen.CompileUnit;
|
||||
import jdk.nashorn.internal.codegen.Compiler;
|
||||
import jdk.nashorn.internal.codegen.CompilerConstants;
|
||||
@ -385,7 +384,7 @@ public final class FunctionNode extends LexicalContextNode implements Flags<Func
|
||||
* @return function node or a new one if state was changed
|
||||
*/
|
||||
public FunctionNode setState(final LexicalContext lc, final CompilationState state) {
|
||||
if (this.compilationState.equals(state)) {
|
||||
if (this.compilationState.contains(state)) {
|
||||
return this;
|
||||
}
|
||||
final EnumSet<CompilationState> newState = EnumSet.copyOf(this.compilationState);
|
||||
|
||||
@ -150,11 +150,11 @@ public final class GenericPropertyDescriptor extends ScriptObject implements Pro
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof AccessorPropertyDescriptor)) {
|
||||
if (!(obj instanceof GenericPropertyDescriptor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final AccessorPropertyDescriptor other = (AccessorPropertyDescriptor)obj;
|
||||
final GenericPropertyDescriptor other = (GenericPropertyDescriptor)obj;
|
||||
return ScriptRuntime.sameValue(configurable, other.configurable) &&
|
||||
ScriptRuntime.sameValue(enumerable, other.enumerable);
|
||||
}
|
||||
|
||||
@ -31,7 +31,6 @@ import jdk.nashorn.internal.objects.annotations.Property;
|
||||
import jdk.nashorn.internal.objects.annotations.ScriptClass;
|
||||
import jdk.nashorn.internal.objects.annotations.SpecializedFunction;
|
||||
import jdk.nashorn.internal.objects.annotations.Where;
|
||||
import jdk.nashorn.internal.runtime.GlobalFunctions;
|
||||
import jdk.nashorn.internal.runtime.JSType;
|
||||
import jdk.nashorn.internal.runtime.ScriptObject;
|
||||
|
||||
|
||||
@ -501,7 +501,7 @@ public final class Context {
|
||||
*
|
||||
* @throws IOException if source cannot be found or loaded
|
||||
*/
|
||||
public Object loadWithNewGlobal(final Object from) throws IOException, RuntimeException {
|
||||
public Object loadWithNewGlobal(final Object from) throws IOException {
|
||||
final ScriptObject oldGlobal = getGlobalTrusted();
|
||||
final ScriptObject newGlobal = AccessController.doPrivileged(new PrivilegedAction<ScriptObject>() {
|
||||
@Override
|
||||
|
||||
@ -15,10 +15,11 @@ import jdk.nashorn.internal.runtime.linker.InvokeByName;
|
||||
* as dequeues, it's still slightly more efficient to be able to translate dequeue operations into pushes, pops, shifts,
|
||||
* and unshifts, than to blindly translate all list's add/remove operations into splices. Also, it is conceivable that a
|
||||
* custom script object that implements an Array-like API can have a background data representation that is optimized
|
||||
* for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@pop} operate at the end of the array,
|
||||
* while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue {@link #push(Object)}
|
||||
* and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script operations respectively,
|
||||
* while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and {@code pop}.
|
||||
* for dequeue-like access. Note that with ECMAScript arrays, {@code push} and {@code pop} operate at the end of the
|
||||
* array, while in Java {@code Deque} they operate on the front of the queue and as such the Java dequeue
|
||||
* {@link #push(Object)} and {@link #pop()} operations will translate to {@code unshift} and {@code shift} script
|
||||
* operations respectively, while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and
|
||||
* {@code pop}.
|
||||
*/
|
||||
public class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
|
||||
// These add to the back and front of the list
|
||||
|
||||
@ -23,23 +23,23 @@ import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnOff;
|
||||
import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup;
|
||||
import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase;
|
||||
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.AnyCharNode;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode.CCStateArg;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.EncloseNode;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.Node;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.StringNode;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode.CCStateArg;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.constants.CCSTATE;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.constants.CCVALTYPE;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.constants.EncloseType;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.constants.TokenType;
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType;
|
||||
|
||||
class Parser extends Lexer {
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user