Skip to content

Commit

Permalink
Showing 10 changed files with 60 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -52,9 +52,7 @@
FileStoreTest: :test_two_classes_autoloading,
KernelTest: [:test_silence_stream,
:test_quietly,
:test_capture],
MultibyteCharsExtrasTest: [:test_limit_should_keep_under_the_specified_byte_limit,
:test_limit_should_work_on_a_multibyte_string]
:test_capture]
}.each do |mod_name, tests|
unless Object.const_defined? mod_name
warn "#{mod_name} not found"
14 changes: 0 additions & 14 deletions spec/truffle/tags/core/marshal/dump_tags.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
fails:Marshal.dump dumps an extended_object
fails:Marshal.dump with a String dumps a String extended with a Module
fails:Marshal.dump with a Regexp dumps a Regexp
fails:Marshal.dump with a Regexp dumps a Regexp with flags
fails:Marshal.dump with a Regexp dumps a Regexp with instance variables
fails:Marshal.dump with a Regexp dumps an extended Regexp
fails:Marshal.dump with a Regexp dumps a Regexp subclass
fails:Marshal.dump with a Regexp dumps a UTF-8 Regexp
fails:Marshal.dump with a Regexp dumps a Regexp in another encoding
fails:Marshal.dump with an Array dumps an extended Array
fails:Marshal.dump with a Hash dumps an extended Hash
fails:Marshal.dump with a Struct dumps an extended Struct
fails:Marshal.dump with an Object dumps an extended Object
fails:Marshal.dump with an Object dumps a BasicObject subclass if it defines respond_to?
fails:Marshal.dump with a Time dumps the zone and the offset
fails:Marshal.dump with a Time dumps the zone, but not the offset if zone is UTC
fails:Marshal.dump with an Exception dumps the message for the exception
fails:Marshal.dump with an Exception contains the filename in the backtrace
fails:Marshal.dump with a Symbol dumps a binary encoded Symbol
fails:Marshal.dump with a String dumps a String subclass extended with a Module
Original file line number Diff line number Diff line change
@@ -32,4 +32,8 @@ public Method getMethod() {
public SourceSection getSourceSection() {
return sourceSection;
}

public List<CallSiteVersion> getVersions() {
return versions;
}
}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ public class CallSiteVersion {

public CallSiteVersion(CallSite callSite) {
this.callSite = callSite;
callSite.getVersions().add(this);
}

public CallSite getCallSite() {
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ private void write(Method method) {
endLine = sourceSection.getEndLine();
}

stream.printf("method %d %s %s %d %d\n",
stream.printf("method %d %s %s %d %d%n",
ids.getId(method),
sharedInfo.getName(),
sourceName,
@@ -73,7 +73,7 @@ private void write(Method method) {
}

private void write(MethodVersion version) {
stream.printf("method-version %d %d\n",
stream.printf("method-version %d %d%n",
ids.getId(version.getMethod()),
ids.getId(version));

@@ -82,22 +82,22 @@ private void write(MethodVersion version) {
}

for (FrameSlot slot : version.getRootNode().getFrameDescriptor().getSlots()) {
stream.printf("local %d %s %s\n",
stream.printf("local %d %s %s%n",
ids.getId(version),
slot.getIdentifier(),
slot.getKind());
}
}

private void write(CallSite callSite) {
stream.printf("callsite %d %d %d\n",
stream.printf("callsite %d %d %d%n",
ids.getId(callSite.getMethod()),
ids.getId(callSite),
callSite.getSourceSection().getStartLine());
}

private void write(CallSiteVersion version) {
stream.printf("callsite-version %d %d\n",
stream.printf("callsite-version %d %d%n",
ids.getId(version.getCallSite()),
ids.getId(version));

@@ -108,15 +108,15 @@ private void write(CallSiteVersion version) {

private void write(CallSiteVersion callSiteVersion, Calls calls) {
if (calls instanceof CallsMegamorphic) {
stream.printf("calls %d mega\n",
stream.printf("calls %d mega%n",
ids.getId(callSiteVersion));
} else if (calls instanceof CallsForeign) {
stream.printf("calls %d foreign\n",
stream.printf("calls %d foreign%n",
ids.getId(callSiteVersion));
} else {
final CallsMethod callsMethod = (CallsMethod) calls;

stream.printf("calls %d %d\n",
stream.printf("calls %d %d%n",
ids.getId(callSiteVersion),
ids.getId(callsMethod.getMethodVersion()));
}
Original file line number Diff line number Diff line change
@@ -44,7 +44,12 @@ public DynamicObject encodingGetObjectEncoding(DynamicObject encoding) {
return encoding;
}

@Specialization(guards = {"!isRubyString(object)", "!isRubySymbol(object)", "!isRubyEncoding(object)"})
@Specialization(guards = "isRubyRegexp(regexp)")
public DynamicObject encodingGetObjectEncodingRegexp(DynamicObject regexp) {
return EncodingNodes.getEncoding(Layouts.REGEXP.getSource(regexp).getEncoding());
}

@Specialization(guards = {"!isRubyString(object)", "!isRubySymbol(object)", "!isRubyEncoding(object)", "!isRubyRegexp(object)"})
public DynamicObject encodingGetObjectEncodingNil(DynamicObject object) {
// TODO(CS, 26 Jan 15) something to do with __encoding__ here?
return nil();
Original file line number Diff line number Diff line change
@@ -57,6 +57,8 @@
import org.jruby.truffle.nodes.core.BasicObjectNodesFactory.ReferenceEqualNodeFactory;
import org.jruby.truffle.nodes.core.KernelNodes;
import org.jruby.truffle.nodes.core.KernelNodesFactory;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.objects.ClassNode;
import org.jruby.truffle.nodes.objects.ClassNodeGen;
import org.jruby.truffle.nodes.objects.IsANode;
@@ -159,6 +161,37 @@ public Object vmExit(Object status) {

}

@RubiniusPrimitive(name = "vm_extended_modules", needsSelf = false)
public static abstract class VMExtendedModulesNode extends RubiniusPrimitiveNode {

@Child private CallDispatchHeadNode newArrayNode;
@Child private CallDispatchHeadNode arrayAppendNode;

public VMExtendedModulesNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
newArrayNode = DispatchHeadNodeFactory.createMethodCall(context);
arrayAppendNode = DispatchHeadNodeFactory.createMethodCall(context);
}

@Specialization
public Object vmExtendedModules(VirtualFrame frame, Object object) {
final DynamicObject metaClass = getContext().getCoreLibrary().getMetaClass(object);

if (Layouts.CLASS.getIsSingleton(metaClass)) {
final Object ret = newArrayNode.call(frame, getContext().getCoreLibrary().getArrayClass(), "new", null);

for (DynamicObject included : Layouts.MODULE.getFields(metaClass).prependedAndIncludedModules()) {
arrayAppendNode.call(frame, ret, "<<", null, included);
}

return ret;
}

return nil();
}

}

@RubiniusPrimitive(name = "vm_get_module_name", needsSelf = false)
public static abstract class VMGetModuleNamePrimitiveNode extends RubiniusPrimitiveNode {

Original file line number Diff line number Diff line change
@@ -661,9 +661,9 @@ public void shutdown() {
callGraph.resolve();

if (options.CALL_GRAPH_WRITE != null) {
try (PrintStream stream = new PrintStream(options.CALL_GRAPH_WRITE)) {
try (PrintStream stream = new PrintStream(options.CALL_GRAPH_WRITE, StandardCharsets.UTF_8.name())) {
new SimpleWriter(callGraph, stream).write();
} catch (FileNotFoundException e) {
} catch (FileNotFoundException | UnsupportedEncodingException e) {
e.printStackTrace();
}
}
5 changes: 5 additions & 0 deletions truffle/src/main/ruby/core/rubinius/bootstrap/rubinius.rb
Original file line number Diff line number Diff line change
@@ -32,6 +32,11 @@ def self.watch_signal(sig, ignored)
raise PrimitiveFailure, "Rubinius.vm_watch_signal primitive failed" # Truffle: simplified failure
end

def self.extended_modules(obj)
Rubinius.primitive :vm_extended_modules
raise PrimitiveFailure, "Rubinius.extended_modules primitive failed"
end

def self.raise_exception(exc)
Rubinius.primitive :vm_raise_exception
raise PrimitiveFailure, "Rubinius.vm_raise_exception primitive failed"
10 changes: 0 additions & 10 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -63,16 +63,6 @@ def self.last_match(n = nil)

module Rubinius
L64 = true

def extended_modules(object)
[]
end
end

class Module
def extended_modules(object)
[]
end
end

class String

0 comments on commit 2572d39

Please sign in to comment.