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: 995184167290
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2ee74f485eb3
Choose a head ref
  • 4 commits
  • 13 files changed
  • 2 contributors

Commits on Oct 18, 2014

  1. Performance improvements to event tracing.

    * Avoid CopyOnWriteArrayList iterator construction (use a simple
      array and iterate over that) for event hook list
    * Use int[] to represent line number hit counts.
    * Fix int[] size checking to avoid excessive allocation.
    * Fixes to trace correctly in compiler without Backtrace.
    headius authored and mkristian committed Oct 18, 2014
    1
    Copy the full SHA
    2592be7 View commit details
  2. Copy the full SHA
    3600ec5 View commit details
  3. [build] * run install goal on maven-integration-tests

    * make sure changes in src/templates will be used with out mvn clean
    mkristian committed Oct 18, 2014
    Copy the full SHA
    fb21bb0 View commit details
  4. Copy the full SHA
    2ee74f4 View commit details
31 changes: 24 additions & 7 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -3005,18 +3005,34 @@ public boolean isInterestedInEvent(RubyEvent event) {

private final CallTraceFuncHook callTraceFuncHook = new CallTraceFuncHook();

public void addEventHook(EventHook hook) {
public synchronized void addEventHook(EventHook hook) {
if (!RubyInstanceConfig.FULL_TRACE_ENABLED) {
// without full tracing, many events will not fire
getWarnings().warn("tracing (e.g. set_trace_func) will not capture all events without --debug flag");
}
eventHooks.add(hook);

EventHook[] hooks = eventHooks;
EventHook[] newHooks = new EventHook[hooks.length + 1];
newHooks[hooks.length] = hook;
eventHooks = newHooks;
hasEventHooks = true;
}

public void removeEventHook(EventHook hook) {
eventHooks.remove(hook);
hasEventHooks = !eventHooks.isEmpty();
public synchronized void removeEventHook(EventHook hook) {
EventHook[] hooks = eventHooks;
if (hooks.length == 0) return;
EventHook[] newHooks = new EventHook[hooks.length - 1];
boolean found = false;
for (int i = 0, j = 0; i < hooks.length; i++) {
if (!found && hooks[i] == hook && !found) { // exclude first found
found = true;
continue;
}
newHooks[j] = hooks[i];
j++;
}
eventHooks = newHooks;
hasEventHooks = newHooks.length > 0;
}

public void setTraceFunction(RubyProc traceFunction) {
@@ -4671,8 +4687,9 @@ public FilenoUtil getFilenoUtil() {

private final RubySymbol.SymbolTable symbolTable = new RubySymbol.SymbolTable(this);

private final List<EventHook> eventHooks = new CopyOnWriteArrayList<EventHook>();
private boolean hasEventHooks;
private static final EventHook[] EMPTY_HOOKS = new EventHook[0];
private volatile EventHook[] eventHooks = new EventHook[0];
private boolean hasEventHooks;
private boolean globalAbortOnExceptionEnabled = false;
private boolean doNotReverseLookupEnabled = false;
private volatile boolean objectSpaceEnabled;
24 changes: 13 additions & 11 deletions core/src/main/java/org/jruby/ext/coverage/CoverageData.java
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@

package org.jruby.ext.coverage;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.jruby.Ruby;
@@ -35,33 +36,33 @@
import org.jruby.runtime.builtin.IRubyObject;

public class CoverageData {
private volatile Map<String, Integer[]> coverage;
private volatile Map<String, int[]> coverage;

public boolean isCoverageEnabled() {
return coverage != null;
}

public synchronized void setCoverageEnabled(Ruby runtime, boolean enabled) {
if (enabled) {
coverage = new HashMap<String, Integer[]>();
coverage = new HashMap<String, int[]>();
runtime.addEventHook(COVERAGE_HOOK);
} else {
coverage = null;
}
}

public synchronized Map<String, Integer[]> resetCoverage(Ruby runtime) {
Map<String, Integer[]> coverage = this.coverage;
public synchronized Map<String, int[]> resetCoverage(Ruby runtime) {
Map<String, int[]> coverage = this.coverage;
runtime.removeEventHook(COVERAGE_HOOK);
this.coverage = null;

return coverage;
}

public synchronized Map<String, Integer[]> prepareCoverage(String filename, Integer[] lines) {
public synchronized Map<String, int[]> prepareCoverage(String filename, int[] lines) {
assert lines != null;

Map<String, Integer[]> coverage = this.coverage;
Map<String, int[]> coverage = this.coverage;

if (coverage != null) {
coverage.put(filename, lines);
@@ -78,21 +79,22 @@ public synchronized void eventHandler(ThreadContext context, String eventName, S
}

// make sure we have a lines array of acceptable length for the given file
Integer[] lines = coverage.get(file);
int[] lines = coverage.get(file);
if (lines == null) {
// loaded before coverage; skip
return;
} else if (lines.length <= line) {
} else if (lines.length < line) {
// can this happen? shouldn't all coverable lines be here already (from parse time)?
Integer[] newLines = new Integer[line];
int[] newLines = new int[line];
Arrays.fill(newLines, lines.length, line, -1); // mark unknown lines as -1
System.arraycopy(lines, 0, newLines, 0, lines.length);
lines = newLines;
coverage.put(file, lines);
}

// increment the line's count or set it to 1
Integer count = lines[line - 1];
if (count == null) {
int count = lines[line - 1];
if (count == -1) {
lines[line - 1] = 1;
} else {
lines[line - 1] = count + 1;
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/ext/coverage/CoverageModule.java
Original file line number Diff line number Diff line change
@@ -58,15 +58,15 @@ public static IRubyObject result(ThreadContext context, IRubyObject self) {
throw runtime.newRuntimeError("coverage measurement is not enabled");
}

Map<String, Integer[]> coverage = runtime.getCoverageData().resetCoverage(runtime);
Map<String, int[]> coverage = runtime.getCoverageData().resetCoverage(runtime);

// populate a Ruby Hash with coverage data
RubyHash covHash = RubyHash.newHash(runtime);
for (Map.Entry<String, Integer[]> entry : coverage.entrySet()) {
for (Map.Entry<String, int[]> entry : coverage.entrySet()) {
RubyArray ary = RubyArray.newArray(runtime, entry.getValue().length);
for (int i = 0; i < entry.getValue().length; i++) {
Integer integer = entry.getValue()[i];
ary.store(i, integer == null ? runtime.getNil() : runtime.newFixnum(integer));
int integer = entry.getValue()[i];
ary.store(i, integer == -1 ? context.nil : runtime.newFixnum(integer));
covHash.fastASetCheckString(runtime, RubyString.newString(runtime, entry.getKey()), ary);
}
}
13 changes: 8 additions & 5 deletions core/src/main/java/org/jruby/parser/ParserConfiguration.java
Original file line number Diff line number Diff line change
@@ -41,6 +41,8 @@
import org.jruby.util.ByteList;
import org.jruby.util.KCode;

import java.util.Arrays;

public class ParserConfiguration {
private DynamicScope existingScope = null;
private boolean asBlock = false;
@@ -60,9 +62,9 @@ public class ParserConfiguration {
private Encoding defaultEncoding;
private Ruby runtime;

private Integer[] coverage = EMPTY_COVERAGE;
private int[] coverage = EMPTY_COVERAGE;

private static final Integer[] EMPTY_COVERAGE = new Integer[0];
private static final int[] EMPTY_COVERAGE = new int[0];

public ParserConfiguration(Ruby runtime, int lineNumber, boolean inlineSource,
CompatVersion version) {
@@ -216,9 +218,10 @@ public void coverLine(int i) {

if (runtime.getCoverageData().isCoverageEnabled()) {
if (coverage == null) {
coverage = new Integer[i + 1];
coverage = new int[i + 1];
} else if (coverage.length <= i) {
Integer[] newCoverage = new Integer[i + 1];
int[] newCoverage = new int[i + 1];
Arrays.fill(newCoverage, -1);
System.arraycopy(coverage, 0, newCoverage, 0, coverage.length);
coverage = newCoverage;
}
@@ -231,7 +234,7 @@ public void coverLine(int i) {
/**
* Get the coverage array, indicating all coverable lines
*/
public Integer[] getCoverage() {
public int[] getCoverage() {
return coverage;
}

1 change: 1 addition & 0 deletions maven/jruby-complete/pom.rb
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@
source = File.join( ctx.basedir.to_pathname, 'src', 'templates', 'osgi_many_bundles_with_embedded_gems' )
[ 'equinox-3.6', 'equinox-3.7', 'felix-3.2', 'felix-4.4' ].each do |m|
target = File.join( ctx.basedir.to_pathname, 'src', 'it', 'osgi_many_bundles_with_embedded_gems_' + m )
FileUtils.rm_rf( target )
FileUtils.cp_r( source, target )
File.open( File.join( target, 'invoker.properties' ), 'w' ) do |f|
f.puts 'invoker.profiles = ' + m
Original file line number Diff line number Diff line change
@@ -78,6 +78,8 @@ public void testJRubyCreate() throws Exception {
System.err.println();

// System.setProperty( "jruby.debug.loadService", "true" );
System.setProperty( "jruby.native.verbose", "true" );

IsolatedScriptingContainer jruby = new IsolatedScriptingContainer();
jruby.addLoadPath( Scripts.class.getClassLoader() );
jruby.addGemPath( Gems.class.getClassLoader() );
@@ -89,24 +91,26 @@ public void testJRubyCreate() throws Exception {
System.err.println();
System.err.println();

String gemPath = (String) jruby.runScriptlet( "Gem::Specification.dirs.inspect" );
gemPath = gemPath.replaceAll( "bundle[^:]*://[^/]*", "bundle:/" );
assertEquals( gemPath, "[\"uri:bundle://specifications\", \"uri:bundle://specifications\", \"uri:bundle://META-INF/jruby.home/lib/ruby/gems/shared/specifications\"]" );

// ensure we can load rake from the default gems
boolean loaded = (Boolean) jruby.runScriptlet( "require 'rake'" );
assertEquals(true, loaded);

String list = (String) jruby.runScriptlet( "Gem.loaded_specs.keys.inspect" );
assertEquals(list, "[\"rake\"]");

// ensure we can load openssl (with its bouncy-castle jars)
loaded = (Boolean) jruby.runScriptlet( "require 'openssl'" );
assertEquals(true, loaded);

// ensure we can load ffi
loaded = (Boolean) jruby.runScriptlet( "require 'ffi'" );
assertEquals(true, loaded);
//assertEquals(true, loaded);
list = (String) jruby.runScriptlet( "Gem.loaded_specs.keys.inspect" );
assertEquals(list, "[\"rake\"]");

String gemPath = (String) jruby.runScriptlet( "Gem::Specification.dirs.inspect" );
gemPath = gemPath.replaceAll( "bundle[^:]*://[^/]*", "bundle:/" );
assertEquals( gemPath, "[\"uri:bundle://specifications\", \"uri:bundle://specifications\", \"uri:bundle://META-INF/jruby.home/lib/ruby/gems/shared/specifications\"]" );
// ensure we can load openssl (with its bouncy-castle jars)
loaded = (Boolean) jruby.runScriptlet( "require 'openssl'" );
assertEquals(true, loaded);

jruby.runScriptlet( "require 'jar-dependencies'; require 'krypt'" );
list = (String) jruby.runScriptlet( "Gem.loaded_specs.keys.inspect" );
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import java.io.*;
import org.codehaus.plexus.util.FileUtils;


String log = FileUtils.fileRead( new File( basedir, "build.log" ) );
String expected = "Successfully loaded native POSIX impl.";
if ( !log.contains( expected ) )
{
throw new RuntimeException( "log file does not contain '" + expected + "'" );
}
4 changes: 2 additions & 2 deletions maven/jruby/pom.rb
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@
activation do
jdk '1.6'
end
plugin :invoker, :pomExcludes => ['jetty/pom.xml','j2ee_jetty/pom.xml','j2ee_wildfly/pom.xml', '${its.j2ee}', '${its.osgi}']
plugin :invoker, :pomExcludes => [ '${its.j2ee}', '${its.osgi}' ]
end

profile :id => :wlp do
@@ -72,7 +72,7 @@
system( 'java -jar ' + wlp.to_pathname + ' --acceptLicense ' + ctx.project.build.directory.to_pathname )
system( File.join( ctx.project.build.directory.to_pathname,
'wlp/bin/server' ) + 'create testing' )
#FileUtils.cp_r( File.join( ctx.basedir.to_pathname, 'src/templates/j2ee_wlp'), File.join( ctx.basedir.to_pathname, 'src/it' ) )
FileUtils.cp_r( File.join( ctx.basedir.to_pathname, 'src/templates/j2ee_wlp'), File.join( ctx.basedir.to_pathname, 'src/it' ) )
end
end
end
3 changes: 0 additions & 3 deletions maven/jruby/pom.xml
Original file line number Diff line number Diff line change
@@ -124,9 +124,6 @@
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<pomExcludes>
<pomExclude>jetty/pom.xml</pomExclude>
<pomExclude>j2ee_jetty/pom.xml</pomExclude>
<pomExclude>j2ee_wildfly/pom.xml</pomExclude>
<pomExclude>${its.j2ee}</pomExclude>
<pomExclude>${its.osgi}</pomExclude>
</pomExcludes>
2 changes: 1 addition & 1 deletion maven/pom.rb
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@

# module to profile map
map = { 'jruby' => [ :release, :main, :osgi, :j2ee ],
'jruby-noasm' => [ :release, :main, :osgi ],
'jruby-noasm' => [ :release, :main ],
'jruby-stdlib' => [ :release, :main, :complete, :dist, 'jruby-jars', :osgi, :j2ee ],
'jruby-complete' => [ :release, :complete, :osgi ],
'jruby-jars' => [ :release, 'jruby-jars' ],
1 change: 0 additions & 1 deletion maven/pom.xml
Original file line number Diff line number Diff line change
@@ -80,7 +80,6 @@
<id>osgi</id>
<modules>
<module>jruby</module>
<module>jruby-noasm</module>
<module>jruby-stdlib</module>
<module>jruby-complete</module>
</modules>
20 changes: 19 additions & 1 deletion pom.rb
Original file line number Diff line number Diff line change
@@ -134,11 +134,14 @@
plugin( :invoker, '1.8',
'settingsFile' => '${basedir}/src/it/settings.xml',
'localRepositoryPath' => '${project.build.directory}/local-repo',
'properties' => { 'project.version' => '${project.version}' },
'pomIncludes' => [ '*/pom.xml' ],
'pomExcludes' => [ '${its.j2ee}', '${its.osgi}' ],
'projectsDirectory' => 'src/it',
'cloneProjectsTo' => '${project.build.directory}/it',
'preBuildHookScript' => 'setup.bsh',
'postBuildHookScript' => 'verify.bsh',
'goals' => [:install],
'streamLogs' => 'true' ) do
execute_goals( 'install', 'run',
:id => 'integration-test' )
@@ -199,7 +202,7 @@
end
end

[ 'osgi', 'j2ee', 'jruby-jars', 'main', 'complete', 'dist' ].each do |name|
[ 'jruby-jars', 'main', 'complete', 'dist' ].each do |name|

profile name do

@@ -211,6 +214,21 @@
end
end

[ 'osgi', 'j2ee' ].each do |name|
profile name do

modules [ 'maven' ]

properties( 'invoker.skip' => false,
"its.#{name}" => 'no-excludes/pom.xml' )

build do
default_goal 'install'
plugin :invoker, 'pomIncludes' => [ "#{name}*/pom.xml" ]
end
end
end

all_modules = [ 'test', 'maven' ]

profile 'all' do
50 changes: 44 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -307,13 +307,23 @@
<configuration>
<settingsFile>${basedir}/src/it/settings.xml</settingsFile>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<properties>
<project.version>${project.version}</project.version>
</properties>
<pomIncludes>
<pomInclude>*/pom.xml</pomInclude>
</pomIncludes>
<pomExcludes>
<pomExclude>${its.j2ee}</pomExclude>
<pomExclude>${its.osgi}</pomExclude>
</pomExcludes>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<preBuildHookScript>setup.bsh</preBuildHookScript>
<postBuildHookScript>verify.bsh</postBuildHookScript>
<goals>
<goal>install</goal>
</goals>
<streamLogs>true</streamLogs>
</configuration>
</plugin>
@@ -580,7 +590,7 @@
</modules>
</profile>
<profile>
<id>osgi</id>
<id>jruby-jars</id>
<build>
<defaultGoal>install</defaultGoal>
</build>
@@ -589,7 +599,7 @@
</modules>
</profile>
<profile>
<id>j2ee</id>
<id>main</id>
<build>
<defaultGoal>install</defaultGoal>
</build>
@@ -598,7 +608,7 @@
</modules>
</profile>
<profile>
<id>jruby-jars</id>
<id>complete</id>
<build>
<defaultGoal>install</defaultGoal>
</build>
@@ -607,7 +617,7 @@
</modules>
</profile>
<profile>
<id>main</id>
<id>dist</id>
<build>
<defaultGoal>install</defaultGoal>
</build>
@@ -616,22 +626,50 @@
</modules>
</profile>
<profile>
<id>complete</id>
<id>osgi</id>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<pomIncludes>
<pomInclude>osgi*/pom.xml</pomInclude>
</pomIncludes>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>maven</module>
</modules>
<properties>
<its.osgi>no-excludes/pom.xml</its.osgi>
<invoker.skip>false</invoker.skip>
</properties>
</profile>
<profile>
<id>dist</id>
<id>j2ee</id>
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<pomIncludes>
<pomInclude>j2ee*/pom.xml</pomInclude>
</pomIncludes>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>maven</module>
</modules>
<properties>
<its.j2ee>no-excludes/pom.xml</its.j2ee>
<invoker.skip>false</invoker.skip>
</properties>
</profile>
<profile>
<id>all</id>