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: aec831499ad9
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 36ef8f182222
Choose a head ref
  • 13 commits
  • 8 files changed
  • 3 contributors

Commits on May 24, 2016

  1. Copy the full SHA
    9db924b View commit details
  2. Copy the full SHA
    1577a78 View commit details
  3. Copy the full SHA
    18d3e4e View commit details
  4. Copy the full SHA
    3a58519 View commit details
  5. Copy the full SHA
    1863ad0 View commit details
  6. Copy the full SHA
    65b8816 View commit details
  7. Copy the full SHA
    686392b View commit details
  8. Copy the full SHA
    bdac068 View commit details
  9. [Truffle] Remove fixed TODO.

    eregon committed May 24, 2016
    Copy the full SHA
    09b910b View commit details
  10. Copy the full SHA
    89702f7 View commit details
  11. Copy the full SHA
    ebb2ab7 View commit details
  12. Copy the full SHA
    29b9e75 View commit details
  13. Copy the full SHA
    36ef8f1 View commit details
17 changes: 16 additions & 1 deletion ci.hocon
Original file line number Diff line number Diff line change
@@ -46,6 +46,20 @@ graal-core: {
}
}

graalvm: {
downloads: {
GRAALVM_DIR: {
name: graalvm-snapshot,
version: latest,
platformspecific: true
}
}

environment: {
GRAAL_BIN: "$GRAALVM_DIR/bin/java"
}
}

gate-caps: {
capabilities: [linux, amd64, gate, post-push]
}
@@ -60,5 +74,6 @@ builds: [
{name: ruby-test-integration} ${common} ${gate-caps} {run: [${jt} [test, integration]]},
{name: ruby-test-tck} ${common} ${gate-caps} {run: [${jt} [test, tck]]},
{name: ruby-tarball} ${common} ${gate-caps} {run: [${jt} [tarball]]},
{name: ruby-test-compiler-graal-core} ${common} ${graal-core} ${gate-caps} {run: [${jt} [test, compiler]]}
{name: ruby-test-compiler-graal-core} ${common} ${graal-core} ${gate-caps} {run: [${jt} [test, compiler]]},
{name: ruby-test-compiler-graalvm} ${common} ${graalvm} ${gate-caps} {run: [${jt} [test, compiler]]}
]
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/io/reopen_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
fails:IO#reopen with a String effects exec/system/fork performed after it
fails:IO#reopen with a String opens a path after writing to the original file descriptor
fails:IO#reopen with a String positions an instance that has been read from at the beginning of the new stream
slow:IO#reopen with a String effects exec/system/fork performed after it
slow:IO#reopen with a String affects exec/system/fork performed after it
fails:IO#reopen with a String affects exec/system/fork performed after it
Original file line number Diff line number Diff line change
@@ -338,29 +338,31 @@ public IOReopenPathPrimitiveNode(RubyContext context, SourceSection sourceSectio

@TruffleBoundary(throwsControlFlowException = true)
public void performReopenPath(DynamicObject self, DynamicObject path, int mode) {
int fdSelf = Layouts.IO.getDescriptor(self);
final int fdSelf = Layouts.IO.getDescriptor(self);
final int newFdSelf;
final String targetPathString = StringOperations.getString(getContext(), path);

int fdTarget = ensureSuccessful(posix().open(targetPathString, mode, 666));
int fdTarget = ensureSuccessful(posix().open(targetPathString, mode, 0_666));

final int result = posix().dup2(fdTarget, fdSelf);
if (result == -1) {
final int errno = posix().errno();
if (errno == Errno.EBADF.intValue()) {
Layouts.IO.setDescriptor(self, fdTarget);
fdSelf = fdTarget;
newFdSelf = fdTarget;
} else {
if (fdTarget > 0) {
ensureSuccessful(posix().close(fdTarget));
}
ensureSuccessful(result, errno);
ensureSuccessful(result, errno); // throws
return;
}

} else {
ensureSuccessful(posix().close(fdTarget));
newFdSelf = fdSelf;
}

final int newSelfMode = ensureSuccessful(posix().fcntl(fdSelf, Fcntl.F_GETFL));
final int newSelfMode = ensureSuccessful(posix().fcntl(newFdSelf, Fcntl.F_GETFL));
Layouts.IO.setMode(self, newSelfMode);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2015, 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
*/
package org.jruby.truffle.core.time;

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.object.DynamicObject;
import com.oracle.truffle.api.utilities.CyclicAssumption;
import org.joda.time.DateTimeZone;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.core.time.TimeNodes.TimeZoneParser;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.SnippetNode;

public abstract class GetTimeZoneNode extends RubyNode {

protected static final CyclicAssumption TZ_UNCHANGED = new CyclicAssumption("ENV['TZ'] is unmodified");

public static void invalidateTZ() {
TZ_UNCHANGED.invalidate();
}

@Child SnippetNode snippetNode = new SnippetNode();

public abstract DateTimeZone executeGetTimeZone(VirtualFrame frame);

@Specialization(assumptions = "TZ_UNCHANGED.getAssumption()")
public DateTimeZone getTimeZone(VirtualFrame frame,
@Cached("getTimeZone(frame)") DateTimeZone zone) {
return zone;
}

protected DateTimeZone getTimeZone(VirtualFrame frame) {
Object tz = snippetNode.execute(frame, "ENV['TZ']");

// TODO CS 4-May-15 not sure how TZ ends up being nil

if (tz == nil()) {
return DateTimeZone.getDefault();
} else if (RubyGuards.isRubyString(tz)) {
return TimeZoneParser.parse(this, StringOperations.getString(getContext(), (DynamicObject) tz));
} else {
throw new UnsupportedOperationException();
}
}

}

This file was deleted.

62 changes: 28 additions & 34 deletions truffle/src/main/java/org/jruby/truffle/core/time/TimeNodes.java
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@
*/
package org.jruby.truffle.core.time;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.ExactMath;
import com.oracle.truffle.api.dsl.Cached;
@@ -34,7 +33,6 @@
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyGuards;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.SnippetNode;
import org.jruby.truffle.language.control.RaiseException;
@@ -86,7 +84,8 @@ public abstract static class InternalOffsetNode extends CoreMethodNode {
public Object internalOffset(DynamicObject time) {
final Object offset = Layouts.TIME.getOffset(time);
if (offset == nil()) {
return Layouts.TIME.getDateTime(time).getZone().getOffset(Layouts.TIME.getDateTime(time).getMillis()) / 1_000;
final DateTime dateTime = Layouts.TIME.getDateTime(time);
return dateTime.getZone().getOffset(dateTime.getMillis()) / 1_000;
} else {
return offset;
}
@@ -95,17 +94,17 @@ public Object internalOffset(DynamicObject time) {

@CoreMethod(names = "localtime_internal", optional = 1)
public abstract static class LocalTimeNode extends CoreMethodArrayArgumentsNode {
@Child private ReadTimeZoneNode readTimeZoneNode;

@Child private GetTimeZoneNode getTimeZoneNode;

public LocalTimeNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
readTimeZoneNode = new ReadTimeZoneNode(context, sourceSection);
getTimeZoneNode = GetTimeZoneNodeGen.create();
}

@Specialization
public DynamicObject localtime(VirtualFrame frame, DynamicObject time, NotProvided offset) {
final DynamicObject zoneName = (DynamicObject) readTimeZoneNode.execute(frame);
final DateTimeZone dateTimeZone = TimeZoneParser.parse(this, StringOperations.getString(getContext(), zoneName));
final DateTimeZone dateTimeZone = getTimeZoneNode.executeGetTimeZone(frame);
final String shortZoneName = TimeZoneParser.getShortZoneName(time, dateTimeZone);
final DynamicObject zone = createString(StringOperations.encodeRope(shortZoneName, UTF8Encoding.INSTANCE));
final DateTime dateTime = Layouts.TIME.getDateTime(time);
@@ -219,36 +218,34 @@ public DynamicObject allocate(DynamicObject rubyClass) {
public static abstract class TimeSNowPrimitiveNode extends PrimitiveArrayArgumentsNode {

@Child private AllocateObjectNode allocateObjectNode;
@Child private ReadTimeZoneNode readTimeZoneNode;
@Child private GetTimeZoneNode getTimeZoneNode;

public TimeSNowPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
allocateObjectNode = AllocateObjectNodeGen.create(context, sourceSection, null, null);
readTimeZoneNode = new ReadTimeZoneNode(context, sourceSection);
getTimeZoneNode = GetTimeZoneNodeGen.create();
}

@Specialization
public DynamicObject timeSNow(VirtualFrame frame, DynamicObject timeClass) {
// TODO CS 4-Mar-15 whenever we get time we have to convert lookup and time zone to a string and look it up - need to cache somehow...
return allocateObjectNode.allocate(timeClass, now((DynamicObject) readTimeZoneNode.execute(frame)), 0, nil(), nil(), false, false);
return allocateObjectNode.allocate(timeClass, now(getTimeZoneNode.executeGetTimeZone(frame)), 0, nil(), nil(), false, false);
}

@TruffleBoundary
private DateTime now(DynamicObject timeZone) {
assert RubyGuards.isRubyString(timeZone);
return DateTime.now(TimeZoneParser.parse(this, StringOperations.getString(getContext(), timeZone)));
private DateTime now(DateTimeZone timeZone) {
return DateTime.now(timeZone);
}

}

@Primitive(name = "time_s_specific", needsSelf = false, lowerFixnumParameters = { 1 })
public static abstract class TimeSSpecificPrimitiveNode extends PrimitiveArrayArgumentsNode {

@Child private ReadTimeZoneNode readTimeZoneNode;
@Child private GetTimeZoneNode getTimeZoneNode;

public TimeSSpecificPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
readTimeZoneNode = new ReadTimeZoneNode(context, sourceSection);
getTimeZoneNode = GetTimeZoneNodeGen.create();
}

@Specialization(guards = { "isUTC" })
@@ -261,7 +258,8 @@ public DynamicObject timeSSpecificUTC(long seconds, int nanoseconds, boolean isU
public DynamicObject timeSSpecific(VirtualFrame frame, long seconds, int nanoseconds, boolean isUTC, Object offset) {
final long milliseconds = getMillis(seconds, nanoseconds);
return Layouts.TIME.createTime(coreLibrary().getTimeFactory(),
localtime(milliseconds, (DynamicObject) readTimeZoneNode.execute(frame)), nanoseconds % 1_000_000, nil(), offset, false, isUTC);
localtime(milliseconds, getTimeZoneNode.executeGetTimeZone(frame)),
nanoseconds % 1_000_000, nil(), offset, false, isUTC);
}

@Specialization(guards = { "!isUTC" })
@@ -291,9 +289,8 @@ private DateTime offsetTime(long milliseconds, long offset) {
}

@TruffleBoundary
private DateTime localtime(long milliseconds, DynamicObject zoneName) {
assert RubyGuards.isRubyString(zoneName);
return new DateTime(milliseconds, TimeZoneParser.parse(this, StringOperations.getString(getContext(), zoneName)));
private DateTime localtime(long milliseconds, DateTimeZone timeZone) {
return new DateTime(milliseconds, timeZone);
}

}
@@ -322,11 +319,8 @@ public long timeUSeconds(DynamicObject time) {
@Primitive(name = "time_decompose")
public static abstract class TimeDecomposePrimitiveNode extends PrimitiveArrayArgumentsNode {

@Child private ReadTimeZoneNode readTimeZoneNode;

public TimeDecomposePrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
readTimeZoneNode = new ReadTimeZoneNode(context, sourceSection);
}

@TruffleBoundary
@@ -384,12 +378,12 @@ public DynamicObject timeStrftime(DynamicObject time, DynamicObject format) {
@Primitive(name = "time_s_from_array", needsSelf = true, lowerFixnumParameters = { 0 /*sec*/, 1 /* min */, 2 /* hour */, 3 /* mday */, 4 /* month */, 5 /* year */, 6 /*nsec*/, 7 /*isdst*/ })
public static abstract class TimeSFromArrayPrimitiveNode extends PrimitiveArrayArgumentsNode {

@Child ReadTimeZoneNode readTimeZoneNode;
@Child GetTimeZoneNode getTimeZoneNode;
@Child AllocateObjectNode allocateObjectNode;

public TimeSFromArrayPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
readTimeZoneNode = new ReadTimeZoneNode(context, sourceSection);
getTimeZoneNode = GetTimeZoneNodeGen.create();
allocateObjectNode = AllocateObjectNodeGen.create(context, sourceSection, null, null);
}

@@ -398,25 +392,25 @@ public DynamicObject timeSFromArray(VirtualFrame frame, DynamicObject timeClass,
int nsec, int isdst, boolean fromutc, DynamicObject utcoffset,
@Cached("new()") SnippetNode snippetNode) {

DynamicObject envZon = null;
DateTimeZone envZone = null;
if (!fromutc && utcoffset == nil()) {
envZon = (DynamicObject) readTimeZoneNode.execute(frame);
envZone = getTimeZoneNode.executeGetTimeZone(frame);
}

final int millis = cast(snippetNode.execute(frame, "(offset * 1000).to_i", "offset", utcoffset));

return buildTime(timeClass, sec, min, hour, mday, month, year, nsec, isdst, fromutc, utcoffset, envZon, millis);
return buildTime(timeClass, sec, min, hour, mday, month, year, nsec, isdst, fromutc, utcoffset, envZone, millis);
}

@Specialization(guards = "(fromutc || !isDynamicObject(utcoffset)) || isNil(utcoffset)")
public DynamicObject timeSFromArray(VirtualFrame frame, DynamicObject timeClass, int sec, int min, int hour, int mday, int month, int year,
int nsec, int isdst, boolean fromutc, Object utcoffset) {

DynamicObject envZon = null;
DateTimeZone envZone = null;
if (!fromutc && utcoffset == nil()) {
envZon = (DynamicObject) readTimeZoneNode.execute(frame);
envZone = getTimeZoneNode.executeGetTimeZone(frame);
}
return buildTime(timeClass, sec, min, hour, mday, month, year, nsec, isdst, fromutc, utcoffset, envZon, -1);
return buildTime(timeClass, sec, min, hour, mday, month, year, nsec, isdst, fromutc, utcoffset, envZone, -1);
}

@Specialization(guards = "!isInteger(sec) || !isInteger(nsec)")
@@ -427,7 +421,7 @@ public DynamicObject timeSFromArrayFallback(VirtualFrame frame, DynamicObject ti

@TruffleBoundary
private DynamicObject buildTime(DynamicObject timeClass, int sec, int min, int hour, int mday, int month, int year,
int nsec, int isdst, boolean fromutc, Object utcoffset, DynamicObject envZon, int millis) {
int nsec, int isdst, boolean fromutc, Object utcoffset, DateTimeZone envZone, int millis) {
if (sec < 0 || sec > 59 ||
min < 0 || min > 59 ||
hour < 0 || hour > 23 ||
@@ -453,7 +447,7 @@ private DynamicObject buildTime(DynamicObject timeClass, int sec, int min, int h
relativeOffset = false;
zoneToStore = nil();
} else if (utcoffset == nil()) {
zone = TimeZoneParser.parse(this, StringOperations.getString(getContext(), envZon));
zone = envZone;
// TODO BJF 16-Feb-2016 verify which zone the following date time should be in
final String zoneName = TimeZoneParser.getShortZoneName(dt.withZoneRetainFields(zone), zone);
zoneToStore = createString(StringOperations.encodeRope(zoneName, UTF8Encoding.INSTANCE));
@@ -594,7 +588,7 @@ public static String getShortZoneName(DateTime dateTime, DateTimeZone zone) {
return zone.getShortName(dateTime.getMillis());
}

@TruffleBoundary
@TruffleBoundary(throwsControlFlowException = true)
public static DateTimeZone parse(RubyNode node, String zone) {
String upZone = zone.toUpperCase(Locale.ENGLISH);

Loading