jdk.nashorn.internal.ir.PropertyNode Java Examples

The following examples show how to use jdk.nashorn.internal.ir.PropertyNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WeighNodes.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    weight += OBJECT_WEIGHT;
    final List<PropertyNode> properties = objectNode.getElements();
    final boolean isSpillObject = properties.size() > CodeGenerator.OBJECT_SPILL_THRESHOLD;

    for (final PropertyNode property : properties) {
        if (!LiteralNode.isConstant(property.getValue())) {
            weight += SETPROP_WEIGHT;
            property.getValue().accept(this);
        } else if (!isSpillObject) {
            // constants in spill object are set via preset spill array,
            // but fields objects need to set constants.
            weight += SETPROP_WEIGHT;
        }

    }

    return false;
}
 
Example #2
Source File: WeighNodes.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    weight += OBJECT_WEIGHT;
    final List<PropertyNode> properties = objectNode.getElements();
    final boolean isSpillObject = properties.size() > CodeGenerator.OBJECT_SPILL_THRESHOLD;

    for (final PropertyNode property : properties) {
        if (!LiteralNode.isConstant(property.getValue())) {
            weight += SETPROP_WEIGHT;
            property.getValue().accept(this);
        } else if (!isSpillObject) {
            // constants in spill object are set via preset spill array,
            // but fields objects need to set constants.
            weight += SETPROP_WEIGHT;
        }

    }

    return false;
}
 
Example #3
Source File: WeighNodes.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    weight += OBJECT_WEIGHT;
    final List<PropertyNode> properties = objectNode.getElements();
    final boolean isSpillObject = properties.size() > CodeGenerator.OBJECT_SPILL_THRESHOLD;

    for (final PropertyNode property : properties) {
        if (!LiteralNode.isConstant(property.getValue())) {
            weight += SETPROP_WEIGHT;
            property.getValue().accept(this);
        } else if (!isSpillObject) {
            // constants in spill object are set via preset spill array,
            // but fields objects need to set constants.
            weight += SETPROP_WEIGHT;
        }

    }

    return false;
}
 
Example #4
Source File: WeighNodes.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    weight += OBJECT_WEIGHT;
    final List<PropertyNode> properties = objectNode.getElements();
    final boolean isSpillObject = properties.size() > CodeGenerator.OBJECT_SPILL_THRESHOLD;

    for (final PropertyNode property : properties) {
        if (!LiteralNode.isConstant(property.getValue())) {
            weight += SETPROP_WEIGHT;
            property.getValue().accept(this);
        } else if (!isSpillObject) {
            // constants in spill object are set via preset spill array,
            // but fields objects need to set constants.
            weight += SETPROP_WEIGHT;
        }

    }

    return false;
}
 
Example #5
Source File: WeighNodes.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    weight += OBJECT_WEIGHT;
    final List<PropertyNode> properties = objectNode.getElements();
    final boolean isSpillObject = properties.size() > CodeGenerator.OBJECT_SPILL_THRESHOLD;

    for (final PropertyNode property : properties) {
        if (!LiteralNode.isConstant(property.getValue())) {
            weight += SETPROP_WEIGHT;
            property.getValue().accept(this);
        } else if (!isSpillObject) {
            // constants in spill object are set via preset spill array,
            // but fields objects need to set constants.
            weight += SETPROP_WEIGHT;
        }

    }

    return false;
}
 
Example #6
Source File: JSONParser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a property assignment from the token stream
 * @return the property assignment as a Node
 */
private PropertyNode propertyAssignment() {
    // Capture firstToken.
    final long propertyToken = token;
    LiteralNode<?> name = null;

    if (type == STRING) {
        name = getStringLiteral();
    } else if (type == ESCSTRING) {
        name = getLiteral();
    }

    if (name != null) {
        expect(COLON);
        final Expression value = jsonLiteral();
        return new PropertyNode(propertyToken, value.getFinish(), name, value, null, null);
    }

    // Raise an error.
    throw error(AbstractParser.message("expected", "string", type.getNameOrType()));
}
 
Example #7
Source File: WeighNodes.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    weight += OBJECT_WEIGHT;
    final List<PropertyNode> properties = objectNode.getElements();
    final boolean isSpillObject = properties.size() > CodeGenerator.OBJECT_SPILL_THRESHOLD;

    for (final PropertyNode property : properties) {
        if (!LiteralNode.isConstant(property.getValue())) {
            weight += SETPROP_WEIGHT;
            property.getValue().accept(this);
        } else if (!isSpillObject) {
            // constants in spill object are set via preset spill array,
            // but fields objects need to set constants.
            weight += SETPROP_WEIGHT;
        }

    }

    return false;
}
 
Example #8
Source File: JSONParser.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parse a property assignment from the token stream
 * @return the property assignment as a Node
 */
private PropertyNode propertyAssignment() {
    // Capture firstToken.
    final long propertyToken = token;
    LiteralNode<?> name = null;

    if (type == STRING) {
        name = getStringLiteral();
    } else if (type == ESCSTRING) {
        name = getLiteral();
    }

    if (name != null) {
        expect(COLON);
        final Expression value = jsonLiteral();
        return new PropertyNode(propertyToken, value.getFinish(), name, value, null, null);
    }

    // Raise an error.
    throw error(AbstractParser.message("expected", "string", type.getNameOrType()));
}
 
Example #9
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    for(final PropertyNode propertyNode: objectNode.getElements()) {
        // Avoid falsely adding property keys to the control flow graph
        final Expression value = propertyNode.getValue();
        if (value != null) {
            visitExpression(value);
        }
    }
    return pushExpressionType(objectNode);
}
 
Example #10
Source File: LocalVariableTypesCalculator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    for(final PropertyNode propertyNode: objectNode.getElements()) {
        // Avoid falsely adding property keys to the control flow graph
        final Expression value = propertyNode.getValue();
        if (value != null) {
            visitExpression(value);
        }
    }
    return pushExpressionType(objectNode);
}
 
Example #11
Source File: OptimisticTypesCalculator.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    if(propertyNode.getKeyName().equals(ScriptObject.PROTO_PROPERTY_NAME)) {
        tagNeverOptimistic(propertyNode.getValue());
    }
    return super.enterPropertyNode(propertyNode);
}
 
Example #12
Source File: LocalVariableTypesCalculator.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    for(final PropertyNode propertyNode: objectNode.getElements()) {
        // Avoid falsely adding property keys to the control flow graph
        final Expression value = propertyNode.getValue();
        if (value != null) {
            visitExpression(value);
        }
    }
    return pushExpressionType(objectNode);
}
 
Example #13
Source File: LocalVariableTypesCalculator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    for(final PropertyNode propertyNode: objectNode.getElements()) {
        // Avoid falsely adding property keys to the control flow graph
        final Expression value = propertyNode.getValue();
        if (value != null) {
            visitExpression(value);
        }
    }
    return pushExpressionType(objectNode);
}
 
Example #14
Source File: OptimisticTypesCalculator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    if(propertyNode.getKeyName().equals(ScriptObject.PROTO_PROPERTY_NAME)) {
        tagNeverOptimistic(propertyNode.getValue());
    }
    return super.enterPropertyNode(propertyNode);
}
 
Example #15
Source File: OptimisticTypesCalculator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    if(propertyNode.getKeyName().equals(ScriptObject.PROTO_PROPERTY_NAME)) {
        tagNeverOptimistic(propertyNode.getValue());
    }
    return super.enterPropertyNode(propertyNode);
}
 
Example #16
Source File: OptimisticTypesCalculator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    if(propertyNode.getKeyName().equals(ScriptObject.PROTO_PROPERTY_NAME)) {
        tagNeverOptimistic(propertyNode.getValue());
    }
    return super.enterPropertyNode(propertyNode);
}
 
Example #17
Source File: OptimisticTypesCalculator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    if(propertyNode.getKeyName().equals(ScriptObject.PROTO_PROPERTY_NAME)) {
        tagNeverOptimistic(propertyNode.getValue());
    }
    return super.enterPropertyNode(propertyNode);
}
 
Example #18
Source File: LocalVariableTypesCalculator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    for(final PropertyNode propertyNode: objectNode.getElements()) {
        // Avoid falsely adding property keys to the control flow graph
        final Expression value = propertyNode.getValue();
        if (value != null) {
            visitExpression(value);
        }
    }
    return pushExpressionType(objectNode);
}
 
Example #19
Source File: OptimisticTypesCalculator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    if(propertyNode.getKeyName().equals(ScriptObject.PROTO_PROPERTY_NAME)) {
        tagNeverOptimistic(propertyNode.getValue());
    }
    return super.enterPropertyNode(propertyNode);
}
 
Example #20
Source File: IRTranslator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    final List<PropertyNode> propNodes = objectNode.getElements();
    final List<? extends PropertyTree> propTrees = translateProperties(propNodes);
    curExpr = new ObjectLiteralTreeImpl(objectNode, propTrees);
    return false;
}
 
Example #21
Source File: IRTranslator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private List<? extends PropertyTree> translateProperties(final List<PropertyNode> propNodes) {
    final List<PropertyTree> propTrees = new ArrayList<>(propNodes.size());
    for (final PropertyNode propNode : propNodes) {
        propTrees.add(translateProperty(propNode));
    }
    return propTrees;
}
 
Example #22
Source File: IRTranslator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private PropertyTree translateProperty(final PropertyNode propNode) {
    return new PropertyTreeImpl(propNode,
                translateExpr(propNode.getKey()),
                translateExpr(propNode.getValue()),
                (FunctionExpressionTree) translateExpr(propNode.getGetter()),
                (FunctionExpressionTree) translateExpr(propNode.getSetter()));
}
 
Example #23
Source File: PropertyTreeImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
PropertyTreeImpl(final PropertyNode node,
        final ExpressionTree key,
        final ExpressionTree value,
        final FunctionExpressionTree getter,
        final FunctionExpressionTree setter) {
    super(node);
    this.key    = key;
    this.value  = value;
    this.getter = getter;
    this.setter = setter;
    this.isStatic = node.isStatic();
    this.isComputed = node.isComputed();
}
 
Example #24
Source File: OptimisticTypesCalculator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    if(ScriptObject.PROTO_PROPERTY_NAME.equals(propertyNode.getKeyName())) {
        tagNeverOptimistic(propertyNode.getValue());
    }
    return super.enterPropertyNode(propertyNode);
}
 
Example #25
Source File: LocalVariableTypesCalculator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
    for(final PropertyNode propertyNode: objectNode.getElements()) {
        // Avoid falsely adding property keys to the control flow graph
        final Expression value = propertyNode.getValue();
        if (value != null) {
            visitExpression(value);
        }
    }
    return pushExpressionType(objectNode);
}
 
Example #26
Source File: JSONWriter.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    final Node key = propertyNode.getKey();

    final Node value = propertyNode.getValue();
    if (value != null) {
        objectStart();
        location(propertyNode);

        property("key");
        key.accept(this);
        comma();

        property("value");
        value.accept(this);
        comma();

        property("kind", "init");

        objectEnd();
    } else {
        // getter
        final Node getter = propertyNode.getGetter();
        if (getter != null) {
            objectStart();
            location(propertyNode);

            property("key");
            key.accept(this);
            comma();

            property("value");
            getter.accept(this);
            comma();

            property("kind", "get");

            objectEnd();
        }

        // setter
        final Node setter = propertyNode.getSetter();
        if (setter != null) {
            if (getter != null) {
                comma();
            }
            objectStart();
            location(propertyNode);

            property("key");
            key.accept(this);
            comma();

            property("value");
            setter.accept(this);
            comma();

            property("kind", "set");

            objectEnd();
        }
    }

    return false;
}
 
Example #27
Source File: WeighNodes.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Node leavePropertyNode(final PropertyNode propertyNode) {
    weight += LITERAL_WEIGHT;
    return propertyNode;
}
 
Example #28
Source File: JSONWriter.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    final Node key = propertyNode.getKey();

    final Node value = propertyNode.getValue();
    if (value != null) {
        objectStart();
        location(propertyNode);

        property("key");
        key.accept(this);
        comma();

        property("value");
        value.accept(this);
        comma();

        property("kind", "init");

        objectEnd();
    } else {
        // getter
        final Node getter = propertyNode.getGetter();
        if (getter != null) {
            objectStart();
            location(propertyNode);

            property("key");
            key.accept(this);
            comma();

            property("value");
            getter.accept(this);
            comma();

            property("kind", "get");

            objectEnd();
        }

        // setter
        final Node setter = propertyNode.getSetter();
        if (setter != null) {
            if (getter != null) {
                comma();
            }
            objectStart();
            location(propertyNode);

            property("key");
            key.accept(this);
            comma();

            property("value");
            setter.accept(this);
            comma();

            property("kind", "set");

            objectEnd();
        }
    }

    return false;
}
 
Example #29
Source File: Parser.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * PropertyAssignment :
 *      PropertyName : AssignmentExpression
 *      get PropertyName ( ) { FunctionBody }
 *      set PropertyName ( PropertySetParameterList ) { FunctionBody }
 *
 * PropertySetParameterList :
 *      Identifier
 *
 * PropertyName :
 *      IdentifierName
 *      StringLiteral
 *      NumericLiteral
 *
 * See 11.1.5
 *
 * Parse an object literal property.
 * @return Property or reference node.
 */
private PropertyNode propertyAssignment() {
    // Capture firstToken.
    final long propertyToken = token;
    final int  functionLine  = line;

    PropertyKey propertyName;

    if (type == IDENT) {
        // Get IDENT.
        final String ident = (String)expectValue(IDENT);

        if (type != COLON) {
            final long getSetToken = propertyToken;

            switch (ident) {
            case "get":
                final PropertyFunction getter = propertyGetterFunction(getSetToken, functionLine);
                return new PropertyNode(propertyToken, finish, getter.ident, null, getter.functionNode, null);

            case "set":
                final PropertyFunction setter = propertySetterFunction(getSetToken, functionLine);
                return new PropertyNode(propertyToken, finish, setter.ident, null, null, setter.functionNode);
            default:
                break;
            }
        }

        propertyName =  createIdentNode(propertyToken, finish, ident).setIsPropertyName();
    } else {
        propertyName = propertyName();
    }

    expect(COLON);

    defaultNames.push(propertyName);
    try {
        return new PropertyNode(propertyToken, finish, propertyName, assignmentExpression(false), null, null);
    } finally {
        defaultNames.pop();
    }
}
 
Example #30
Source File: LocalVariableTypesCalculator.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
    // Property nodes are only accessible through object literals, and we handled that case above
    throw new AssertionError();
}