3636import com .oracle .truffle .api .frame .Frame ;
3737import com .oracle .truffle .api .frame .FrameDescriptor ;
3838import com .oracle .truffle .api .frame .FrameSlot ;
39- import com .oracle .truffle .api .frame .FrameSlotKind ;
4039import com .oracle .truffle .api .frame .FrameSlotTypeException ;
4140import com .oracle .truffle .api .frame .MaterializedFrame ;
4241import com .oracle .truffle .api .frame .VirtualFrame ;
@@ -138,7 +137,7 @@ LookupNode copyAsSilenMissing() {
138137 * a particular layout of frame descriptors and enclosing environments, and re-specializes in case
139138 * the layout changes.
140139 */
141- public final class ReadVariableNode extends RBaseNode {
140+ public final class ReadVariableNode extends ReadVariableNodeBase {
142141
143142 private static final int MAX_INVALIDATION_COUNT = 8 ;
144143
@@ -210,8 +209,8 @@ private static RNode wrapAsSilentMissing(LookupNode node) {
210209 private final ConditionProfile isPromiseProfile = ConditionProfile .createBinaryProfile ();
211210 private final ConditionProfile isActiveBindingProfile = ConditionProfile .createBinaryProfile ();
212211 private final ConditionProfile copyProfile ;
213- private final BranchProfile unexpectedMissingProfile = BranchProfile . create () ;
214- private final ValueProfile superEnclosingFrameProfile = ValueProfile . createClassProfile () ;
212+ private final BranchProfile unexpectedMissingProfile ;
213+ private final ValueProfile superEnclosingFrameProfile ;
215214
216215 private final Object identifier ;
217216 private final String identifierAsString ;
@@ -222,8 +221,6 @@ private static RNode wrapAsSilentMissing(LookupNode node) {
222221 // inlined varargs, which should not show missing value error
223222 private final boolean silentMissing ;
224223
225- @ CompilationFinal (dimensions = 1 ) private final boolean [] seenValueKinds = new boolean [FrameSlotKind .values ().length ];
226-
227224 ReadVariableNode (ReadVariableNode node , boolean silentMissing ) {
228225 this (node .identifier , node .mode , node .kind , silentMissing );
229226 }
@@ -238,6 +235,8 @@ private ReadVariableNode(Object identifier, RType mode, ReadKind kind, boolean s
238235 this .mode = mode ;
239236 this .kind = kind ;
240237 this .silentMissing = silentMissing ;
238+ unexpectedMissingProfile = silentMissing ? null : BranchProfile .create ();
239+ superEnclosingFrameProfile = kind == ReadKind .Super ? ValueProfile .createClassProfile () : null ;
241240
242241 this .copyProfile = kind != ReadKind .Copying ? null : ConditionProfile .createBinaryProfile ();
243242 }
@@ -359,7 +358,7 @@ private Mismatch(FrameLevel next, FrameSlot slot) {
359358 @ Override
360359 public Object execute (VirtualFrame frame , Frame variableFrame ) throws InvalidAssumptionException , LayoutChangedException , FrameSlotTypeException {
361360 Frame profiledVariableFrame = frameProfile .profile (variableFrame );
362- Object value = profiledGetValue (seenValueKinds , profiledVariableFrame , slot );
361+ Object value = profiledGetValue (profiledVariableFrame , slot );
363362 if (checkType (frame , value , isNullProfile )) {
364363 CompilerDirectives .transferToInterpreterAndInvalidate ();
365364 throw new LayoutChangedException ();
@@ -408,7 +407,7 @@ private Match(FrameSlot slot) {
408407
409408 @ Override
410409 public Object execute (VirtualFrame frame , Frame variableFrame ) throws LayoutChangedException , FrameSlotTypeException {
411- Object value = valueProfile .profile (profiledGetValue (seenValueKinds , frameProfile .profile (variableFrame ), slot ));
410+ Object value = valueProfile .profile (profiledGetValue (frameProfile .profile (variableFrame ), slot ));
412411 if (!checkType (frame , value , isNullProfile )) {
413412 throw new LayoutChangedException ();
414413 }
@@ -613,7 +612,7 @@ private FrameAndSlotLookupLevel(FrameAndSlotLookupResult lookup) {
613612
614613 @ Override
615614 public Object execute (VirtualFrame frame ) throws InvalidAssumptionException , LayoutChangedException , FrameSlotTypeException {
616- Object value = profiledGetValue (seenValueKinds , frameProfile .profile (lookup .getFrame ()), lookup .getSlot ());
615+ Object value = profiledGetValue (frameProfile .profile (lookup .getFrame ()), lookup .getSlot ());
617616 if (!checkType (frame , value , isNullProfile )) {
618617 CompilerDirectives .transferToInterpreterAndInvalidate ();
619618 throw new LayoutChangedException ();
@@ -648,7 +647,7 @@ private FrameLevel initialize(VirtualFrame frame, Frame variableFrame) {
648647 FrameSlot localSlot = variableFrame .getFrameDescriptor ().findFrameSlot (identifier );
649648 // non-local reads can only be handled in a simple way if they are successful
650649 if (localSlot != null ) {
651- Object val = getValue (seenValueKinds , variableFrame , localSlot );
650+ Object val = getValue (variableFrame , localSlot );
652651 if (checkTypeSlowPath (frame , val )) {
653652 if (val instanceof MultiSlotData ) {
654653 RError .performanceWarning ("polymorphic (slow path) lookup of symbol \" " + identifier + "\" from a multi slot" );
@@ -721,7 +720,7 @@ private FrameLevel createLevels(VirtualFrame frame, Frame variableFrame, ArrayLi
721720 FrameDescriptor currentDescriptor = variableFrame .getFrameDescriptor ();
722721 FrameSlot frameSlot = currentDescriptor .findFrameSlot (identifier );
723722 if (frameSlot != null ) {
724- Object value = getValue (seenValueKinds , variableFrame , frameSlot );
723+ Object value = getValue (variableFrame , frameSlot );
725724 if (checkTypeSlowPath (frame , value )) {
726725 StableValue <Object > valueAssumption = FrameSlotChangeMonitor .getStableValueAssumption (currentDescriptor , frameSlot , value );
727726 if (valueAssumption != null ) {
@@ -768,7 +767,7 @@ private FrameLevel createLevels(VirtualFrame frame, Frame variableFrame, ArrayLi
768767 if (frameSlot == null ) {
769768 assumptions .add (currentDescriptor .getNotInFrameAssumption (identifier ));
770769 } else {
771- StableValue <Object > valueAssumption = FrameSlotChangeMonitor .getStableValueAssumption (currentDescriptor , frameSlot , getValue (seenValueKinds , variableFrame , frameSlot ));
770+ StableValue <Object > valueAssumption = FrameSlotChangeMonitor .getStableValueAssumption (currentDescriptor , frameSlot , getValue (variableFrame , frameSlot ));
772771 if (valueAssumption != null && lastLevel instanceof DescriptorLevel ) {
773772 assumptions .add (valueAssumption .getAssumption ());
774773 } else {
@@ -873,44 +872,6 @@ public static RArgsValuesAndNames lookupVarArgs(Frame variableFrame) {
873872 return null ;
874873 }
875874
876- private static Object getValue (boolean [] seenValueKinds , Frame variableFrame , FrameSlot frameSlot ) {
877- assert variableFrame .getFrameDescriptor ().getSlots ().contains (frameSlot ) : frameSlot .getIdentifier ();
878- Object value = variableFrame .getValue (frameSlot );
879- if (variableFrame .isObject (frameSlot )) {
880- value = FrameSlotChangeMonitor .getValue (frameSlot , variableFrame );
881- seenValueKinds [FrameSlotKind .Object .ordinal ()] = true ;
882- } else if (variableFrame .isByte (frameSlot )) {
883- seenValueKinds [FrameSlotKind .Byte .ordinal ()] = true ;
884- } else if (variableFrame .isInt (frameSlot )) {
885- seenValueKinds [FrameSlotKind .Int .ordinal ()] = true ;
886- } else if (variableFrame .isDouble (frameSlot )) {
887- seenValueKinds [FrameSlotKind .Double .ordinal ()] = true ;
888- }
889- return value ;
890- }
891-
892- static Object profiledGetValue (boolean [] seenValueKinds , Frame variableFrame , FrameSlot frameSlot ) {
893- assert variableFrame .getFrameDescriptor ().getSlots ().contains (frameSlot ) : frameSlot .getIdentifier ();
894- try {
895- if (seenValueKinds [FrameSlotKind .Object .ordinal ()] && variableFrame .isObject (frameSlot )) {
896- return FrameSlotChangeMonitor .getObject (frameSlot , variableFrame );
897- } else if (seenValueKinds [FrameSlotKind .Byte .ordinal ()] && variableFrame .isByte (frameSlot )) {
898- return variableFrame .getByte (frameSlot );
899- } else if (seenValueKinds [FrameSlotKind .Int .ordinal ()] && variableFrame .isInt (frameSlot )) {
900- return variableFrame .getInt (frameSlot );
901- } else if (seenValueKinds [FrameSlotKind .Double .ordinal ()] && variableFrame .isDouble (frameSlot )) {
902- return variableFrame .getDouble (frameSlot );
903- } else {
904- CompilerDirectives .transferToInterpreterAndInvalidate ();
905- // re-profile to widen the set of expected types
906- return getValue (seenValueKinds , variableFrame , frameSlot );
907- }
908- } catch (FrameSlotTypeException e ) {
909- CompilerDirectives .transferToInterpreter ();
910- throw new RInternalError (e , "unexpected frame slot type mismatch" );
911- }
912- }
913-
914875 /**
915876 * This method checks the value a RVN just read. It is used to determine whether the value just
916877 * read matches the expected type or if we have to look in a frame up the lexical chain. It
0 commit comments