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: 56be36f60f36
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 871889f0b557
Choose a head ref

Commits on Mar 11, 2015

  1. Copy the full SHA
    142fce8 View commit details
  2. tune ArrayProxy - allow indexing by Java Integer wrappers (inspired by

    …#2658)
    
    avoids "ugly-sh" failures such as :
    
    TypeError: wrong argument type Java::JavaLang::Integer (expected Range)
        org/jruby/java/proxies/ArrayJavaProxy.java:81:in `[]'
    kares committed Mar 11, 2015
    Copy the full SHA
    3f4bb5f View commit details
  3. Copy the full SHA
    c4e0a68 View commit details
  4. share ArrayProxy's array index conversion code (between [] and []=) +…

    … review internals
    
    ... also added a test for new `[]` and `[]=` index conversion (inspired by #2658)
    kares committed Mar 11, 2015
    Copy the full SHA
    9cb1fac View commit details
  5. Copy the full SHA
    5779228 View commit details
  6. Copy the full SHA
    d45a1c8 View commit details
  7. Copy the full SHA
    13ab4a3 View commit details
  8. Copy the full SHA
    4c2d934 View commit details

Commits on Mar 12, 2015

  1. Copy the full SHA
    19510fa View commit details
  2. [Truffle] RubyTruffleError should inherit from Exception.

    * So it is not rescued by empty rescue statements.
    eregon committed Mar 12, 2015
    Copy the full SHA
    a3650b3 View commit details
  3. [Truffle] Use the Assumption as a flag, less confusing than callling …

    …isValid() in void context.
    eregon committed Mar 12, 2015
    Copy the full SHA
    13a6c15 View commit details
  4. Revert "[Truffle] Empty Kernel#raise should re-raise the last excepti…

    …on."
    
    This reverts commit 19510fa.
    nirvdrum committed Mar 12, 2015
    Copy the full SHA
    1b00142 View commit details
  5. Copy the full SHA
    20be989 View commit details
  6. Copy the full SHA
    4df660d View commit details
  7. Copy the full SHA
    2d63a39 View commit details
  8. Copy the full SHA
    befd757 View commit details
  9. Merge pull request #2687 from bjfish/truffle_array_frozen_bulk

    [Truffle] Bulk adding frozen checks to methods.
    chrisseaton committed Mar 12, 2015
    Copy the full SHA
    f8f85d0 View commit details
  10. Copy the full SHA
    f26dda1 View commit details
  11. 4
    Copy the full SHA
    6754792 View commit details
  12. Copy the full SHA
    01deae8 View commit details
  13. Copy the full SHA
    dc73005 View commit details
  14. Reverse order of constructors for b* instrs to match internal orderin…

    …g so decode can use in-order
    
    decoding.  I have internally rearranged their order so that operands[0] would be a label for all
    branch types a month or two ago.  This unfortunately meant if I left constructors as-is I would
    need to decode out of order to match our constructors...
    
    Add decode.decodeLabel to not have to cast everywhere.
    enebo committed Mar 12, 2015
    Copy the full SHA
    f0f2acc View commit details
  15. Copy the full SHA
    cffe91e View commit details
  16. Copy the full SHA
    487b2c8 View commit details
  17. Copy the full SHA
    422d2b3 View commit details
  18. Copy the full SHA
    92d2cc7 View commit details
  19. Copy the full SHA
    5433238 View commit details
  20. Merge remote-tracking branch 'origin/jruby-1_7'

    Conflicts:
    	core/src/main/java/org/jruby/RubyBasicObject.java
    	core/src/main/java/org/jruby/java/proxies/ArrayJavaProxy.java
    headius committed Mar 12, 2015
    Copy the full SHA
    3b067b7 View commit details
  21. Copy the full SHA
    4d05b2a View commit details
  22. Copy the full SHA
    e66f08e View commit details
  23. Copy the full SHA
    74861eb View commit details
  24. Copy the full SHA
    763bd8e View commit details
  25. Copy the full SHA
    d00be24 View commit details
  26. Copy the full SHA
    f6b0705 View commit details
  27. 2
    Copy the full SHA
    3f5a605 View commit details
  28. Merge remote-tracking branch 'origin/jruby-1_7'

    Conflicts:
    	core/pom.xml
    headius committed Mar 12, 2015
    Copy the full SHA
    90b5d29 View commit details
  29. Copy the full SHA
    304ed3c View commit details
  30. Copy the full SHA
    67f92ae View commit details
  31. Copy the full SHA
    8298c35 View commit details
  32. Copy the full SHA
    4dd6513 View commit details
  33. Copy the full SHA
    b61c5f1 View commit details
  34. Copy the full SHA
    2e3294f View commit details
  35. Merge branch 'master' into truffle-head

    Conflicts:
    	tool/jt.rb
    	truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
    	truffle/src/main/java/org/jruby/truffle/nodes/core/PrimitiveNodes.java
    	truffle/src/main/java/org/jruby/truffle/nodes/debug/AssertConstantNode.java
    chrisseaton committed Mar 12, 2015
    Copy the full SHA
    871889f View commit details
Showing with 1,216 additions and 892 deletions.
  1. +1 −1 core/pom.xml
  2. +9 −8 core/src/main/java/org/jruby/Ruby.java
  3. +42 −40 core/src/main/java/org/jruby/RubyBasicObject.java
  4. +7 −2 core/src/main/java/org/jruby/RubyIO.java
  5. +11 −1 core/src/main/java/org/jruby/RubyMethod.java
  6. +11 −40 core/src/main/java/org/jruby/RubyString.java
  7. +2 −2 core/src/main/java/org/jruby/anno/InvokerGenerator.java
  8. +5 −4 core/src/main/java/org/jruby/compiler/util/HandleFactory.java
  9. +6 −5 core/src/main/java/org/jruby/internal/runtime/methods/InvocationMethodFactory.java
  10. +3 −5 core/src/main/java/org/jruby/ir/Compiler.java
  11. +2 −2 core/src/main/java/org/jruby/ir/IRTranslator.java
  12. +4 −2 core/src/main/java/org/jruby/ir/dataflow/analyses/LoadLocalVarPlacementNode.java
  13. +4 −2 core/src/main/java/org/jruby/ir/dataflow/analyses/StoreLocalVarPlacementNode.java
  14. +2 −2 core/src/main/java/org/jruby/ir/dataflow/analyses/UnboxableOpsAnalysisNode.java
  15. +13 −6 core/src/main/java/org/jruby/ir/instructions/BEQInstr.java
  16. +7 −7 core/src/main/java/org/jruby/ir/instructions/BFalseInstr.java
  17. +9 −5 core/src/main/java/org/jruby/ir/instructions/BNEInstr.java
  18. +7 −2 core/src/main/java/org/jruby/ir/instructions/BNilInstr.java
  19. +8 −7 core/src/main/java/org/jruby/ir/instructions/BTrueInstr.java
  20. +7 −2 core/src/main/java/org/jruby/ir/instructions/BUndefInstr.java
  21. +6 −2 core/src/main/java/org/jruby/ir/instructions/CheckArityInstr.java
  22. +16 −8 core/src/main/java/org/jruby/ir/persistence/IRReader.java
  23. +2 −0 core/src/main/java/org/jruby/ir/persistence/IRReaderDecoder.java
  24. +42 −17 core/src/main/java/org/jruby/ir/persistence/{IRReaderFile.java → IRReaderStream.java}
  25. +14 −12 core/src/main/java/org/jruby/ir/persistence/{IRWriterFile.java → IRWriterStream.java}
  26. +8 −37 core/src/main/java/org/jruby/ir/persistence/InstrDecoderMap.java
  27. +15 −0 core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
  28. +5 −5 core/src/main/java/org/jruby/java/codegen/RealClassGenerator.java
  29. +238 −130 core/src/main/java/org/jruby/java/proxies/ArrayJavaProxy.java
  30. +19 −22 core/src/main/java/org/jruby/java/util/ArrayUtils.java
  31. +2 −3 core/src/main/java/org/jruby/runtime/MethodFactory.java
  32. +2 −2 ...in/java/org/jruby/util/{ClassDefininngJRubyClassLoader.java → ClassDefiningJRubyClassLoader.java}
  33. +1 −0 core/src/main/java/org/jruby/util/CodeRangeable.java
  34. +1 −1 core/src/main/java/org/jruby/util/JRubyClassLoader.java
  35. +1 −1 core/src/main/java/org/jruby/util/OneShotClassLoader.java
  36. +45 −0 core/src/main/java/org/jruby/util/StringSupport.java
  37. +4 −1 core/src/main/ruby/jruby/jruby.rb
  38. +47 −19 lib/ruby/stdlib/jruby/compiler.rb
  39. +2 −2 spec/profiler/runtime_spec.rb
  40. +10 −0 spec/regression/GH-2581_utf32_should_alias_utf32be_spec.rb
  41. +6 −0 spec/regression/GH-2627_stdio_should_reflect_pipe_tty_spec.rb
  42. +10 −0 spec/regression/GH-2632_method_proc_should_accept_block_arguments_spec.rb
  43. +0 −1 spec/truffle/tags/core/array/append_tags.txt
  44. +1 −3 spec/truffle/tags/core/array/collect_tags.txt
  45. +0 −2 spec/truffle/tags/core/array/concat_tags.txt
  46. +1 −2 spec/truffle/tags/core/array/delete_at_tags.txt
  47. +0 −3 spec/truffle/tags/core/array/delete_if_tags.txt
  48. +1 −2 spec/truffle/tags/core/array/initialize_copy_tags.txt
  49. +0 −1 spec/truffle/tags/core/array/initialize_tags.txt
  50. +0 −1 spec/truffle/tags/core/array/insert_tags.txt
  51. +0 −2 spec/truffle/tags/core/array/map_tags.txt
  52. +0 −2 spec/truffle/tags/core/array/pop_tags.txt
  53. +0 −1 spec/truffle/tags/core/array/push_tags.txt
  54. +0 −2 spec/truffle/tags/core/array/reject_tags.txt
  55. +0 −1 spec/truffle/tags/core/array/replace_tags.txt
  56. +0 −2 spec/truffle/tags/core/array/shift_tags.txt
  57. +0 −1 spec/truffle/tags/core/array/sort_tags.txt
  58. +0 −2 spec/truffle/tags/core/array/unshift_tags.txt
  59. +0 −12 spec/truffle/tags/core/string/delete_tags.txt
  60. +96 −0 test/jruby/test_higher_javasupport.rb
  61. +0 −1 test/pom.rb
  62. +0 −1 test/pom.xml
  63. +10 −16 test/truffle/pe/core/array_pe.rb
  64. +21 −74 test/truffle/pe/core/fixnum_pe.rb
  65. +20 −67 test/truffle/pe/core/float_pe.rb
  66. +10 −16 test/truffle/pe/core/hash_pe.rb
  67. +0 −33 test/truffle/pe/core/kernel/set_trace_func_pe.rb
  68. +11 −17 test/truffle/pe/core/symbol_pe.rb
  69. +10 −15 test/truffle/pe/core/truefalse_pe.rb
  70. +12 −18 test/truffle/pe/language/metaprogramming_pe.rb
  71. +9 −8 test/truffle/pe/macro/pushing_pixels_pe.rb
  72. +71 −123 test/truffle/pe/pe.rb
  73. +1 −4 tool/jt.rb
  74. +5 −2 truffle/src/main/java/org/jruby/truffle/nodes/control/TryNode.java
  75. +3 −6 truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayAllocationSite.java
  76. +13 −13 truffle/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  77. +16 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java
  78. +19 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/PrimitiveNodes.java
  79. +59 −0 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  80. +10 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/ThreadNodes.java
  81. +16 −3 truffle/src/main/java/org/jruby/truffle/nodes/debug/AssertConstantNode.java
  82. +47 −0 truffle/src/main/java/org/jruby/truffle/nodes/debug/AssertNotCompiledNode.java
  83. +13 −9 truffle/src/main/java/org/jruby/truffle/nodes/globals/ReadLastBacktraceNode.java
  84. +8 −9 truffle/src/main/java/org/jruby/truffle/nodes/globals/UpdateLastBacktraceNode.java
  85. +16 −1 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/StringPrimitiveNodes.java
  86. +15 −2 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/VMPrimitiveNodes.java
  87. +3 −1 truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  88. +7 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyString.java
  89. +7 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/RubySymbol.java
  90. +15 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyThread.java
  91. +9 −2 truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
  92. +5 −0 truffle/src/main/ruby/core/rubinius/common/string.rb
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@
<dependency>
<groupId>org.jruby.jcodings</groupId>
<artifactId>jcodings</artifactId>
<version>1.0.12</version>
<version>1.0.13-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
17 changes: 9 additions & 8 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@
import org.jruby.javasupport.JavaSupportImpl;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.parser.StaticScope;
import org.jruby.util.ClassDefiningClassLoader;
import org.objectweb.asm.util.TraceClassVisitor;

import jnr.constants.Constant;
@@ -96,7 +97,7 @@
import org.jruby.ir.IRManager;
import org.jruby.ir.interpreter.Interpreter;
import org.jruby.ir.persistence.IRReader;
import org.jruby.ir.persistence.IRReaderFile;
import org.jruby.ir.persistence.IRReaderStream;
import org.jruby.ir.persistence.util.IRFileExpert;
import org.jruby.javasupport.proxy.JavaProxyClassFactory;
import org.jruby.management.BeanManager;
@@ -143,7 +144,7 @@
import org.jruby.util.SelfFirstJRubyClassLoader;
import org.jruby.util.IOInputStream;
import org.jruby.util.IOOutputStream;
import org.jruby.util.ClassDefininngJRubyClassLoader;
import org.jruby.util.ClassDefiningJRubyClassLoader;
import org.jruby.util.KCode;
import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.cli.Options;
@@ -762,7 +763,7 @@ private ScriptAndCode precompileCLI(Node scriptNode) {
// IR JIT does not handle all scripts yet, so let those that fail run in interpreter instead
// FIXME: restore error once JIT should handle everything
try {
scriptAndCode = tryCompile(scriptNode, new ClassDefininngJRubyClassLoader(getJRubyClassLoader()));
scriptAndCode = tryCompile(scriptNode, new ClassDefiningJRubyClassLoader(getJRubyClassLoader()));
if (scriptAndCode != null && Options.JIT_LOGGING.load()) {
LOG.info("done compiling target script: " + scriptNode.getPosition().getFile());
}
@@ -786,7 +787,7 @@ private ScriptAndCode precompileCLI(Node scriptNode) {
* @return an instance of the successfully-compiled Script, or null.
*/
public Script tryCompile(Node node) {
return tryCompile(node, new ClassDefininngJRubyClassLoader(getJRubyClassLoader())).script();
return tryCompile(node, new ClassDefiningJRubyClassLoader(getJRubyClassLoader())).script();
}

private void failForcedCompile(Node scriptNode) throws RaiseException {
@@ -802,7 +803,7 @@ private void handeCompileError(Node node, Throwable t) {
}
}

private ScriptAndCode tryCompile(Node node, ClassDefininngJRubyClassLoader classLoader) {
private ScriptAndCode tryCompile(Node node, ClassDefiningClassLoader classLoader) {
try {
return Compiler.getInstance().execute(this, node, classLoader);
} catch (NotCompilableException e) {
@@ -2697,7 +2698,7 @@ public ParseResult parseFile(String file, InputStream in, DynamicScope scope, in

try {
// Get IR from .ir file
return IRReader.load(getIRManager(), new IRReaderFile(getIRManager(), IRFileExpert.getIRPersistedFile(file)));
return IRReader.load(getIRManager(), new IRReaderStream(getIRManager(), IRFileExpert.getIRPersistedFile(file)));
} catch (IOException e) {
// FIXME: What is something actually throws IOException
return parseFileAndGetAST(in, file, scope, lineNumber, false);
@@ -2718,7 +2719,7 @@ public ParseResult parseFileFromMain(String file, InputStream in, DynamicScope s
if (!RubyInstanceConfig.IR_READING) return parseFileFromMainAndGetAST(in, file, scope);

try {
return IRReader.load(getIRManager(), new IRReaderFile(getIRManager(), IRFileExpert.getIRPersistedFile(file)));
return IRReader.load(getIRManager(), new IRReaderStream(getIRManager(), IRFileExpert.getIRPersistedFile(file)));
} catch (IOException e) {
System.out.println(e);
e.printStackTrace();
@@ -2968,7 +2969,7 @@ public void compileAndLoadFile(String filename, InputStream in, boolean wrap) {
// script was not found in cache above, so proceed to compile
Node scriptNode = parseFile(readStream, filename, null);
if (script == null) {
scriptAndCode = tryCompile(scriptNode, new ClassDefininngJRubyClassLoader(jrubyClassLoader));
scriptAndCode = tryCompile(scriptNode, new ClassDefiningJRubyClassLoader(jrubyClassLoader));
if (scriptAndCode != null) script = scriptAndCode.script();
}

82 changes: 42 additions & 40 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@
* and internal variables are handled this way, but the implementation
* in RubyObject only returns "this" in {@link #getInstanceVariables()} and
* {@link #getInternalVariables()}.
*
*
* Methods that are implemented here, such as "initialize" should be implemented
* with care; reification of Ruby classes into Java classes can produce
* conflicting method names in rare cases. See JRUBY-5906 for an example.
@@ -111,7 +111,7 @@ public class RubyBasicObject implements Cloneable, IRubyObject, Serializable, Co
private static final Logger LOG = LoggerFactory.getLogger("RubyBasicObject");

private static final boolean DEBUG = false;

/** The class of this object */
protected transient RubyClass metaClass;

@@ -120,13 +120,13 @@ public class RubyBasicObject implements Cloneable, IRubyObject, Serializable, Co

/** variable table, lazily allocated as needed (if needed) */
public transient Object[] varTable;

/** locking stamp for Unsafe ops updating the vartable */
public transient volatile int varTableStamp;

/** offset of the varTable field in RubyBasicObject */
public static final long VAR_TABLE_OFFSET = UnsafeHolder.fieldOffset(RubyBasicObject.class, "varTable");

/** offset of the varTableTamp field in RubyBasicObject */
public static final long STAMP_OFFSET = UnsafeHolder.fieldOffset(RubyBasicObject.class, "varTableStamp");

@@ -441,7 +441,7 @@ public boolean isTaint() {
public void setTaint(boolean taint) {
// JRUBY-4113: callers should not call setTaint on immediate objects
if (isImmediate()) return;

if (taint) {
flags |= TAINTED_F;
} else {
@@ -817,26 +817,28 @@ public Object toJava(Class target) {
// for callers that unconditionally pass null retval type (JRUBY-4737)
if (target == void.class) return null;

if (dataGetStruct() instanceof JavaObject) {
final Object innerWrapper = dataGetStruct();
if (innerWrapper instanceof JavaObject) {
// for interface impls

JavaObject innerWrapper = (JavaObject)dataGetStruct();

final Object value = ((JavaObject) innerWrapper).getValue();
// ensure the object is associated with the wrapper we found it in,
// so that if it comes back we don't re-wrap it
if (target.isAssignableFrom(innerWrapper.getValue().getClass())) {
getRuntime().getJavaSupport().getObjectProxyCache().put(innerWrapper.getValue(), this);
if (target.isAssignableFrom(value.getClass())) {
getRuntime().getJavaSupport().getObjectProxyCache().put(value, this);

return innerWrapper.getValue();
return value;
}
} else if (JavaUtil.isDuckTypeConvertable(getClass(), target)) {
}
else if (JavaUtil.isDuckTypeConvertable(getClass(), target)) {
if (!respondsTo("java_object")) {
return JavaUtil.convertProcToInterface(getRuntime().getCurrentContext(), this, target);
}
} else if (target.isAssignableFrom(getClass())) {
}
else if (target.isAssignableFrom(getClass())) {
return this;
}

throw getRuntime().newTypeError("cannot convert instance of " + getClass() + " to " + target);
}

@@ -1121,7 +1123,7 @@ private StringBuilder inspectObj(StringBuilder part) {
for (Map.Entry<String, VariableAccessor> entry : metaClass.getVariableTableManager().getVariableAccessorsForRead().entrySet()) {
Object value = entry.getValue().get(this);
if (value == null || !(value instanceof IRubyObject) || !IdUtil.isInstanceVariable(entry.getKey())) continue;

part.append(sep).append(" ").append(entry.getKey()).append("=");
part.append(invokedynamic(context, (IRubyObject)value, INSPECT));
sep = ",";
@@ -1158,22 +1160,22 @@ public int compareTo(IRubyObject other) {
try {
IRubyObject cmp = invokedynamic(getRuntime().getCurrentContext(),
this, OP_CMP, other);

// if RubyBasicObject#op_cmp is used, the result may be nil
if (!cmp.isNil()) {
return (int) cmp.convertToInteger().getLongValue();
}
} catch (RaiseException ex) {
getRuntime().getGlobalVariables().set("$!", oldExc);
}

/* We used to raise an error if two IRubyObject were not comparable, but
* in order to support the new ConcurrentHashMapV8 and other libraries
* and containers that arbitrarily call compareTo expecting it to always
* succeed, we have opted to return 0 here. This will allow all
* RubyBasicObject subclasses to be compared, but if the comparison is
* not valid we they will appear the same for sorting purposes.
*
*
* See https://jira.codehaus.org/browse/JRUBY-7013
*/
return 0;
@@ -1264,7 +1266,7 @@ public void removeFinalizers() {
public Object getVariable(int index) {
return VariableAccessor.getVariable(this, index);
}

@Override
public void setVariable(int index, Object value) {
ensureInstanceVariablesSettable();
@@ -1286,8 +1288,8 @@ public final void setFFIHandle(Object value) {

/**
* Returns true if object has any variables
*
* @see VariableTableManager#hasVariables(org.jruby.RubyBasicObject)
*
* @see VariableTableManager#hasVariables(org.jruby.RubyBasicObject)
*/
@Override
public boolean hasVariables() {
@@ -1420,7 +1422,7 @@ public Object removeInternalVariable(String name) {
assert !IdUtil.isRubyVariable(name);
return variableTableRemove(name);
}

/**
* Sync one this object's variables with other's - this is used to make
* rbClone work correctly.
@@ -1429,7 +1431,7 @@ public Object removeInternalVariable(String name) {
public void syncVariables(IRubyObject other) {
metaClass.getVariableTableManager().syncVariables(this, other);
}

//
// INSTANCE VARIABLE API METHODS
//
@@ -1627,7 +1629,7 @@ public IRubyObject send19(ThreadContext context, IRubyObject[] args, Block block

return getMetaClass().finvoke(context, this, name, newArgs, block);
}

@JRubyMethod(name = "instance_eval",
reads = {LASTLINE, BACKREF, VISIBILITY, BLOCK, SELF, METHODNAME, LINE, JUMPTARGET, CLASS, FILENAME, SCOPE},
writes = {LASTLINE, BACKREF, VISIBILITY, BLOCK, SELF, METHODNAME, LINE, JUMPTARGET, CLASS, FILENAME, SCOPE})
@@ -1908,7 +1910,7 @@ public void finalize() {
}
}
}

private void callFinalizer(IRubyObject finalizer) {
Helpers.invoke(
finalizer.getRuntime().getCurrentContext(),
@@ -2658,7 +2660,7 @@ public IRubyObject send(ThreadContext context, IRubyObject arg0, IRubyObject arg
}
public IRubyObject send(ThreadContext context, IRubyObject[] args, Block block) {
if (args.length == 0) return send(context, block);

String name = RubySymbol.objectToSymbolString(args[0]);
int newArgsLength = args.length - 1;

@@ -2872,20 +2874,20 @@ protected String validateInstanceVariable(String name) {

throw getRuntime().newNameError("`" + name + "' is not allowable as an instance variable name", name);
}

/**
* Serialization of a Ruby (basic) object involves three steps:
*
*
* <ol>
* <li>Dump the object itself</li>
* <li>Dump a String used to load the appropriate Ruby class</li>
* <li>Dump each variable from varTable in turn</li>
* </ol>
*
*
* The metaClass field is marked transient since Ruby classes generally will
* not be able to serialize (since they hold references to method tables,
* other classes, and potentially thread-, runtime-, or jvm-local state.
*
*
* The varTable field is transient because the layout of the same class may
* differ across runtimes, since it is determined at runtime based on the
* order in which variables get assigned for a given class. We serialize
@@ -2895,36 +2897,36 @@ private void writeObject(ObjectOutputStream oos) throws IOException {
if (metaClass.isSingleton()) {
throw new IOException("can not serialize singleton object");
}

oos.defaultWriteObject();
oos.writeUTF(metaClass.getName());

metaClass.getVariableTableManager().serializeVariables(this, oos);
}

/**
* Deserialization proceeds as follows:
*
*
* <ol>
* <li>Deserialize the object instance. It will have null metaClass and
* varTable fields.</li>
* <li>Deserialize the name of the object's class, and retrieve class from a
* thread-local JRuby instance.</li>
* <li>Retrieve each variable in turn, re-assigning them by name.</li>
* </ol>
*
* @see RubyBasicObject#writeObject(java.io.ObjectOutputStream)
*
* @see RubyBasicObject#writeObject(java.io.ObjectOutputStream)
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
Ruby ruby = Ruby.getThreadLocalRuntime();

if (ruby == null) {
throw new IOException("No thread-local org.jruby.Ruby available; can't deserialize Ruby object. Set with Ruby#setThreadLocalRuntime.");
}

ois.defaultReadObject();
metaClass = (RubyClass)ruby.getClassFromPath(ois.readUTF());

metaClass.getVariableTableManager().deserializeVariables(this, ois);
}

9 changes: 7 additions & 2 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import jnr.constants.platform.OpenFlags;
import jnr.enxio.channels.NativeDeviceChannel;
import jnr.enxio.channels.NativeSelectableChannel;
import jnr.posix.POSIX;
import org.jcodings.transcode.EConvFlags;
import org.jruby.runtime.Helpers;
import org.jruby.util.StringSupport;
@@ -1828,15 +1829,19 @@ public RubyBoolean eof_p(ThreadContext context) {
@JRubyMethod(name = {"tty?", "isatty"})
public RubyBoolean tty_p(ThreadContext context) {
Ruby runtime = context.runtime;
POSIX posix = runtime.getPosix();
OpenFile fptr;

fptr = getOpenFileChecked();

fptr.lock();
try {
if (fptr.isStdio()) return runtime.getTrue();
if (runtime.getPosix().isNative() && runtime.getPosix().libc().isatty(fptr.getFileno()) != 0)
if (posix.isNative() && fptr.fd().realFileno != -1) {
return posix.libc().isatty(fptr.getFileno()) == 0 ? runtime.getFalse() : runtime.getTrue();
} else if (fptr.isStdio()) {
// This is a bit of a hack for platforms where we can't do native stdio
return runtime.getTrue();
}
} finally {
fptr.unlock();
}
12 changes: 11 additions & 1 deletion core/src/main/java/org/jruby/RubyMethod.java
Original file line number Diff line number Diff line change
@@ -197,7 +197,17 @@ public int getLine() {
return RubyMethod.this.getLine();
}
};
BlockBody body = CompiledBlockLight19.newCompiledBlockLight(method.getArity(), runtime.getStaticScopeFactory().getDummyScope(), callback, false, 0, JRubyLibrary.MethodExtensions.methodParameters(runtime, method));
int argumentType;
if (method.getArity().isFixed()) {
if (method.getArity().required() > 0) {
argumentType = BlockBody.MULTIPLE_ASSIGNMENT;
} else {
argumentType = BlockBody.ZERO_ARGS;
}
} else {
argumentType = BlockBody.MULTIPLE_ASSIGNMENT;
}
BlockBody body = CompiledBlockLight19.newCompiledBlockLight(method.getArity(), runtime.getStaticScopeFactory().getDummyScope(), callback, false, argumentType, JRubyLibrary.MethodExtensions.methodParameters(runtime, method));
Block b = new Block(body, context.currentBinding(receiver, Visibility.PUBLIC));

return RubyProc.newProc(runtime, b, Block.Type.LAMBDA);
Loading