Skip to content

Commit

Permalink
Instance variable shaping updates allocator, so invalidate class.
Browse files Browse the repository at this point in the history
Indy logic was caching the allocator permanently, which meant that
.new from Ruby code would forever do a hierarchy-walk before
allocation to look for instance variables. This change causes the
initially-cached allocator+initialize to get tossed out after the
the type has settled on a specialized shape.
headius committed Jul 14, 2016
1 parent d55ae5f commit 51075bf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/main/java/org/jruby/RubyObject.java
Original file line number Diff line number Diff line change
@@ -267,6 +267,9 @@ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
klass.setAllocator(allocator);
klass.setReifiedClass(reified);

// invalidate metaclass so new allocator is picked up for specialized .new
klass.getMetaClass().invalidateCacheDescendants();

return allocator.allocate(runtime, klass);
}
};

0 comments on commit 51075bf

Please sign in to comment.