# HG changeset patch # User Andreas Woess # Date 1414064759 -7200 # Node ID 94f16a759646293a58cbb706a9d888ea6a09e477 # Parent 30e03a7f91101cd47bff4a504051ca521559a057 Truffle: remove FrameTypeConversion interface diff -r 30e03a7f9110 -r 94f16a759646 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Thu Oct 23 12:02:02 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Thu Oct 23 13:45:59 2014 +0200 @@ -51,7 +51,7 @@ this.arguments = arguments; int size = descriptor.getSize(); this.locals = new Object[size]; - Arrays.fill(locals, descriptor.getTypeConversion().getDefaultValue()); + Arrays.fill(locals, descriptor.getDefaultValue()); this.primitiveLocals = new long[size]; this.tags = new byte[size]; } @@ -252,12 +252,6 @@ byte tag = this.getTags()[slotIndex]; if (tag != accessKind.ordinal()) { CompilerDirectives.transferToInterpreter(); - if (slot.getKind() == accessKind || tag == 0) { - descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot)); - if (getTags()[slotIndex] == accessKind.ordinal()) { - return; - } - } throw new FrameSlotTypeException(); } } @@ -293,7 +287,7 @@ int newSize = descriptor.getSize(); if (newSize > oldSize) { locals = Arrays.copyOf(locals, newSize); - Arrays.fill(locals, oldSize, newSize, descriptor.getTypeConversion().getDefaultValue()); + Arrays.fill(locals, oldSize, newSize, descriptor.getDefaultValue()); primitiveLocals = Arrays.copyOf(primitiveLocals, newSize); tags = Arrays.copyOf(tags, newSize); return true; diff -r 30e03a7f9110 -r 94f16a759646 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java Thu Oct 23 12:02:02 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java Thu Oct 23 13:45:59 2014 +0200 @@ -177,7 +177,7 @@ if (frameSize > 0) { FrameDescriptor frameDescriptor = getConstantFrameDescriptor(); - ConstantNode objectDefault = ConstantNode.forConstant(getSnippetReflection().forObject(frameDescriptor.getTypeConversion().getDefaultValue()), tool.getMetaAccessProvider(), graph()); + ConstantNode objectDefault = ConstantNode.forConstant(getSnippetReflection().forObject(frameDescriptor.getDefaultValue()), tool.getMetaAccessProvider(), graph()); ConstantNode tagDefault = ConstantNode.forByte((byte) 0, graph()); Arrays.fill(objectArrayEntryState, objectDefault); Arrays.fill(tagArrayEntryState, tagDefault); diff -r 30e03a7f9110 -r 94f16a759646 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java Thu Oct 23 12:02:02 2014 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java Thu Oct 23 13:45:59 2014 +0200 @@ -117,6 +117,7 @@ if (o instanceof Integer) { frame.setInt(slot, (Integer) o); } else { + slot.setKind(FrameSlotKind.Object); frame.setObject(slot, o); this.replace(new ObjectAssignLocal(slot, value)); } @@ -136,6 +137,7 @@ @Override Object execute(VirtualFrame frame) { Object o = value.execute(frame); + slot.setKind(FrameSlotKind.Object); frame.setObject(slot, o); return null; } diff -r 30e03a7f9110 -r 94f16a759646 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java Thu Oct 23 12:02:02 2014 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java Thu Oct 23 13:45:59 2014 +0200 @@ -30,7 +30,7 @@ /** *

Specializing Return Types

- * + * *

* In order to avoid boxing and/or type casts on the return value of a node, the return value the * method for executing a node can have a specific type and need not be of type @@ -124,6 +124,7 @@ int result = value.executeInt(frame); frame.setInt(slot, result); } catch (UnexpectedResultException e) { + slot.setKind(FrameSlotKind.Object); frame.setObject(slot, e.getResult()); replace(new ObjectAssignLocal(slot, value)); } @@ -143,6 +144,7 @@ @Override Object execute(VirtualFrame frame) { Object o = value.execute(frame); + slot.setKind(FrameSlotKind.Object); frame.setObject(slot, o); return null; } diff -r 30e03a7f9110 -r 94f16a759646 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java Thu Oct 23 12:02:02 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java Thu Oct 23 13:45:59 2014 +0200 @@ -27,7 +27,6 @@ import java.util.*; import com.oracle.truffle.api.*; -import com.oracle.truffle.api.impl.*; /** * Descriptor of the slots of frame objects. Multiple frame instances are associated with one such @@ -35,23 +34,31 @@ */ public final class FrameDescriptor implements Cloneable { - private final FrameTypeConversion typeConversion; + private final Object defaultValue; private final ArrayList slots; private final HashMap identifierToSlotMap; private Assumption version; private HashMap identifierToNotInFrameAssumptionMap; public FrameDescriptor() { - this(DefaultFrameTypeConversion.getInstance()); + this(null); } - public FrameDescriptor(FrameTypeConversion typeConversion) { - this.typeConversion = typeConversion; + public FrameDescriptor(Object defaultValue) { + this.defaultValue = defaultValue; slots = new ArrayList<>(); identifierToSlotMap = new HashMap<>(); version = createVersion(); } + public static FrameDescriptor create() { + return new FrameDescriptor(); + } + + public static FrameDescriptor create(Object defaultValue) { + return new FrameDescriptor(defaultValue); + } + public FrameSlot addFrameSlot(Object identifier) { return addFrameSlot(identifier, null, FrameSlotKind.Illegal); } @@ -91,6 +98,14 @@ return addFrameSlot(identifier, kind); } + public FrameSlot findOrAddFrameSlot(Object identifier, Object info, FrameSlotKind kind) { + FrameSlot result = findFrameSlot(identifier); + if (result != null) { + return result; + } + return addFrameSlot(identifier, info, kind); + } + public void removeFrameSlot(Object identifier) { CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations."); assert identifierToSlotMap.containsKey(identifier); @@ -118,7 +133,7 @@ } public FrameDescriptor copy() { - FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.typeConversion); + FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue); for (int i = 0; i < this.getSlots().size(); i++) { Object identifier = this.getSlots().get(i).getIdentifier(); clonedFrameDescriptor.addFrameSlot(identifier); @@ -127,7 +142,7 @@ } public FrameDescriptor shallowCopy() { - FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.typeConversion); + FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue); clonedFrameDescriptor.slots.addAll(slots); clonedFrameDescriptor.identifierToSlotMap.putAll(identifierToSlotMap); return clonedFrameDescriptor; @@ -146,8 +161,8 @@ return Truffle.getRuntime().createAssumption("frame version"); } - public FrameTypeConversion getTypeConversion() { - return typeConversion; + public Object getDefaultValue() { + return defaultValue; } public Assumption getNotInFrameAssumption(Object identifier) { diff -r 30e03a7f9110 -r 94f16a759646 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameTypeConversion.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameTypeConversion.java Thu Oct 23 12:02:02 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.api.frame; - -/** - * Interface for defining type conversions for frame slot values. - */ -public interface FrameTypeConversion { - - Object getDefaultValue(); - - void updateFrameSlot(Frame frame, FrameSlot slot, Object value); -} diff -r 30e03a7f9110 -r 94f16a759646 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultFrameTypeConversion.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultFrameTypeConversion.java Thu Oct 23 12:02:02 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.api.impl; - -import com.oracle.truffle.api.frame.*; - -/** - * Interface for defining type conversions for frame slot values. - */ -public class DefaultFrameTypeConversion implements FrameTypeConversion { - - private static final DefaultFrameTypeConversion INSTANCE = new DefaultFrameTypeConversion(); - - @Override - public Object getDefaultValue() { - return null; - } - - @Override - public void updateFrameSlot(Frame frame, FrameSlot slot, Object value) { - if (slot.getKind() != FrameSlotKind.Object) { - slot.setKind(FrameSlotKind.Object); - } - frame.setObject(slot, value); - } - - public static DefaultFrameTypeConversion getInstance() { - return INSTANCE; - } -} diff -r 30e03a7f9110 -r 94f16a759646 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Thu Oct 23 12:02:02 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java Thu Oct 23 13:45:59 2014 +0200 @@ -45,7 +45,7 @@ this.descriptor = descriptor; this.arguments = arguments; this.locals = new Object[descriptor.getSize()]; - Arrays.fill(locals, descriptor.getTypeConversion().getDefaultValue()); + Arrays.fill(locals, descriptor.getDefaultValue()); this.tags = new byte[descriptor.getSize()]; } @@ -178,12 +178,6 @@ } byte tag = tags[slotIndex]; if (accessKind == FrameSlotKind.Object ? tag != 0 : tag != accessKind.ordinal()) { - if (slot.getKind() == accessKind || tag == 0) { - descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot)); - if (tags[slotIndex] == accessKind.ordinal()) { - return; - } - } throw new FrameSlotTypeException(); } } @@ -193,7 +187,7 @@ int newSize = descriptor.getSize(); if (newSize > oldSize) { locals = Arrays.copyOf(locals, newSize); - Arrays.fill(locals, oldSize, newSize, descriptor.getTypeConversion().getDefaultValue()); + Arrays.fill(locals, oldSize, newSize, descriptor.getDefaultValue()); tags = Arrays.copyOf(tags, newSize); return true; }