Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 86ac58bcc715
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4e98b716f585
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Jun 14, 2016

  1. Copy the full SHA
    93b5851 View commit details
  2. Wire up -X+C to file loads.

    headius committed Jun 14, 2016
    Copy the full SHA
    4e98b71 View commit details
Showing with 21 additions and 61 deletions.
  1. +0 −9 .travis.yml
  2. +14 −51 core/src/main/java/org/jruby/Ruby.java
  3. +6 −1 core/src/main/java/org/jruby/runtime/load/LibrarySearcher.java
  4. +1 −0 core/src/main/ruby/jruby/kernel/kernel.rb
9 changes: 0 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -105,15 +105,6 @@ matrix:
# group: edge
# jdk: oraclejdk9

branches:
only:
- master
- jruby-1_7
- truffle-head
- /^test-.*$/
- /^ha-feature/
- ruby-2.4

install: tool/travis-install.sh
script: tool/travis-script.sh

65 changes: 14 additions & 51 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -3015,61 +3015,24 @@ public void loadScope(IRScope scope, boolean wrap) {
public void compileAndLoadFile(String filename, InputStream in, boolean wrap) {
InputStream readStream = in;

Script script = null;

try {
// read full contents of file, hash it, and try to load that class first
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int num;
while ((num = in.read(buffer)) > -1) {
baos.write(buffer, 0, num);
}
buffer = baos.toByteArray();
String hash = JITCompiler.getHashForBytes(buffer);
final String className = JITCompiler.RUBY_JIT_PREFIX + ".FILE_" + hash;

// FIXME: duplicated from ClassCache
Class contents;
try {
contents = getJRubyClassLoader().loadClass(className);
if (LOG.isDebugEnabled()) { // RubyInstanceConfig.JIT_LOADING_DEBUG
LOG.debug("found jitted code for " + filename + " at class: " + className);
}
script = (Script) contents.newInstance();
readStream = new ByteArrayInputStream(buffer);
} catch (ClassNotFoundException cnfe) {
if (LOG.isDebugEnabled()) { // RubyInstanceConfig.JIT_LOADING_DEBUG
LOG.debug("no jitted code in classloader for file " + filename + " at class: " + className);
}
} catch (InstantiationException ex) {
if (LOG.isDebugEnabled()) { // RubyInstanceConfig.JIT_LOADING_DEBUG
LOG.debug("jitted code could not be instantiated for file " + filename + " at class: " + className + ' ' + ex);
}
} catch (IllegalAccessException ex) {
if (LOG.isDebugEnabled()) { // RubyInstanceConfig.JIT_LOADING_DEBUG
LOG.debug("jitted code could not be instantiated for file " + filename + " at class: " + className + ' ' + ex);
}
}
} catch (IOException ioe) {
// TODO: log something?
}

// script was not found in cache above, so proceed to compile
RootNode scriptNode = (RootNode) parseFile(readStream, filename, null);
if (script == null) {
ScriptAndCode scriptAndCode = tryCompile(scriptNode,
new ClassDefiningJRubyClassLoader(getJRubyClassLoader())
);
if (scriptAndCode != null) script = scriptAndCode.script();
}

if (script == null) {
failForcedCompile(scriptNode);
ThreadContext context = getCurrentContext();

runInterpreter(scriptNode);
} else {
runScript(script, wrap);
String oldFile = context.getFile();
int oldLine = context.getLine();
try {
context.setFileAndLine(scriptNode.getFile(), scriptNode.getLine());

if (config.isAssumePrinting() || config.isAssumeLoop()) {
runWithGetsLoop(scriptNode, config.isAssumePrinting(), config.isProcessLineEnds(),
config.isSplit());
} else {
runNormally(scriptNode);
}
} finally {
context.setFileAndLine(oldFile, oldLine);
}
}

Original file line number Diff line number Diff line change
@@ -232,7 +232,12 @@ public void load(Ruby runtime, boolean wrap) {
InputStream ris = null;
try {
ris = resource.inputStream();
runtime.loadFile(scriptName, new LoadServiceResourceInputStream(ris), wrap);

if (runtime.getInstanceConfig().getCompileMode().shouldPrecompileAll()) {
runtime.compileAndLoadFile(scriptName, ris, wrap);
} else {
runtime.loadFile(scriptName, new LoadServiceResourceInputStream(ris), wrap);
}
} catch(IOException e) {
throw runtime.newLoadError("no such file to load -- " + searchName, searchName);
} finally {
1 change: 1 addition & 0 deletions core/src/main/ruby/jruby/kernel/kernel.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Kernel
module_function
p :here
def require_relative(relative_arg)
relative_arg = relative_arg.to_path if relative_arg.respond_to? :to_path
relative_arg = JRuby::Type.convert_to_str(relative_arg)