< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java

Print this page

        

*** 1246,1256 **** if (oldProto != newProto) { proto = newProto; // Let current listeners know that the prototype has changed ! getMap().protoChanged(true); // Replace our current allocator map with one that is associated with the new prototype. setMap(getMap().changeProto(newProto)); } } --- 1246,1256 ---- if (oldProto != newProto) { proto = newProto; // Let current listeners know that the prototype has changed ! getMap().protoChanged(); // Replace our current allocator map with one that is associated with the new prototype. setMap(getMap().changeProto(newProto)); } }
*** 2118,2154 **** public final SwitchPoint[] getProtoSwitchPoints(final String name, final ScriptObject owner) { if (owner == this || getProto() == null) { return null; } ! final List<SwitchPoint> switchPoints = new ArrayList<>(); for (ScriptObject obj = this; obj != owner && obj.getProto() != null; obj = obj.getProto()) { ! final ScriptObject parent = obj.getProto(); ! parent.getMap().addListener(name, obj.getMap()); ! final SwitchPoint sp = parent.getMap().getSharedProtoSwitchPoint(); ! if (sp != null && !sp.hasBeenInvalidated()) { ! switchPoints.add(sp); } } - switchPoints.add(getMap().getSwitchPoint(name)); return switchPoints.toArray(new SwitchPoint[0]); } // Similar to getProtoSwitchPoints method above, but used for additional prototype switchpoints of // properties that are known not to exist, e.g. the original property name in a __noSuchProperty__ invocation. final SwitchPoint getProtoSwitchPoint(final String name) { if (getProto() == null) { return null; } for (ScriptObject obj = this; obj.getProto() != null; obj = obj.getProto()) { ! final ScriptObject parent = obj.getProto(); ! parent.getMap().addListener(name, obj.getMap()); } ! return getMap().getSwitchPoint(name); } private void checkSharedProtoMap() { // Check if our map has an expected shared prototype property map. If it has, make sure that // the prototype map has not been invalidated, and that it does match the actual map of the prototype. --- 2118,2166 ---- public final SwitchPoint[] getProtoSwitchPoints(final String name, final ScriptObject owner) { if (owner == this || getProto() == null) { return null; } ! final Set<SwitchPoint> switchPoints = new HashSet<>(); ! SwitchPoint switchPoint = getProto().getMap().getSwitchPoint(name); ! ! if (switchPoint == null) { ! switchPoint = new SwitchPoint(); ! for (ScriptObject obj = this; obj != owner && obj.getProto() != null; obj = obj.getProto()) { ! obj.getProto().getMap().addSwitchPoint(name, switchPoint); ! } ! } ! ! switchPoints.add(switchPoint); ! for (ScriptObject obj = this; obj != owner && obj.getProto() != null; obj = obj.getProto()) { ! final SwitchPoint sharedProtoSwitchPoint = obj.getProto().getMap().getSharedProtoSwitchPoint(); ! if (sharedProtoSwitchPoint != null && !sharedProtoSwitchPoint.hasBeenInvalidated()) { ! switchPoints.add(sharedProtoSwitchPoint); } } return switchPoints.toArray(new SwitchPoint[0]); } // Similar to getProtoSwitchPoints method above, but used for additional prototype switchpoints of // properties that are known not to exist, e.g. the original property name in a __noSuchProperty__ invocation. final SwitchPoint getProtoSwitchPoint(final String name) { if (getProto() == null) { return null; } + SwitchPoint switchPoint = getProto().getMap().getSwitchPoint(name); + + if (switchPoint == null) { + switchPoint = new SwitchPoint(); for (ScriptObject obj = this; obj.getProto() != null; obj = obj.getProto()) { ! obj.getProto().getMap().addSwitchPoint(name, switchPoint); ! } } ! return switchPoint; } private void checkSharedProtoMap() { // Check if our map has an expected shared prototype property map. If it has, make sure that // the prototype map has not been invalidated, and that it does match the actual map of the prototype.
< prev index next >