Permalink
Browse files

Updates to current invokedynamic logic.

* New jsr292-mock for building
* Updated dynalink-0.1.jar for binding
* Updated to use java.lang.invoke and appropriate bootstrapping handles throughout
* Fixed complete jar build to include dynalink
  • Loading branch information...
1 parent 46a1bea commit 489d4aaad3785a8716c831c355eb2fcb29bfc7d0 @headius headius committed May 8, 2011
View
@@ -104,6 +104,7 @@ namespace :jar do
zipfileset :src => 'dist/mirah.jar'
zipfileset :src => 'javalib/jruby-complete.jar'
zipfileset :src => 'javalib/mirah-parser.jar'
+ zipfileset :src => 'javalib/dynalink-0.1.jar'
manifest do
attribute :name => 'Main-Class', :value => 'org.mirah.MirahCommand'
end
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -816,20 +816,6 @@ def empty_array(type, size)
type.newarray(@method)
end
- def bootstrap_dynamic
- # hacky, I know
- unless defined? @class.bootstrapped
- def @class.bootstrapped; true; end
- method = @class.build_method("<clinit>", :public, :static, [], Java::void)
- method.start
- method.ldc org.mirah.DynalangBootstrap
- method.ldc "bootstrap"
- method.invokestatic java.dyn.Linkage, "registerBootstrapMethod", [method.void, java.lang.Class, method.string]
- method.returnvoid
- method.stop
- end
- end
-
class ClosureCompiler < JVMBytecode
def initialize(file, type, parent)
@file = file
@@ -280,16 +280,21 @@ def call(compiler, ast, expression)
ast.parameters.each do |param|
param.compile(compiler, true)
end
+ handle = compiler.method.mh_invokestatic(
+ org.mirah.DynalangBootstrap,
+ "bootstrap",
+ java.lang.invoke.CallSite,
+ java.lang.invoke.MethodHandles::Lookup,
+ java.lang.String,
+ java.lang.invoke.MethodType)
compiler.method.invokedynamic(
- target,
"dyn:callPropWithThis:#{name}",
- [return_type, target, *@types])
+ [return_type, target, *@types],
+ handle)
unless expression
return_type.pop(compiler.method)
end
-
- compiler.bootstrap_dynamic
end
end
@@ -19,7 +19,6 @@ module Mirah
module Util
class CompilationState
def initialize
- BiteScript.bytecode_version = BiteScript::JAVA1_5
@save_extensions = true
end
@@ -18,7 +18,7 @@
import org.dynalang.dynalink.*;
import org.dynalang.dynalink.beans.*;
-import java.dyn.*;
+import java.lang.invoke.*;
public class DynalangBootstrap {
private static final DynamicLinker dynamicLinker = createDynamicLinker();
@@ -28,9 +28,9 @@ private static DynamicLinker createDynamicLinker() {
return factory.createLinker();
}
- public static CallSite bootstrap(Class caller, String name, MethodType type) {
- final RelinkableCallSite callSite = new MonomorphicCallSite(caller, name, type);
+ public static CallSite bootstrap(MethodHandles.Lookup caller, String name, MethodType type) {
+ final RelinkableCallSite callSite = new MonomorphicCallSite(name, type);
dynamicLinker.link(callSite);
- return callSite;
+ return callSite;
}
}

0 comments on commit 489d4aa

Please sign in to comment.