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

Commits on Jul 24, 2016

  1. Copy the full SHA
    98325c5 View commit details
  2. Copy the full SHA
    1a9c209 View commit details
  3. [Truffle] rb_mEnumerable

    chrisseaton committed Jul 24, 2016
    Copy the full SHA
    19d8576 View commit details
  4. [Truffle] SYMBOL_P

    chrisseaton committed Jul 24, 2016
    Copy the full SHA
    9dfed45 View commit details
  5. [Truffle] rb_block_call

    chrisseaton committed Jul 24, 2016
    Copy the full SHA
    72a3632 View commit details
  6. Copy the full SHA
    8d572ff View commit details
  7. Copy the full SHA
    cac4e36 View commit details
  8. Copy the full SHA
    7b2e478 View commit details
  9. Copy the full SHA
    8b0faff View commit details
  10. Copy the full SHA
    df4aac4 View commit details
  11. [Truffle] Stub rb_attr

    chrisseaton committed Jul 24, 2016
    Copy the full SHA
    55daf7c View commit details
  12. Copy the full SHA
    ddf9daa View commit details
15 changes: 15 additions & 0 deletions lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -144,6 +144,8 @@ void rb_check_type(VALUE value, int type);

VALUE rb_obj_is_kind_of(VALUE object, VALUE ruby_class);

bool SYMBOL_P(VALUE value);

// Constants

VALUE get_Qfalse(void);
@@ -160,13 +162,15 @@ VALUE get_rb_cHash(void);
VALUE get_rb_mKernel(void);
VALUE get_rb_cProc(void);
VALUE get_rb_cTime(void);
VALUE get_rb_mEnumerable(void);

#define rb_cObject get_rb_cObject()
#define rb_cArray get_rb_cArray()
#define rb_cHash get_rb_cHash()
#define rb_mKernel get_rb_mKernel()
#define rb_cProc get_rb_cProc()
#define rb_cTime get_rb_cTime()
#define rb_mEnumerable get_rb_mEnumerable()

VALUE get_rb_eException(void);
VALUE get_rb_eRuntimeError(void);
@@ -258,6 +262,10 @@ char *rb_string_value_cstr(volatile VALUE* value_pointer);
VALUE rb_str_buf_new(long capacity);
VALUE rb_sprintf(const char *format, ...);
VALUE rb_vsprintf(const char *format, va_list args);
VALUE rb_str_append(VALUE string, VALUE to_append);
void rb_str_set_len(VALUE string, long length);
VALUE rb_str_new_frozen(VALUE value);
#define rb_str_new4(value) rb_str_new_frozen(value)

// Symbol

@@ -283,6 +291,7 @@ VALUE rb_ary_pop(VALUE array);
void rb_ary_store(VALUE array, long index, VALUE value);
VALUE rb_ary_entry(VALUE array, long index);
VALUE rb_ary_dup(VALUE array);
VALUE rb_ary_each(VALUE array);

// Hash

@@ -297,6 +306,7 @@ VALUE rb_hash_lookup2(VALUE hash, VALUE key, VALUE default_value);
const char* rb_class2name(VALUE module);

VALUE rb_class_real(VALUE ruby_class);
VALUE rb_class_superclass(VALUE ruby_class);

VALUE rb_class_of(VALUE object);
VALUE rb_obj_class(VALUE object);
@@ -328,6 +338,8 @@ VALUE rb_funcallv_public(VALUE object, ID name, int args_count, const VALUE *arg
#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
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);

int rb_block_given_p();
VALUE rb_yield(VALUE value);
@@ -375,6 +387,7 @@ VALUE rb_define_class_under(VALUE module, const char *name, VALUE superclass);
VALUE rb_define_class_id_under(VALUE module, ID name, VALUE superclass);
VALUE rb_define_module(const char *name);
VALUE rb_define_module_under(VALUE module, const char *name);
void rb_include_module(VALUE module, VALUE to_include);

void rb_define_method(VALUE module, const char *name, void *function, int argc);
void rb_define_private_method(VALUE module, const char *name, void *function, int argc);
@@ -389,6 +402,8 @@ 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);

void rb_attr(VALUE ruby_class, ID name, int read, int write, int ex);

// Mutexes

VALUE rb_mutex_new(void);
55 changes: 52 additions & 3 deletions truffle/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
@@ -40,6 +40,10 @@ VALUE rb_obj_is_kind_of(VALUE object, VALUE ruby_class) {
return truffle_invoke(object, "kind_of?", ruby_class);
}

bool SYMBOL_P(VALUE value) {
return truffle_invoke_b(RUBY_CEXT, "SYMBOL_P", value);
}

// Constants

VALUE get_Qfalse(void) {
@@ -74,15 +78,19 @@ VALUE get_rb_cTime(void) {
return (VALUE) truffle_read(RUBY_CEXT, "rb_cTime");
}

VALUE get_rb_mKernel() {
VALUE get_rb_mKernel(void) {
return (VALUE) truffle_read(RUBY_CEXT, "rb_mKernel");
}

VALUE get_rb_eException() {
VALUE get_rb_mEnumerable(void) {
return (VALUE) truffle_read(RUBY_CEXT, "rb_mEnumerable");
}

VALUE get_rb_eException(void) {
return (VALUE) truffle_read(RUBY_CEXT, "rb_eException");
}

VALUE get_rb_eRuntimeError() {
VALUE get_rb_eRuntimeError(void) {
return (VALUE) truffle_read(RUBY_CEXT, "rb_eRuntimeError");
}

@@ -284,6 +292,20 @@ VALUE rb_vsprintf(const char *format, va_list args) {
abort();
}

VALUE rb_str_append(VALUE string, VALUE to_append) {
fprintf(stderr, "rb_str_append not implemented\n");
abort();
}

void rb_str_set_len(VALUE string, long length) {
fprintf(stderr, "rb_str_set_len not implemented\n");
abort();
}

VALUE rb_str_new_frozen(VALUE value) {
return truffle_invoke(RUBY_CEXT, "rb_str_new_frozen", value);
}

// Symbol

ID rb_intern(const char *string) {
@@ -358,6 +380,11 @@ VALUE rb_ary_dup(VALUE array) {
return (VALUE) truffle_invoke(array, "dup");
}

VALUE rb_ary_each(VALUE array) {
fprintf(stderr, "rb_ary_each not implemented\n");
abort();
}

// Hash

VALUE rb_hash_new() {
@@ -391,6 +418,10 @@ VALUE rb_class_real(VALUE ruby_class) {
return (VALUE) truffle_invoke(RUBY_CEXT, "rb_class_real", ruby_class);
}

VALUE rb_class_superclass(VALUE ruby_class) {
return truffle_invoke(ruby_class, "superclass");
}

VALUE rb_obj_class(VALUE object) {
return rb_class_real(rb_class_of(object));
}
@@ -449,6 +480,15 @@ VALUE rb_funcallv_public(VALUE object, ID name, int args_count, const VALUE *arg
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();
}

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

VALUE rb_yield(VALUE value) {
return truffle_invoke(RUBY_CEXT, "rb_yield", value);
}
@@ -573,6 +613,10 @@ VALUE rb_define_module_under(VALUE module, const char *name) {
return truffle_invoke(RUBY_CEXT, "rb_define_module_under", module, rb_str_new_cstr(name));
}

void rb_include_module(VALUE module, VALUE to_include) {
truffle_invoke(module, "include", to_include);
}

void rb_define_method(VALUE module, const char *name, void *function, int argc) {
truffle_invoke(RUBY_CEXT, "rb_define_method", module, rb_str_new_cstr(name), truffle_address_to_function(function), argc);
}
@@ -613,6 +657,11 @@ void rb_undef(VALUE module, ID name) {
truffle_invoke(RUBY_CEXT, "rb_undef", module, name);
}

void rb_attr(VALUE ruby_class, ID name, int read, int write, int ex) {
fprintf(stderr, "rb_attr not implemented\n");
abort();
}

// Rational

VALUE rb_Rational(VALUE num, VALUE den) {
Original file line number Diff line number Diff line change
@@ -223,15 +223,15 @@ public DynamicObject toRubyString(DynamicObject string) {
public abstract static class BlockGivenNode extends CoreMethodArrayArgumentsNode {

@Specialization
public boolean blockGiven(MaterializedFrame callerFrame,
public int blockGiven(MaterializedFrame callerFrame,
@Cached("createBinaryProfile()") ConditionProfile blockProfile) {
return blockProfile.profile(RubyArguments.getBlock(callerFrame) != null);
return blockProfile.profile(RubyArguments.getBlock(callerFrame) != null) ? 1 : 0;
}

@TruffleBoundary
@Specialization
public boolean blockGiven(NotProvided noCallerFrame) {
return RubyArguments.getBlock(Truffle.getRuntime().getCallerFrame().getFrame(FrameInstance.FrameAccess.READ_ONLY, false)) != null;
public int blockGiven(NotProvided noCallerFrame) {
return RubyArguments.getBlock(Truffle.getRuntime().getCallerFrame().getFrame(FrameInstance.FrameAccess.READ_ONLY, false)) != null ? 1 : 0;
}

}
20 changes: 20 additions & 0 deletions truffle/src/main/ruby/core/truffle/cext.rb
Original file line number Diff line number Diff line change
@@ -96,6 +96,9 @@ def rb_type(value)
end

def RB_TYPE_P(value, type)
# TODO CS 23-Jul-16 we could do with making this a kind of specialising case
# that puts never seen cases behind a transfer

case type
when T_STRING
value.is_a?(String)
@@ -111,6 +114,10 @@ def rb_check_type(value, type)
end
end

def SYMBOL_P(value)
value.is_a?(Symbol)
end

def Qfalse
false
end
@@ -147,6 +154,10 @@ def rb_mKernel
Kernel
end

def rb_mEnumerable
Enumerable
end

def rb_eException
Exception
end
@@ -219,6 +230,15 @@ def RSTRING_PTR(string)
Truffle::Interop.to_java_string(string)
end

def rb_str_new_frozen(value)
if value.frozen?
value
else
# There's more to rb_str_new_frozen than this
String(value).freeze
end
end

def rb_intern(str)
str.intern
end