Skip to content

Commit

Permalink
Showing 15 changed files with 68 additions and 54 deletions.
15 changes: 8 additions & 7 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -703,13 +703,15 @@ public IRubyObject default_value_get(ThreadContext context, IRubyObject[] args)
throw context.runtime.newArgumentError(args.length, 1);
}
}

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
return getRuntime().getNil();
return context.nil;
}
return ifNone;
}

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context, IRubyObject arg) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
@@ -1015,7 +1017,7 @@ protected void op_asetForString(Ruby runtime, RubyString key, IRubyObject value)
entry.value = value;
} else {
checkIterating();
if (!key.isFrozen()) key = runtime.freezeAndDedupString(key);
if (!key.isFrozen()) key = (RubyString)key.dupFrozen();
internalPut(key, value, false);
}
}
@@ -1026,7 +1028,7 @@ protected void op_asetSmallForString(Ruby runtime, RubyString key, IRubyObject v
entry.value = value;
} else {
checkIterating();
if (!key.isFrozen()) key = runtime.freezeAndDedupString(key);
if (!key.isFrozen()) key = (RubyString)key.dupFrozen();
internalPutSmall(key, value, false);
}
}
@@ -1533,16 +1535,15 @@ public IRubyObject shift(ThreadContext context) {

RubyHashEntry entry = head.nextAdded;
if (entry != head) {
RubyArray result = RubyArray.newArray(getRuntime(), entry.key, entry.value);
RubyArray result = RubyArray.newArray(context.runtime, entry.key, entry.value);
internalDeleteEntry(entry);
return result;
}

if ((flags & PROCDEFAULT_HASH_F) != 0) {
return Helpers.invoke(context, ifNone, "call", this, getRuntime().getNil());
} else {
return ifNone;
return this.callMethod(context, "default", context.nil);
}
return ifNone;
}

public final boolean fastDelete(IRubyObject key) {
9 changes: 8 additions & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -2531,7 +2531,14 @@ public Operand buildHash(HashNode hashNode) {
addInstr(new RuntimeHelperCall(hash, MERGE_KWARGS, new Operand[] { hash, splat}));
continue;
} else {
keyOperand = buildWithOrder(key, hasAssignments);
// TODO: This isn't super pretty. If AST were aware of literal hash string keys being "special"
// it could have an appropriate AST node for frozen string and this code would just go away.
if (key instanceof StrNode) {
StrNode strKey = (StrNode)key;
keyOperand = new FrozenString(strKey.getValue(), strKey.getCodeRange());
} else {
keyOperand = buildWithOrder(key, hasAssignments);
}
}

args.add(new KeyValuePair<>(keyOperand, buildWithOrder(pair.getValue(), hasAssignments)));
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/ir/operands/FrozenString.java
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@
* This is not an immutable literal because I can gsub!,
* for example, and modify the contents of the string.
* This is not like a Java string.
*
* TODO: This really should be ImmutableLiteral so it can constant propagate, etc.
*/
public class FrozenString extends StringLiteral {
/**
13 changes: 0 additions & 13 deletions core/src/main/java/org/jruby/util/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
@@ -387,7 +387,6 @@ private void processArgument() {
config.setCompileMode(RubyInstanceConfig.CompileMode.OFF);
config.setDisableGems(false);
} else if (extendedOption.equals("+T")) {
checkGraalVersion();
Options.PARSER_WARN_GROUPED_EXPRESSIONS.force(Boolean.FALSE.toString());
config.setCompileMode(RubyInstanceConfig.CompileMode.TRUFFLE);
config.setDisableGems(true);
@@ -713,18 +712,6 @@ private void logScriptResolutionFailure(String path) {
}
}

public static void checkGraalVersion() {
final String graalVersion = System.getProperty("graal.version", "unknown");
final String expectedGraalVersion = "0.7";

if (graalVersion.equals("unknown")) {
return;
} else if (!graalVersion.equals(expectedGraalVersion)) {
throw new RuntimeException("This version of JRuby is built against Graal " + expectedGraalVersion +
" but you are using it with version " + graalVersion + " - either update Graal or use with (-J)-original to disable Graal and ignore this error");
}
}

private static final Set<String> KNOWN_PROPERTIES = new HashSet<>();

static {
2 changes: 1 addition & 1 deletion maven/jruby-complete/src/it/integrity/verify.bsh
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ if ( !file.exists() )
throw new RuntimeException( "file '" + file + "' does not exists" );
}

expected = "uri:classloader:/META-INF/jruby.home";
expected = "uri:classloader://META-INF/jruby.home";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );

expected = "jruby home is a file: falsefalse";
2 changes: 1 addition & 1 deletion maven/jruby-dist/src/it/integrity/verify.bsh
Original file line number Diff line number Diff line change
@@ -49,5 +49,5 @@ if ( !log.contains( expected ) )
throw new RuntimeException( "log file does not contain '" + expected + "'" );
}

String unexpected = "uri:classloader:/META-INF/jruby.home";
String unexpected = "uri:classloader://META-INF/jruby.home";
if ( log.contains( unexpected ) ) throw new RuntimeException( "log file does contain unexpected '" + unexpected + "'" );
2 changes: 1 addition & 1 deletion maven/jruby-jars/src/it/integrity/verify.bsh
Original file line number Diff line number Diff line change
@@ -49,5 +49,5 @@ if ( !log.contains( expected ) )
throw new RuntimeException( "log file does not contain '" + expected + "'" );
}

expected = "uri:classloader:/META-INF/jruby.home";
expected = "uri:classloader://META-INF/jruby.home";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );
2 changes: 1 addition & 1 deletion maven/jruby/src/it/integrity/verify.bsh
Original file line number Diff line number Diff line change
@@ -67,5 +67,5 @@ if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not
expected = "maven/jruby/target/it/integrity/target/classes/hello.rb";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );

expected = "uri:classloader:/META-INF/jruby.home";
expected = "uri:classloader://META-INF/jruby.home";
if ( !log.contains( expected ) ) throw new RuntimeException( "log file does not contain '" + expected + "'" );
1 change: 1 addition & 0 deletions spec/truffle/tags/core/encoding/default_external_tags.txt
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ windows:Encoding.default_external with command line options returns the encoding
slow:Encoding.default_external with command line options is not changed by the -U option
slow:Encoding.default_external with command line options returns the encoding specified by '-E external'
slow:Encoding.default_external with command line options returns the encoding specified by '-E external:'
fails:Encoding.default_external with command line options is not changed by the -U option
2 changes: 1 addition & 1 deletion test/mri/excludes/TestHash.rb
Original file line number Diff line number Diff line change
@@ -12,5 +12,5 @@
exclude :test_NEWHASH_fstring_key, "needs investigation"
exclude :test_recursive_hash_value_struct, "needs investigation"
exclude :test_reject, "needs investigation"
exclude :test_shift_none, "needs investigation"
exclude :test_AREF_fstring_key, "Depends on MRI-specific GC.stat key"
exclude :test_ASET_fstring_key, "due https://github.com/jruby/jruby/commit/f3f0091da7d98c5df285"
1 change: 1 addition & 0 deletions test/mri/excludes/TestHash/TestSubHash.rb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
exclude :test_AREF_fstring_key, "Depends on MRI-specific GC.stat key"
exclude :test_ASET_fstring_key, "due https://github.com/jruby/jruby/commit/f3f0091da7d98c5df285"
16 changes: 11 additions & 5 deletions test/mri/ruby/test_hash.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: us-ascii -*-
require 'test/unit'
require 'continuation'
require_relative 'envutil'
EnvUtil.suppress_warning {require 'continuation'}

class TestHash < Test::Unit::TestCase

@@ -1265,8 +1265,14 @@ def eql?(other)
end
end

hash = {5 => bug9381}
assert_equal(bug9381, hash[wrapper.new(5)])
bad = [
5, true, false, nil,
0.0, 1.72723e-77,
].select do |x|
hash = {x => bug9381}
hash[wrapper.new(x)] != bug9381
end
assert_empty(bad, bug9381)
end

def test_label_syntax
@@ -1275,9 +1281,9 @@ def test_label_syntax
feature4935 = '[ruby-core:37553] [Feature #4935]'
x = 'world'
hash = assert_nothing_raised(SyntaxError) do
break eval(%q({foo: 1, "foo-bar": 2, "hello-#{x}": 3, 'hello-#{x}': 4}))
break eval(%q({foo: 1, "foo-bar": 2, "hello-#{x}": 3, 'hello-#{x}': 4, 'bar': {}}))
end
assert_equal({:foo => 1, :'foo-bar' => 2, :'hello-world' => 3, :'hello-#{x}' => 4}, hash)
assert_equal({:foo => 1, :'foo-bar' => 2, :'hello-world' => 3, :'hello-#{x}' => 4, :bar => {}}, hash)
end

class TestSubHash < TestHash
49 changes: 29 additions & 20 deletions tool/jt.rb
Original file line number Diff line number Diff line change
@@ -172,11 +172,12 @@ module Commands
include ShellUtils

def help
puts 'jt build build'
puts 'jt build truffle build only the Truffle part, assumes the rest is up-to-date'
puts 'jt build [options] build'
puts 'jt build truffle [options] build only the Truffle part, assumes the rest is up-to-date'
puts 'jt rebuild [options] clean and build'
puts ' --no-tests don\'t run JUnit unit tests'
puts 'jt clean clean'
puts 'jt irb irb'
puts 'jt rebuild clean and build'
puts 'jt run [options] args... run JRuby with -X+T and args'
puts ' --graal use Graal (set GRAAL_BIN or it will try to automagically find it)'
puts ' --asm show assembly (implies --graal)'
@@ -217,15 +218,22 @@ def help
puts ' branch names are mangled - eg truffle-head becomes GRAAL_BIN_TRUFFLE_HEAD'
end

def build(project = nil)
case project
when 'truffle'
mvn '-pl', 'truffle', 'package'
when nil
mvn 'package'
else
raise ArgumentError, project
def build(*args)
mvn_args = []

if args.delete 'truffle'
mvn_args += ['-pl', 'truffle', 'package']
end

if args.delete '--no-tests'
mvn_args << '-DskipTests'
end

unless args.empty?
raise ArgumentError, args.inspect
end

mvn *mvn_args
end

def clean
@@ -236,9 +244,9 @@ def irb(*args)
run(*%w[-S irb], *args)
end

def rebuild
def rebuild(*args)
clean
build
build *args
end

def run(*args)
@@ -503,13 +511,14 @@ def main(args)
exit
end

case args.first
when "rebuild"
send(args.shift)
when "build"
command = [args.shift]
command << args.shift if args.first == "truffle"
send(*command)
if ['build', 'rebuild'].include? args.first
build_args = [args.shift]

while ['truffle', '--no-tests'].include? args.first
build_args << args.shift
end

send(*build_args)
end

return if args.empty?
Original file line number Diff line number Diff line change
@@ -77,8 +77,8 @@ public CompareAndSetNode(RubyContext context, SourceSection sourceSection) {
}

@Specialization
public boolean compareAndSet(DynamicObject self, Object expected_value, Object value) {
return Layouts.ATOMIC_REFERENCE.compareAndSetValue(self, expected_value, value);
public boolean compareAndSet(DynamicObject self, Object expectedValue, Object value) {
return Layouts.ATOMIC_REFERENCE.compareAndSetValue(self, expectedValue, value);
}
}

Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ DynamicObject createAtomicReference(DynamicObjectFactory factory,

Object getValue(DynamicObject object);
void setValue(DynamicObject object, Object value);
boolean compareAndSetValue(DynamicObject object, Object expected_value, Object value);
boolean compareAndSetValue(DynamicObject object, Object expectedValue, Object value);
Object getAndSetValue(DynamicObject object, Object value);

}

0 comments on commit 23f4d15

Please sign in to comment.