Skip to content
Permalink
Browse files
Merge branch 'master' into truffle-head
Conflicts:
	core/src/main/java/org/jruby/truffle/runtime/core/RubyRegexp.java
  • Loading branch information
chrisseaton committed Dec 19, 2014
2 parents ddee507 + 40ba655 commit 8b16e6b00a3efa200838d4141c2e6894ff9d85c3
Showing with 744 additions and 702 deletions.
  1. +11 −0 core/src/main/java/org/jruby/Ruby.java
  2. +50 −13 core/src/main/java/org/jruby/RubyFile.java
  3. +2 −1 core/src/main/java/org/jruby/RubyInstanceConfig.java
  4. +1 −3 core/src/main/java/org/jruby/RubyMatchData.java
  5. +13 −152 core/src/main/java/org/jruby/RubyString.java
  6. +19 −19 core/src/main/java/org/jruby/ir/IRBuilder.java
  7. +35 −0 core/src/main/java/org/jruby/ir/IRManager.java
  8. +1 −1 core/src/main/java/org/jruby/ir/IRScope.java
  9. +0 −3 core/src/main/java/org/jruby/ir/IRVisitor.java
  10. +1 −2 core/src/main/java/org/jruby/ir/Operation.java
  11. +70 −10 core/src/main/java/org/jruby/ir/dataflow/analyses/UnboxableOpsAnalysisNode.java
  12. +4 −6 core/src/main/java/org/jruby/ir/instructions/AttrAssignInstr.java
  13. +19 −23 core/src/main/java/org/jruby/ir/instructions/CallBase.java
  14. +12 −15 core/src/main/java/org/jruby/ir/instructions/CallInstr.java
  15. +5 −6 core/src/main/java/org/jruby/ir/instructions/ClassSuperInstr.java
  16. +1 −2 core/src/main/java/org/jruby/ir/instructions/ConstMissingInstr.java
  17. +5 −7 core/src/main/java/org/jruby/ir/instructions/InstanceSuperInstr.java
  18. +0 −76 core/src/main/java/org/jruby/ir/instructions/MethodLookupInstr.java
  19. +5 −7 core/src/main/java/org/jruby/ir/instructions/NoResultCallInstr.java
  20. +4 −5 core/src/main/java/org/jruby/ir/instructions/PushFrameInstr.java
  21. +3 −2 core/src/main/java/org/jruby/ir/instructions/UnresolvedSuperInstr.java
  22. +1 −1 core/src/main/java/org/jruby/ir/instructions/specialized/OneArgOperandAttrAssignInstr.java
  23. +1 −1 core/src/main/java/org/jruby/ir/operands/LocalVariable.java
  24. +0 −113 core/src/main/java/org/jruby/ir/operands/MethAddr.java
  25. +0 −120 core/src/main/java/org/jruby/ir/operands/MethodHandle.java
  26. +0 −2 core/src/main/java/org/jruby/ir/operands/OperandType.java
  27. +1 −2 core/src/main/java/org/jruby/ir/passes/AddCallProtocolInstructions.java
  28. +5 −6 core/src/main/java/org/jruby/ir/persistence/InstrDecoderMap.java
  29. +2 −7 core/src/main/java/org/jruby/ir/persistence/InstrEncoderMap.java
  30. +0 −4 core/src/main/java/org/jruby/ir/persistence/OperandDecoderMap.java
  31. +0 −10 core/src/main/java/org/jruby/ir/persistence/OperandEncoderMap.java
  32. +8 −26 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  33. +4 −0 core/src/main/java/org/jruby/runtime/ThreadContext.java
  34. +4 −3 core/src/main/java/org/jruby/truffle/nodes/core/FixnumOrBignumNode.java
  35. +38 −0 core/src/main/java/org/jruby/truffle/nodes/core/FloatNodes.java
  36. +45 −5 core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  37. +7 −0 core/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  38. +61 −17 core/src/main/java/org/jruby/truffle/runtime/core/RubyRegexp.java
  39. +9 −0 core/src/main/java/org/jruby/truffle/runtime/core/RubyString.java
  40. +78 −0 core/src/main/java/org/jruby/util/Dir.java
  41. +143 −1 core/src/main/java/org/jruby/util/StringSupport.java
  42. +1 −1 maven/jruby-jars/src/it/extended/src/test/java/org/example/SimpleTest.java
  43. +1 −1 maven/jruby/src/it/extended/src/test/java/org/example/SimpleTest.java
  44. +5 −4 spec/java_integration/rubygems/rubygems_spec.rb
  45. +54 −1 spec/ruby/core/file/shared/fnmatch.rb
  46. +10 −2 spec/truffle/tags/core/file/fnmatch_tags.txt
  47. +0 −1 spec/truffle/tags/core/float/to_f_tags.txt
  48. +0 −1 spec/truffle/tags/core/float/to_i_tags.txt
  49. +0 −1 spec/truffle/tags/core/float/to_int_tags.txt
  50. +0 −9 spec/truffle/tags/core/float/to_s_tags.txt
  51. +0 −1 spec/truffle/tags/core/float/truncate_tags.txt
  52. +0 −7 spec/truffle/tags/core/string/scan_tags.txt
  53. +5 −0 test/jruby/test_file.rb
  54. +0 −2 test/mri/excludes/TestFnmatch.rb
@@ -42,6 +42,7 @@
import org.jruby.compiler.Constantizable;
import org.jruby.compiler.NotCompilableException;
import org.jruby.ir.IRScriptBody;
import org.jruby.parser.StaticScope;
import org.objectweb.asm.util.TraceClassVisitor;

import jnr.constants.Constant;
@@ -3164,6 +3165,16 @@ public void tearDown(boolean systemExit) {
// clear out threadlocals so they don't leak
recursive = new ThreadLocal<Map<String, RubyHash>>();

ThreadContext context = getCurrentContext();

// FIXME: 73df3d230b9d92c7237d581c6366df1b92ad9b2b exposed no toplevel scope existing anymore (I think the
// bogus scope I removed was playing surrogate toplevel scope and wallpapering this bug). For now, add a
// bogus scope back for at_exit block run. This is buggy if at_exit is capturing vars.
if (!context.hasAnyScopes()) {
StaticScope topStaticScope = getStaticScopeFactory().newLocalScope(null);
context.pushScope(new ManyVarsDynamicScope(topStaticScope, null));
}

while (!atExitBlocks.empty()) {
RubyProc proc = atExitBlocks.pop();
try {
@@ -53,6 +53,7 @@
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
import java.nio.file.attribute.PosixFileAttributeView;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.concurrent.TimeUnit;
import java.util.jar.JarFile;
@@ -199,6 +200,7 @@ public static RubyClass createFileClass(Ruby runtime) {
constants.setConstant("FNM_SYSCASE", runtime.newFixnum(FNM_SYSCASE));
constants.setConstant("FNM_DOTMATCH", runtime.newFixnum(FNM_DOTMATCH));
constants.setConstant("FNM_PATHNAME", runtime.newFixnum(FNM_PATHNAME));
constants.setConstant("FNM_EXTGLOB", runtime.newFixnum(FNM_EXTGLOB));

// flock operations
constants.setConstant("LOCK_SH", runtime.newFixnum(RubyFile.LOCK_SH));
@@ -765,7 +767,7 @@ public static IRubyObject expand_path(ThreadContext context, IRubyObject recv, I

@JRubyMethod(name = "expand_path", required = 1, optional = 1, meta = true)
public static IRubyObject expand_path19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
RubyString path = (RubyString) expandPathInternal(context, recv, args, true);
RubyString path = (RubyString) expandPathInternal(context, recv, args, true, false);
path.force_encoding(context, context.runtime.getEncodingService().getDefaultExternal());

return path;
@@ -793,25 +795,21 @@ public static IRubyObject expand_path19(ThreadContext context, IRubyObject recv,
*/
@JRubyMethod(required = 1, optional = 1, meta = true)
public static IRubyObject absolute_path(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
return expandPathInternal(context, recv, args, false);
return expandPathInternal(context, recv, args, false, false);
}

@JRubyMethod(required = 1, optional = 1, meta = true)
public static IRubyObject realdirpath(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
return expandPathInternal(context, recv, args, false);
return expandPathInternal(context, recv, args, false, false);
}

@JRubyMethod(required = 1, optional = 1, meta = true)
public static IRubyObject realpath(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
IRubyObject file = expandPathInternal(context, recv, args, false);
IRubyObject file = expandPathInternal(context, recv, args, false, true);
if (!RubyFileTest.exist_p(recv, file).isTrue()) {
throw context.runtime.newErrnoENOENTError(file.toString());
}
try {
return context.runtime.newString(new File(file.toString()).getCanonicalPath());
} catch (IOException ioex) {
throw context.runtime.newErrnoENOENTError(file.toString());
}
return file;
}

/**
@@ -826,16 +824,41 @@ public static IRubyObject realpath(ThreadContext context, IRubyObject recv, IRub
@JRubyMethod(name = {"fnmatch", "fnmatch?"}, required = 2, optional = 1, meta = true)
public static IRubyObject fnmatch(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
int flags = args.length == 3 ? RubyNumeric.num2int(args[2]) : 0;
boolean braces_match = false;
boolean extglob = (flags & FNM_EXTGLOB) != 0;

ByteList pattern = args[0].convertToString().getByteList();
ByteList path = get_path(context, args[1]).getByteList();

if (org.jruby.util.Dir.fnmatch(pattern.getUnsafeBytes(), pattern.getBegin(), pattern.getBegin()+pattern.getRealSize(), path.getUnsafeBytes(), path.getBegin(), path.getBegin()+path.getRealSize(), flags) == 0) {
if(extglob) {
String spattern = args[0].asJavaString();
ArrayList<String> patterns = org.jruby.util.Dir.braces(spattern, flags, new ArrayList<String>());

ArrayList<Boolean> matches = new ArrayList<Boolean>();
for(int i = 0; i < patterns.size(); i++) {
String p = patterns.get(i);
boolean match = dir_fnmatch(new ByteList(p.getBytes()), path, flags);
matches.add(match);
}
braces_match = matches.contains(true);
}

if(braces_match || dir_fnmatch(pattern, path, flags)) {
return context.runtime.getTrue();
}
return context.runtime.getFalse();
}


private static boolean dir_fnmatch(ByteList pattern, ByteList path, int flags) {
return org.jruby.util.Dir.fnmatch(pattern.getUnsafeBytes(),
pattern.getBegin(),
pattern.getBegin()+pattern.getRealSize(),
path.getUnsafeBytes(),
path.getBegin(),
path.getBegin()+path.getRealSize(),
flags) == 0;
}

@JRubyMethod(name = "ftype", required = 1, meta = true)
public static IRubyObject ftype(ThreadContext context, IRubyObject recv, IRubyObject filename) {
return context.runtime.newFileStat(get_path(context, filename).getUnicodeValue(), true).ftype();
@@ -1462,7 +1485,7 @@ private static boolean isWindowsDriveLetter(char c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}

private static IRubyObject expandPathInternal(ThreadContext context, IRubyObject recv, IRubyObject[] args, boolean expandUser) {
private static IRubyObject expandPathInternal(ThreadContext context, IRubyObject recv, IRubyObject[] args, boolean expandUser, boolean canonicalize) {
Ruby runtime = context.runtime;

String relativePath = get_path(context, args[0]).getUnicodeValue();
@@ -1493,6 +1516,9 @@ private static IRubyObject expandPathInternal(ThreadContext context, IRubyObject
relativePath = uriParts[1];
}

// Now that we're not treating it as a URI, we need to honor the canonicalize flag.
// Do not insert early returns below.

// If there's a second argument, it's the path to which the first
// argument is relative.
if (args.length == 2 && !args[1].isNil()) {
@@ -1582,7 +1608,17 @@ private static IRubyObject expandPathInternal(ThreadContext context, IRubyObject
path = JRubyFile.create(cwd, relativePath);
}

return runtime.newString(padSlashes + canonicalize(path.getAbsolutePath()));
String realPath = padSlashes + canonicalize(path.getAbsolutePath());

if (canonicalize) {
try {
realPath = new File(realPath).getCanonicalPath();
} catch (IOException ioe) {
// Earlier canonicalization will have to do.
}
}

return runtime.newString(realPath);
}

public static String[] splitURI(String path) {
@@ -1886,6 +1922,7 @@ public IRubyObject initialize19(IRubyObject[] args, Block block) {
private static final int FNM_PATHNAME = 2;
private static final int FNM_DOTMATCH = 4;
private static final int FNM_CASEFOLD = 8;
private static final int FNM_EXTGLOB = 16;
private static final int FNM_SYSCASE = Platform.IS_WINDOWS ? FNM_CASEFOLD : 0;

private static final String[] SLASHES = {"", "/", "//"};
@@ -1798,7 +1798,8 @@ private static int initGlobalJavaVersion() {
} else if (specVersion.equals("1.7") || specVersion.equals("1.8")) {
return Opcodes.V1_7;
} else {
throw new RuntimeException("unsupported Java version: " + specVersion);
System.err.println("unsupported Java version \"" + specVersion + "\", defaulting to 1.5");
return Opcodes.V1_5;
}
}
public void setTruffleHooks(TruffleHooksStub truffleHooks) {
@@ -593,10 +593,8 @@ public IRubyObject initialize_copy(IRubyObject original) {

checkFrozen();

Ruby runtime = getRuntime();
ThreadContext context = runtime.getCurrentContext();
if (!(original instanceof RubyMatchData)) {
throw runtime.newTypeError("wrong argument class");
throw getRuntime().newTypeError("wrong argument class");
}

RubyMatchData origMatchData = (RubyMatchData)original;

0 comments on commit 8b16e6b

Please sign in to comment.