Skip to content

Commit

Permalink
Showing 1,112 changed files with 1,075 additions and 123,501 deletions.
4 changes: 2 additions & 2 deletions ci.hocon
Original file line number Diff line number Diff line change
@@ -295,7 +295,7 @@ test-cexts: {
environment: {
GEM_HOME: jruby-truffle-gem-test-pack/gems
GRAAL_HOME: sulong-workspace/sulong,
SULONG_DIR: sulong-workspace/sulong,
SULONG_HOME: sulong-workspace/sulong,
USE_SYSTEM_CLANG: "true",
HOST_VM: server,
HOST_VM_CONFIG: graal-core
@@ -343,7 +343,7 @@ sulong-benchmarks: {

environment: {
GRAAL_HOME: sulong-workspace/sulong,
SULONG_DIR: sulong-workspace/sulong,
SULONG_HOME: sulong-workspace/sulong,
USE_SYSTEM_CLANG: "true",
HOST_VM: server,
HOST_VM_CONFIG: graal-core,
22 changes: 11 additions & 11 deletions core/src/main/java/org/jruby/RubyRegexp.java
Original file line number Diff line number Diff line change
@@ -309,7 +309,7 @@ private RubyRegexp(Ruby runtime, ByteList str, RegexpOptions options) {
this(runtime);
str.getClass();

initializeCommon19(str, str.getEncoding(), options);
regexpInitialize(str, str.getEncoding(), options);
}

// used only by the compiler/interpreter (will set the literal flag)
@@ -401,7 +401,7 @@ static RubyRegexp newDummyRegexp(Ruby runtime, Regex regex) {
// MRI: rb_reg_new_str
public static RubyRegexp newRegexpFromStr(Ruby runtime, RubyString s, int options) {
RubyRegexp re = (RubyRegexp)runtime.getRegexp().allocate();
re.initializeCommon19(s, RegexpOptions.fromJoniOptions(options));
re.regexpInitializeString(s, RegexpOptions.fromJoniOptions(options));
return re;
}

@@ -886,7 +886,7 @@ public IRubyObject initialize_copy(IRubyObject re) {
RubyRegexp regexp = (RubyRegexp)re;
regexp.check();

return initializeCommon19(regexp.str, regexp.str.getEncoding(), regexp.getOptions());
return regexpInitialize(regexp.str, regexp.str.getEncoding(), regexp.getOptions());
}

private int objectAsJoniOptions(IRubyObject arg) {
@@ -911,7 +911,7 @@ public IRubyObject initialize_m(IRubyObject arg0, IRubyObject arg1, IRubyObject
@JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE)
public IRubyObject initialize_m19(IRubyObject arg) {
if (arg instanceof RubyRegexp) return initializeByRegexp19((RubyRegexp)arg);
return initializeCommon19(arg.convertToString(), new RegexpOptions());
return regexpInitializeString(arg.convertToString(), new RegexpOptions());
}

@JRubyMethod(name = "initialize", visibility = Visibility.PRIVATE)
@@ -921,7 +921,7 @@ public IRubyObject initialize_m19(IRubyObject arg0, IRubyObject arg1) {
return initializeByRegexp19((RubyRegexp)arg0);
}

return initializeCommon19(arg0.convertToString(),
return regexpInitializeString(arg0.convertToString(),
RegexpOptions.fromJoniOptions(objectAsJoniOptions(arg1)));
}

@@ -938,12 +938,12 @@ public IRubyObject initialize_m19(IRubyObject arg0, IRubyObject arg1, IRubyObjec
ByteList kcodeBytes = arg2.convertToString().getByteList();
if ((kcodeBytes.getRealSize() > 0 && kcodeBytes.getUnsafeBytes()[kcodeBytes.getBegin()] == 'n') ||
(kcodeBytes.getRealSize() > 1 && kcodeBytes.getUnsafeBytes()[kcodeBytes.getBegin() + 1] == 'N')) {
return initializeCommon19(arg0.convertToString().getByteList(), ASCIIEncoding.INSTANCE, newOptions);
return regexpInitialize(arg0.convertToString().getByteList(), ASCIIEncoding.INSTANCE, newOptions);
} else {
getRuntime().getWarnings().warn("encoding option is ignored - " + kcodeBytes);
}
}
return initializeCommon19(arg0.convertToString(), newOptions);
return regexpInitializeString(arg0.convertToString(), newOptions);
}

private IRubyObject initializeByRegexp19(RubyRegexp regexp) {
@@ -952,11 +952,11 @@ private IRubyObject initializeByRegexp19(RubyRegexp regexp) {
// but it did come from one.
RegexpOptions newOptions = (RegexpOptions) regexp.getOptions().clone();
newOptions.setLiteral(false);
return initializeCommon19(regexp.str, regexp.getEncoding(), newOptions);
return regexpInitialize(regexp.str, regexp.getEncoding(), newOptions);
}

// rb_reg_initialize_str
private RubyRegexp initializeCommon19(RubyString str, RegexpOptions options) {
private RubyRegexp regexpInitializeString(RubyString str, RegexpOptions options) {
if (isLiteral()) throw getRuntime().newSecurityError("can't modify literal regexp");
ByteList bytes = str.getByteList();
Encoding enc = bytes.getEncoding();
@@ -968,11 +968,11 @@ private RubyRegexp initializeCommon19(RubyString str, RegexpOptions options) {
enc = ASCIIEncoding.INSTANCE;
}
}
return initializeCommon19(bytes, enc, options);
return regexpInitialize(bytes, enc, options);
}

// rb_reg_initialize
private RubyRegexp initializeCommon19(ByteList bytes, Encoding enc, RegexpOptions options) {
public RubyRegexp regexpInitialize(ByteList bytes, Encoding enc, RegexpOptions options) {
Ruby runtime = getRuntime();
this.options = options;

47 changes: 18 additions & 29 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1444,30 +1444,7 @@ public Operand buildGetDefinition(Node node) {
case TRUENODE:
return new FrozenString("true");
case DREGEXPNODE: case DSTRNODE: {
final Node dNode = node;

// protected code
CodeBlock protectedCode = new CodeBlock() {
public Operand run() {
build(dNode);
// always an expression as long as we get through here without an exception!
return new FrozenString("expression");
}
};
// rescue block
CodeBlock rescueBlock = new CodeBlock() {
public Operand run() { return manager.getNil(); } // Nothing to do if we got an exception
};

// Try verifying definition, and if we get an JumpException exception, process it with the rescue block above
Operand v = protectCodeWithRescue(protectedCode, rescueBlock);
Label doneLabel = getNewLabel();
Variable tmpVar = getValueInTemporaryVariable(v);
addInstr(BNEInstr.create(doneLabel, tmpVar, manager.getNil()));
addInstr(new CopyInstr(tmpVar, new FrozenString("expression")));
addInstr(new LabelInstr(doneLabel));

return tmpVar;
return new FrozenString("expression");
}
case ARRAYNODE: { // If all elts of array are defined the array is as well
ArrayNode array = (ArrayNode) node;
@@ -1551,12 +1528,24 @@ public Operand run() {

CodeBlock protectedCode = new CodeBlock() {
public Operand run() {
Operand v = colon instanceof Colon2Node ?
build(((Colon2Node)colon).getLeftNode()) : new ObjectClass();
if (!(colon instanceof Colon2Node)) { // colon3 (weird inheritance)
return addResultInstr(new RuntimeHelperCall(createTemporaryVariable(),
IS_DEFINED_CONSTANT_OR_METHOD, new Operand[] {new ObjectClass(), new FrozenString(name)}));
}

Variable tmpVar = createTemporaryVariable();
addInstr(new RuntimeHelperCall(tmpVar, IS_DEFINED_CONSTANT_OR_METHOD, new Operand[] {v, new FrozenString(name)}));
return tmpVar;
Label bad = getNewLabel();
Label done = getNewLabel();
Variable result = createTemporaryVariable();
Operand test = buildGetDefinition(((Colon2Node) colon).getLeftNode());
addInstr(BEQInstr.create(test, manager.getNil(), bad));
Operand lhs = build(((Colon2Node) colon).getLeftNode());
addInstr(new RuntimeHelperCall(result, IS_DEFINED_CONSTANT_OR_METHOD, new Operand[] {lhs, new FrozenString(name)}));
addInstr(new JumpInstr(done));
addInstr(new LabelInstr(bad));
addInstr(new CopyInstr(result, manager.getNil()));
addInstr(new LabelInstr(done));

return result;
}
};

Original file line number Diff line number Diff line change
@@ -821,7 +821,14 @@ public static RubyModule findInstanceMethodContainer(ThreadContext context, Dyna
case MODULE_BODY:
case CLASS_BODY:
case METACLASS_BODY:
return (RubyModule) self;
// This is a similar scenario as the FIXME above that was added
// in b65a5842ecf56ca32edc2a17800968f021b6a064. At that time,
// I was wondering if it would affect this site here and looks
// like it does.
//
// Verify that the test in GH issue 4014 runs when ripping out
// this special instanceof check below.
return self instanceof RubyModule ? (RubyModule) self : self.getMetaClass();

case INSTANCE_METHOD:
case SCRIPT_BODY:
Original file line number Diff line number Diff line change
@@ -289,11 +289,13 @@ private IRubyObject unmarshalRegexp(MarshalState state) throws IOException {
byte opts = readSignedByte();
RegexpOptions reOpts = RegexpOptions.fromJoniOptions(opts);

RubyRegexp regexp = (RubyRegexp) runtime.getRegexp().allocate();
registerLinkTarget(regexp);

IRubyObject ivarHolder = null;

if (state.isIvarWaiting()) {
RubyString tmpStr = RubyString.newString(runtime, byteList);
registerLinkTarget(tmpStr);
defaultVariablesUnmarshal(tmpStr);
byteList = tmpStr.getByteList();
state.setIvarWaiting(false);
@@ -351,14 +353,12 @@ private IRubyObject unmarshalRegexp(MarshalState state) throws IOException {
byteList.setRealSize(dst - ptr);
}

RubyRegexp regexp = RubyRegexp.newRegexp(runtime, byteList, reOpts);
regexp.regexpInitialize(byteList, byteList.getEncoding(), reOpts);

if (ivarHolder != null) {
ivarHolder.getInstanceVariables().copyInstanceVariablesInto(regexp);
}

registerLinkTarget(regexp);

return regexp;
}

60 changes: 58 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);

@@ -95,6 +101,8 @@ int RTEST(VALUE value);
// Float

VALUE rb_float_new(double value);
VALUE rb_Float(VALUE value);
double RFLOAT_VALUE(VALUE value);

// String

@@ -125,6 +133,7 @@ VALUE rb_ary_new_capa(long capacity);
#define rb_ary_new2 rb_ary_new_capa
VALUE rb_ary_new_from_args(long n, ...);
#define rb_ary_new3 rb_ary_new_from_args
VALUE rb_ary_new4(long n, const VALUE *values);
VALUE rb_ary_push(VALUE array, VALUE value);
VALUE rb_ary_pop(VALUE array);
void rb_ary_store(VALUE array, long index, VALUE value);
@@ -198,6 +207,53 @@ 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);

// Mutexes

VALUE rb_mutex_new(void);
VALUE rb_mutex_locked_p(VALUE mutex);
VALUE rb_mutex_trylock(VALUE mutex);
VALUE rb_mutex_lock(VALUE mutex);
VALUE rb_mutex_unlock(VALUE mutex);
VALUE rb_mutex_sleep(VALUE mutex, VALUE timeout);
VALUE rb_mutex_synchronize(VALUE mutex, VALUE (*func)(VALUE arg), VALUE arg);

// Rational

VALUE rb_Rational(VALUE num, VALUE den);
#define rb_Rational1(x) rb_Rational((x), INT2FIX(1))
#define rb_Rational2(x,y) rb_Rational((x), (y))
VALUE rb_rational_raw(VALUE num, VALUE den);
#define rb_rational_raw1(x) rb_rational_raw((x), INT2FIX(1))
#define rb_rational_raw2(x,y) rb_rational_raw((x), (y))
VALUE rb_rational_new(VALUE num, VALUE den);
#define rb_rational_new1(x) rb_rational_new((x), INT2FIX(1))
#define rb_rational_new2(x,y) rb_rational_new((x), (y))
VALUE rb_rational_num(VALUE rat);
VALUE rb_rational_den(VALUE rat);
VALUE rb_flt_rationalize_with_prec(VALUE value, VALUE precision);
VALUE rb_flt_rationalize(VALUE value);

// Complex

VALUE rb_Complex(VALUE real, VALUE imag);
#define rb_Complex1(x) rb_Complex((x), INT2FIX(0))
#define rb_Complex2(x,y) rb_Complex((x), (y))
VALUE rb_complex_new(VALUE real, VALUE imag);
#define rb_complex_new1(x) rb_complex_new((x), INT2FIX(0))
#define rb_complex_new2(x,y) rb_complex_new((x), (y))
VALUE rb_complex_raw(VALUE real, VALUE imag);
#define rb_complex_raw1(x) rb_complex_raw((x), INT2FIX(0))
#define rb_complex_raw2(x,y) rb_complex_raw((x), (y))
VALUE rb_complex_polar(VALUE r, VALUE theta);
VALUE rb_complex_set_real(VALUE complex, VALUE real);
VALUE rb_complex_set_imag(VALUE complex, VALUE imag);

// GC

void rb_gc_register_address(VALUE *address);
VALUE rb_gc_enable();
VALUE rb_gc_disable();

#if defined(__cplusplus)
}
#endif
Original file line number Diff line number Diff line change
@@ -38,11 +38,6 @@ RequestForgeryProtectionControllerUsingExceptionTest:
FreeCookieControllerTest:
- test_should_not_render_button_to_with_token_tag
- test_should_not_render_form_with_token_tag
RescueControllerTest:
- test_block_rescue_handler_with_argument
- test_block_rescue_handler_with_argument_as_string
- test_proc_rescue_handle_with_argument
- test_proc_rescue_handle_with_argument_as_string
TestCaseTest:
- test_assert_select_with_body
- test_assert_select_without_body
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/English.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/English'
require_relative '../../stdlib/English'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/abbrev.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/abbrev'
require_relative '../../stdlib/abbrev'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/base64.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/base64'
require_relative '../../stdlib/base64'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/benchmark.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/benchmark'
require_relative '../../stdlib/benchmark'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/bigdecimal/jacobian.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/bigdecimal/jacobian'
require_relative '../../../stdlib/bigdecimal/jacobian'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/bigdecimal/ludcmp.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/bigdecimal/ludcmp'
require_relative '../../../stdlib/bigdecimal/ludcmp'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/bigdecimal/math.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/bigdecimal/math'
require_relative '../../../stdlib/bigdecimal/math'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/bigdecimal/newton.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/bigdecimal/newton'
require_relative '../../../stdlib/bigdecimal/newton'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/bigdecimal/util.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/bigdecimal/util'
require_relative '../../../stdlib/bigdecimal/util'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/cgi.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/cgi'
require_relative '../../stdlib/cgi'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/cgi/cookie.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/cgi/cookie'
require_relative '../../../stdlib/cgi/cookie'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/cgi/core.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/cgi/core'
require_relative '../../../stdlib/cgi/core'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/cgi/html.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/cgi/html'
require_relative '../../../stdlib/cgi/html'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/cgi/session.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/cgi/session'
require_relative '../../../stdlib/cgi/session'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/cgi/session/pstore.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../../stdlib/cgi/session/pstore'
require_relative '../../../../stdlib/cgi/session/pstore'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/cgi/util.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/cgi/util'
require_relative '../../../stdlib/cgi/util'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/cmath.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/cmath'
require_relative '../../stdlib/cmath'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/csv.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/csv'
require_relative '../../stdlib/csv'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/delegate.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/delegate'
require_relative '../../stdlib/delegate'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/drb.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../stdlib/drb'
require_relative '../../stdlib/drb'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/drb/acl.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/drb/acl'
require_relative '../../../stdlib/drb/acl'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/drb/drb.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/drb/drb'
require_relative '../../../stdlib/drb/drb'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/drb/eq.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/drb/eq'
require_relative '../../../stdlib/drb/eq'
2 changes: 1 addition & 1 deletion lib/ruby/truffle/mri/drb/extserv.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require_relative '../../stdlib/drb/extserv'
require_relative '../../../stdlib/drb/extserv'
Loading

0 comments on commit bc878fa

Please sign in to comment.