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

Commits on Jul 16, 2016

  1. Copy the full SHA
    db1ee83 View commit details
  2. [Truffle] SIZEOF_ macros.

    chrisseaton committed Jul 16, 2016
    Copy the full SHA
    4ff4181 View commit details

Commits on Jul 17, 2016

  1. Copy the full SHA
    c3ff752 View commit details
15 changes: 13 additions & 2 deletions lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@ extern "C" {

#define JRUBY_TRUFFLE 1

#define SIZEOF_INT 32
#define SIZEOF_LONG 64

#include <truffle.h>

#define RUBY_CEXT truffle_import_cached("ruby_cext")
@@ -76,13 +79,16 @@ int FIX2INT(VALUE value);
unsigned int FIX2UINT(VALUE value);
long FIX2LONG(VALUE value);

VALUE INT2NUM(int value);
VALUE INT2FIX(int value);
VALUE INT2NUM(long value);
VALUE INT2FIX(long value);
VALUE UINT2NUM(unsigned int value);

VALUE LONG2NUM(long value);
VALUE LONG2FIX(long value);

int rb_fix2int(VALUE value);
unsigned long rb_fix2uint(VALUE value);

ID SYM2ID(VALUE value);
VALUE ID2SYM(ID value);

@@ -198,6 +204,11 @@ void rb_alias(VALUE module, ID new_name, ID old_name);
void rb_undef_method(VALUE module, const char *name);
void rb_undef(VALUE module, ID name);

// GC

VALUE rb_gc_enable();
VALUE rb_gc_disable();

#if defined(__cplusplus)
}
#endif
8 changes: 0 additions & 8 deletions spec/ruby/optional/capi/ext/jruby_truffle.h
Original file line number Diff line number Diff line change
@@ -335,8 +335,6 @@

/* GC */
#undef HAVE_RB_GC_REGISTER_ADDRESS
#undef HAVE_RB_GC_ENABLE
#undef HAVE_RB_GC_DISABLE

/* Marshal */
#undef HAVE_RB_MARSHAL_DUMP
@@ -361,12 +359,6 @@
#undef HAVE_RB_NUM_COERCE_RELOP
#undef HAVE_RB_NUM_ZERODIV

/* Fixnum */
#if SIZEOF_INT < SIZEOF_LONG
#undef HAVE_RB_FIX2UINT
#undef HAVE_RB_FIX2INT
#endif

/* Object */
#undef HAVE_OBJ_TAINT
#undef HAVE_OBJ_TAINTED
14 changes: 0 additions & 14 deletions spec/truffle/tags/optional/capi/fixnum_tags.txt

This file was deleted.

4 changes: 0 additions & 4 deletions spec/truffle/tags/optional/capi/gc_tags.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
fails:CApiGCSpecs correctly gets the value from a registered address
fails:CApiGCSpecs rb_gc_enable enables GC when disabled
fails:CApiGCSpecs rb_gc_enable GC stays enabled when enabled
fails:CApiGCSpecs rb_gc_enable disables GC when enabled
fails:CApiGCSpecs rb_gc_enable GC stays disabled when disabled
22 changes: 20 additions & 2 deletions truffle/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
@@ -83,11 +83,11 @@ long FIX2LONG(VALUE value) {
return truffle_invoke_l(RUBY_CEXT, "FIX2LONG", value);
}

VALUE INT2NUM(int value) {
VALUE INT2NUM(long value) {
return (VALUE) truffle_invoke(RUBY_CEXT, "INT2NUM", value);
}

VALUE INT2FIX(int value) {
VALUE INT2FIX(long value) {
return (VALUE) truffle_invoke(RUBY_CEXT, "INT2FIX", value);
}

@@ -103,6 +103,14 @@ VALUE LONG2FIX(long value) {
return (VALUE) truffle_invoke(RUBY_CEXT, "LONG2FIX", value);
}

int rb_fix2int(VALUE value) {
return truffle_invoke_i(RUBY_CEXT, "rb_fix2int", value);
}

unsigned long rb_fix2uint(VALUE value) {
return truffle_invoke_l(RUBY_CEXT, "rb_fix2uint", value);
}

ID SYM2ID(VALUE value) {
return (ID) value;
}
@@ -379,3 +387,13 @@ void rb_undef_method(VALUE module, const char *name) {
void rb_undef(VALUE module, ID name) {
truffle_invoke(RUBY_CEXT, "rb_undef", module, name);
}

// GC

VALUE rb_gc_enable() {
return truffle_invoke(RUBY_CEXT, "rb_gc_enable");
}

VALUE rb_gc_disable() {
return truffle_invoke(RUBY_CEXT, "rb_gc_disable");
}
18 changes: 18 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/interop/InteropNodes.java
Original file line number Diff line number Diff line change
@@ -51,6 +51,24 @@
@CoreClass("Truffle::Interop")
public abstract class InteropNodes {

@CoreMethod(names = "import_file", isModuleFunction = true, required = 1)
public abstract static class ImportFileNode extends CoreMethodArrayArgumentsNode {

@TruffleBoundary
@Specialization(guards = "isRubyString(fileName)")
public Object importFile(DynamicObject fileName) {
try {
final Source sourceObject = Source.fromFileName(fileName.toString());
getContext().getEnv().parse(sourceObject).call();
} catch (IOException e) {
throw new JavaException(e);
}

return nil();
}

}

@CoreMethod(names = "executable?", isModuleFunction = true, required = 1)
public abstract static class IsExecutableNode extends CoreMethodArrayArgumentsNode {

Original file line number Diff line number Diff line change
@@ -85,6 +85,12 @@ public int fix2uint(int num) {
return num;
}

@Specialization
public long fix2uint(long num) {
// TODO CS 2-May-16 what to do about the fact it's unsigned?
return num;
}

}

@CoreMethod(names = "FIX2LONG", isModuleFunction = true, required = 1)
@@ -105,6 +111,11 @@ public int int2num(int num) {
return num;
}

@Specialization
public long int2num(long num) {
return num;
}

}

@CoreMethod(names = "INT2FIX", isModuleFunction = true, required = 1)
@@ -115,6 +126,11 @@ public int int2fix(int num) {
return num;
}

@Specialization
public long int2fix(long num) {
return num;
}

}

@CoreMethod(names = "UINT2NUM", isModuleFunction = true, required = 1)
28 changes: 28 additions & 0 deletions truffle/src/main/ruby/core/truffle/cext.rb
Original file line number Diff line number Diff line change
@@ -49,6 +49,26 @@ def rb_eRuntimeError
raise 'not implemented'
end

def rb_fix2int(value)
if value.nil?
raise TypeError
else
int = value.to_int
raise RangeError if int >= 2**32
int
end
end

def rb_fix2uint(value)
if value.nil?
raise TypeError
else
int = value.to_int
raise RangeError if int >= 2**32
int
end
end

def NIL_P(value)
nil.equal?(value)
end
@@ -190,6 +210,14 @@ def rb_undef(mod, name)
def rb_funcall(object, name, argc, args)
object.__send__(name, *args)
end

def rb_gc_enable
GC.enable
end

def rb_gc_disable
GC.disable
end
end

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