6262import com .oracle .truffle .api .nodes .UnexpectedResultException ;
6363import com .oracle .truffle .api .object .DynamicObject ;
6464import com .oracle .truffle .api .object .DynamicObjectLibrary ;
65- import com .oracle .truffle .api .object .Property ;
6665import com .oracle .truffle .api .profiles .BranchProfile ;
6766import com .oracle .truffle .api .profiles .ConditionProfile ;
6867import com .oracle .truffle .js .builtins .helper .ListGetNode ;
114113import com .oracle .truffle .js .runtime .objects .JSDynamicObject ;
115114import com .oracle .truffle .js .runtime .objects .JSLazyString ;
116115import com .oracle .truffle .js .runtime .objects .JSObject ;
117- import com .oracle .truffle .js .runtime .objects .JSProperty ;
118- import com .oracle .truffle .js .runtime .objects .PropertyReference ;
119116import com .oracle .truffle .js .runtime .objects .Undefined ;
120117import com .oracle .truffle .js .runtime .util .JSClassProfile ;
121118import com .oracle .truffle .js .runtime .util .TRegexUtil ;
@@ -666,7 +663,7 @@ protected Object executeWithTargetAndIndexUnchecked(Object target, int index, Ob
666663 return getProperty (targetObject , Boundaries .stringValueOf (index ), receiver , defaultValue );
667664 }
668665 } else {
669- return getNonArrayNode (). getPropertyGeneric (targetObject , index , receiver , defaultValue , root );
666+ return readNonArrayObjectIndex (targetObject , index , receiver , defaultValue , root );
670667 }
671668 }
672669
@@ -702,7 +699,7 @@ protected int executeWithTargetAndIndexUncheckedInt(Object target, int index, Ob
702699 return JSTypesGen .expectInteger (getProperty (targetObject , Boundaries .stringValueOf (index ), receiver , defaultValue ));
703700 }
704701 } else {
705- return JSTypesGen .expectInteger (getNonArrayNode (). getPropertyGeneric (targetObject , index , receiver , defaultValue , root ));
702+ return JSTypesGen .expectInteger (readNonArrayObjectIndex (targetObject , index , receiver , defaultValue , root ));
706703 }
707704 }
708705
@@ -738,7 +735,7 @@ protected double executeWithTargetAndIndexUncheckedDouble(Object target, int ind
738735 return JSTypesGen .expectDouble (getProperty (targetObject , Boundaries .stringValueOf (index ), receiver , defaultValue ));
739736 }
740737 } else {
741- return JSTypesGen .expectDouble (getNonArrayNode (). getPropertyGeneric (targetObject , index , receiver , defaultValue , root ));
738+ return JSTypesGen .expectDouble (readNonArrayObjectIndex (targetObject , index , receiver , defaultValue , root ));
742739 }
743740 }
744741
@@ -762,38 +759,12 @@ private JSObjectReadElementNonArrayTypeCacheNode getNonArrayNode() {
762759
763760 private static class JSObjectReadElementNonArrayTypeCacheNode extends JavaScriptBaseNode {
764761
765- private final ConditionProfile propertyReferenceProfile = ConditionProfile .createBinaryProfile ();
766- private final ConditionProfile isDataPropertyBranch = ConditionProfile .createBinaryProfile ();
767762 @ Child private CachedGetPropertyNode getPropertyCachedNode ;
768763
769764 JSObjectReadElementNonArrayTypeCacheNode () {
770765 }
771766
772767 public Object execute (DynamicObject targetObject , Object index , Object receiver , Object defaultValue , ReadElementNode root ) {
773- if (propertyReferenceProfile .profile (
774- index instanceof PropertyReference && ((PropertyReference ) index ).getDepth () == 0 && ((PropertyReference ) index ).getShape () == targetObject .getShape ())) {
775- return readPropertyReference (index , targetObject );
776- } else {
777- return getPropertyGeneric (targetObject , index , receiver , defaultValue , root );
778- }
779- }
780-
781- private Object readPropertyReference (Object index , DynamicObject targetObject ) {
782- Property property = ((PropertyReference ) index ).getProperty ();
783- if (isDataPropertyBranch .profile (JSProperty .isData (property ))) {
784- // TODO PIC for location class
785- // return locationClassProfile.profileClass(property.getLocation())
786- return property .getLocation ().get (targetObject , false );
787- } else {
788- return JSProperty .getValue (property , targetObject , targetObject , false );
789- }
790- }
791-
792- public Object getPropertyGeneric (DynamicObject targetObject , Object index , Object receiver , Object defaultValue , ReadElementNode root ) {
793- return getCachedProperty (targetObject , index , receiver , defaultValue , root );
794- }
795-
796- private Object getCachedProperty (DynamicObject targetObject , Object index , Object receiver , Object defaultValue , ReadElementNode root ) {
797768 if (getPropertyCachedNode == null ) {
798769 CompilerDirectives .transferToInterpreterAndInvalidate ();
799770 getPropertyCachedNode = insert (CachedGetPropertyNode .create (root .context ));
0 commit comments