Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
Conflicts:
	truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  • Loading branch information
chrisseaton committed Mar 21, 2015
2 parents f397049 + ed2f7e0 commit 3b85723
Show file tree
Hide file tree
Showing 53 changed files with 1,369 additions and 284 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyGenerator.java
Expand Up @@ -62,7 +62,7 @@ public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block b
IRubyObject proc;

if (args.length == 0) {
proc = RubyProc.newProc(runtime, block, Block.Type.LAMBDA);
proc = RubyProc.newProc(runtime, block, Block.Type.PROC);
} else {
if (!(args[0] instanceof RubyProc)) {
throw runtime.newTypeError(args[0], runtime.getProc());
Expand Down
42 changes: 3 additions & 39 deletions core/src/main/java/org/jruby/RubyString.java
Expand Up @@ -1402,45 +1402,9 @@ public IRubyObject reverse(ThreadContext context) {

@JRubyMethod(name = "reverse")
public IRubyObject reverse19(ThreadContext context) {
Ruby runtime = context.runtime;
if (value.getRealSize() <= 1) return strDup(context.runtime);

byte[]bytes = value.getUnsafeBytes();
int p = value.getBegin();
int len = value.getRealSize();
byte[]obytes = new byte[len];

boolean single = true;
Encoding enc = value.getEncoding();
// this really needs to be inlined here
if (singleByteOptimizable(enc)) {
for (int i = 0; i <= len >> 1; i++) {
obytes[i] = bytes[p + len - i - 1];
obytes[len - i - 1] = bytes[p + i];
}
} else {
int end = p + len;
int op = len;
while (p < end) {
int cl = StringSupport.length(enc, bytes, p, end);
if (cl > 1 || (bytes[p] & 0x80) != 0) {
single = false;
op -= cl;
System.arraycopy(bytes, p, obytes, op, cl);
p += cl;
} else {
obytes[--op] = bytes[p++];
}
}
}

RubyString result = new RubyString(runtime, getMetaClass(), new ByteList(obytes, false));

if (getCodeRange() == CR_UNKNOWN) setCodeRange(single ? CR_7BIT : CR_VALID);
Encoding encoding = value.getEncoding();
result.value.setEncoding(encoding);
result.copyCodeRangeForSubstr(this, encoding);
return result.infectBy(this);
RubyString str = strDup(context.runtime);
str.reverse_bang19(context);
return str;
}

public RubyString reverse_bang(ThreadContext context) {
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/java/org/jruby/ast/ArgsNode.java
Expand Up @@ -154,6 +154,18 @@ protected Arity calculateArity() {
public boolean hasKwargs() {
return hasKwargs;
}

public int countKeywords() {
if (hasKwargs) {
if (keywords == null) {
// Rest keyword argument
return 0;
}
return keywords.size();
} else {
return 0;
}
}

protected boolean hasMasgnArgs() {
if (preCount > 0) for (Node node : pre.childNodes()) {
Expand Down Expand Up @@ -254,6 +266,10 @@ public KeywordRestArgNode getKeyRest() {
return keyRest;
}

public boolean hasKeyRest() {
return keyRest != null;
}

public void checkArgCount(Ruby runtime, int argsLength) {
Arity.checkArgumentCount(runtime, argsLength, requiredArgsCount, maxArgsCount, hasKwargs);
}
Expand Down
18 changes: 8 additions & 10 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Expand Up @@ -187,23 +187,21 @@ public static IRubyObject initiateBreak(ThreadContext context, DynamicScope dynS
}
}

@Interp @JIT
@JIT
public static IRubyObject handleBreakAndReturnsInLambdas(ThreadContext context, StaticScope scope, DynamicScope dynScope, Object exc, Block.Type blockType) throws RuntimeException {
if ((exc instanceof IRBreakJump) && inNonMethodBodyLambda(scope, blockType)) {
// We just unwound all the way up because of a non-local break
if (((IRBreakJump)exc).scopeToReturnTo == dynScope) throw IRException.BREAK_LocalJumpError.getException(context.getRuntime());
}

if (exc instanceof IRReturnJump && (blockType == null || inLambda(blockType))) {
throw IRException.BREAK_LocalJumpError.getException(context.getRuntime());
} else if (exc instanceof IRReturnJump && (blockType == null || inLambda(blockType))) {
// Ignore non-local return processing in non-lambda blocks.
// Methods have a null blocktype
return handleNonlocalReturn(scope, dynScope, exc, blockType);
} else {
// Propagate
Helpers.throwException((Throwable)exc);
// should not get here
return null;
}

// Propagate
Helpers.throwException((Throwable)exc);
// should not get here
return null;
}

@JIT
Expand Down
1 change: 1 addition & 0 deletions spec/truffle/tags/core/array/delete_if_tags.txt
@@ -0,0 +1 @@
fails:Array#delete_if returns self when called on an Array emptied with #shift
1 change: 0 additions & 1 deletion spec/truffle/tags/core/array/delete_tags.txt
@@ -1,2 +1 @@
fails:Array#delete may be given a block that is executed if no element matches object
fails:Array#delete raises a RuntimeError on a frozen array
13 changes: 0 additions & 13 deletions spec/truffle/tags/core/array/pop_tags.txt

This file was deleted.

4 changes: 1 addition & 3 deletions spec/truffle/tags/core/array/reject_tags.txt
@@ -1,4 +1,2 @@
fails:Array#reject! removes elements for which block is true
fails:Array#reject! properly handles recursive arrays
fails:Array#reject! returns nil when called on an Array emptied with #shift
fails:Array#reject! returns nil if no changes are made

1 change: 0 additions & 1 deletion spec/truffle/tags/core/array/rindex_tags.txt

This file was deleted.

5 changes: 0 additions & 5 deletions spec/truffle/tags/core/array/sort_by_tags.txt
@@ -1,7 +1,2 @@
fails:Array#sort_by! sorts array in place by passing each element to the given block
fails:Array#sort_by! returns an Enumerator if not given a block
fails:Array#sort_by! completes when supplied a block that always returns the same result
fails:Array#sort_by! raises a RuntimeError on a frozen array
fails:Array#sort_by! raises a RuntimeError on an empty frozen array
fails:Array#sort_by! returns the specified value when it would break in the given block
fails:Array#sort_by! makes some modification even if finished sorting when it would break in the given block
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/append_tags.txt
@@ -1,4 +1 @@
fails:String#<< with Integer concatencates the argument interpreted as a codepoint
fails:String#<< with Integer returns a ASCII-8BIT string if self is US-ASCII and the argument is between 128-255 (inclusive)
fails:String#<< with Integer raises RangeError if the argument is an invalid codepoint for self's encoding
fails:String#<< with Integer raises RangeError if the argument is negative
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/chop_tags.txt

This file was deleted.

3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/concat_tags.txt
@@ -1,4 +1 @@
fails:String#concat with Integer concatencates the argument interpreted as a codepoint
fails:String#concat with Integer returns a ASCII-8BIT string if self is US-ASCII and the argument is between 128-255 (inclusive)
fails:String#concat with Integer raises RangeError if the argument is an invalid codepoint for self's encoding
fails:String#concat with Integer raises RangeError if the argument is negative
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/delete_tags.txt
@@ -1,2 +1 @@
fails:String#delete deletes multibyte characters
fails:String#delete deletes all chars in a sequence
1 change: 0 additions & 1 deletion spec/truffle/tags/core/string/dump_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/force_encoding_tags.txt

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/core/string/reverse_tags.txt

This file was deleted.

18 changes: 8 additions & 10 deletions tool/jt.rb
Expand Up @@ -16,6 +16,9 @@

JRUBY_DIR = File.expand_path('../..', __FILE__)

# wait for sub-processes to handle the interrupt
trap(:INT) {}

module Utilities

def self.graal_version
Expand Down Expand Up @@ -70,7 +73,7 @@ def self.igv_running?

def self.ensure_igv_running
unless igv_running?
spawn "#{find_graal_mx} igv"
spawn "#{find_graal_mx} igv", pgroup: true
sleep 5
puts
puts
Expand Down Expand Up @@ -111,15 +114,10 @@ module ShellUtils
private

def raw_sh(*args)
begin
result = system(*args)
rescue Interrupt
abort # Ignore Ctrl+C
else
unless result
$stderr.puts "FAILED (#{$?}): #{args * ' '}"
exit $?.exitstatus
end
result = system(*args)
unless result
$stderr.puts "FAILED (#{$?}): #{args * ' '}"
exit $?.exitstatus
end
end

Expand Down
4 changes: 4 additions & 0 deletions tool/truffle-findbugs-exclude.xml
Expand Up @@ -90,4 +90,8 @@
<Class name="org.jruby.truffle.nodes.debug.AssertNotCompiledNode" />
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD" />
</Match>
<Match>
<Class name="org.jruby.truffle.nodes.RubyCallNode" />
<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS" />
</Match>
</FindBugsFilter>
Expand Up @@ -96,7 +96,7 @@ public void init() {
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, SymbolNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, ThreadNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, TrueClassNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, PrimitiveNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, TrufflePrimitiveNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, EncodingNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, EncodingConverterNodesFactory.getFactories());
CoreMethodNodeManager.addCoreMethodNodes(rubyObjectClass, MethodNodesFactory.getFactories());
Expand Down Expand Up @@ -169,7 +169,7 @@ public void init() {

@Override
public Object execute(final Object self, final org.jruby.ast.RootNode rootNode) {
return execute(TranslatorDriver.ParserContext.TOP_LEVEL, self, null, rootNode);
return execute(TranslatorDriver.ParserContext.TOP_LEVEL, self, null, rootNode);
}

public Object execute(final TranslatorDriver.ParserContext parserContext, final Object self, final MaterializedFrame parentFrame, final org.jruby.ast.RootNode rootNode) {
Expand Down

0 comments on commit 3b85723

Please sign in to comment.