提交 15a6a44e 编写于 作者: A attila

8015684: FieldObjectCreator.putField ignores getValueType

Reviewed-by: jlaskey, lagergren
上级 2810bfa7
...@@ -60,7 +60,6 @@ import java.util.LinkedList; ...@@ -60,7 +60,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.TreeMap; import java.util.TreeMap;
import jdk.nashorn.internal.codegen.ClassEmitter.Flag; import jdk.nashorn.internal.codegen.ClassEmitter.Flag;
import jdk.nashorn.internal.codegen.CompilerConstants.Call; import jdk.nashorn.internal.codegen.CompilerConstants.Call;
import jdk.nashorn.internal.codegen.RuntimeCallSite.SpecializedRuntimeNode; import jdk.nashorn.internal.codegen.RuntimeCallSite.SpecializedRuntimeNode;
...@@ -80,11 +79,11 @@ import jdk.nashorn.internal.ir.EmptyNode; ...@@ -80,11 +79,11 @@ import jdk.nashorn.internal.ir.EmptyNode;
import jdk.nashorn.internal.ir.ExecuteNode; import jdk.nashorn.internal.ir.ExecuteNode;
import jdk.nashorn.internal.ir.ForNode; import jdk.nashorn.internal.ir.ForNode;
import jdk.nashorn.internal.ir.FunctionNode; import jdk.nashorn.internal.ir.FunctionNode;
import jdk.nashorn.internal.ir.LexicalContext;
import jdk.nashorn.internal.ir.FunctionNode.CompilationState; import jdk.nashorn.internal.ir.FunctionNode.CompilationState;
import jdk.nashorn.internal.ir.IdentNode; import jdk.nashorn.internal.ir.IdentNode;
import jdk.nashorn.internal.ir.IfNode; import jdk.nashorn.internal.ir.IfNode;
import jdk.nashorn.internal.ir.IndexNode; import jdk.nashorn.internal.ir.IndexNode;
import jdk.nashorn.internal.ir.LexicalContext;
import jdk.nashorn.internal.ir.LexicalContextNode; import jdk.nashorn.internal.ir.LexicalContextNode;
import jdk.nashorn.internal.ir.LiteralNode; import jdk.nashorn.internal.ir.LiteralNode;
import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode;
...@@ -941,11 +940,6 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex ...@@ -941,11 +940,6 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
* bootstrap code for object * bootstrap code for object
*/ */
final FieldObjectCreator<Symbol> foc = new FieldObjectCreator<Symbol>(this, nameList, newSymbols, values, true, hasArguments) { final FieldObjectCreator<Symbol> foc = new FieldObjectCreator<Symbol>(this, nameList, newSymbols, values, true, hasArguments) {
@Override
protected Type getValueType(final Symbol value) {
return value.getSymbolType();
}
@Override @Override
protected void loadValue(final Symbol value) { protected void loadValue(final Symbol value) {
method.load(value); method.load(value);
...@@ -1356,11 +1350,6 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex ...@@ -1356,11 +1350,6 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
} }
new FieldObjectCreator<Node>(this, keys, symbols, values) { new FieldObjectCreator<Node>(this, keys, symbols, values) {
@Override
protected Type getValueType(final Node node) {
return node.getType();
}
@Override @Override
protected void loadValue(final Node node) { protected void loadValue(final Node node) {
load(node); load(node);
......
...@@ -144,15 +144,6 @@ public abstract class FieldObjectCreator<T> extends ObjectCreator { ...@@ -144,15 +144,6 @@ public abstract class FieldObjectCreator<T> extends ObjectCreator {
*/ */
protected abstract void loadValue(T value); protected abstract void loadValue(T value);
/**
* Determine the type of a value. Defined by anonymous subclasses in code gen.
*
* @param value Value to inspect.
*
* @return Value type.
*/
protected abstract Type getValueType(T value);
/** /**
* Store a value in a field of the generated class object. * Store a value in a field of the generated class object.
* *
...@@ -165,13 +156,6 @@ public abstract class FieldObjectCreator<T> extends ObjectCreator { ...@@ -165,13 +156,6 @@ public abstract class FieldObjectCreator<T> extends ObjectCreator {
method.dup(); method.dup();
loadValue(value); loadValue(value);
final Type valueType = getValueType(value);
// for example when we have a with scope
if (valueType.isObject() || valueType.isBoolean()) {
method.convert(OBJECT);
}
method.convert(OBJECT); method.convert(OBJECT);
method.putField(getClassName(), ObjectClassGenerator.getFieldName(fieldIndex, Type.OBJECT), typeDescriptor(Object.class)); method.putField(getClassName(), ObjectClassGenerator.getFieldName(fieldIndex, Type.OBJECT), typeDescriptor(Object.class));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册