Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d89439fb71db^
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1c5497235db6
Choose a head ref
  • 8 commits
  • 24 files changed
  • 3 contributors

Commits on Sep 21, 2015

  1. Copy the full SHA
    e06bdf6 View commit details

Commits on Sep 22, 2015

  1. Maybe Fixes #3340. JRuby NoMethodError: undefined method "open?" for …

    …#<File:/dev/tty>
    enebo committed Sep 22, 2015
    Copy the full SHA
    94423c4 View commit details
  2. Have identifiers track their coderange.

    Have symbols constructed from symbols no longer:
    1. double construct strings (and intern)
    2. No construction of extra ByteList to perform length check
    3. No more length check since we now supply coderange
    
    The StrNode path of symbol may also be able to set its CR as well, but that
    is a larger activity and for symbols is a very rare occurance.
    enebo committed Sep 22, 2015
    Copy the full SHA
    92d26c5 View commit details
  3. Copy the full SHA
    6d4df5b View commit details
  4. Copy the full SHA
    935c331 View commit details
  5. Copy the full SHA
    6948f92 View commit details
  6. Copy the full SHA
    d89439f View commit details
  7. Merge branch 'truffle-head' into truffle-head-om-dsl-jars

    Conflicts:
    	truffle/pom.xml
    chrisseaton committed Sep 22, 2015
    Copy the full SHA
    1c54972 View commit details
Showing with 303 additions and 49 deletions.
  1. +20 −5 core/src/main/java/org/jruby/ast/SymbolNode.java
  2. +13 −1 core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
  3. +1 −10 core/src/main/java/org/jruby/parser/ParserSupport.java
  4. +1 −1 lib/ruby/stdlib/io/console.rb
  5. +1 −1 pom.rb
  6. +2 −0 pom.xml
  7. +40 −0 truffle-om-dsl-api/pom.rb
  8. +86 −0 truffle-om-dsl-api/pom.xml
  9. +0 −5 {truffle → truffle-om-dsl-api}/src/main/java/org/jruby/truffle/om/dsl/api/Layout.java
  10. 0 {truffle → truffle-om-dsl-api}/src/main/java/org/jruby/truffle/om/dsl/api/Nullable.java
  11. 0 ...ffle-om-dsl-api}/src/main/java/org/jruby/truffle/om/dsl/api/UnexpectedLayoutRefusalException.java
  12. 0 {truffle → truffle-om-dsl-api}/src/main/java/org/jruby/truffle/om/dsl/api/Volatile.java
  13. +33 −0 truffle-om-dsl-processor/pom.rb
  14. +71 −0 truffle-om-dsl-processor/pom.xml
  15. 0 ...fle → truffle-om-dsl-processor}/src/main/java/org/jruby/truffle/om/dsl/processor/OMProcessor.java
  16. 0 ...le-om-dsl-processor}/src/main/java/org/jruby/truffle/om/dsl/processor/layout/LayoutGenerator.java
  17. 0 ...uffle-om-dsl-processor}/src/main/java/org/jruby/truffle/om/dsl/processor/layout/LayoutParser.java
  18. 0 ...-om-dsl-processor}/src/main/java/org/jruby/truffle/om/dsl/processor/layout/model/LayoutModel.java
  19. 0 ...le-om-dsl-processor}/src/main/java/org/jruby/truffle/om/dsl/processor/layout/model/NameUtils.java
  20. 0 ...dsl-processor}/src/main/java/org/jruby/truffle/om/dsl/processor/layout/model/PropertyBuilder.java
  21. 0 ...m-dsl-processor}/src/main/java/org/jruby/truffle/om/dsl/processor/layout/model/PropertyModel.java
  22. +4 −7 truffle/pom.rb
  23. +16 −16 truffle/pom.xml
  24. +15 −3 truffle/src/main/java/org/jruby/truffle/nodes/objectstorage/WriteHeadObjectFieldNode.java
25 changes: 20 additions & 5 deletions core/src/main/java/org/jruby/ast/SymbolNode.java
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@
package org.jruby.ast;

import java.awt.image.ByteLookupTable;
import java.nio.charset.Charset;
import java.util.List;

import org.jcodings.Encoding;
@@ -48,6 +49,7 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;

/**
* Represents a symbol (:symbol_name).
@@ -56,14 +58,27 @@ public class SymbolNode extends Node implements ILiteralNode, INameNode {
private String name;
private Encoding encoding;

public SymbolNode(ISourcePosition position, ByteList value) {
// Interned ident path (e.g. [':', ident]).
public SymbolNode(ISourcePosition position, String name, Encoding encoding, int cr) {
super(position, false);
this.name = value.toString().intern();
// FIXME: A full scan to determine whether we should back off to US-ASCII. Lexer should just do this properly.
if (value.lengthEnc() == value.length()) {
this.name = name; // Assumed all names are already intern'd by lexer.

if (encoding == USASCIIEncoding.INSTANCE || cr == StringSupport.CR_7BIT) {
this.encoding = USASCIIEncoding.INSTANCE;
} else {
this.encoding = value.getEncoding();
this.encoding = encoding;
}
}

// String path (e.g. [':', str_beg, str_content, str_end])
public SymbolNode(ISourcePosition position, ByteList value) {
super(position, false);
this.name = value.toString().intern();

if (value.getEncoding() != USASCIIEncoding.INSTANCE) {
int size = value.realSize();
this.encoding = value.getEncoding().strLength(value.unsafeBytes(), value.begin(), size) == size ?
USASCIIEncoding.INSTANCE : value.getEncoding();
}
}

14 changes: 13 additions & 1 deletion core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
Original file line number Diff line number Diff line change
@@ -286,9 +286,16 @@ public static Keyword getKeyword(String str) {
private LexState lex_state;
private LexState last_state;
public ISourcePosition tokline;
private int tokenCR;

public int getTokenCR() {
return tokenCR;
}

public void newtok(boolean unreadOnce) {
tokline = getPosition();
// We assume all idents are 7BIT until they aren't.
tokenCR = StringSupport.CR_7BIT;

tokp = lex_p - (unreadOnce ? 1 : 0); // We use tokp of ripper to mark beginning of tokens.
}
@@ -2706,7 +2713,12 @@ public void readUTFEscapeRegexpLiteral(ByteList buffer) throws IOException {
public boolean tokadd_mbchar(int first_byte) {
int length = precise_mbclen();

if (length <= 0) compile_error("invalid multibyte char (" + current_enc + ")");

if (length <= 0) {
compile_error("invalid multibyte char (" + current_enc + ")");
} else if (length > 1) {
tokenCR = StringSupport.CR_VALID;
}

lex_p += length - 1; // we already read first byte so advance pointer for remainder

11 changes: 1 addition & 10 deletions core/src/main/java/org/jruby/parser/ParserSupport.java
Original file line number Diff line number Diff line change
@@ -882,16 +882,7 @@ public DStrNode createDStrNode(ISourcePosition position) {
}

public Node asSymbol(ISourcePosition position, String value) {
// FIXME: tLABEL and identifiers could return ByteList and not String and make String on-demand for method names
// or lvars. This would prevent this re-extraction of bytes from a string with proper charset
try {
Charset charset = lexer.getEncoding().getCharset();
if (charset != null) return new SymbolNode(position, new ByteList(value.getBytes(charset), lexer.getEncoding()));
} catch (UnsupportedCharsetException e) {}

// for non-charsets we are screwed here since bytes will file.encoding and not what we read them as (see above FIXME for
// a much more invasive solution.
return new SymbolNode(position, new ByteList(value.getBytes(), lexer.getEncoding()));
return new SymbolNode(position, value, lexer.getEncoding(), lexer.getTokenCR());
}

public Node asSymbol(ISourcePosition position, Node value) {
2 changes: 1 addition & 1 deletion lib/ruby/stdlib/io/console.rb
Original file line number Diff line number Diff line change
@@ -156,7 +156,7 @@ def self.console(sym = nil)
con = @console
end

if !con.kind_of?(File) || !con.open? || !con.readable? # MRI checks IO internals here
if !con.kind_of?(File) || (con.kind_of?(IO) && !con.open? || !con.readable?) # MRI checks IO internals here
remove_instance_variable :@console if defined?(@console)
con = nil
end
2 changes: 1 addition & 1 deletion pom.rb
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@
'test-unit.version' => '3.0.3',
'power_assert.version' => '0.2.3' )

modules [ 'truffle', 'core', 'lib' ]
modules [ 'truffle', 'truffle-om-dsl-api', 'truffle-om-dsl-processor', 'core', 'lib' ]

plugin_management do
jar( 'junit:junit:4.11',
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -85,6 +85,8 @@ DO NOT MODIFIY - GENERATED CODE
</mailingLists>
<modules>
<module>truffle</module>
<module>truffle-om-dsl-api</module>
<module>truffle-om-dsl-processor</module>
<module>core</module>
<module>lib</module>
</modules>
40 changes: 40 additions & 0 deletions truffle-om-dsl-api/pom.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version = File.read( File.join( basedir, '..', 'VERSION' ) ).strip
project 'JRuby Truffle OM DSL API' do

model_version '4.0.0'
inherit 'org.jruby:jruby-parent', version
id 'org.jruby:jruby-truffle-om-dsl-api'

properties( 'polyglot.dump.pom' => 'pom.xml',
'polyglot.dump.readonly' => true,

'jruby.basedir' => '${basedir}/..' )

jar 'org.jruby:jruby-core', '${project.version}', :scope => 'provided'

truffle_version = '7a6719b66a744b822d9761cf8f2cd34904e22b2d-SNAPSHOT'
jar 'com.oracle.truffle:truffle-api:' + truffle_version

plugin( :compiler,
'encoding' => 'utf-8',
'debug' => 'true',
'verbose' => 'false',
'showWarnings' => 'true',
'showDeprecation' => 'true',
'source' => [ '${base.java.version}', '1.7' ],
'target' => [ '${base.javac.version}', '1.7' ],
'useIncrementalCompilation' => 'false' ) do
execute_goals( 'compile',
:id => 'anno',
:phase => 'process-resources',
'compilerArgs' => [ '-XDignore.symbol.file=true',
'-J-ea' ] )
end

plugin :shade do
execute_goals( 'shade',
:id => 'create lib/jruby-truffle-om-dsl.jar',
:phase => 'package',
'outputFile' => '${jruby.basedir}/lib/jruby-truffle-om-dsl.jar' )
end
end
86 changes: 86 additions & 0 deletions truffle-om-dsl-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT MODIFIY - GENERATED CODE
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.0.2.0-SNAPSHOT</version>
</parent>
<artifactId>jruby-truffle-om-dsl-api</artifactId>
<name>JRuby Truffle OM DSL API</name>
<properties>
<jruby.basedir>${basedir}/..</jruby.basedir>
<polyglot.dump.readonly>true</polyglot.dump.readonly>
<polyglot.dump.pom>pom.xml</polyglot.dump.pom>
</properties>
<dependencies>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>7a6719b66a744b822d9761cf8f2cd34904e22b2d-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>anno</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<compilerArg>-XDignore.symbol.file=true</compilerArg>
<compilerArg>-J-ea</compilerArg>
</compilerArgs>
</configuration>
</execution>
</executions>
<configuration>
<encoding>utf-8</encoding>
<debug>true</debug>
<verbose>false</verbose>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<source>${base.java.version}</source>
<source>1.7</source>
<target>${base.javac.version}</target>
<target>1.7</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>create lib/jruby-truffle-om-dsl.jar</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${jruby.basedir}/lib/jruby-truffle-om-dsl.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@

import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.ObjectType;
import org.jruby.truffle.om.dsl.processor.OMProcessor;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -190,10 +189,6 @@
* inherit the object type of the inherited shape.
*
* The class used should have empty constructor that is protected or more visible.
*
* <p><strong>Processing</strong></p>
*
* {@link Layout} annotations are processed by {@link OMProcessor}.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
33 changes: 33 additions & 0 deletions truffle-om-dsl-processor/pom.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version = File.read( File.join( basedir, '..', 'VERSION' ) ).strip
project 'JRuby Truffle OM DSL Processor' do

model_version '4.0.0'
inherit 'org.jruby:jruby-parent', version
id 'org.jruby:jruby-truffle-om-dsl-processor'

properties( 'polyglot.dump.pom' => 'pom.xml',
'polyglot.dump.readonly' => true,

'jruby.basedir' => '${basedir}/..' )

jar 'org.jruby:jruby-truffle-om-dsl-api', '${project.version}', :scope => 'provided'

truffle_version = '7a6719b66a744b822d9761cf8f2cd34904e22b2d-SNAPSHOT'
jar 'com.oracle.truffle:truffle-api:' + truffle_version

plugin( :compiler,
'encoding' => 'utf-8',
'debug' => 'true',
'verbose' => 'false',
'showWarnings' => 'true',
'showDeprecation' => 'true',
'source' => [ '${base.java.version}', '1.7' ],
'target' => [ '${base.javac.version}', '1.7' ],
'useIncrementalCompilation' => 'false' ) do
execute_goals( 'compile',
:id => 'anno',
:phase => 'process-resources',
'compilerArgs' => [ '-XDignore.symbol.file=true',
'-J-ea' ] )
end
end
71 changes: 71 additions & 0 deletions truffle-om-dsl-processor/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT MODIFIY - GENERATED CODE
-->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.0.2.0-SNAPSHOT</version>
</parent>
<artifactId>jruby-truffle-om-dsl-processor</artifactId>
<name>JRuby Truffle OM DSL Processor</name>
<properties>
<jruby.basedir>${basedir}/..</jruby.basedir>
<polyglot.dump.readonly>true</polyglot.dump.readonly>
<polyglot.dump.pom>pom.xml</polyglot.dump.pom>
</properties>
<dependencies>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-truffle-om-dsl-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>7a6719b66a744b822d9761cf8f2cd34904e22b2d-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>anno</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<compilerArgs>
<compilerArg>-XDignore.symbol.file=true</compilerArg>
<compilerArg>-J-ea</compilerArg>
</compilerArgs>
</configuration>
</execution>
</executions>
<configuration>
<encoding>utf-8</encoding>
<debug>true</debug>
<verbose>false</verbose>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<source>${base.java.version}</source>
<source>1.7</source>
<target>${base.javac.version}</target>
<target>1.7</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
</plugins>
</build>
</project>
11 changes: 4 additions & 7 deletions truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@
'jruby.basedir' => '${basedir}/..' )

jar 'org.jruby:jruby-core', '${project.version}', :scope => 'provided'
jar 'org.jruby:jruby-truffle-om-dsl-processor', '${project.version}', :scope => 'provided'
jar 'org.jruby:jruby-truffle-om-dsl-api', '${project.version}', :scope => 'provided'

repository( :url => 'http://lafo.ssw.uni-linz.ac.at/nexus/content/repositories/snapshots/',
:id => 'truffle' )
@@ -31,12 +33,6 @@
'source' => [ '${base.java.version}', '1.7' ],
'target' => [ '${base.javac.version}', '1.7' ],
'useIncrementalCompilation' => 'false' ) do
execute_goals( 'compile',
:id => 'anno',
:phase => 'process-resources',
'includes' => [ 'org/jruby/truffle/om/dsl/processor/OMProcessor.java' ],
'compilerArgs' => [ '-XDignore.symbol.file=true',
'-J-ea' ] )
execute_goals( 'compile',
:id => 'default-compile',
:phase => 'compile',
@@ -75,7 +71,8 @@
:phase => 'verify',
:artifactSet => { :includes => [
'com.oracle:truffle',
'com.oracle:truffle-interop' ] },
'com.oracle:truffle-interop',
'org.jruby:jruby-truffle-om-dsl-api' ] },
:outputFile => '${project.build.directory}/jruby-truffle-${project.version}-complete.jar' )
end
end
32 changes: 16 additions & 16 deletions truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -28,6 +28,18 @@ DO NOT MODIFIY - GENERATED CODE
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-truffle-om-dsl-processor</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-truffle-om-dsl-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.oracle.truffle</groupId>
<artifactId>truffle-api</artifactId>
@@ -77,22 +89,6 @@ DO NOT MODIFIY - GENERATED CODE
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>anno</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>org/jruby/truffle/om/dsl/processor/OMProcessor.java</include>
</includes>
<compilerArgs>
<compilerArg>-XDignore.symbol.file=true</compilerArg>
<compilerArg>-J-ea</compilerArg>
</compilerArgs>
</configuration>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
@@ -164,6 +160,7 @@ DO NOT MODIFIY - GENERATED CODE
<includes>
<include>com.oracle:truffle</include>
<include>com.oracle:truffle-interop</include>
<include>org.jruby:jruby-truffle-om-dsl-api</include>
</includes>
</artifactSet>
<outputFile>${project.build.directory}/jruby-truffle-${project.version}-complete.jar</outputFile>
@@ -192,6 +189,7 @@ DO NOT MODIFIY - GENERATED CODE
<includes>
<include>com.oracle:truffle</include>
<include>com.oracle:truffle-interop</include>
<include>org.jruby:jruby-truffle-om-dsl-api</include>
</includes>
</artifactSet>
<outputFile>${project.build.directory}/jruby-truffle-${project.version}-complete.jar</outputFile>
@@ -220,6 +218,7 @@ DO NOT MODIFIY - GENERATED CODE
<includes>
<include>com.oracle:truffle</include>
<include>com.oracle:truffle-interop</include>
<include>org.jruby:jruby-truffle-om-dsl-api</include>
</includes>
</artifactSet>
<outputFile>${project.build.directory}/jruby-truffle-${project.version}-complete.jar</outputFile>
@@ -248,6 +247,7 @@ DO NOT MODIFIY - GENERATED CODE
<includes>
<include>com.oracle:truffle</include>
<include>com.oracle:truffle-interop</include>
<include>org.jruby:jruby-truffle-om-dsl-api</include>
</includes>
</artifactSet>
<outputFile>${project.build.directory}/jruby-truffle-${project.version}-complete.jar</outputFile>
Original file line number Diff line number Diff line change
@@ -118,9 +118,21 @@ protected boolean hasField(DynamicObject object, Object value) {
}

protected Shape transitionWithNewField(Shape oldShape, Object value) {
final Location location = oldShape.allocator().locationForValue(value, EnumSet.of(LocationModifier.NonNull));
final Property property = Property.create(name, location, 0);
return oldShape.addProperty(property);
// This duplicates quite a bit of DynamicObject.define(), but should be fixed in Truffle soon.
final Property oldProperty = oldShape.getProperty(name);
if (oldProperty != null) {
if (oldProperty.getFlags() == 0 && oldProperty.getLocation().canSet(null, value)) {
return oldShape; // already the right shape
} else {
DynamicObject copy = oldShape.getLayout().newInstance(oldShape);
copy.define(name, value, 0);
return copy.getShape();
}
} else {
final Location location = oldShape.allocator().locationForValue(value, EnumSet.of(LocationModifier.NonNull));
final Property newProperty = Property.create(name, location, 0);
return oldShape.addProperty(newProperty);
}
}

protected Location getNewLocation(Shape newShape) {