Skip to content

Commit

Permalink
[Truffle] Updated AOT substitutions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Dec 5, 2016
1 parent 7e4e3a9 commit c87882b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 185 deletions.
Expand Up @@ -79,95 +79,13 @@ InputStream openResource(String name) throws IOException {
}
}

/*@SuppressWarnings("unused")
final class Target_org_jruby_util_URLResource {
URL url;
static FileResource createClassloaderURI(Ruby runtime, String pathname, boolean isFile) {
throw new RuntimeException("Not supported on Substrate VM");
}
InputStream openInputStream() throws IOException {
return url.openStream();
}
}*/

/*final class Target_org_jruby_RubyInstanceConfig {
PrintStream error;
Map<String, String> environment;
static native String verifyHome(String home, PrintStream error);
static ClassLoader defaultClassLoader() {
return null;
}
void setupEnvironment(String jrubyHome) {
if (!new File(jrubyHome).exists() && !environment.containsKey("RUBY")) {
environment.put("RUBY", "svm_jruby");
}
}
String calculateJRubyHome() {
String newJRubyHome = null;
// try the normal property first
if (!Ruby.isSecurityRestricted()) {
newJRubyHome = SafePropertyAccessor.getProperty("jruby.home");
}
if (newJRubyHome != null) {
// verify it if it's there
newJRubyHome = verifyHome(newJRubyHome, error);
} else {
try {
newJRubyHome = SafePropertyAccessor.getenv("JRUBY_HOME");
} catch (Exception e) {
}
if (newJRubyHome != null) {
// verify it if it's there
newJRubyHome = verifyHome(newJRubyHome, error);
} else {
// otherwise fall back on system temp location
newJRubyHome = SafePropertyAccessor.getProperty("java.io.tmpdir");
}
}
return newJRubyHome;
}
}*/

final class Target_org_joda_time_DateTimeUtils {
static DateFormatSymbols getDateFormatSymbols(Locale locale) {
return DateFormatSymbols.getInstance(locale);
}
}

@SuppressWarnings("unused")
final class Target_org_jruby_util_JarResource {
static Object create(String pathname) {
return null;
}
}

@SuppressWarnings({"static-method", "unused"})
final class Target_org_jruby_RubyBasicObject {
static long VAR_TABLE_OFFSET;
static long STAMP_OFFSET;

<T> T defaultToJava(Class<T> target) {
return null;
}
}

final class Target_org_jruby_RubyEncoding {
static int CHAR_ARRAY_BASE;
static int BYTE_ARRAY_BASE;
static long VALUE_FIELD_OFFSET;
}

final class Target_org_jruby_util_StringSupport {
final class Target_org_jruby_truffle_core_string_StringSupport {
static int ARRAY_BYTE_BASE_OFFSET;
}

Expand Down
102 changes: 1 addition & 101 deletions truffle/src/main/java/org/jruby/truffle/aot/substitutions.json
Expand Up @@ -49,76 +49,6 @@
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_RubyBasicObject",
"originalClass": "org.jruby.RubyBasicObject",
"methods": [
{
"annotatedName": "defaultToJava",
"substitute": true
}
],
"fields": [
{
"annotatedName": "STAMP_OFFSET",
"delete": true
},
{
"annotatedName": "VAR_TABLE_OFFSET",
"delete": true
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_RubyEncoding",
"originalClass": "org.jruby.RubyEncoding",
"fields": [
{
"annotatedName": "BYTE_ARRAY_BASE",
"delete": true
},
{
"annotatedName": "CHAR_ARRAY_BASE",
"delete": true
},
{
"annotatedName": "VALUE_FIELD_OFFSET",
"delete": true
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_RubyInstanceConfig",
"originalClass": "org.jruby.RubyInstanceConfig",
"methods": [
{
"annotatedName": "calculateJRubyHome",
"substitute": true
},
{
"annotatedName": "defaultClassLoader",
"substitute": true
},
{
"annotatedName": "setupEnvironment",
"substitute": true
},
{
"annotatedName": "verifyHome",
"alias": true
}
],
"fields": [
{
"annotatedName": "environment",
"alias": true
},
{
"annotatedName": "error",
"alias": true
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_truffle_language_loader_SourceLoader",
"originalClass": "org.jruby.truffle.language.loader.SourceLoader",
Expand All @@ -130,17 +60,7 @@
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_util_JarResource",
"originalClass": "org.jruby.util.JarResource",
"methods": [
{
"annotatedName": "create",
"substitute": true
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_util_StringSupport",
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_truffle_core_string_StringSupport",
"originalClass": "org.jruby.util.StringSupport",
"fields": [
{
Expand All @@ -149,26 +69,6 @@
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_util_URLResource",
"originalClass": "org.jruby.util.URLResource",
"methods": [
{
"annotatedName": "createClassloaderURI",
"substitute": true
},
{
"annotatedName": "openInputStream",
"substitute": true
}
],
"fields": [
{
"annotatedName": "url",
"alias": true
}
]
},
{
"annotatedClass": "org.jruby.truffle.aot.Target_org_jruby_util_unsafe_UnsafeHolder",
"originalClass": "org.jruby.util.unsafe.UnsafeHolder",
Expand Down
Expand Up @@ -28,6 +28,7 @@
***** END LICENSE BLOCK *****/
package org.jruby.truffle.options;

import com.oracle.truffle.api.TruffleOptions;
import jnr.posix.util.Platform;
import org.jruby.truffle.core.string.StringSupport;
import org.jruby.truffle.language.control.JavaException;
Expand Down Expand Up @@ -138,7 +139,7 @@ private String calculateJRubyHome() {
newJRubyHome = SafePropertyAccessor.getProperty("jruby.home");
}

if (newJRubyHome == null && getLoader().getResource("META-INF/jruby.home/.jrubydir") != null) {
if (!TruffleOptions.AOT && newJRubyHome == null && getLoader().getResource("META-INF/jruby.home/.jrubydir") != null) {
newJRubyHome = "uri:classloader://META-INF/jruby.home";
}
if (newJRubyHome != null) {
Expand Down Expand Up @@ -556,6 +557,10 @@ public void setFrozenStringLiteral(boolean frozenStringLiteral) {


public static ClassLoader defaultClassLoader() {
if (TruffleOptions.AOT) {
return null;
}

ClassLoader loader = RubyInstanceConfig.class.getClassLoader();

// loader can be null for example when jruby comes from the boot-classLoader
Expand Down

0 comments on commit c87882b

Please sign in to comment.