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: 592e312afaa9
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 617be2d793c2
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Apr 27, 2016

  1. Copy the full SHA
    b1707bb View commit details
  2. Copy the full SHA
    617be2d View commit details
6 changes: 3 additions & 3 deletions spec/truffle/specs/truffle/gc/count_spec.rb
Original file line number Diff line number Diff line change
@@ -11,16 +11,16 @@
describe "Truffle::GC.count" do

it "returns an Integer" do
Truffle::GC.gc_count.should be_kind_of(Integer)
Truffle::GC.count.should be_kind_of(Integer)
end

it "increases as collections are run" do
count_before = Truffle::GC.gc_count
count_before = Truffle::GC.count
escape = []
100_000.times do
escape << Time.now.to_s
end
Truffle::GC.gc_count.should > count_before
Truffle::GC.count.should > count_before
end

end
4 changes: 4 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -73,6 +73,7 @@
import org.jruby.truffle.core.time.TimeNodesFactory;
import org.jruby.truffle.core.tracepoint.TracePointNodesFactory;
import org.jruby.truffle.extra.TruffleNodesFactory;
import org.jruby.truffle.extra.AttachmentsNodesFactory;
import org.jruby.truffle.extra.GraalNodesFactory;
import org.jruby.truffle.interop.CExtNodesFactory;
import org.jruby.truffle.interop.InteropNodesFactory;
@@ -569,6 +570,7 @@ public CoreLibrary(RubyContext context) {
defineModule(truffleModule, "Coverage");
defineModule(truffleModule, "Graal");
defineModule(truffleModule, "GC");
defineModule(truffleModule, "Attachments");
psychModule = defineModule("Psych");
psychParserClass = defineClass(psychModule, objectClass, "Parser");
final DynamicObject psychHandlerClass = defineClass(psychModule, objectClass, "Handler");
@@ -695,6 +697,8 @@ public void addCoreMethods() {
coreMethodNodeManager.addCoreMethodNodes(ThreadNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(TrueClassNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(TruffleNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(GCNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(AttachmentsNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(GraalNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(EncodingNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(EncodingConverterNodesFactory.getFactories());
100 changes: 100 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/extra/AttachmentsNodes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2013, 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.extra;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.RootCallTarget;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.frame.FrameInstanceVisitor;
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.instrumentation.EventBinding;
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;
import jnr.posix.SpawnFileAction;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.ext.rbconfig.RbConfigLibrary;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.CoreClass;
import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.CoreMethod;
import org.jruby.truffle.core.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.core.CoreMethodNode;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.UnaryCoreMethodNode;
import org.jruby.truffle.core.YieldingCoreMethodNode;
import org.jruby.truffle.core.array.ArrayOperations;
import org.jruby.truffle.core.array.ArrayStrategy;
import org.jruby.truffle.core.binding.BindingNodes;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeBuffer;
import org.jruby.truffle.core.rope.RopeNodes;
import org.jruby.truffle.core.rope.RopeNodesFactory;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyRootNode;
import org.jruby.truffle.language.backtrace.BacktraceFormatter;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.loader.CodeLoader;
import org.jruby.truffle.language.loader.SourceLoader;
import org.jruby.truffle.language.methods.DeclarationContext;
import org.jruby.truffle.language.methods.InternalMethod;
import org.jruby.truffle.language.parser.ParserContext;
import org.jruby.truffle.platform.UnsafeGroup;
import org.jruby.truffle.tools.simpleshell.SimpleShell;
import org.jruby.util.ByteList;
import org.jruby.util.Memo;
import org.jruby.util.unsafe.UnsafeHolder;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@CoreClass(name = "Truffle::Attachments")
public abstract class AttachmentsNodes {

@CoreMethod(names = "attach_internal", onSingleton = true, required = 2, needsBlock = true)
public abstract static class AttachNode extends CoreMethodArrayArgumentsNode {

@TruffleBoundary
@Specialization(guards = "isRubyString(file)")
public DynamicObject attach(DynamicObject file, int line, DynamicObject block) {
return Layouts.HANDLE.createHandle(coreLibrary().getHandleFactory(), getContext().getAttachmentsManager().attach(file.toString(), line, block));
}

}

@CoreMethod(names = "detach_internal", onSingleton = true, required = 1)
public abstract static class DetachNode extends CoreMethodArrayArgumentsNode {

@TruffleBoundary
@Specialization(guards = "isHandle(handle)")
public DynamicObject detach(DynamicObject handle) {
final EventBinding<?> binding = (EventBinding<?>) Layouts.HANDLE.getObject(handle);
binding.dispose();
return getContext().getCoreLibrary().getNilObject();
}

}

}
24 changes: 0 additions & 24 deletions truffle/src/main/java/org/jruby/truffle/extra/TruffleNodes.java
Original file line number Diff line number Diff line change
@@ -182,30 +182,6 @@ public DynamicObject simpleShell() {

}

@CoreMethod(names = "attach", onSingleton = true, required = 2, needsBlock = true)
public abstract static class AttachNode extends CoreMethodArrayArgumentsNode {

@TruffleBoundary
@Specialization(guards = "isRubyString(file)")
public DynamicObject attach(DynamicObject file, int line, DynamicObject block) {
return Layouts.HANDLE.createHandle(coreLibrary().getHandleFactory(), getContext().getAttachmentsManager().attach(file.toString(), line, block));
}

}

@CoreMethod(names = "detach", onSingleton = true, required = 1)
public abstract static class DetachNode extends CoreMethodArrayArgumentsNode {

@TruffleBoundary
@Specialization(guards = "isHandle(handle)")
public DynamicObject detach(DynamicObject handle) {
final EventBinding<?> binding = (EventBinding<?>) Layouts.HANDLE.getObject(handle);
binding.dispose();
return getContext().getCoreLibrary().getNilObject();
}

}

@CoreMethod(names = "debug_print", onSingleton = true, required = 1, unsafe = UnsafeGroup.IO)
public abstract static class DebugPrintNode extends CoreMethodArrayArgumentsNode {

4 changes: 2 additions & 2 deletions truffle/src/main/ruby/core/truffle/attachments.rb
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ module Attachments
# attachment.detach
# ```
def self.attach(file, line, &block)
Attachment.new(Truffle.attach(file, line, &block))
Attachment.new(attach_internal(file, line, &block))
end

# Represents a block which has been installed.
@@ -40,7 +40,7 @@ def initialize(handle)

# Detach the code which was attached.
def detach
Truffle.detach @handle
Attachments.detach_internal @handle
end

end