forked from jruby/jruby
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move more bootstrap to logical homes
- Loading branch information
Showing
14 changed files
with
959 additions
and
880 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
core/src/main/java/org/jruby/ir/targets/indy/ArrayBootstrap.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.jruby.ir.targets.indy; | ||
|
||
import com.headius.invokebinder.Binder; | ||
import org.jruby.RubyArray; | ||
import org.jruby.runtime.ThreadContext; | ||
import org.jruby.runtime.builtin.IRubyObject; | ||
import org.jruby.specialized.RubyArraySpecialized; | ||
|
||
import java.lang.invoke.CallSite; | ||
import java.lang.invoke.ConstantCallSite; | ||
import java.lang.invoke.MethodHandle; | ||
import java.lang.invoke.MethodHandles; | ||
import java.lang.invoke.MethodType; | ||
|
||
public class ArrayBootstrap { | ||
private static final MethodHandle ARRAY_HANDLE = | ||
Binder | ||
.from(RubyArray.class, ThreadContext.class, IRubyObject[].class) | ||
.invokeStaticQuiet(Bootstrap.LOOKUP, Bootstrap.class, "array"); | ||
|
||
public static CallSite array(MethodHandles.Lookup lookup, String name, MethodType type) { | ||
MethodHandle handle = Binder | ||
.from(type) | ||
.collect(1, IRubyObject[].class) | ||
.invoke(ARRAY_HANDLE); | ||
|
||
return new ConstantCallSite(handle); | ||
} | ||
|
||
public static RubyArray array(ThreadContext context, IRubyObject[] ary) { | ||
assert ary.length > RubyArraySpecialized.MAX_PACKED_SIZE; | ||
// Bootstrap.array() only dispatches here if ^^ holds | ||
return RubyArray.newArrayNoCopy(context.runtime, ary); | ||
} | ||
} |
Oops, something went wrong.