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: 53109c5f99af
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 131f64cdf8df
Choose a head ref
  • 16 commits
  • 19 files changed
  • 5 contributors

Commits on Apr 25, 2016

  1. 8
    Copy the full SHA
    5ade4ed View commit details
  2. Copy the full SHA
    1b05d58 View commit details
  3. Copy the full SHA
    5928283 View commit details
  4. Copy the full SHA
    163dc2f View commit details
  5. Copy the full SHA
    16f5cf9 View commit details
  6. Copy the full SHA
    01ade30 View commit details
  7. Copy the full SHA
    7aec008 View commit details

Commits on Apr 26, 2016

  1. Copy the full SHA
    e8aed55 View commit details
  2. Copy the full SHA
    1dff0b5 View commit details
  3. Copy the full SHA
    ea79fdc View commit details
  4. [Truffle] Use a recursive execute over calling another specialization…

    … directly when coercing.
    eregon committed Apr 26, 2016
    3
    Copy the full SHA
    bd8c92e View commit details
  5. [Truffle] Use ArrayStrategy in Array#pop and cleanup.

    * Saves about 300 lines!
    eregon committed Apr 26, 2016
    Copy the full SHA
    7f3da89 View commit details
  6. Copy the full SHA
    06b8e76 View commit details
  7. Copy the full SHA
    97a9221 View commit details
  8. Merge branch 'master' into truffle-head

    # Conflicts:
    #	truffle/pom.rb
    #	truffle/pom.xml
    chrisseaton committed Apr 26, 2016
    Copy the full SHA
    81f5776 View commit details
  9. Copy the full SHA
    131f64c View commit details
11 changes: 10 additions & 1 deletion lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ extern "C" {
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <math.h>

#define xmalloc malloc
#define xfree free
@@ -44,7 +45,8 @@ VALUE get_rb_cHash();

VALUE get_rb_eRuntimeError();

#define rb_eRuntimeError get_rb_eRuntimeError();
#define rb_eRuntimeError get_rb_eRuntimeError()


int NUM2INT(VALUE value);
unsigned int NUM2UINT(VALUE value);
@@ -63,9 +65,13 @@ VALUE LONG2FIX(long value);

int FIXNUM_P(VALUE value);

VALUE rb_float_new(double value);

char *RSTRING_PTR(VALUE string);
int RSTRING_LEN(VALUE string);
ID rb_intern(const char *string);
VALUE rb_str_new2(const char *string);
VALUE ID2SYM(ID id);
VALUE rb_intern_str(VALUE string);
void rb_str_cat(VALUE string, char *to_concat, long length);

@@ -77,7 +83,10 @@ VALUE rb_ary_new();
void rb_ary_push(VALUE array, VALUE value);
void rb_ary_store(VALUE array, long index, VALUE value);
VALUE rb_ary_entry(VALUE array, long index);
int RARRAY_LENINT(VALUE array);
VALUE rb_ary_dup(VALUE array);

VALUE rb_hash_new();
VALUE rb_hash_aref(VALUE hash, VALUE key);
void rb_hash_aset(VALUE hash, VALUE key, VALUE value);

Binary file modified lib/ruby/truffle/cext/ruby.su
Binary file not shown.
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/bignum/right_shift_tags.txt

This file was deleted.

2 changes: 1 addition & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

properties( 'polyglot.dump.pom' => 'pom.xml',
'polyglot.dump.readonly' => true,
'truffle.version' => 'd0afa11d368d07000b5ec8c9e23494798a175ef1-SNAPSHOT',
'truffle.version' => '778ac8a3d9810e4d1a51a7b61d6de055065c8726-SNAPSHOT',
'jruby.basedir' => '${basedir}/..' )

jar 'org.yaml:snakeyaml:1.14'
2 changes: 1 addition & 1 deletion truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ DO NOT MODIFIY - GENERATED CODE
<jruby.basedir>${basedir}/..</jruby.basedir>
<polyglot.dump.readonly>true</polyglot.dump.readonly>
<polyglot.dump.pom>pom.xml</polyglot.dump.pom>
<truffle.version>d0afa11d368d07000b5ec8c9e23494798a175ef1-SNAPSHOT</truffle.version>
<truffle.version>778ac8a3d9810e4d1a51a7b61d6de055065c8726-SNAPSHOT</truffle.version>
</properties>
<dependencies>
<dependency>
24 changes: 24 additions & 0 deletions truffle/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
@@ -95,6 +95,10 @@ int FIXNUM_P(VALUE value) {
return truffle_invoke_i(ruby_cext, "fixnum?", value);
}

VALUE rb_float_new(double value) {
return (VALUE) truffle_invoke(ruby_cext, "float_new", value);
}

char *RSTRING_PTR(VALUE string) {
// Needs to return a fake char* which actually calls back into Ruby when read or written
return (char*) truffle_invoke(ruby_cext, "string_ptr", string);
@@ -104,14 +108,26 @@ int RSTRING_LEN(VALUE string) {
return truffle_get_size(string);
}

VALUE rb_ary_dup(VALUE array) {
return (VALUE) truffle_invoke(array, "dup");
}

ID rb_intern(const char *string) {
return (ID) truffle_invoke(ruby_cext, "intern", string);
}

VALUE rb_str_new2(const char *string) {
return (VALUE) truffle_invoke(ruby_cext, "str_new2", string);
}

VALUE rb_intern_str(VALUE string) {
return (VALUE) truffle_invoke(ruby_cext, "intern", string);
}

VALUE ID2SYM(ID id) {
return truffle_invoke(ruby_cext, "id2sym", id);
}

void rb_str_cat(VALUE string, char *to_concat, long length) {
truffle_invoke(ruby_cext, "string_cat", string, to_concat, length);
}
@@ -149,6 +165,14 @@ VALUE rb_ary_entry(VALUE array, long index) {
return truffle_read_idx(array, (int) index);
}

int RARRAY_LENINT(VALUE array) {
return truffle_get_size(array);
}

VALUE rb_hash_new() {
return (VALUE) truffle_invoke(ruby_cext, "hash_new");
}

VALUE rb_hash_aref(VALUE hash, VALUE key) {
return truffle_read(hash, key);
}
333 changes: 32 additions & 301 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -66,6 +66,10 @@ public DynamicObject argumentErrorOutOfRange(Node currentNode) {
return argumentError(coreStrings().OUT_OF_RANGE.getRope(), currentNode, null);
}

public DynamicObject argumentErrorNegativeArraySize(Node currentNode) {
return argumentError(coreStrings().NEGATIVE_ARRAY_SIZE.getRope(), currentNode, null);
}

@TruffleBoundary
public DynamicObject argumentErrorUnknownKeyword(Object name, Node currentNode) {
return argumentError("unknown keyword: " + name, currentNode);
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ public static boolean verySlowIsFrozen(RubyContext context, Object object) {
@Child RubyNode child = node;
}.adoptChildren();

return (boolean) node.executeIsFrozen(object);
return node.executeIsFrozen(object);
}

public void insertAfter(DynamicObject module) {
Original file line number Diff line number Diff line change
@@ -453,7 +453,7 @@ public abstract static class RightShiftNode extends BignumCoreMethodNode {
private final BranchProfile bLessThanZero = BranchProfile.create();

@Specialization
public Object leftShift(DynamicObject a, int b) {
public Object rightShift(DynamicObject a, int b) {
if (b >= 0) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).shiftRight(b));
} else {
@@ -462,6 +462,25 @@ public Object leftShift(DynamicObject a, int b) {
}
}

@Specialization(guards = "isRubyBignum(b)")
public int rightShift(DynamicObject a, DynamicObject b) {
return 0;
}

@Specialization(guards = {"!isRubyBignum(b)", "!isInteger(b)"})
public Object rightShift(VirtualFrame frame,
DynamicObject a,
Object b,
@Cached("new()") SnippetNode snippetNode) {
int bInt = (int) snippetNode.execute(frame, "Rubinius::Type.coerce_to(y, Integer, :to_int)", "y", b);
if (bInt >= 0) {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).shiftRight(bInt));
} else {
return fixnumOrBignum(Layouts.BIGNUM.getValue(a).shiftLeft(-bInt));
}
}


}

@CoreMethod(names = { "abs", "magnitude" })
Original file line number Diff line number Diff line change
@@ -380,8 +380,6 @@ public double div(long a, double b) {

@Specialization(guards = {"!isLongMinValue(a)", "isRubyBignum(b)"})
public int div(long a, DynamicObject b) {
assert Layouts.BIGNUM.getValue(b).compareTo(BigInteger.valueOf(Long.MAX_VALUE)) == 1 ||
Layouts.BIGNUM.getValue(b).compareTo(BigInteger.valueOf(Long.MIN_VALUE)) == -1;
return 0;
}

Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ public class CoreStrings {
public final CoreString LINE;
public final CoreString LOCAL_VARIABLE;
public final CoreString METHOD;
public final CoreString NEGATIVE_ARRAY_SIZE;
public final CoreString NIL;
public final CoreString ONE_HASH_REQUIRED;
public final CoreString OUT_OF_RANGE;
@@ -56,6 +57,7 @@ public CoreStrings(RubyContext context) {
LINE = new CoreString(context, "line");
LOCAL_VARIABLE = new CoreString(context, "local-variable");
METHOD = new CoreString(context, "method");
NEGATIVE_ARRAY_SIZE = new CoreString(context, "negative array size");
NIL = new CoreString(context, "nil");
ONE_HASH_REQUIRED = new CoreString(context, "one hash required");
OUT_OF_RANGE = new CoreString(context, "out of range");
Original file line number Diff line number Diff line change
@@ -27,17 +27,15 @@ public InteropManager(RubyContext context) {
this.context = context;
}

public void exportObject(DynamicObject name, TruffleObject object) {
assert RubyGuards.isRubyString(name);
exported.put(name.toString(), object);
public void exportObject(String name, TruffleObject object) {
exported.put(name, object);
}

public Object findExportedObject(String name) {
return exported.get(name);
}

public Object importObject(DynamicObject name) {
assert RubyGuards.isRubyString(name);
public Object importObject(String name) {
return context.getEnv().importSymbol(name.toString());
}

Original file line number Diff line number Diff line change
@@ -566,7 +566,7 @@ public abstract static class ExportNode extends CoreMethodArrayArgumentsNode {
@TruffleBoundary
@Specialization(guards = "isRubyString(name) || isRubySymbol(name)")
public Object export(DynamicObject name, TruffleObject object) {
getContext().getInteropManager().exportObject(name, object);
getContext().getInteropManager().exportObject(name.toString(), object);
return object;
}

@@ -578,7 +578,7 @@ public abstract static class ImportNode extends CoreMethodArrayArgumentsNode {
@TruffleBoundary
@Specialization(guards = "isRubyString(name) || isRubySymbol(name)")
public Object importObject(DynamicObject name) {
return getContext().getInteropManager().importObject(name);
return getContext().getInteropManager().importObject(name.toString());
}

}
Original file line number Diff line number Diff line change
@@ -158,6 +158,10 @@ public RubyContext getContext() {

// Source section

public void unsafeSetSourceSection(SourceSection sourceSection) {
this.sourceSection = sourceSection;
}

@Override
public SourceSection getSourceSection() {
return sourceSection;
Original file line number Diff line number Diff line change
@@ -98,11 +98,13 @@ public Object execute(VirtualFrame frame, String expression, Object... arguments
}

private boolean ensureConstantExpressionParameters(String expression, Object[] arguments) {
boolean test = this.expression == expression;
assert this.expression == expression :
"has to be always called with same expression: " + this.expression + " != " + expression;
for (int n = 0; n < parameters.length; n++) {
test = test && parameters[n] == arguments[2 * n];
assert parameters[n] == arguments[2 * n] :
"has to be always called with same parameter name at " + n + ": " + parameters[n] + " != " + arguments[2 * n];
}
return test;
return true;
}

@ExplodeLoop
Original file line number Diff line number Diff line change
@@ -38,7 +38,11 @@ public Source load(String canonicalPath) throws IOException {
} else if (canonicalPath.startsWith(TRUFFLE_SCHEME) || canonicalPath.startsWith(JRUBY_SCHEME)) {
return loadResource(canonicalPath);
} else {
assert new File(canonicalPath).getCanonicalPath().equals(canonicalPath) : canonicalPath;
final File file = new File(canonicalPath);
if (!file.canRead()) {
throw new IOException("Can't read file " + canonicalPath);
}
assert file.getCanonicalPath().equals(canonicalPath) : canonicalPath;
return Source.fromFileName(canonicalPath);
}
}
Original file line number Diff line number Diff line change
@@ -192,8 +192,7 @@ public static RubyNode createCheckArityNode(RubyContext context, SourceSection s
}

protected void setSourceSection(RubyNode node, SourceSection sourceSection) {
node.clearSourceSection();
node.assignSourceSection(sourceSection);
node.unsafeSetSourceSection(sourceSection);
}

}
2 changes: 2 additions & 0 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -294,3 +294,5 @@ def when_splat(cases, expression)
c === expression
end
end

Truffle::Interop.export(:ruby_cext, Truffle::CExt)