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: 69132ce53de6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7922f7d5dc2b
Choose a head ref
  • 7 commits
  • 13 files changed
  • 1 contributor

Commits on Apr 7, 2016

  1. Copy the full SHA
    d44e544 View commit details
  2. [Truffle] Formatting.

    chrisseaton committed Apr 7, 2016
    Copy the full SHA
    c111cba View commit details
  3. Copy the full SHA
    f7b07fe View commit details
  4. [Truffle] Remove the abstraction around creating FDSets - it's curren…

    …tly the same for all platforms.
    chrisseaton committed Apr 7, 2016
    Copy the full SHA
    f93f45d View commit details
  5. Copy the full SHA
    08415d6 View commit details
  6. Copy the full SHA
    706c86d View commit details
  7. Copy the full SHA
    7922f7d View commit details
Original file line number Diff line number Diff line change
@@ -500,7 +500,6 @@ public CoreLibrary(RubyContext context) {
defineModule(truffleModule, "Etc");
psychModule = defineModule("Psych");
psychParserClass = defineClass(psychModule, objectClass, "Parser");
Layouts.CLASS.setInstanceFactoryUnsafe(psychParserClass, Layouts.PSYCH_PARSER.createParserShape(psychParserClass, psychParserClass));
final DynamicObject psychHandlerClass = defineClass(psychModule, objectClass, "Handler");
final DynamicObject psychEmitterClass = defineClass(psychModule, psychHandlerClass, "Emitter");
Layouts.CLASS.setInstanceFactoryUnsafe(psychEmitterClass, Layouts.PSYCH_EMITTER.createEmitterShape(psychEmitterClass, psychEmitterClass));
3 changes: 0 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/core/Layouts.java
Original file line number Diff line number Diff line change
@@ -82,8 +82,6 @@
import org.jruby.truffle.stdlib.BigDecimalLayoutImpl;
import org.jruby.truffle.stdlib.psych.EmitterLayout;
import org.jruby.truffle.stdlib.psych.EmitterLayoutImpl;
import org.jruby.truffle.stdlib.psych.ParserLayout;
import org.jruby.truffle.stdlib.psych.ParserLayoutImpl;

public abstract class Layouts {

@@ -122,7 +120,6 @@ public abstract class Layouts {
public static final TimeLayout TIME = TimeLayoutImpl.INSTANCE;
public static final UnboundMethodLayout UNBOUND_METHOD = UnboundMethodLayoutImpl.INSTANCE;
public static final WeakRefLayout WEAK_REF_LAYOUT = WeakRefLayoutImpl.INSTANCE;
public static final ParserLayout PSYCH_PARSER = ParserLayoutImpl.INSTANCE;
public static final EmitterLayout PSYCH_EMITTER = EmitterLayoutImpl.INSTANCE;
public static final RandomizerLayout RANDOMIZER = RandomizerLayoutImpl.INSTANCE;
public static final AtomicReferenceLayout ATOMIC_REFERENCE = AtomicReferenceLayoutImpl.INSTANCE;
Original file line number Diff line number Diff line change
@@ -61,9 +61,7 @@
import org.jruby.truffle.language.objects.AllocateObjectNode;
import org.jruby.truffle.language.objects.AllocateObjectNodeGen;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.truffle.stdlib.sockets.FDSet;
import org.jruby.truffle.stdlib.sockets.FDSetFactory;
import org.jruby.truffle.stdlib.sockets.FDSetFactoryFactory;
import org.jruby.truffle.platform.posix.FDSet;
import org.jruby.util.ByteList;
import org.jruby.util.Dir;
import org.jruby.util.unsafe.UnsafeHolder;
@@ -250,8 +248,6 @@ public DynamicObject ensureOpen(VirtualFrame frame, DynamicObject file) {
@RubiniusPrimitive(name = "io_read_if_available", lowerFixnumParameters = 0, unsafe = UnsafeGroup.IO)
public static abstract class IOReadIfAvailableNode extends RubiniusPrimitiveArrayArgumentsNode {

private static final FDSetFactory fdSetFactory = FDSetFactoryFactory.create();

public IOReadIfAvailableNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -267,7 +263,7 @@ public Object readIfAvailable(DynamicObject file, int numberOfBytes) {

final int fd = Layouts.IO.getDescriptor(file);

final FDSet fdSet = fdSetFactory.create();
final FDSet fdSet = new FDSet();
fdSet.set(fd);

final Timeval timeoutObject = new DefaultNativeTimeval(jnr.ffi.Runtime.getSystemRuntime());
@@ -573,8 +569,6 @@ public DynamicObject sysread(VirtualFrame frame, DynamicObject file, int length)
@RubiniusPrimitive(name = "io_select", needsSelf = false, lowerFixnumParameters = 3, unsafe = UnsafeGroup.IO)
public static abstract class IOSelectPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

private static final FDSetFactory fdSetFactory = FDSetFactoryFactory.create();

public IOSelectPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -596,7 +590,7 @@ public Object select(DynamicObject readables, DynamicObject writables, DynamicOb
final int[] readableFds = getFileDescriptors(readables);
final int nfds = max(readableFds) + 1;

final FDSet readableSet = fdSetFactory.create();
final FDSet readableSet = new FDSet();

final ThreadManager.ResultOrTimeout<Integer> result = getContext().getThreadManager().runUntilTimeout(this, timeoutMicros, new ThreadManager.BlockingTimeoutAction<Integer>() {
@Override
@@ -651,7 +645,7 @@ public Object selectNilReadables(DynamicObject readables, DynamicObject writable
final int[] writableFds = getFileDescriptors(writables);
final int nfds = max(writableFds) + 1;

final FDSet writableSet = fdSetFactory.create();
final FDSet writableSet = new FDSet();


final int result = getContext().getThreadManager().runUntilResult(this, new ThreadManager.BlockingAction<Integer>() {
Original file line number Diff line number Diff line change
@@ -8,23 +8,22 @@
* GNU Lesser General Public License version 2.1
*/

package org.jruby.truffle.stdlib.sockets;
package org.jruby.truffle.platform.posix;

import jnr.ffi.Pointer;

public class LinuxFDSet implements FDSet {
public class FDSet {

private final static int MAX_FDS = 1024;
private final static int FIELD_SIZE_IN_BYTES = 4;
private final static int FIELD_SIZE_IN_BITS = FIELD_SIZE_IN_BYTES * 8;

private final Pointer bitmap;

public LinuxFDSet() {
public FDSet() {
bitmap = jnr.ffi.Runtime.getSystemRuntime().getMemoryManager().allocateDirect(MAX_FDS / 8);
}

@Override
public void set(int fd) {
checkBounds(fd);

@@ -33,14 +32,12 @@ public void set(int fd) {
bitmap.putInt(offset, bitmap.getInt(offset) | bitmapElementMask(fd));
}

@Override
public boolean isSet(int fd) {
checkBounds(fd);

return (bitmap.getInt(bitmapAddressOffset(fd)) & bitmapElementMask(fd)) != 0;
}

@Override
public Pointer getPointer() {
return bitmap;
}
Original file line number Diff line number Diff line change
@@ -19,12 +19,14 @@
@Layout
public interface BigDecimalLayout extends BasicObjectLayout {

DynamicObjectFactory createBigDecimalShape(DynamicObject logicalClass,
DynamicObject metaClass);

DynamicObject createBigDecimal(DynamicObjectFactory factory,
BigDecimal value,
BigDecimalNodes.Type type);
DynamicObjectFactory createBigDecimalShape(
DynamicObject logicalClass,
DynamicObject metaClass);

DynamicObject createBigDecimal(
DynamicObjectFactory factory,
BigDecimal value,
BigDecimalNodes.Type type);

boolean isBigDecimal(DynamicObject object);

10 changes: 6 additions & 4 deletions truffle/src/main/java/org/jruby/truffle/stdlib/DigestLayout.java
Original file line number Diff line number Diff line change
@@ -19,11 +19,13 @@
@Layout
public interface DigestLayout extends BasicObjectLayout {

DynamicObjectFactory createDigestShape(DynamicObject logicalClass,
DynamicObject metaClass);
DynamicObjectFactory createDigestShape(
DynamicObject logicalClass,
DynamicObject metaClass);

DynamicObject createDigest(DynamicObjectFactory factory,
MessageDigest digest);
DynamicObject createDigest(
DynamicObjectFactory factory,
MessageDigest digest);

MessageDigest getDigest(DynamicObject object);

Original file line number Diff line number Diff line change
@@ -13,13 +13,15 @@
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.specific.ASCIIEncoding;
import org.jruby.ext.digest.BubbleBabble;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.CoreClass;
import org.jruby.truffle.core.CoreMethod;
import org.jruby.truffle.core.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.rope.BytesVisitor;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.string.StringOperations;
@@ -202,7 +204,8 @@ public DynamicObject digest(DynamicObject digestObject) {
throw new RuntimeException(e);
}

return createString(new ByteList(clonedDigest.digest()));
return createString(RopeOperations.create(
clonedDigest.digest(), ASCIIEncoding.INSTANCE, CodeRange.CR_VALID));
}

}
@@ -233,7 +236,6 @@ public BubbleBabbleNode(RubyContext context, SourceSection sourceSection) {
@Specialization(guards = "isRubyString(message)")
public DynamicObject bubblebabble(DynamicObject message) {
final Rope rope = StringOperations.rope(message);

return createString(BubbleBabble.bubblebabble(rope.getBytes(), rope.begin(), rope.byteLength()));
}

Original file line number Diff line number Diff line change
@@ -20,13 +20,15 @@
@Layout
public interface EmitterLayout extends BasicObjectLayout {

DynamicObjectFactory createEmitterShape(DynamicObject logicalClass,
DynamicObject metaClass);

DynamicObject createEmitter(DynamicObjectFactory factory,
@Nullable Emitter emitter,
@Nullable DumperOptions options,
@Nullable Object io);
DynamicObjectFactory createEmitterShape(
DynamicObject logicalClass,
DynamicObject metaClass);

DynamicObject createEmitter(
DynamicObjectFactory factory,
@Nullable Emitter emitter,
@Nullable DumperOptions options,
@Nullable Object io);

boolean isEmitter(DynamicObject object);

This file was deleted.

Original file line number Diff line number Diff line change
@@ -148,8 +148,6 @@ private Object doParse(DynamicObject parserObject, DynamicObject yaml, DynamicOb

Parser parser = new ParserImpl(streamReader);
try {
Layouts.PSYCH_PARSER.setParser(parserObject, parser);

if (isNil(path) && (boolean) ruby("yaml.respond_to? :path", "yaml", yaml)) {
path = (DynamicObject) ruby("yaml.path", "yaml", yaml);
}
@@ -158,7 +156,6 @@ private Object doParse(DynamicObject parserObject, DynamicObject yaml, DynamicOb

while (true) {
Event event = parser.getEvent();
Layouts.PSYCH_PARSER.setEvent(parserObject, event);

// FIXME: Event should expose a getID, so it can be switched
if (event.is(Event.ID.StreamStart)) {
@@ -188,21 +185,17 @@ private Object doParse(DynamicObject parserObject, DynamicObject yaml, DynamicOb
}
}
} catch (ParserException pe) {
Layouts.PSYCH_PARSER.setParser(parserObject, null);
raiseParserException(yaml, pe, path);
} catch (ScannerException se) {
Layouts.PSYCH_PARSER.setParser(parserObject, null);
StringBuilder message = new StringBuilder("syntax error");
if (se.getProblemMark() != null) {
message.append(se.getProblemMark().toString());
}
raiseParserException(yaml, se, path);
} catch (ReaderException re) {
Layouts.PSYCH_PARSER.setParser(parserObject, null);
raiseParserException(yaml, re, path);
} catch (Throwable t) {
Helpers.throwException(t);
Layouts.PSYCH_PARSER.setParser(parserObject, null);
return parserObject;
}

22 changes: 0 additions & 22 deletions truffle/src/main/java/org/jruby/truffle/stdlib/sockets/FDSet.java

This file was deleted.

This file was deleted.

This file was deleted.