Skip to content

Commit

Permalink
Showing 19 changed files with 71 additions and 96 deletions.
2 changes: 1 addition & 1 deletion core/pom.rb
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@

jar 'org.jruby.joni:joni:2.1.10'
jar 'org.jruby.extras:bytelist:1.0.13'
jar 'org.jruby.jcodings:jcodings:1.0.17'
jar 'org.jruby.jcodings:jcodings:1.0.18-SNAPSHOT'
jar 'org.jruby:dirgra:0.3'

jar 'com.headius:invokebinder:1.7'
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -184,7 +184,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>org.jruby.jcodings</groupId>
<artifactId>jcodings</artifactId>
<version>1.0.17</version>
<version>1.0.18-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
8 changes: 4 additions & 4 deletions lib/ruby/truffle/cext/ruby.h
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ extern "C" {

// Support

#define RUBY_CEXT truffle_import_cached("ruby_cext")
#define RUBY_CEXT (void *)truffle_import_cached("ruby_cext")

// Configuration

@@ -433,8 +433,8 @@ int rb_const_defined(VALUE module, ID name);
int rb_const_defined_at(VALUE module, ID name);

VALUE rb_const_get(VALUE module, ID name);
VALUE rb_const_at(VALUE module, ID name);
VALUE rb_const_from(VALUE module, ID name);
VALUE rb_const_get_at(VALUE module, ID name);
VALUE rb_const_get_from(VALUE module, ID name);

VALUE rb_const_set(VALUE module, ID name, VALUE value);
VALUE rb_define_const(VALUE module, const char *name, VALUE value);
@@ -571,7 +571,7 @@ int rb_jt_io_handle(VALUE file);

// Data

#define DATA_PTR(value) *((volatile int*) 0)
#define DATA_PTR(value) *((volatile intptr_t*) 0)

// Typed data

1 change: 1 addition & 0 deletions spec/ruby/core/class/dup_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

# NOTE: This is actually implemented by Module#initialize_copy
describe "Class#dup" do
it "duplicates both the class and the singleton class" do
klass = Class.new do

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/fixnum/bit_xor_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/truffle/tags/core/struct/dup_tags.txt

This file was deleted.

7 changes: 0 additions & 7 deletions spec/truffle/tags/optional/capi/module_tags.txt

This file was deleted.

16 changes: 15 additions & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -393,6 +393,11 @@ def mspec(command, *args)

sh env_vars, Utilities.find_ruby, 'spec/mspec/bin/mspec', command, '--config', 'spec/truffle/truffle.mspec', *args
end

def newer?(input, output)
return true unless File.exist? output
File.mtime(input) > File.mtime(output)
end
end

module Commands
@@ -618,14 +623,23 @@ def command_p(*args)
def cextc(cext_dir, *clang_opts)
abort "You need to set SULONG_HOME" unless SULONG_HOME

# Ensure ruby.su is up-to-date
ruby_cext_api = "#{JRUBY_DIR}/truffle/src/main/c/cext"
ruby_c = "#{JRUBY_DIR}/truffle/src/main/c/cext/ruby.c"
ruby_h = "#{JRUBY_DIR}/lib/ruby/truffle/cext/ruby.h"
ruby_su = "#{JRUBY_DIR}/lib/ruby/truffle/cext/ruby.su"
if cext_dir != ruby_cext_api and (newer?(ruby_h, ruby_su) or newer?(ruby_c, ruby_su))
puts "Compiling outdated ruby.su"
cextc ruby_cext_api
end

config_file = File.join(cext_dir, '.jruby-cext-build.yml')

unless File.exist?(config_file)
abort "There is no .jruby-cext-build.yml in #{cext_dir} at the moment - I don't know how to build it"
end

config = YAML.load_file(config_file)

config_src = config['src']

if config_src.start_with?('$GEM_HOME/')
7 changes: 3 additions & 4 deletions tool/truffle/callgraph2html.rb
Original file line number Diff line number Diff line change
@@ -136,7 +136,6 @@ def reachable
method_version = objects[Integer(line[1])]
eval_code = line.drop(2).join(' ')
method_version.eval_code.push eval_code
when 'local'
when 'callsite'
method = objects[Integer(line[1])]
callsite = CG::CallSite.new(line[2], method, line[3])
@@ -245,15 +244,15 @@ def annotate(method_version, offset)
<% if reachable_objects.include?(method_version) %>
<div id='method-version-<%= method_version.id %>' class='method-version'>
<% unless method_version.called_from.empty? %>
<p>Called from:</p>
<p>Called from:</p>
<ul>
<% method_version.called_from.each do |caller| %>
<li><a href='#method-version-<%= caller.method_version.id %>'><%= h(caller.method_version.method.name) %></a></li>
<% end %>
</ul>
<% end %>
<% unless method_version.locals.empty? %>
<p>Locals:</p>
<p>Locals:</p>
<ul>
<% method_version.locals.each do |name, types| %>
<li><code><%= h(name) %></li>
@@ -266,7 +265,7 @@ def annotate(method_version, offset)
</ul>
<% end %>
<% unless method_version.eval_code.empty? %>
<p>Evals:</p>
<p>Evals:</p>
<ul>
<% method_version.eval_code.each do |eval_code| %>
<li><code><%= h(eval_code) %></code></li>
9 changes: 3 additions & 6 deletions truffle/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
@@ -19,9 +19,6 @@
#include <truffle.h>

#include <ruby.h>

#define RUBY_CEXT (void *)truffle_import_cached("ruby_cext")

// Helpers

VALUE rb_f_notimplement(int args_count, const VALUE *args, VALUE object) {
@@ -61,7 +58,7 @@ void rb_check_type(VALUE value, int type) {
}

VALUE rb_obj_is_instance_of(VALUE object, VALUE ruby_class) {
truffle_invoke(RUBY_CEXT, "rb_obj_is_instance_of", object, ruby_class);
return truffle_invoke(RUBY_CEXT, "rb_obj_is_instance_of", object, ruby_class);
}

VALUE rb_obj_is_kind_of(VALUE object, VALUE ruby_class) {
@@ -991,7 +988,7 @@ void rb_fd_fix_cloexec(int fd) {
}

int rb_jt_io_handle(VALUE io) {
return (VALUE) truffle_invoke(RUBY_CEXT, "rb_jt_io_handle", io);
return truffle_invoke_i(RUBY_CEXT, "rb_jt_io_handle", io);
}

// Data
@@ -1004,7 +1001,7 @@ VALUE rb_data_typed_object_wrap(VALUE ruby_class, void *data, const rb_data_type

VALUE rb_data_typed_object_zalloc(VALUE ruby_class, size_t size, const rb_data_type_t *data_type) {
VALUE obj = rb_data_typed_object_wrap(ruby_class, 0, data_type);
DATA_PTR(obj) = calloc(1, size);
DATA_PTR(obj) = (intptr_t) calloc(1, size);
return obj;
}

Original file line number Diff line number Diff line change
@@ -392,7 +392,8 @@ public Object encodingConverterLastError(VirtualFrame frame, DynamicObject encod
lookupTableWriteNode.call(frame, ret, "[]=", getSymbol("result"), eConvResultToSymbol(lastError.getResult()));
lookupTableWriteNode.call(frame, ret, "[]=", getSymbol("source_encoding_name"), createString(new ByteList(lastError.getSource())));
lookupTableWriteNode.call(frame, ret, "[]=", getSymbol("destination_encoding_name"), createString(new ByteList(lastError.getDestination())));
lookupTableWriteNode.call(frame, ret, "[]=", getSymbol("error_bytes"), createString(new ByteList(lastError.getErrorBytes())));
lookupTableWriteNode.call(frame, ret, "[]=", getSymbol("error_bytes"), createString(new ByteList(lastError.getErrorBytes(),
lastError.getErrorBytesP(), lastError.getErrorBytesP() + lastError.getErrorBytesLength())));

if (lastError.getReadAgainLength() != 0) {
lookupTableWriteNode.call(frame, ret, "[]=", getSymbol("read_again_bytes"), createString(new ByteList(lastError.getErrorBytes(),
Original file line number Diff line number Diff line change
@@ -468,7 +468,6 @@ public abstract static class DupNode extends CoreMethodArrayArgumentsNode {

@Child private CopyNode copyNode;
@Child private CallDispatchHeadNode initializeDupNode;
@Child private SingletonClassNode singletonClassNode;

public DupNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -477,7 +476,7 @@ public DupNode(RubyContext context, SourceSection sourceSection) {
initializeDupNode = DispatchHeadNodeFactory.createMethodCallOnSelf(context);
}

@Specialization(guards = "!isRubyClass(self)")
@Specialization
public DynamicObject dup(VirtualFrame frame, DynamicObject self) {
final DynamicObject newObject = copyNode.executeCopy(frame, self);

@@ -486,27 +485,6 @@ public DynamicObject dup(VirtualFrame frame, DynamicObject self) {
return newObject;
}

@Specialization(guards = "isRubyClass(self)")
public DynamicObject dupClass(VirtualFrame frame, DynamicObject self) {
if (singletonClassNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
singletonClassNode = insert(SingletonClassNodeGen.create(getContext(), getSourceSection(), null));
}

final DynamicObject newObject = copyNode.executeCopy(frame, self);
final DynamicObject newObjectMetaClass = singletonClassNode.executeSingletonClass(newObject);
final DynamicObject selfMetaClass = Layouts.BASIC_OBJECT.getMetaClass(self);

assert Layouts.CLASS.getIsSingleton(selfMetaClass);
assert Layouts.CLASS.getIsSingleton(Layouts.BASIC_OBJECT.getMetaClass(newObject));

Layouts.MODULE.getFields(newObjectMetaClass).initCopy(selfMetaClass); // copies class methods
initializeDupNode.call(frame, newObject, "initialize_dup", self);
Layouts.CLASS.setSuperclass(newObject, Layouts.CLASS.getSuperclass(self));

return newObject;
}

}

@CoreMethod(names = "eval", isModuleFunction = true, required = 1, optional = 3, lowerFixnum = 4)
Original file line number Diff line number Diff line change
@@ -1150,14 +1150,16 @@ public DynamicObject initialize(VirtualFrame frame, DynamicObject module, Dynami
@CoreMethod(names = "initialize_copy", required = 1)
public abstract static class InitializeCopyNode extends CoreMethodArrayArgumentsNode {

@Child private SingletonClassNode singletonClassNode;

@Specialization(guards = { "!isRubyClass(self)", "isRubyModule(from)", "!isRubyClass(from)" })
public Object initializeCopyModule(DynamicObject self, DynamicObject from) {
Layouts.MODULE.getFields(self).initCopy(from);
return nil();
}

@Specialization(guards = {"isRubyClass(self)", "isRubyClass(from)"})
public Object initializeCopy(DynamicObject self, DynamicObject from,
public Object initializeCopyClass(DynamicObject self, DynamicObject from,
@Cached("create()") BranchProfile errorProfile) {
if (from == coreLibrary().getBasicObjectClass()) {
errorProfile.enter();
@@ -1168,9 +1170,28 @@ public Object initializeCopy(DynamicObject self, DynamicObject from,
}

Layouts.MODULE.getFields(self).initCopy(from);

final DynamicObject selfMetaClass = getSingletonClass(self);
final DynamicObject fromMetaClass = Layouts.BASIC_OBJECT.getMetaClass(from);

assert Layouts.CLASS.getIsSingleton(fromMetaClass);
assert Layouts.CLASS.getIsSingleton(Layouts.BASIC_OBJECT.getMetaClass(self));

Layouts.MODULE.getFields(selfMetaClass).initCopy(fromMetaClass); // copy class methods
Layouts.CLASS.setSuperclass(self, Layouts.CLASS.getSuperclass(from));

return nil();
}

protected DynamicObject getSingletonClass(DynamicObject object) {
if (singletonClassNode == null) {
CompilerDirectives.transferToInterpreterAndInvalidate();
singletonClassNode = insert(SingletonClassNodeGen.create(getContext(), getSourceSection(), null));
}

return singletonClassNode.executeSingletonClass(object);
}

}

@CoreMethod(names = "included", required = 1, visibility = Visibility.PRIVATE)
Original file line number Diff line number Diff line change
@@ -804,7 +804,7 @@ public Object bitXOr(
Object a,
DynamicObject b,
@Cached("new()") SnippetNode snippetNode) {
return snippetNode.execute(frame, "a ^ Rubinius::Type.coerce_to_bitwise_operand(b)", "a", a, "b", b);
return snippetNode.execute(frame, "redo_coerced :^, b", "b", b);
}

}
Loading

0 comments on commit 8369f8a

Please sign in to comment.