forked from jruby/jruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNailMain.java
More file actions
39 lines (31 loc) · 1.16 KB
/
Copy pathNailMain.java
File metadata and controls
39 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.jruby.util;
import com.martiansoftware.nailgun.NGContext;
import org.jruby.Main;
import org.jruby.RubyInstanceConfig;
import org.jruby.ast.executable.Script;
import org.jruby.runtime.Constants;
public class NailMain {
public static final ClassCache<Script> classCache;
static {
classCache = new ClassCache<Script>(NailMain.class.getClassLoader(), Constants.JIT_MAX_METHODS_LIMIT);
}
public static void nailMain(NGContext context) {
NailMain main = new NailMain();
int status = main.run(context);
if (status != 0) {
context.exit(status);
}
// force a full GC so objects aren't kept alive longer than they should
System.gc();
}
public int run(NGContext context) {
context.assertLoopbackClient();
RubyInstanceConfig config = new RubyInstanceConfig();
Main main = new Main(config);
config.setCurrentDirectory(context.getWorkingDirectory());
config.setEnvironment(context.getEnv());
// reuse one cache of compiled bodies
config.setClassCache(classCache);
return main.run(context.getArgs()).getStatus();
}
}