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: 09920db1f838
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9f00f5b8d993
Choose a head ref
  • 16 commits
  • 6 files changed
  • 1 contributor

Commits on Jul 28, 2016

  1. [Truffle] Until we resolve the type of VALUE we can compile openssl w…

    …ith uintptr_t and everything else with void*
    chrisseaton committed Jul 28, 2016
    Copy the full SHA
    0630d85 View commit details
  2. Copy the full SHA
    276a9a0 View commit details
  3. Copy the full SHA
    0dbae41 View commit details
  4. Copy the full SHA
    ccedb7c View commit details
  5. 4
    Copy the full SHA
    5c88af6 View commit details
  6. Copy the full SHA
    e584c61 View commit details
  7. Copy the full SHA
    3613d42 View commit details
  8. Copy the full SHA
    8696f44 View commit details
  9. Copy the full SHA
    935d4b4 View commit details
  10. [Truffle] TIMET2NUM

    chrisseaton committed Jul 28, 2016
    Copy the full SHA
    80d68a0 View commit details
  11. Copy the full SHA
    0706ebe View commit details
  12. [Truffle] rb_mComparable

    chrisseaton committed Jul 28, 2016
    Copy the full SHA
    98045a6 View commit details
  13. Copy the full SHA
    30aa2f3 View commit details
  14. [Truffle] We need to protect RB_BLOCK_CALL_FUNC_ARGLIST because there…

    … are also user-named arguments.
    chrisseaton committed Jul 28, 2016
    Copy the full SHA
    bf01a99 View commit details
  15. Copy the full SHA
    3fa83dd View commit details
  16. Copy the full SHA
    9f00f5b View commit details
2 changes: 1 addition & 1 deletion ci.hocon
Original file line number Diff line number Diff line change
@@ -291,7 +291,7 @@ test-cexts: {
[cd, ../..],
[mv, temp_mx, mx.jruby]
[mx, sclone, --kind, git, "https://github.com/jruby/jruby-truffle-gem-test-pack.git", jruby-truffle-gem-test-pack],
${jt} [build, cexts, --no-openssl]
${jt} [build, cexts]
]

environment: {
74 changes: 71 additions & 3 deletions lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -52,8 +52,12 @@ extern "C" {

// Basic types

//typedef uint64_t VALUE;
typedef void *VALUE;
#ifdef JT_INT_VALUE
typedef uintptr_t VALUE;
#else
typedef void *VALUE;
#endif

typedef VALUE ID;

// Helpers
@@ -181,6 +185,7 @@ VALUE rb_jt_get_cTime(void);
VALUE rb_jt_get_mEnumerable(void);
VALUE rb_jt_get_mWaitReadable(void);
VALUE rb_jt_get_mWaitWritable(void);
VALUE rb_jt_get_mComparable(void);

#define rb_cObject rb_jt_get_cObject()
#define rb_cArray rb_jt_get_cArray()
@@ -191,6 +196,7 @@ VALUE rb_jt_get_mWaitWritable(void);
#define rb_mEnumerable rb_jt_get_mEnumerable()
#define rb_mWaitReadable rb_jt_get_mWaitReadable()
#define rb_mWaitWritable rb_jt_get_mWaitWritable()
#define rb_mComparable rb_jt_get_mComparable()

VALUE rb_jt_get_eException(void);
VALUE rb_jt_get_eRuntimeError(void);
@@ -240,6 +246,7 @@ ID SYM2ID(VALUE value);
VALUE ID2SYM(ID value);

#define NUM2TIMET(value) NUM2LONG(value)
#define TIMET2NUM(value) LONG2NUM(value)

// Type checks

@@ -258,7 +265,36 @@ VALUE rb_require(const char *feature);
// Object

VALUE rb_obj_dup(VALUE object);

VALUE rb_jt_obj_taint(VALUE object);
bool rb_jt_obj_taintable_p(VALUE object);
bool rb_jt_obj_tainted_p(VALUE object);
#define RB_OBJ_TAINTABLE(object) rb_jt_obj_taintable_p(object)
#define RB_OBJ_TAINTED_RAW(object) rb_jt_obj_tainted_p(object)
#define RB_OBJ_TAINTED(object) rb_jt_obj_tainted_p(object)
#define RB_OBJ_TAINT_RAW(object) rb_jt_obj_taint(object)
#define RB_OBJ_TAINT(object) rb_jt_obj_taint(object)
#define RB_OBJ_UNTRUSTED(object) rb_jt_obj_tainted_p(object)
#define RB_OBJ_UNTRUST(object) rb_jt_obj_taint(object)
#define OBJ_TAINTABLE(object) rb_jt_obj_taintable_p(object)
#define OBJ_TAINTED_RAW(object) rb_jt_obj_tainted_p(object)
#define OBJ_TAINTED(object) rb_jt_obj_tainted_p(object)
#define OBJ_TAINT_RAW(object) rb_jt_obj_taint(object)
#define OBJ_TAINT(object) rb_jt_obj_taint(object)
#define OBJ_UNTRUSTED(object) rb_jt_obj_tainted_p(object)
#define OBJ_UNTRUST(object) rb_jt_obj_tainted_p(object)

VALUE rb_obj_freeze(VALUE object);
bool rb_jt_obj_frozen_p(VALUE object);
#define rb_obj_freeze_inline(object) rb_obj_freeze(object)
#define RB_OBJ_FROZEN_RAW(x) rb_jt_obj_frozen_p(object)
#define RB_OBJ_FROZEN(x) rb_jt_obj_frozen_p(object)
#define RB_OBJ_FREEZE_RAW(object) rb_obj_freeze(object)
#define RB_OBJ_FREEZE(x) rb_obj_freeze((VALUE)x)
#define OBJ_FROZEN_RAW(object) rb_jt_obj_frozen_p(object)
#define OBJ_FROZEN(object) rb_jt_obj_frozen_p(object)
#define OBJ_FREEZE_RAW(object) rb_obj_freeze(object)
#define OBJ_FREEZE(object) rb_obj_freeze(object)

// Integer

@@ -331,6 +367,7 @@ VALUE rb_String(VALUE value);
VALUE rb_str_resize(VALUE string, long length);
#define RSTRING_GETMEM(string, data_pointer, length_pointer) ((data_pointer) = RSTRING_PTR(string), (length_pointer) = rb_str_len(string))
VALUE rb_str_split(VALUE string, const char *split);
void rb_str_modify(VALUE string);

// Symbol

@@ -368,6 +405,8 @@ VALUE rb_hash_aref(VALUE hash, VALUE key);
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE value);
VALUE rb_hash_lookup(VALUE hash, VALUE key);
VALUE rb_hash_lookup2(VALUE hash, VALUE key, VALUE default_value);
VALUE rb_hash_set_ifnone(VALUE hash, VALUE if_none);
#define RHASH_SET_IFNONE(hash, if_none) rb_hash_set_ifnone((VALUE) hash, if_none)

typedef unsigned long st_data_t;
typedef st_data_t st_index_t;
@@ -406,14 +445,18 @@ VALUE rb_funcallv(VALUE object, ID name, int args_count, const VALUE *args);
VALUE rb_funcallv_public(VALUE object, ID name, int args_count, const VALUE *args);
#define rb_funcall2 rb_funcallv
#define rb_funcall3 rb_funcallv_public
VALUE rb_apply(VALUE object, ID name, VALUE args);

#define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) VALUE yielded_arg, VALUE callback_arg, int args_count, const VALUE *args, VALUE block_arg
#define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) VALUE yielded_arg, VALUE callback_arg, int __args_count, const VALUE *__args, VALUE __block_arg
typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg));
typedef rb_block_call_func *rb_block_call_func_t;
VALUE rb_block_call(VALUE object, ID name, int args_count, const VALUE *args, rb_block_call_func_t block_call_func, VALUE data);

VALUE rb_call_super(int args_count, const VALUE *args);

int rb_block_given_p();
VALUE rb_block_proc(void);
VALUE rb_yield(VALUE value);

// Instance variables
@@ -569,8 +612,25 @@ int rb_jt_io_handle(VALUE file);

#define GetOpenFile(file, pointer) ((pointer)->fd = rb_jt_io_handle(file))

int rb_io_wait_readable(int fd);
int rb_io_wait_writable(int fd);
void rb_thread_wait_fd(int fd);

NORETURN(void rb_eof_error(void));

// Data

struct RData {
// No RBasic object header
void (*dmark)(void *data);
void (*dfree)(void *data);
void *data;
};

struct RData *rb_jt_wrap_rdata(VALUE value);

#define RDATA(value) rb_jt_wrap_rdata(value)

#define DATA_PTR(value) *((volatile intptr_t*) 0)

// Typed data
@@ -612,6 +672,14 @@ void *rb_check_typeddata(VALUE value, const rb_data_type_t *data_type);

#define RTYPEDDATA_DATA(value) *((volatile int*) 0)

// VM

VALUE *rb_ruby_verbose_ptr(void);
#define ruby_verbose (*rb_ruby_verbose_ptr())

VALUE *rb_ruby_debug_ptr(void);
#define ruby_debug (*rb_ruby_debug_ptr())

#if defined(__cplusplus)
}
#endif
5 changes: 1 addition & 4 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -505,14 +505,11 @@ def build(*options)
mvn env, *maven_options, '-pl', 'truffle', 'package'
when 'cexts'
no_openssl = options.delete('--no-openssl')

cextc "#{JRUBY_DIR}/truffle/src/main/c/cext"

openssl_home = ENV['OPENSSL_HOME'] || '/usr'

unless no_openssl
cextc "#{JRUBY_DIR}/truffle/src/main/c/openssl",
'-DRUBY_EXTCONF_H="extconf.h"',
'-DJT_INT_VALUE=true',
'-Werror=implicit-function-declaration'
end
when nil
87 changes: 87 additions & 0 deletions truffle/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
@@ -133,6 +133,10 @@ VALUE rb_jt_get_mWaitWritable(void) {
return (VALUE) truffle_read(RUBY_CEXT, "rb_mWaitWritable");
}

VALUE rb_jt_get_mComparable(void) {
return (VALUE) truffle_read(RUBY_CEXT, "rb_mComparable");
}

VALUE rb_jt_get_eException(void) {
return (VALUE) truffle_read(RUBY_CEXT, "rb_eException");
}
@@ -269,14 +273,32 @@ VALUE rb_require(const char *feature) {
abort();
}

// Object

VALUE rb_obj_dup(VALUE object) {
return (VALUE) truffle_invoke((void *)object, "dup");
}

VALUE rb_jt_obj_taint(VALUE object) {
return (VALUE) truffle_invoke((void *)object, "taint");
}

bool rb_jt_obj_taintable_p(VALUE object) {
return truffle_invoke_b(RUBY_CEXT, "RB_OBJ_TAINTED", object);
}

bool rb_jt_obj_tainted_p(VALUE object) {
return truffle_invoke_b((void *)object, "tainted?");
}

VALUE rb_obj_freeze(VALUE object) {
return (VALUE) truffle_invoke((void *)object, "freeze");
}

bool rb_jt_obj_frozen_p(VALUE object) {
return truffle_invoke_b((void *)object, "frozen?");
}

// Integer

VALUE rb_Integer(VALUE value) {
@@ -426,6 +448,10 @@ VALUE rb_str_split(VALUE string, const char *split) {
return (VALUE) truffle_invoke(string, "split", rb_str_new_cstr(split));
}

void rb_str_modify(VALUE string) {
// Does nothing because writing to the string pointer will cause necessary invalidations anyway
}

// Symbol

ID rb_intern(const char *string) {
@@ -537,6 +563,11 @@ VALUE rb_hash_lookup2(VALUE hash, VALUE key, VALUE default_value) {
return (VALUE) truffle_invoke((void *)hash, "fetch", key, default_value);
}

VALUE rb_hash_set_ifnone(VALUE hash, VALUE if_none) {
fprintf(stderr, "rb_hash_set_ifnone not implemented\n");
abort();
}

st_index_t rb_memhash(const void *data, long length) {
// Not a proper hash - just something that produces a stable result for now

@@ -631,15 +662,30 @@ VALUE rb_funcallv_public(VALUE object, ID name, int args_count, const VALUE *arg
abort();
}

VALUE rb_apply(VALUE object, ID name, VALUE args) {
fprintf(stderr, "rb_apply not implemented\n");
abort();
}

VALUE rb_block_call(VALUE object, ID name, int args_count, const VALUE *args, rb_block_call_func_t block_call_func, VALUE data) {
fprintf(stderr, "rb_block_call not implemented\n");
abort();
}

VALUE rb_call_super(int args_count, const VALUE *args) {
fprintf(stderr, "rb_call_super not implemented\n");
abort();
}

int rb_block_given_p() {
return truffle_invoke_i(RUBY_CEXT, "rb_block_given_p");
}

VALUE rb_block_proc(void) {
fprintf(stderr, "rb_block_proc not implemented\n");
abort();
}

VALUE rb_yield(VALUE value) {
return (VALUE) truffle_invoke(RUBY_CEXT, "rb_yield", value);
}
@@ -991,8 +1037,33 @@ int rb_jt_io_handle(VALUE io) {
return truffle_invoke_i(RUBY_CEXT, "rb_jt_io_handle", io);
}

int rb_io_wait_readable(int fd) {
fprintf(stderr, "rb_io_wait_readable not implemented\n");
abort();
}

int rb_io_wait_writable(int fd) {
fprintf(stderr, "rb_io_wait_writable not implemented\n");
abort();
}

void rb_thread_wait_fd(int fd) {
fprintf(stderr, "rb_thread_wait_fd not implemented\n");
abort();
}

NORETURN(void rb_eof_error(void)) {
fprintf(stderr, "rb_eof_error not implemented\n");
abort();
}

// Data

struct RData *rb_jt_wrap_rdata(VALUE value) {
fprintf(stderr, "RDATA not implemented\n");
abort();
}

// Typed data

VALUE rb_data_typed_object_wrap(VALUE ruby_class, void *data, const rb_data_type_t *data_type) {
@@ -1014,3 +1085,19 @@ void *rb_check_typeddata(VALUE value, const rb_data_type_t *data_type) {
fprintf(stderr, "rb_check_typeddata not implemented\n");
abort();
}

// VM

VALUE rb_jt_ruby_verbose_ptr;

VALUE *rb_ruby_verbose_ptr(void) {
rb_jt_ruby_verbose_ptr = truffle_invoke(RUBY_CEXT, "rb_ruby_verbose_ptr");
return &rb_jt_ruby_verbose_ptr;
}

VALUE rb_jt_ruby_debug_ptr;

VALUE *rb_ruby_debug_ptr(void) {
rb_jt_ruby_debug_ptr = truffle_invoke(RUBY_CEXT, "rb_ruby_debug_ptr");
return &rb_jt_ruby_debug_ptr;
}
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@ public Object taint(double object) {
return object;
}


@Specialization(guards = "isRubySymbol(object) || isNil(object)")
public Object taintNilOrSymbol(DynamicObject object) {
return object;
21 changes: 21 additions & 0 deletions truffle/src/main/ruby/core/truffle/cext.rb
Original file line number Diff line number Diff line change
@@ -170,6 +170,10 @@ def rb_mWaitReadable
WaitReadable
end

def rb_mComparable
Comparable
end

def rb_mWaitWritable
WaitWritable
end
@@ -238,6 +242,15 @@ def RTEST(value)
!nil.equal?(value) && !false.equal?(value)
end

def RB_OBJ_TAINTED(object)
case object
when TrueClass, FalseClass, Fixnum, Float, NilClass, Symbol
true
else
false
end
end

def rb_float_new(value)
value.to_f
end
@@ -512,6 +525,14 @@ def rb_data_typed_object_wrap(ruby_class, data, data_type)
raise 'not implemented'
end

def rb_ruby_verbose_ptr
$VERBOSE
end

def rb_ruby_debug_ptr
$DEBUG
end

end

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