Skip to content

Commit c7d05d2

Browse files
committed
Fast-path markShared()
* Use a dispatched library as we already cache on the Shape.
1 parent 6c4d0de commit c7d05d2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/org/truffleruby/language/objects/shared/ShareObjectNode.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
import com.oracle.truffle.api.dsl.Cached;
2222
import com.oracle.truffle.api.dsl.ImportStatic;
2323
import com.oracle.truffle.api.dsl.Specialization;
24+
import com.oracle.truffle.api.library.CachedLibrary;
2425
import com.oracle.truffle.api.nodes.ExplodeLoop;
2526
import com.oracle.truffle.api.object.DynamicObject;
27+
import com.oracle.truffle.api.object.DynamicObjectLibrary;
2628
import com.oracle.truffle.api.object.ObjectLocation;
2729
import com.oracle.truffle.api.object.Property;
2830
import com.oracle.truffle.api.object.Shape;
@@ -48,14 +50,15 @@ public ShareObjectNode(int depth) {
4850
@ExplodeLoop
4951
protected void shareCached(DynamicObject object,
5052
@Cached("object.getShape()") Shape cachedShape,
53+
@CachedLibrary(limit = "1") DynamicObjectLibrary objectLibrary,
5154
@Cached("BASIC_OBJECT.getLogicalClass(cachedShape.getObjectType())") DynamicObject logicalClass,
5255
@Cached("BASIC_OBJECT.getMetaClass(cachedShape.getObjectType())") DynamicObject metaClass,
5356
@Cached("createShareInternalFieldsNode()") ShareInternalFieldsNode shareInternalFieldsNode,
5457
@Cached("createReadAndShareFieldNodes(getObjectProperties(cachedShape))") ReadAndShareFieldNode[] readAndShareFieldNodes,
5558
@Cached("createSharedShape(cachedShape)") Shape sharedShape) {
5659
// Mark the object as shared first to avoid recursion
5760
assert object.getShape() == cachedShape;
58-
object.setShapeAndGrow(cachedShape, sharedShape);
61+
objectLibrary.markShared(object);
5962
assert object.getShape() == sharedShape;
6063

6164
// Share the logical class

0 commit comments

Comments
 (0)