@@ -990,28 +990,35 @@ public abstract static class CopyPropertiesNode extends Node {
990990 public abstract void execute (DynamicObject from , DynamicObject to );
991991
992992 @ ExplodeLoop
993- @ Specialization (guards = " shape == cachedShape" , limit = "SHAPE_CACHE_LIMIT" )
993+ @ Specialization (guards = { "from != to" , " shape == cachedShape"} , limit = "SHAPE_CACHE_LIMIT" )
994994 static void doCached (DynamicObject from , DynamicObject to ,
995995 @ Bind ("from.getShape()" ) @ SuppressWarnings ("unused" ) Shape shape ,
996996 @ Cached ("shape" ) @ SuppressWarnings ("unused" ) Shape cachedShape ,
997997 @ Cached (value = "createPropertyGetters(cachedShape)" , dimensions = 1 ) PropertyGetter [] getters ,
998- @ Cached DynamicObject . PutNode putNode ) {
998+ @ Cached ( value = "createPutNodes(getters)" ) PutNode [] putNodes ) {
999999 for (int i = 0 ; i < getters .length ; i ++) {
10001000 PropertyGetter getter = getters [i ];
1001- putNode .executeWithFlags (to , getter .getKey (), getter .get (from ), getter .getFlags ());
1001+ putNodes [ i ] .executeWithFlags (to , getter .getKey (), getter .get (from ), getter .getFlags ());
10021002 }
10031003 }
10041004
10051005 @ TruffleBoundary
1006- @ Specialization (replaces = "doCached" )
1006+ @ Specialization (guards = { "from != to" }, replaces = "doCached" )
10071007 static void doGeneric (DynamicObject from , DynamicObject to ) {
10081008 Property [] properties = from .getShape ().getPropertyArray ();
10091009 for (int i = 0 ; i < properties .length ; i ++) {
10101010 Property property = properties [i ];
1011- PutNode .getUncached ().executeWithFlags (to , property .getKey (), property .get (from , false ), property .getFlags ());
1011+ Object value = property .get (from , false );
1012+ PutNode .getUncached ().executeWithFlags (to , property .getKey (), value , property .getFlags ());
10121013 }
10131014 }
10141015
1016+ @ SuppressWarnings ("unused" )
1017+ @ Specialization (guards = {"from == to" })
1018+ static void doSameObject (DynamicObject from , DynamicObject to ) {
1019+ // nothing to do
1020+ }
1021+
10151022 static PropertyGetter [] createPropertyGetters (Shape shape ) {
10161023 Property [] properties = shape .getPropertyArray ();
10171024 PropertyGetter [] getters = new PropertyGetter [properties .length ];
@@ -1023,6 +1030,14 @@ static PropertyGetter[] createPropertyGetters(Shape shape) {
10231030 return getters ;
10241031 }
10251032
1033+ static PutNode [] createPutNodes (PropertyGetter [] getters ) {
1034+ PutNode [] putNodes = new PutNode [getters .length ];
1035+ for (int i = 0 ; i < getters .length ; i ++) {
1036+ putNodes [i ] = PutNode .create ();
1037+ }
1038+ return putNodes ;
1039+ }
1040+
10261041 /**
10271042 * @since 25.1
10281043 */
0 commit comments