Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into truffle-head
Browse files Browse the repository at this point in the history
Conflicts:
* truffle/pom.rb
* truffle/pom.xml
* truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
* truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
eregon committed Dec 2, 2015
2 parents 3f28478 + 511b580 commit 2f319b7
Showing 16 changed files with 85 additions and 224 deletions.
17 changes: 5 additions & 12 deletions core/src/main/java/org/jruby/ir/interpreter/InterpreterEngine.java
Original file line number Diff line number Diff line change
@@ -366,27 +366,20 @@ protected static void processCall(ThreadContext context, Instr instr, Operation
protected static void processBookKeepingOp(ThreadContext context, Block block, Instr instr, Operation operation,
String name, IRubyObject[] args, IRubyObject self, Block blockArg, RubyModule implClass,
DynamicScope currDynScope, Object[] temp, StaticScope currScope) {
Block.Type blockType = block == null ? null : block.type;
Frame f;
Visibility viz;
switch(operation) {
case LABEL:
break;
case SAVE_BINDING_VIZ:
viz = block.getBinding().getVisibility();
setResult(temp, currDynScope, ((SaveBindingVisibilityInstr)instr).getResult(), viz);
setResult(temp, currDynScope, ((SaveBindingVisibilityInstr) instr).getResult(), block.getBinding().getVisibility());
break;
case RESTORE_BINDING_VIZ:
viz = (Visibility)retrieveOp(((RestoreBindingVisibilityInstr)instr).getVisibility(), context, self, currDynScope, currScope, temp);
block.getBinding().setVisibility(viz);
block.getBinding().setVisibility((Visibility) retrieveOp(((RestoreBindingVisibilityInstr) instr).getVisibility(), context, self, currDynScope, currScope, temp));
break;
case PUSH_BLOCK_FRAME:
f = context.preYieldNoScope(block.getBinding());
setResult(temp, currDynScope, ((PushBlockFrameInstr)instr).getResult(), f);
setResult(temp, currDynScope, ((PushBlockFrameInstr) instr).getResult(), context.preYieldNoScope(block.getBinding()));
break;
case POP_BLOCK_FRAME:
f = (Frame)retrieveOp(((PopBlockFrameInstr)instr).getFrame(), context, self, currDynScope, currScope, temp);
context.postYieldNoScope(f);
context.postYieldNoScope((Frame) retrieveOp(((PopBlockFrameInstr)instr).getFrame(), context, self, currDynScope, currScope, temp));
break;
case PUSH_METHOD_FRAME:
context.preMethodFrameOnly(implClass, name, self, blockArg);
@@ -406,7 +399,7 @@ protected static void processBookKeepingOp(ThreadContext context, Block block, I
context.callThreadPoll();
break;
case CHECK_ARITY:
((CheckArityInstr)instr).checkArity(context, args, blockType);
((CheckArityInstr) instr).checkArity(context, args, block == null ? null : block.type);
break;
case LINE_NUM:
context.setLine(((LineNumberInstr)instr).lineNumber);
2 changes: 1 addition & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -427,7 +427,7 @@ def bench(command, *args)
"JRUBY_9000_DEV_DIR" => JRUBY_DIR,
"GRAAL_BIN" => Utilities.find_graal,
}
bench_args = ["-I#{bench_dir}/lib", "#{bench_dir}/bin/bench"]
bench_args = ["#{bench_dir}/bin/bench"]
case command
when 'debug'
if args.delete '--ruby-backtrace'
3 changes: 2 additions & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -43,7 +43,8 @@
:phase => 'compile',
'annotationProcessors' => [ 'org.jruby.truffle.om.dsl.processor.OMProcessor',
'com.oracle.truffle.dsl.processor.TruffleProcessor',
'com.oracle.truffle.dsl.processor.LanguageRegistrationProcessor' ],
'com.oracle.truffle.dsl.processor.verify.VerifyTruffleProcessor',
'com.oracle.truffle.dsl.processor.LanguageRegistrationProcessor' ],
'generatedSourcesDirectory' => 'target/generated-sources',
'compilerArgs' => [ '-XDignore.symbol.file=true',
'-J-Duser.language=en',
1 change: 1 addition & 0 deletions truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@ DO NOT MODIFIY - GENERATED CODE
<annotationProcessors>
<annotationProcessor>org.jruby.truffle.om.dsl.processor.OMProcessor</annotationProcessor>
<annotationProcessor>com.oracle.truffle.dsl.processor.TruffleProcessor</annotationProcessor>
<annotationProcessor>com.oracle.truffle.dsl.processor.verify.VerifyTruffleProcessor</annotationProcessor>
<annotationProcessor>com.oracle.truffle.dsl.processor.LanguageRegistrationProcessor</annotationProcessor>
</annotationProcessors>
<generatedSourcesDirectory>target/generated-sources</generatedSourcesDirectory>
Original file line number Diff line number Diff line change
@@ -15,13 +15,11 @@
import com.oracle.truffle.api.dsl.ImportStatic;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.dispatch.DoesRespondDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.RespondToNode;
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNode;
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNodeGen;
import org.jruby.truffle.runtime.ModuleOperations;
@@ -69,14 +67,7 @@ public DynamicObject id2Ref(
final long id,
@Cached("createReadObjectIDNode()") ReadHeadObjectFieldNode readObjectIdNode) {
for (DynamicObject object : ObjectGraph.stopAndGetAllObjects(this, getContext())) {
final long objectID;

try {
objectID = readObjectIdNode.executeLong(object);
} catch (UnexpectedResultException e) {
throw new UnsupportedOperationException(e);
}

final long objectID = (long) readObjectIdNode.execute(object);
if (objectID == id) {
return object;
}
Original file line number Diff line number Diff line change
@@ -39,9 +39,13 @@
package org.jruby.truffle.nodes.ext.psych;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;

import org.jcodings.Encoding;
import org.jcodings.specific.UTF16BEEncoding;
import org.jcodings.specific.UTF16LEEncoding;
@@ -50,6 +54,8 @@
import org.jruby.RubyEncoding;
import org.jruby.runtime.Helpers;
import org.jruby.truffle.nodes.RubyGuards;
import org.jruby.truffle.nodes.coerce.ToStrNode;
import org.jruby.truffle.nodes.coerce.ToStrNodeGen;
import org.jruby.truffle.nodes.core.CoreClass;
import org.jruby.truffle.nodes.core.CoreMethod;
import org.jruby.truffle.nodes.core.CoreMethodArrayArgumentsNode;
@@ -58,11 +64,9 @@
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.adapaters.InputStreamAdapter;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.StringOperations;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;
import org.jruby.util.io.EncodingUtils;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.error.Mark;
@@ -117,28 +121,29 @@ public DynamicObject allocate(DynamicObject rubyClass) {
@CoreMethod(names = "parse", required = 1, optional = 1)
public abstract static class ParseNode extends CoreMethodArrayArgumentsNode {

@Node.Child private ToStrNode toStrNode;

public ParseNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
toStrNode = ToStrNodeGen.create(getContext(), getSourceSection(), null);
}

@Specialization
public Object parse(DynamicObject parserObject, DynamicObject yaml, NotProvided path) {
return doParse(parserObject, yaml, nil());
public Object parse(VirtualFrame frame, DynamicObject parserObject, DynamicObject yaml, NotProvided path) {
return parse(frame, parserObject, yaml, nil());
}

@Specialization
public Object parse(DynamicObject parserObject, DynamicObject yaml, DynamicObject path) {
return doParse(parserObject, yaml, path);
public Object parse(VirtualFrame frame, DynamicObject parserObject, DynamicObject yaml, DynamicObject path) {
return doParse(parserObject, yaml, path, readerFor(frame, yaml));
}

@CompilerDirectives.TruffleBoundary
private Object doParse(DynamicObject parserObject, DynamicObject yaml, DynamicObject path) {
@TruffleBoundary
private Object doParse(DynamicObject parserObject, DynamicObject yaml, DynamicObject path, StreamReader streamReader) {
boolean tainted = (boolean) ruby("yaml.tainted? || yaml.is_a?(IO)", "yaml", yaml);

Parser parser = null;

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

if (isNil(path) && (boolean) ruby("yaml.respond_to? :path", "yaml", yaml)) {
@@ -200,42 +205,36 @@ private Object doParse(DynamicObject parserObject, DynamicObject yaml, DynamicOb
return parserObject;
}

private StreamReader readerFor(DynamicObject yaml) {
if (RubyGuards.isRubyString(yaml)) {
ByteList byteList = StringOperations.getByteList(yaml);
Encoding enc = byteList.getEncoding();

// if not unicode, transcode to UTF8
if (!(enc instanceof UnicodeEncoding)) {
byteList = EncodingUtils.strConvEnc(getContext().getRuntime().getCurrentContext(), byteList, enc, UTF8Encoding.INSTANCE);
enc = UTF8Encoding.INSTANCE;
}

ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize());

Charset charset = enc.getCharset();

assert charset != null : "charset for encoding " + enc + " should not be null";

InputStreamReader isr = new InputStreamReader(bais, charset);

return new StreamReader(isr);
}

private StreamReader readerFor(VirtualFrame frame, DynamicObject yaml) {
// fall back on IOInputStream, using default charset
if ((boolean) ruby("yaml.respond_to? :read", "yaml", yaml)) {
if (!RubyGuards.isRubyString(yaml) && (boolean) ruby("yaml.respond_to? :read", "yaml", yaml)) {
//final boolean isIO = (boolean) ruby("yaml.is_a? IO", "yaml", yaml);
//Encoding enc = isIO
// ? UTF8Encoding.INSTANCE // ((RubyIO)yaml).getReadEncoding()
// : UTF8Encoding.INSTANCE;
final Encoding enc = UTF8Encoding.INSTANCE;
Charset charset = enc.getCharset();
return new StreamReader(new InputStreamReader(new InputStreamAdapter(getContext(), yaml), charset));
} else {
// TODO CS 28-Sep-15 implement this code path
throw new UnsupportedOperationException();
//throw runtime.newTypeError(yaml, runtime.getIO());
}

ByteList byteList = StringOperations.getByteList(toStrNode.coerceObject(frame, yaml));
Encoding enc = byteList.getEncoding();

// if not unicode, transcode to UTF8
if (!(enc instanceof UnicodeEncoding)) {
byteList = EncodingUtils.strConvEnc(getContext().getRuntime().getCurrentContext(), byteList, enc, UTF8Encoding.INSTANCE);
enc = UTF8Encoding.INSTANCE;
}

ByteArrayInputStream bais = new ByteArrayInputStream(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize());

Charset charset = enc.getCharset();

assert charset != null : "charset for encoding " + enc + " should not be null";

InputStreamReader isr = new InputStreamReader(bais, charset);

return new StreamReader(isr);
}

private void handleDocumentStart(DocumentStartEvent dse, boolean tainted, Object handler) {
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
@@ -54,11 +53,7 @@ public boolean isFrozen(double object) {
@Specialization
protected boolean isFrozen(DynamicObject object,
@Cached("createReadFrozenNode()") ReadHeadObjectFieldNode readFrozenNode) {
try {
return readFrozenNode.executeBoolean(object);
} catch (UnexpectedResultException e) {
throw new UnsupportedOperationException(e);
}
return (boolean) readFrozenNode.execute(object);
}

protected ReadHeadObjectFieldNode createReadFrozenNode() {
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
@@ -55,11 +54,7 @@ public boolean isTainted(double object) {
@Specialization
protected boolean isTainted(DynamicObject object,
@Cached("createReadTaintedNode()") ReadHeadObjectFieldNode readTaintedNode) {
try {
return readTaintedNode.executeBoolean(object);
} catch (UnexpectedResultException e) {
throw new UnsupportedOperationException(e);
}
return (boolean) readTaintedNode.execute(object);
}

protected ReadHeadObjectFieldNode createReadTaintedNode() {
Original file line number Diff line number Diff line change
@@ -9,22 +9,17 @@
*/
package org.jruby.truffle.nodes.objects;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Property;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNode;
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNodeGen;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.StringOperations;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.util.StringSupport;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;

public class ReadInstanceVariableNode extends RubyNode {

@@ -39,48 +34,6 @@ public ReadInstanceVariableNode(RubyContext context, SourceSection sourceSection
readNode = ReadHeadObjectFieldNodeGen.create(name, nil());
}

@Override
public int executeInteger(VirtualFrame frame) throws UnexpectedResultException {
final Object receiverObject = receiver.execute(frame);

if (receiverObject instanceof DynamicObject) {
return readNode.executeInteger((DynamicObject) receiverObject);
} else {
// TODO(CS): need to put this onto the fast path?

CompilerDirectives.transferToInterpreter();
throw new UnexpectedResultException(nil());
}
}

@Override
public long executeLong(VirtualFrame frame) throws UnexpectedResultException {
final Object receiverObject = receiver.execute(frame);

if (receiverObject instanceof DynamicObject) {
return readNode.executeLong((DynamicObject) receiverObject);
} else {
// TODO(CS): need to put this onto the fast path?

CompilerDirectives.transferToInterpreter();
throw new UnexpectedResultException(nil());
}
}

@Override
public double executeDouble(VirtualFrame frame) throws UnexpectedResultException {
final Object receiverObject = receiver.execute(frame);

if (receiverObject instanceof DynamicObject) {
return readNode.executeDouble((DynamicObject) receiverObject);
} else {
// TODO(CS): need to put this onto the fast path?

CompilerDirectives.transferToInterpreter();
throw new UnexpectedResultException(nil());
}
}

@Override
public Object execute(VirtualFrame frame) {
final Object receiverObject = receiver.execute(frame);
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.*;

import org.jruby.truffle.runtime.Options;
@@ -31,58 +30,12 @@ public Object getName() {
return name;
}

public abstract boolean executeBoolean(DynamicObject object) throws UnexpectedResultException;
public abstract int executeInteger(DynamicObject object) throws UnexpectedResultException;
public abstract long executeLong(DynamicObject object) throws UnexpectedResultException;
public abstract double executeDouble(DynamicObject object) throws UnexpectedResultException;

public abstract Object execute(DynamicObject object);

@Specialization(
guards = { "location != null", "receiver.getShape() == cachedShape" },
assumptions = "cachedShape.getValidAssumption()",
limit = "getCacheLimit()")
protected boolean readBooleanObjectFieldCached(DynamicObject receiver,
@Cached("receiver.getShape()") Shape cachedShape,
@Cached("getBooleanLocation(cachedShape)") BooleanLocation location) {
return location.getBoolean(receiver, cachedShape);
}

@Specialization(
guards = { "location != null", "receiver.getShape() == cachedShape" },
assumptions = "cachedShape.getValidAssumption()",
limit = "getCacheLimit()")
protected int readIntObjectFieldCached(DynamicObject receiver,
@Cached("receiver.getShape()") Shape cachedShape,
@Cached("getIntLocation(cachedShape)") IntLocation location) {
return location.getInt(receiver, cachedShape);
}

@Specialization(
guards = { "location != null", "receiver.getShape() == cachedShape" },
assumptions = "cachedShape.getValidAssumption()",
limit = "getCacheLimit()")
protected long readLongObjectFieldCached(DynamicObject receiver,
@Cached("receiver.getShape()") Shape cachedShape,
@Cached("getLongLocation(cachedShape)") LongLocation location) {
return location.getLong(receiver, cachedShape);
}

@Specialization(
guards = { "location != null", "receiver.getShape() == cachedShape" },
assumptions = "cachedShape.getValidAssumption()",
limit = "getCacheLimit()")
protected double readDoubleObjectFieldCached(DynamicObject receiver,
@Cached("receiver.getShape()") Shape cachedShape,
@Cached("getDoubleLocation(cachedShape)") DoubleLocation location) {
return location.getDouble(receiver, cachedShape);
}

@Specialization(
guards = "receiver.getShape() == cachedShape",
assumptions = "cachedShape.getValidAssumption()",
limit = "getCacheLimit()",
contains = { "readBooleanObjectFieldCached", "readIntObjectFieldCached", "readLongObjectFieldCached", "readDoubleObjectFieldCached" })
limit = "getCacheLimit()")
protected Object readObjectFieldCached(DynamicObject receiver,
@Cached("receiver.getShape()") Shape cachedShape,
@Cached("cachedShape.getProperty(name)") Property property) {
@@ -96,45 +49,7 @@ protected Object readObjectFieldCached(DynamicObject receiver,
@TruffleBoundary
@Specialization
protected Object readObjectFieldUncached(DynamicObject receiver) {
final Shape shape = receiver.getShape();
final Property property = shape.getProperty(name);
if (property != null) {
return property.get(receiver, shape);
} else {
return defaultValue;
}
}

protected BooleanLocation getBooleanLocation(Shape shape) {
final Property property = shape.getProperty(name);
if (property != null && property.getLocation() instanceof BooleanLocation) {
return (BooleanLocation) property.getLocation();
}
return null;
}

protected IntLocation getIntLocation(Shape shape) {
final Property property = shape.getProperty(name);
if (property != null && property.getLocation() instanceof IntLocation) {
return (IntLocation) property.getLocation();
}
return null;
}

protected LongLocation getLongLocation(Shape shape) {
final Property property = shape.getProperty(name);
if (property != null && property.getLocation() instanceof LongLocation) {
return (LongLocation) property.getLocation();
}
return null;
}

protected DoubleLocation getDoubleLocation(Shape shape) {
final Property property = shape.getProperty(name);
if (property != null && property.getLocation() instanceof DoubleLocation) {
return (DoubleLocation) property.getLocation();
}
return null;
return receiver.get(name, defaultValue);
}

protected int getCacheLimit() {
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;
@@ -87,12 +86,7 @@ public Object objectID(double value) {
public long objectID(DynamicObject object,
@Cached("createReadObjectIDNode()") ReadHeadObjectFieldNode readObjectIdNode,
@Cached("createWriteObjectIDNode()") WriteHeadObjectFieldNode writeObjectIdNode) {
final long id;
try {
id = readObjectIdNode.executeLong(object);
} catch (UnexpectedResultException e) {
throw new UnsupportedOperationException(e);
}
final long id = (long) readObjectIdNode.execute(object);

if (id == 0) {
final long newId = getContext().getNextObjectID();
Original file line number Diff line number Diff line change
@@ -29,10 +29,8 @@ public class RubyObjectType extends ObjectType {
public String toString(DynamicObject object) {
CompilerAsserts.neverPartOfCompilation();

final RubyContext context = getContext();

if (RubyGuards.isRubyString(object)) {
return Helpers.decodeByteList(context.getRuntime(), StringOperations.getByteList(object));
return Helpers.decodeByteList(getContext().getRuntime(), StringOperations.getByteList(object));
} else if (RubyGuards.isRubySymbol(object)) {
return Layouts.SYMBOL.getString(object);
} else if (RubyGuards.isRubyException(object)) {
Original file line number Diff line number Diff line change
@@ -1197,7 +1197,7 @@ public DynamicObject loadError(String message, String path, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
DynamicObject messageString = StringOperations.createString(context, StringOperations.encodeByteList(message, UTF8Encoding.INSTANCE));
DynamicObject loadError = ExceptionNodes.createRubyException(context.getCoreLibrary().getLoadErrorClass(), messageString, RubyCallStack.getBacktrace(currentNode));
loadError.define("@path", StringOperations.createString(context, StringOperations.encodeByteList(path, UTF8Encoding.INSTANCE)));
loadError.define("@path", StringOperations.createString(context, StringOperations.encodeByteList(path, UTF8Encoding.INSTANCE)), 0);
return loadError;
}

Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;

import org.jcodings.specific.UTF8Encoding;
import org.joni.NameEntry;
import org.joni.Regex;
import org.joni.Syntax;
@@ -970,6 +971,12 @@ public RubyNode visitConstNode(org.jruby.ast.ConstNode node) {
return addNewlineIfNeeded(node, ret);
}

// TODO (pitr 01-Dec-2015): remove when RUBY_PLATFORM is set to "truffle"
if (name.equals("RUBY_PLATFORM") && sourceSection.getSource().getPath().contains("test/xml_mini/jdom_engine_test.rb")) {
final LiteralNode ret = new LiteralNode(context, sourceSection, StringOperations.createString(context, StringOperations.encodeByteList("truffle", UTF8Encoding.INSTANCE)));
return addNewlineIfNeeded(node, ret);
}

final LexicalScope lexicalScope = environment.getLexicalScope();
final RubyNode ret = new ReadConstantWithLexicalScopeNode(context, sourceSection, lexicalScope, name);
return addNewlineIfNeeded(node, ret);
1 change: 1 addition & 0 deletions truffle/src/main/ruby/core.rb
Original file line number Diff line number Diff line change
@@ -181,6 +181,7 @@ def self.omit(reason)
require_relative 'core/rubinius/common/dir_glob'
require_relative 'core/rubinius/common/file_test'
require_relative 'core/rubinius/common/stat'
require_relative 'core/rubinius/api/shims/stat'
require_relative 'core/rubinius/common/float'
require_relative 'core/rubinius/common/immediate'
#require_relative 'core/rubinius/common/location'
18 changes: 18 additions & 0 deletions truffle/src/main/ruby/core/rubinius/api/shims/stat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2014, 2015 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

class Rubinius::Stat

# Process.groups only return supplemental groups, so we need to check if gid/egid match too.
def grpowned?
gid = gid()
return true if gid == Process.gid || gid == Process.egid
Process.groups.include?(gid)
end

end

0 comments on commit 2f319b7

Please sign in to comment.