Skip to content

Commit

Permalink
Showing 49 changed files with 6,616 additions and 6,923 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ lib/ruby/gems
lib/ruby/stdlib/*jopenssl*.jar
lib/ruby/stdlib/bcpkix-jdk15on-*.jar
lib/ruby/stdlib/bcprov-jdk15on-*.jar
lib/ruby/stdlib/did_you_mean*
lib/ruby/stdlib/gauntlet_rdoc.rb
lib/ruby/stdlib/jar*
lib/ruby/stdlib/jline
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -948,7 +948,9 @@ public void setUpUseDefLocalVarMaps() {
if (i instanceof ResultInstr) {
Variable v = ((ResultInstr) i).getResult();

if (v instanceof LocalVariable) definedLocalVars.add((LocalVariable) v);
if (v instanceof LocalVariable && ((LocalVariable)v).getScopeDepth() == 0) {
definedLocalVars.add((LocalVariable) v);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -14,8 +14,7 @@ public class LiveVariablesProblem extends DataFlowProblem<LiveVariablesProblem,

public LiveVariablesProblem(IRScope scope) {
super(DataFlowProblem.DF_Direction.BACKWARD);
alwaysLiveVars = new ArrayList<LocalVariable>();
varsLiveOnScopeExit = new ArrayList<LocalVariable>(alwaysLiveVars);
varsLiveOnScopeExit = new ArrayList<LocalVariable>();
setup(scope);
}

@@ -43,18 +42,6 @@ public void addDFVar(Variable v) {

if (v instanceof LocalVariable && !v.isSelf()) {
//System.out.println("Adding df var for " + v + ":" + dfv.id);
IRScope s = getScope();
for (int n = ((LocalVariable) v).getScopeDepth(); s != null && n >= 0; n--) {
if (s instanceof IREvalScript) {
// If a variable is at the topmost scope of the eval OR crosses an eval boundary,
// it is going to be marked always live since it could be used by other evals (n = 0)
// or by enclosing scopes (n > 0)
alwaysLiveVars.add((LocalVariable) v);
break;
}

s = s.getLexicalParent();
}
localVars.add((LocalVariable) v);
}
}
@@ -125,8 +112,5 @@ public String getName() {
private HashMap<Variable, Integer> dfVarMap = new HashMap<Variable, Integer>();
private HashMap<Integer, Variable> varDfVarMap = new HashMap<Integer, Variable>();
private HashSet<LocalVariable> localVars = new HashSet<LocalVariable>(); // Local variables that can be live across dataflow barriers

// Variables that cross eval boundaries and are always live in this scope
private List<LocalVariable> alwaysLiveVars;
private Collection<LocalVariable> varsLiveOnScopeExit;
}
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
import org.jruby.runtime.ThreadContext;

@@ -65,8 +66,8 @@ public static CheckArityInstr decode(IRReaderDecoder d) {
return new CheckArityInstr(d.decodeInt(), d.decodeInt(), d.decodeBoolean(), d.decodeBoolean(), d.decodeInt());
}

public void checkArity(ThreadContext context, Object[] args, Block.Type blockType) {
IRRuntimeHelpers.checkArity(context.runtime, context.getCurrentStaticScope(), args, required, opt, rest, receivesKeywords, restKey, blockType);
public void checkArity(ThreadContext context, StaticScope scope, Object[] args, Block.Type blockType) {
IRRuntimeHelpers.checkArity(context.runtime, scope, args, required, opt, rest, receivesKeywords, restKey, blockType);
}

@Override
Original file line number Diff line number Diff line change
@@ -384,7 +384,7 @@ protected static void processBookKeepingOp(ThreadContext context, Block block, I
context.callThreadPoll();
break;
case CHECK_ARITY:
((CheckArityInstr) instr).checkArity(context, args, block == null ? null : block.type);
((CheckArityInstr) instr).checkArity(context, currScope, args, block == null ? null : block.type);
break;
case LINE_NUM:
context.setLine(((LineNumberInstr)instr).lineNumber);
69 changes: 50 additions & 19 deletions lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -29,30 +29,33 @@ extern "C" {
typedef void *ID;
typedef void *VALUE;

VALUE get_Qfalse();
VALUE get_Qtrue();
VALUE get_Qnil();
VALUE get_rb_cProc();
VALUE get_rb_eException();
// Constants

VALUE get_Qfalse(void);
VALUE get_Qtrue(void);
VALUE get_Qnil(void);
VALUE get_rb_cProc(void);
VALUE get_rb_eException(void);

#define Qfalse get_Qfalse()
#define Qtrue get_Qtrue()
#define Qnil get_Qnil()
#define rb_cProc get_rb_cProc();
#define rb_eException get_rb_eException();

VALUE get_rb_cObject();
VALUE get_rb_cArray();
VALUE get_rb_cHash();
VALUE get_rb_cObject(void);
VALUE get_rb_cArray(void);
VALUE get_rb_cHash(void);

#define rb_cObject get_rb_cObject()
#define rb_cArray get_rb_cArray()
#define rb_cHash get_rb_cHash()

VALUE get_rb_eRuntimeError();
VALUE get_rb_eRuntimeError(void);

#define rb_eRuntimeError get_rb_eRuntimeError()

// Conversions

int NUM2INT(VALUE value);
unsigned int NUM2UINT(VALUE value);
@@ -69,44 +72,72 @@ VALUE UINT2NUM(unsigned int value);
VALUE LONG2NUM(long value);
VALUE LONG2FIX(long value);

// Type checks

int FIXNUM_P(VALUE value);

// Float

VALUE rb_float_new(double value);

// String

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);
VALUE rb_str_new2(const char *string);
void rb_str_cat(VALUE string, const char *to_concat, long length);

// Symbol

ID rb_intern(const char *string);
VALUE ID2SYM(ID id);

// Array

int RARRAY_LEN(VALUE array);
int RARRAY_LENINT(VALUE array);
VALUE *RARRAY_PTR(VALUE array);
VALUE RARRAY_AREF(VALUE array, long index);
VALUE rb_Array(VALUE value);
VALUE rb_ary_new(void);
VALUE rb_ary_new_capa(long capacity);
VALUE rb_ary_new2();
VALUE rb_ary_new();
void rb_ary_push(VALUE array, VALUE value);
#define rb_ary_new2 rb_ary_new_capa
VALUE rb_ary_push(VALUE array, VALUE value);
VALUE rb_ary_pop(VALUE array);
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();
// Hash

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

// Utilities

void rb_scan_args(int argc, VALUE *argv, const char *format, ...);
int rb_scan_args(int argc, VALUE *argv, const char *format, ...);

// Calls

VALUE rb_funcall(VALUE object, ID name, int argc, ...);

// Instance variables

VALUE rb_iv_get(VALUE object, const char *name);
VALUE rb_iv_set(VALUE object, const char *name, VALUE value);

// Accessing constants

VALUE rb_const_get(VALUE object, ID name);

// Raising exceptions

void rb_raise(VALUE exception, const char *format, ...);

// Defining classes, modules and methods

VALUE rb_define_class(const char *name, VALUE superclass);
VALUE rb_define_module(const char *name);
VALUE rb_define_module_under(VALUE module, const char *name);
Binary file modified lib/ruby/truffle/cext/ruby.su
Binary file not shown.
6 changes: 6 additions & 0 deletions lib/ruby/truffle/cext/version.h
Original file line number Diff line number Diff line change
@@ -11,4 +11,10 @@
#ifndef TRUFFLE_VERSION_H
#define TRUFFLE_VERSION_H

/* API version */
#define RUBY_API_VERSION_MAJOR 2
#define RUBY_API_VERSION_MINOR 3
#define RUBY_API_VERSION_TEENY 0
#define RUBY_API_VERSION_CODE (RUBY_API_VERSION_MAJOR*10000+RUBY_API_VERSION_MINOR*100+RUBY_API_VERSION_TEENY)

#endif
7 changes: 6 additions & 1 deletion spec/ruby/optional/capi/ext/array_spec.c
Original file line number Diff line number Diff line change
@@ -35,7 +35,9 @@ static VALUE array_spec_RARRAY_PTR_assign(VALUE self, VALUE array, VALUE value)
}
return Qnil;
}
#endif

#ifdef HAVE_RARRAY_LEN
static VALUE array_spec_RARRAY_LEN(VALUE self, VALUE array) {
return INT2FIX(RARRAY_LEN(array));
}
@@ -272,8 +274,11 @@ void Init_array_spec() {
rb_define_method(cls, "rb_Array", array_spec_rb_Array, 1);
#endif

#if defined(HAVE_RARRAY_LEN) && defined(HAVE_RARRAY_PTR)
#ifdef HAVE_RARRAY_LEN
rb_define_method(cls, "RARRAY_LEN", array_spec_RARRAY_LEN, 1);
#endif

#if defined(HAVE_RARRAY_LEN) && defined(HAVE_RARRAY_PTR)
rb_define_method(cls, "RARRAY_PTR_iterate", array_spec_RARRAY_PTR_iterate, 1);
rb_define_method(cls, "RARRAY_PTR_assign", array_spec_RARRAY_PTR_assign, 2);
#endif
11 changes: 0 additions & 11 deletions spec/ruby/optional/capi/ext/jruby_truffle.h
Original file line number Diff line number Diff line change
@@ -12,32 +12,21 @@
#undef RUBYSPEC_CAPI_JRUBY_TRUFFLE_H

/* Array */
#undef HAVE_RB_ARRAY
#ifdef RUBY_VERSION_IS_2_1
#undef HAVE_RARRAY_AREF
#endif
#undef HAVE_RARRAY_LEN
#undef HAVE_RARRAY_PTR
#undef HAVE_RB_ARY_AREF
#undef HAVE_RB_ARY_CLEAR
#undef HAVE_RB_ARY_DELETE
#undef HAVE_RB_ARY_DELETE_AT
#undef HAVE_RB_ARY_DUP
#undef HAVE_RB_ARY_ENTRY
#undef HAVE_RB_ARY_FREEZE
#undef HAVE_RB_ARY_INCLUDES
#undef HAVE_RB_ARY_JOIN
#undef HAVE_RB_ARY_NEW2
#undef HAVE_RB_ARY_NEW3
#ifdef RUBY_VERSION_IS_2_1
#undef HAVE_RB_ARY_NEW_FROM_ARGS
#endif
#undef HAVE_RB_ARY_NEW4
#undef HAVE_RB_ARY_POP
#undef HAVE_RB_ARY_PUSH
#undef HAVE_RB_ARY_REVERSE
#undef HAVE_RB_ARY_SHIFT
#undef HAVE_RB_ARY_STORE
#undef HAVE_RB_ARY_CONCAT
#undef HAVE_RB_ARY_PLUS
#undef HAVE_RB_ARY_TO_ARY
15 changes: 0 additions & 15 deletions spec/truffle/tags/optional/capi/array_tags.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
fails:C-API Array function rb_Array returns obj if it is an array
fails:C-API Array function rb_Array tries to convert obj to an array
fails:C-API Array function rb_Array returns obj wrapped in an array if it cannot be converted to an array
fails:C-API Array function rb_ary_new2 returns an empty array
fails:C-API Array function rb_ary_new3 returns an array with the passed cardinality and varargs
fails:C-API Array function rb_ary_new_from_args returns an array with the passed cardinality and varargs
fails:C-API Array function rb_ary_new4 returns returns an array with the passed values
fails:C-API Array function rb_ary_push adds an element to the array
fails:C-API Array function rb_ary_pop removes and returns the last element in the array
fails:C-API Array function rb_ary_join joins elements of an array with a string
fails:C-API Array function rb_ary_to_s creates an Array literal representation as a String
fails:C-API Array function rb_ary_reverse reverses the order of elements in the array
fails:C-API Array function rb_ary_reverse returns the original array
fails:C-API Array function rb_ary_entry returns nil when passed an empty array
fails:C-API Array function rb_ary_entry returns elements from the end when passed a negative index
fails:C-API Array function rb_ary_entry returns nil if the index is out of range
fails:C-API Array function rb_ary_clear removes all elements from the array
fails:C-API Array function rb_ary_dup duplicates the array
fails:C-API Array function rb_ary_unshift prepends the element to the array
fails:C-API Array function rb_ary_shift removes and returns the first element
fails:C-API Array function rb_ary_shift returns nil when the array is empty
fails:C-API Array function rb_ary_store overwrites the element at the given position
fails:C-API Array function rb_ary_store writes to elements offset from the end if passed a negative index
fails:C-API Array function rb_ary_store raises on IndexError if the negative index is greater than the length
fails:C-API Array function rb_ary_store enlarges the array as needed
fails:C-API Array function rb_ary_concat concats two arrays
fails:C-API Array function rb_ary_plus adds two arrays together
fails:C-API Array function RARRAY_PTR returns a pointer to a C array of the array's elements
fails:C-API Array function RARRAY_PTR allows assigning to the elements of the C array
fails:C-API Array function RARRAY_LEN returns the size of the array
fails:C-API Array function RARRAY_AREF returns an element from the array
fails:C-API Array function rb_assoc_new returns an array containing the two elements
fails:C-API Array function rb_ary_includes returns true if the array includes the element
fails:C-API Array function rb_ary_includes returns false if the array does not include the element
Loading

0 comments on commit a8a22c4

Please sign in to comment.