Permalink
Browse files

If JIT fails, fallback to interpreter

This is actually a hack, but works if e.g. the
generated byte code is too large.
  • Loading branch information...
1 parent 6b4fe22 commit e7c36cdcb7f15dee83de03a0e8ef8af8f94b75ab @krestenkrab krestenkrab committed Jun 6, 2012
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/main/java/erjang/EModuleLoader.java
View
15 src/main/java/erjang/EModuleLoader.java
@@ -77,9 +77,18 @@ public static EModule load_module(String moduleName, EBinary beamBin) throws IOE
loaded_module = erjang.beam.interpreter.Interpreter.beamFileToEModule(bfd);
after = System.currentTimeMillis();
} else { // Use compiler
- EModuleClassLoader moduleClassLoader = ErjangCodeCache.getModuleClassLoader(moduleName, beamBin, beamParser);
- after = System.currentTimeMillis();
- loaded_module = load_compiled_module(moduleName, moduleClassLoader);
+ try {
+ EModuleClassLoader moduleClassLoader = ErjangCodeCache.getModuleClassLoader(moduleName, beamBin, beamParser);
+ after = System.currentTimeMillis();
+ loaded_module = load_compiled_module(moduleName, moduleClassLoader);
+ } catch (RuntimeException e) {
+
+ use_interpreter = true;
+ // i something fails, ... try interpreted ...
+ BeamFileData bfd = beamParser.load(beamBin.toByteArray());
+ loaded_module = erjang.beam.interpreter.Interpreter.beamFileToEModule(bfd);
+ after = System.currentTimeMillis();
+ }
}
if (log.isLoggable(Level.FINE)) {
long after_load = System.currentTimeMillis();

0 comments on commit e7c36cd

Please sign in to comment.