Skip to content

Commit

Permalink
Showing 4 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/RubyContext.java
Original file line number Diff line number Diff line change
@@ -172,6 +172,8 @@ public RubyContext(Ruby jrubyRuntime, TruffleLanguage.Env env) {
attachmentsManager = new AttachmentsManager(this, instrumenter);
traceManager = new TraceManager(this, instrumenter);
coverageManager = new CoverageManager(this, instrumenter);

coreLibrary.initializePostBoot();
}

public Object send(Object object, String methodName, DynamicObject block, Object... arguments) {
21 changes: 21 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -911,6 +911,27 @@ public void initializeAfterBasicMethodsAdded() {
assert Layouts.CLASS.isClass(eagainWaitWritable);
}

public void initializePostBoot() {
// Load code that can't be run until everything else is boostrapped, such as pre-loaded Ruby stdlib.

try {
Main.printTruffleTimeMetric("before-post-boot");
try {
final RubyRootNode rootNode = context.getCodeLoader().parse(context.getSourceCache().getSource(getCoreLoadPath() + "/core/post-boot.rb"), UTF8Encoding.INSTANCE, ParserContext.TOP_LEVEL, null, true, node);
final CodeLoader.DeferredCall deferredCall = context.getCodeLoader().prepareExecute(ParserContext.TOP_LEVEL, DeclarationContext.TOP_LEVEL, rootNode, null, context.getCoreLibrary().getMainObject());
deferredCall.callWithoutCallNode();
} catch (IOException e) {
throw new RuntimeException(e);
}

Main.printTruffleTimeMetric("after-post-boot");
} catch (RaiseException e) {
final DynamicObject rubyException = e.getException();
BacktraceFormatter.createDefaultFormatter(getContext()).printBacktrace(context, rubyException, Layouts.EXCEPTION.getBacktrace(rubyException));
throw new TruffleFatalException("couldn't load the post-boot code", e);
}
}

private void initializeRubiniusFFI() {
Layouts.MODULE.getFields(rubiniusFFIModule).setConstant(context, node, "TYPE_CHAR", RubiniusTypes.TYPE_CHAR);
Layouts.MODULE.getFields(rubiniusFFIModule).setConstant(context, node, "TYPE_UCHAR", RubiniusTypes.TYPE_UCHAR);
10 changes: 10 additions & 0 deletions truffle/src/main/ruby/core/post-boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

require 'rubygems'
Truffle::Boot.require_core 'core/post-boot/shims'
14 changes: 14 additions & 0 deletions truffle/src/main/ruby/core/post-boot/shims.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

module Gem
# Update the default_dir to match JRuby's.
def self.default_dir
File.expand_path(File.join(ConfigMap[:libdir], '..', '..', 'ruby', 'gems', 'shared'))
end
end

0 comments on commit d0fd960

Please sign in to comment.