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: 14c901a30bed
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 864a3a69a48f
Choose a head ref
  • 2 commits
  • 9 files changed
  • 1 contributor

Commits on Sep 12, 2016

  1. Copy the full SHA
    4a657ad View commit details
  2. Copy the full SHA
    864a3a6 View commit details
125 changes: 79 additions & 46 deletions truffle/src/main/c/openssl/ossl_asn1.c
Original file line number Diff line number Diff line change
@@ -504,48 +504,49 @@ decode_eoc(unsigned char *der, long length)

/********/

typedef struct {
const char *name;
VALUE *klass;
} ossl_asn1_info_t;

// TODO CS 06-09-16 Removed the address of the classes for now as it causes problems in Sulong

static const ossl_asn1_info_t ossl_asn1_info[] = {
{ "EOC", NULL /*&cASN1EndOfContent*/, }, /* 0 */
{ "BOOLEAN", NULL /*&cASN1Boolean*/, }, /* 1 */
{ "INTEGER", NULL /*&cASN1Integer*/, }, /* 2 */
{ "BIT_STRING", NULL /*&cASN1BitString*/, }, /* 3 */
{ "OCTET_STRING", NULL /*&cASN1OctetString*/, }, /* 4 */
{ "NULL", NULL /*&cASN1Null*/, }, /* 5 */
{ "OBJECT", NULL /*&cASN1ObjectId*/, }, /* 6 */
{ "OBJECT_DESCRIPTOR", NULL, }, /* 7 */
{ "EXTERNAL", NULL, }, /* 8 */
{ "REAL", NULL, }, /* 9 */
{ "ENUMERATED", NULL /*&cASN1Enumerated*/, }, /* 10 */
{ "EMBEDDED_PDV", NULL, }, /* 11 */
{ "UTF8STRING", NULL /*&cASN1UTF8String*/, }, /* 12 */
{ "RELATIVE_OID", NULL, }, /* 13 */
{ "[UNIVERSAL 14]", NULL, }, /* 14 */
{ "[UNIVERSAL 15]", NULL, }, /* 15 */
{ "SEQUENCE", NULL /*&cASN1Sequence*/, }, /* 16 */
{ "SET", NULL /*&cASN1Set*/, }, /* 17 */
{ "NUMERICSTRING", NULL /*&cASN1NumericString*/, }, /* 18 */
{ "PRINTABLESTRING", NULL /*&cASN1PrintableString*/, }, /* 19 */
{ "T61STRING", NULL /*&cASN1T61String*/, }, /* 20 */
{ "VIDEOTEXSTRING", NULL /*&cASN1VideotexString*/, }, /* 21 */
{ "IA5STRING", NULL /*&cASN1IA5String*/, }, /* 22 */
{ "UTCTIME", NULL /*&cASN1UTCTime*/, }, /* 23 */
{ "GENERALIZEDTIME", NULL /*&cASN1GeneralizedTime*/, }, /* 24 */
{ "GRAPHICSTRING", NULL /*&cASN1GraphicString*/, }, /* 25 */
{ "ISO64STRING", NULL /*&cASN1ISO64String*/, }, /* 26 */
{ "GENERALSTRING", NULL /*&cASN1GeneralString*/, }, /* 27 */
{ "UNIVERSALSTRING", NULL /*&cASN1UniversalString*/, }, /* 28 */
{ "CHARACTER_STRING", NULL, }, /* 29 */
{ "BMPSTRING", NULL /*&cASN1BMPString*/, }, /* 30 */
/*
* Modified for Sulong to flatten the array of ossl_asn1_info_t structures,
* into an array of names and array of classes, because the classes are
* managed and can't be stored in a static array of structures like that.
*/

static const char *ossl_asn1_info_names[] = {
"EOC",
"BOOLEAN",
"INTEGER",
"BIT_STRING",
"OCTET_STRING",
"NULL",
"OBJECT",
"OBJECT_DESCRIPTOR",
"EXTERNAL",
"REAL",
"ENUMERATED",
"EMBEDDED_PDV",
"UTF8STRING",
"RELATIVE_OID",
"[UNIVERSAL 14]",
"[UNIVERSAL 15]",
"SEQUENCE",
"SET",
"NUMERICSTRING",
"PRINTABLESTRING",
"T61STRING",
"VIDEOTEXSTRING",
"IA5STRING",
"UTCTIME",
"GENERALIZEDTIME",
"GRAPHICSTRING",
"ISO64STRING",
"GENERALSTRING",
"UNIVERSALSTRING",
"CHARACTER_STRING",
"BMPSTRING"
};

enum {ossl_asn1_info_size = (sizeof(ossl_asn1_info)/sizeof(ossl_asn1_info[0]))};
static VALUE *ossl_asn1_info_klasses;

enum {ossl_asn1_info_size = (sizeof(ossl_asn1_info_names)/sizeof(ossl_asn1_info_names[0]))};

static VALUE class_tag_map;

@@ -859,8 +860,8 @@ int_ossl_asn1_decode0_prim(unsigned char **pp, long length, long hlen, int tag,
*pp += hlen + length;
*num_read = hlen + length;

if (tc == sUNIVERSAL && tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass) {
VALUE klass = *ossl_asn1_info[tag].klass;
if (tc == sUNIVERSAL && tag < ossl_asn1_info_size && ossl_asn1_info_klasses[tag]) {
VALUE klass = ossl_asn1_info_klasses[tag];
VALUE args[4];
args[0] = value;
args[1] = INT2NUM(tag);
@@ -924,7 +925,7 @@ int_ossl_asn1_decode0_cons(unsigned char **pp, long max_len, long length,
}
}
else {
VALUE klass = *ossl_asn1_info[tag].klass;
VALUE klass = ossl_asn1_info_klasses[tag];
asn1data = rb_obj_alloc(klass);
}
args[0] = ary;
@@ -1634,9 +1635,9 @@ Init_ossl_asn1(void)
*/
rb_define_const(mASN1, "UNIVERSAL_TAG_NAME", ary);
for(i = 0; i < ossl_asn1_info_size; i++){
if(ossl_asn1_info[i].name[0] == '[') continue;
rb_define_const(mASN1, ossl_asn1_info[i].name, INT2NUM(i));
rb_ary_store(ary, i, rb_str_new2(ossl_asn1_info[i].name));
if(ossl_asn1_info_names[i][0] == '[') continue;
rb_define_const(mASN1, ossl_asn1_info_names[i], INT2NUM(i));
rb_ary_store(ary, i, rb_str_new2(ossl_asn1_info_names[i]));
}

/* Document-class: OpenSSL::ASN1::ASN1Data
@@ -1950,6 +1951,38 @@ do{\

OSSL_ASN1_DEFINE_CLASS(EndOfContent, Data);

ossl_asn1_info_klasses = (VALUE *) truffle_managed_malloc(ossl_asn1_info_size * sizeof(VALUE));
ossl_asn1_info_klasses[0] = cASN1EndOfContent;
ossl_asn1_info_klasses[1] = cASN1Boolean;
ossl_asn1_info_klasses[2] = cASN1Integer;
ossl_asn1_info_klasses[3] = cASN1BitString;
ossl_asn1_info_klasses[4] = cASN1OctetString;
ossl_asn1_info_klasses[5] = cASN1Null;
ossl_asn1_info_klasses[6] = cASN1ObjectId;
ossl_asn1_info_klasses[7] = NULL;
ossl_asn1_info_klasses[8] = NULL;
ossl_asn1_info_klasses[9] = NULL;
ossl_asn1_info_klasses[10] = cASN1Enumerated;
ossl_asn1_info_klasses[11] = NULL;
ossl_asn1_info_klasses[12] = cASN1UTF8String;
ossl_asn1_info_klasses[13] = NULL;
ossl_asn1_info_klasses[14] = NULL;
ossl_asn1_info_klasses[15] = NULL;
ossl_asn1_info_klasses[16] = cASN1Sequence;
ossl_asn1_info_klasses[17] = cASN1Set;
ossl_asn1_info_klasses[18] = cASN1NumericString;
ossl_asn1_info_klasses[19] = cASN1PrintableString;
ossl_asn1_info_klasses[20] = cASN1T61String;
ossl_asn1_info_klasses[21] = cASN1VideotexString;
ossl_asn1_info_klasses[22] = cASN1IA5String;
ossl_asn1_info_klasses[23] = cASN1UTCTime;
ossl_asn1_info_klasses[24] = cASN1GeneralizedTime;
ossl_asn1_info_klasses[25] = cASN1GraphicString;
ossl_asn1_info_klasses[26] = cASN1ISO64String;
ossl_asn1_info_klasses[27] = cASN1GeneralString;
ossl_asn1_info_klasses[28] = cASN1UniversalString;
ossl_asn1_info_klasses[29] = NULL;
ossl_asn1_info_klasses[30] = cASN1BMPString;

/* Document-class: OpenSSL::ASN1::ObjectId
*
25 changes: 9 additions & 16 deletions truffle/src/main/java/org/jruby/truffle/core/rope/NativeRope.java
Original file line number Diff line number Diff line change
@@ -9,32 +9,25 @@
*/
package org.jruby.truffle.core.rope;

import jnr.ffi.Pointer;
import jnr.ffi.provider.MemoryManager;
import org.jcodings.Encoding;
import org.jruby.truffle.platform.NativePointer;
import org.jruby.truffle.platform.SimpleNativeMemoryManager;

public class NativeRope extends Rope {

private NativePointer pointer;
private Pointer pointer;

public NativeRope(SimpleNativeMemoryManager nativeMemoryManager, byte[] bytes, Encoding encoding, int characterLength) {
public NativeRope(MemoryManager memoryManager, byte[] bytes, Encoding encoding, int characterLength) {
super(encoding, CodeRange.CR_UNKNOWN, false, bytes.length, characterLength, 1, null);

pointer = nativeMemoryManager.allocate(bytes.length);

for (int n = 0; n < bytes.length; n++) {
pointer.writeByte(n, bytes[n]);
}
pointer = memoryManager.allocateDirect(bytes.length, false);
pointer.put(0, bytes, 0, bytes.length);
}

@Override
protected byte[] getBytesSlow() {
final byte[] bytes = new byte[byteLength()];

for (int n = 0; n < bytes.length; n++) {
bytes[n] = pointer.readByte(n);
}

pointer.get(0, bytes, 0, bytes.length);
return bytes;
}

@@ -45,7 +38,7 @@ public byte getByteSlow(int index) {

@Override
public byte get(int index) {
return pointer.readByte(index);
return pointer.getByte(index);
}

@Override
@@ -58,7 +51,7 @@ public Rope withEncoding(Encoding newEncoding, CodeRange newCodeRange) {
throw new UnsupportedOperationException();
}

public NativePointer getNativePointer() {
public Pointer getNativePointer() {
return pointer;
}

Original file line number Diff line number Diff line change
@@ -126,11 +126,11 @@ protected Object access(CExtString cExtString) {
context = RubyLanguage.INSTANCE.unprotectedFindContext(findContextNode);
}

nativeRope = new NativeRope(context.getNativePlatform().getSimpleNativeMemoryManager(), currentRope.getBytes(), currentRope.getEncoding(), currentRope.characterLength());
nativeRope = new NativeRope(context.getNativePlatform().getMemoryManager(), currentRope.getBytes(), currentRope.getEncoding(), currentRope.characterLength());
Layouts.STRING.setRope(cExtString.getString(), nativeRope);
}

return nativeRope.getNativePointer().getAddress();
return nativeRope.getNativePointer().address();
}

}
Original file line number Diff line number Diff line change
@@ -23,8 +23,6 @@ public interface NativePlatform {

MemoryManager getMemoryManager();

SimpleNativeMemoryManager getSimpleNativeMemoryManager();

SignalManager getSignalManager();

ProcessName getProcessName();

This file was deleted.

Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
import org.jruby.truffle.platform.NativePlatform;
import org.jruby.truffle.platform.ProcessName;
import org.jruby.truffle.platform.RubiniusConfiguration;
import org.jruby.truffle.platform.SimpleNativeMemoryManager;
import org.jruby.truffle.platform.java.JavaClockGetTime;
import org.jruby.truffle.platform.openjdk.OpenJDKArrayBlockingQueueLocksConditions;
import org.jruby.truffle.platform.openjdk.OpenJDKLinkedBlockingQueueLocksConditions;
@@ -31,14 +30,11 @@
import org.jruby.truffle.platform.posix.TrufflePosixHandler;
import org.jruby.truffle.platform.signal.SignalManager;
import org.jruby.truffle.platform.sunmisc.SunMiscSignalManager;
import org.jruby.truffle.platform.sunmisc.SunMiscUnsafeSimpleNativeMemoryManager;
import org.jruby.util.unsafe.UnsafeHolder;

public class DarwinPlatform implements NativePlatform {

private final TrufflePosix posix;
private final MemoryManager memoryManager;
private final SimpleNativeMemoryManager simpleNativeMemoryManager;
private final SignalManager signalManager;
private final ProcessName processName;
private final Sockets sockets;
@@ -48,7 +44,6 @@ public class DarwinPlatform implements NativePlatform {
public DarwinPlatform(RubyContext context) {
posix = new JNRTrufflePosix(POSIXFactory.getNativePOSIX(new TrufflePosixHandler(context)));
memoryManager = Runtime.getSystemRuntime().getMemoryManager();
simpleNativeMemoryManager = new SunMiscUnsafeSimpleNativeMemoryManager(UnsafeHolder.U);
signalManager = new SunMiscSignalManager();
processName = new DarwinProcessName();
sockets = LibraryLoader.create(Sockets.class).library("c").load();
@@ -68,11 +63,6 @@ public MemoryManager getMemoryManager() {
return memoryManager;
}

@Override
public SimpleNativeMemoryManager getSimpleNativeMemoryManager() {
return simpleNativeMemoryManager;
}

@Override
public SignalManager getSignalManager() {
return signalManager;
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@
import org.jruby.truffle.platform.NativePlatform;
import org.jruby.truffle.platform.ProcessName;
import org.jruby.truffle.platform.RubiniusConfiguration;
import org.jruby.truffle.platform.SimpleNativeMemoryManager;
import org.jruby.truffle.platform.linux.LinuxRubiniusConfiguration;
import org.jruby.truffle.platform.openjdk.OpenJDKArrayBlockingQueueLocksConditions;
import org.jruby.truffle.platform.openjdk.OpenJDKLinkedBlockingQueueLocksConditions;
@@ -28,14 +27,11 @@
import org.jruby.truffle.platform.posix.TrufflePosixHandler;
import org.jruby.truffle.platform.signal.SignalManager;
import org.jruby.truffle.platform.sunmisc.SunMiscSignalManager;
import org.jruby.truffle.platform.sunmisc.SunMiscUnsafeSimpleNativeMemoryManager;
import org.jruby.util.unsafe.UnsafeHolder;

public class JavaPlatform implements NativePlatform {

private final TrufflePosix posix;
private final MemoryManager memoryManager;
private final SimpleNativeMemoryManager simpleNativeMemoryManager;
private final SignalManager signalManager;
private final ProcessName processName;
private final Sockets sockets;
@@ -45,7 +41,6 @@ public class JavaPlatform implements NativePlatform {
public JavaPlatform(RubyContext context) {
posix = new JavaTrufflePosix(POSIXFactory.getJavaPOSIX(new TrufflePosixHandler(context)));
memoryManager = new JavaMemoryManager();
simpleNativeMemoryManager = new SunMiscUnsafeSimpleNativeMemoryManager(UnsafeHolder.U);
signalManager = new SunMiscSignalManager();
processName = new JavaProcessName();
sockets = new JavaSockets();
@@ -65,11 +60,6 @@ public MemoryManager getMemoryManager() {
return memoryManager;
}

@Override
public SimpleNativeMemoryManager getSimpleNativeMemoryManager() {
return simpleNativeMemoryManager;
}

@Override
public SignalManager getSignalManager() {
return signalManager;
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@
import org.jruby.truffle.platform.NativePlatform;
import org.jruby.truffle.platform.ProcessName;
import org.jruby.truffle.platform.RubiniusConfiguration;
import org.jruby.truffle.platform.SimpleNativeMemoryManager;
import org.jruby.truffle.platform.java.JavaProcessName;
import org.jruby.truffle.platform.openjdk.OpenJDKArrayBlockingQueueLocksConditions;
import org.jruby.truffle.platform.openjdk.OpenJDKLinkedBlockingQueueLocksConditions;
@@ -31,14 +30,11 @@
import org.jruby.truffle.platform.posix.TrufflePosixHandler;
import org.jruby.truffle.platform.signal.SignalManager;
import org.jruby.truffle.platform.sunmisc.SunMiscSignalManager;
import org.jruby.truffle.platform.sunmisc.SunMiscUnsafeSimpleNativeMemoryManager;
import org.jruby.util.unsafe.UnsafeHolder;

public class LinuxPlatform implements NativePlatform {

private final TrufflePosix posix;
private final MemoryManager memoryManager;
private final SimpleNativeMemoryManager simpleNativeMemoryManager;
private final SignalManager signalManager;
private final ProcessName processName;
private final Sockets sockets;
@@ -48,7 +44,6 @@ public class LinuxPlatform implements NativePlatform {
public LinuxPlatform(RubyContext context) {
posix = new JNRTrufflePosix(POSIXFactory.getNativePOSIX(new TrufflePosixHandler(context)));
memoryManager = Runtime.getSystemRuntime().getMemoryManager();
simpleNativeMemoryManager = new SunMiscUnsafeSimpleNativeMemoryManager(UnsafeHolder.U);
signalManager = new SunMiscSignalManager();
processName = new JavaProcessName();
sockets = LibraryLoader.create(Sockets.class).library("c").load();
@@ -68,11 +63,6 @@ public MemoryManager getMemoryManager() {
return memoryManager;
}

@Override
public SimpleNativeMemoryManager getSimpleNativeMemoryManager() {
return simpleNativeMemoryManager;
}

@Override
public SignalManager getSignalManager() {
return signalManager;
Loading