8074545: Undefined object values in object literals with spill properties

Reviewed-by: lagergren, attila
This commit is contained in:
Hannes Wallnöfer 2015-03-06 15:26:51 +01:00
parent e776a10ce3
commit e1ac257862
4 changed files with 1051 additions and 10 deletions

View File

@ -100,15 +100,16 @@ public class MapCreator<T> {
for (final MapTuple<T> tuple : tuples) {
final String key = tuple.key;
final Symbol symbol = tuple.symbol;
final Class<?> initialType = tuple.getValueType();
//TODO initial type is object here no matter what. Is that right?
if (symbol != null && !isValidArrayIndex(getArrayIndex(key))) {
final int flags = getPropertyFlags(symbol, hasArguments, false);
properties.add(
new SpillProperty(
key,
flags,
spillIndex++));
spillIndex++,
initialType));
}
}

View File

@ -244,20 +244,15 @@ public class JSONParser {
private static PropertyMap addObjectProperty(final PropertyMap propertyMap, final List<Object> values,
final String id, final Object value) {
final Property oldProperty = propertyMap.findProperty(id);
final Property newProperty;
final PropertyMap newMap;
final Class<?> type = ObjectClassGenerator.OBJECT_FIELDS_ONLY ? Object.class : getType(value);
if (oldProperty != null) {
values.set(oldProperty.getSlot(), value);
newProperty = new SpillProperty(id, 0, oldProperty.getSlot());
newProperty.setType(type);
newMap = propertyMap.replaceProperty(oldProperty, newProperty);;
newMap = propertyMap.replaceProperty(oldProperty, new SpillProperty(id, 0, oldProperty.getSlot(), type));;
} else {
values.add(value);
newProperty = new SpillProperty(id, 0, propertyMap.size());
newProperty.setType(type);
newMap = propertyMap.addProperty(newProperty);
newMap = propertyMap.addProperty(new SpillProperty(id, 0, propertyMap.size(), type));
}
return newMap;

View File

@ -164,7 +164,14 @@ public class SpillProperty extends AccessorProperty {
assert !OBJECT_FIELDS_ONLY || getLocalType() == Object.class;
}
SpillProperty(final String key, final int flags, final int slot, final Class<?> initialType) {
/**
* Constructor for spill properties with an initial type.
* @param key the property key
* @param flags the property flags
* @param slot spill slot
* @param initialType initial type
*/
public SpillProperty(final String key, final int flags, final int slot, final Class<?> initialType) {
this(key, flags, slot);
setType(OBJECT_FIELDS_ONLY ? Object.class : initialType);
}

File diff suppressed because it is too large Load Diff