MigrateNode.java

  1. /*
  2.  * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. This
  3.  * code is released under a tri EPL/GPL/LGPL license. You can use it,
  4.  * redistribute it and/or modify it under the terms of the:
  5.  *
  6.  * Eclipse Public License version 1.0
  7.  * GNU General Public License version 2
  8.  * GNU Lesser General Public License version 2.1
  9.  */
  10. package org.jruby.truffle.nodes.objectstorage;

  11. import com.oracle.truffle.api.object.Shape;
  12. import org.jruby.truffle.runtime.core.RubyBasicObject;

  13. public class MigrateNode extends WriteObjectFieldChainNode {

  14.     private final Shape expectedShape;

  15.     public MigrateNode(Shape expectedShape, WriteObjectFieldNode next) {
  16.         super(next);
  17.         this.expectedShape = expectedShape;
  18.     }

  19.     @Override
  20.     public void execute(RubyBasicObject object, Object value) {
  21.         if (object.getObjectLayout() == expectedShape) {
  22.             object.getDynamicObject().updateShape();
  23.         }

  24.         next.execute(object, value);
  25.     }

  26. }