-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into truffle-head
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
- 9.1.0.0
Showing
18 changed files
with
420 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require File.dirname(__FILE__) + "/../spec_helper" | ||
|
||
java_import 'java_integration.fixtures.SingleMethodInterface' | ||
java_import 'java_integration.fixtures.BeanLikeInterface' | ||
|
||
describe 'interface comparison' do | ||
|
||
it 'compares against interface like with an included module' do | ||
value_holder1 = Class.new do | ||
include SingleMethodInterface | ||
def initialize(val) | ||
@value = val | ||
end | ||
def callIt | ||
@value | ||
end | ||
end | ||
|
||
expect( value_holder1 < SingleMethodInterface ).to be true | ||
expect( value_holder1 === SingleMethodInterface ).to be false | ||
expect( SingleMethodInterface === value_holder1 ).to be false | ||
|
||
val = value_holder1.new(111) | ||
expect( val.class < SingleMethodInterface ).to be true | ||
expect( SingleMethodInterface === val.class ).to be false | ||
expect( SingleMethodInterface === val ).to be true | ||
expect( val === SingleMethodInterface ).to be false | ||
end | ||
|
||
it 'compares with interface like with an included module' do | ||
mod = Module.new { include Enumerable } | ||
val = Class.new { include mod }.new | ||
|
||
expect( val.class < Enumerable ).to be true | ||
expect( Enumerable === val.class ).to be false | ||
expect( val.class === Enumerable ).to be false | ||
expect( Enumerable === val ).to be true | ||
expect( val === Enumerable ).to be false | ||
expect( val === val.class.new ).to be false | ||
expect( val === mod ).to be false | ||
|
||
mod = Module.new do | ||
include BeanLikeInterface | ||
end | ||
sup = Class.new do | ||
include mod, java.lang.Runnable, java.lang.Iterable # includes Enumerable | ||
def each; yield nil end | ||
end | ||
child = Class.new(sup) { include java.lang.Cloneable; def getValue; 1; end } | ||
obj = child.new | ||
|
||
expect( child < BeanLikeInterface ).to be true | ||
expect( obj.class < java.lang.Runnable ).to be true | ||
expect( java.lang.Cloneable === obj ).to be true | ||
expect( java.lang.Iterable === obj ).to be true | ||
expect( BeanLikeInterface === obj ).to be true | ||
expect( Enumerable === obj ).to be true | ||
expect( obj === BeanLikeInterface ).to be false | ||
|
||
expect( obj === obj ).to be true | ||
expect( obj === sup.new ).to be false | ||
expect( obj === java.lang.Runnable.impl {} ).to be false # was true in < 9.1 ! | ||
expect( obj === java.util.HashSet.new ).to be false # was true in < 9.1 ! | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
require 'test/unit' | ||
|
||
class TestInclude < Test::Unit::TestCase | ||
module X ; end | ||
|
||
class Q | ||
def foo arg = [] | ||
arg << :Q | ||
end | ||
end | ||
|
||
class Y < Q ; include X end | ||
|
||
module A | ||
def foo arg = [] | ||
arg << :A ; super | ||
end | ||
end | ||
|
||
module X ; include A end | ||
|
||
module Z | ||
def foo arg = [] | ||
arg << :Z ; super | ||
end | ||
end | ||
|
||
class Y ; include Z end | ||
|
||
class Y ; include X end | ||
|
||
def test_include_order | ||
pend '[:A, :Z, :Q] on JRuby GH-1938' if defined? JRUBY_VERSION | ||
assert_equal [:Z, :A, :Q], Y.new.foo | ||
end | ||
|
||
module M1 ; V = 123 end | ||
module M2 ; V = 456 end | ||
|
||
class Foo | ||
include M1 | ||
|
||
def self.get; return V end | ||
end | ||
|
||
def test_including_module_busts_constant_caches | ||
assert_equal 123, Foo.get | ||
Foo.send(:include, M2) | ||
assert_equal 456, Foo.get | ||
end | ||
|
||
class Bar | ||
include M1, M2 | ||
end | ||
|
||
def test_multi_include | ||
assert_equal 123, Bar::V | ||
assert_equal Bar, Bar.send(:include) | ||
assert_equal Bar, Bar.send(:include, Comparable, Enumerable) | ||
|
||
assert_equal Object, Object.include | ||
assert_equal Object, Object.include(*[]) | ||
end | ||
|
||
# JRUBY-3036 | ||
def test_included_does_not_hit_each_class | ||
ObjectSpace.each_object(Class) do |cls| | ||
if cls < Top | ||
assert cls.top | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
module IncludedTestCaseModule; end | ||
|
||
class Top | ||
def self.top; true; end | ||
end | ||
|
||
class Next < Top | ||
include IncludedTestCaseModule | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
truffle/src/main/java/org/jruby/truffle/core/rope/LazyIntRope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.core.rope; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.nodes.ExplodeLoop; | ||
import org.jcodings.Encoding; | ||
import org.jcodings.specific.USASCIIEncoding; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
public class LazyIntRope extends LazyRope { | ||
|
||
final int value; | ||
|
||
public LazyIntRope(int value) { | ||
this(value, USASCIIEncoding.INSTANCE, length(value)); | ||
} | ||
|
||
protected LazyIntRope(int value, Encoding encoding, int length) { | ||
super(encoding, length, length); | ||
this.value = value; | ||
assert Integer.toString(value).length() == length; | ||
} | ||
|
||
@ExplodeLoop | ||
private static int length(int value) { | ||
if (value < 0) { | ||
/* | ||
* We can't represent -Integer.MIN_VALUE, and we're about to multiple by 10 to add the space needed for the | ||
* negative character, so handle both of those out-of-range cases. | ||
*/ | ||
|
||
if (value <= -1000000000) { | ||
return 11; | ||
} | ||
|
||
value = -value; | ||
value *= 10; | ||
} | ||
|
||
// If values were evenly distributed it would make more sense to do this in the reverse order, but they aren't | ||
|
||
for (int n = 1, limit = 10; n < 10; n++, limit *= 10) { | ||
if (value < limit) { | ||
return n; | ||
} | ||
} | ||
|
||
return 10; | ||
} | ||
|
||
@Override | ||
public Rope withEncoding(Encoding newEncoding, CodeRange newCodeRange) { | ||
if (newCodeRange != getCodeRange()) { | ||
CompilerDirectives.transferToInterpreter(); | ||
throw new UnsupportedOperationException("Cannot fast-path updating encoding with different code range."); | ||
} | ||
|
||
return new LazyIntRope(value, newEncoding, length(value)); | ||
} | ||
|
||
@Override | ||
public byte[] fulfill() { | ||
if (bytes == null) { | ||
bytes = Integer.toString(value).getBytes(StandardCharsets.US_ASCII); | ||
} | ||
|
||
return bytes; | ||
} | ||
|
||
public int getValue() { | ||
return value; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
truffle/src/main/java/org/jruby/truffle/core/rope/LazyRope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This | ||
* code is released under a tri EPL/GPL/LGPL license. You can use it, | ||
* redistribute it and/or modify it under the terms of the: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.core.rope; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; | ||
import org.jcodings.Encoding; | ||
|
||
public abstract class LazyRope extends Rope { | ||
|
||
protected LazyRope(Encoding encoding, int byteLength, int characterLength) { | ||
super(encoding, CodeRange.CR_7BIT, true, byteLength, characterLength, 1, null); | ||
} | ||
|
||
@Override | ||
protected byte getByteSlow(int index) { | ||
return getBytes()[index]; | ||
} | ||
|
||
public byte[] getBytes() { | ||
if (bytes == null) { | ||
doFulfill(); | ||
} | ||
|
||
return bytes; | ||
} | ||
|
||
@TruffleBoundary | ||
private void doFulfill() { | ||
bytes = fulfill(); | ||
} | ||
|
||
protected abstract byte[] fulfill(); | ||
|
||
@Override | ||
public String toString() { | ||
return RopeOperations.decodeUTF8(this); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters