Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into codedb-ffi-io
Browse files Browse the repository at this point in the history
brixen committed Jul 10, 2016
2 parents 11458eb + 8438157 commit f7665ae
Showing 43 changed files with 509 additions and 424 deletions.
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
@@ -161,7 +161,7 @@ class Configure
@vendored_libdir = File.join(root, "/vendor")

# Ruby compatibility version
@ruby_version = "2.3.0"
@ruby_version = "2.3.1"
@ruby_libversion = @ruby_version.split(/\./)[0..1].join.to_i

@build_bin = "#{@sourcedir}/build/bin"
8 changes: 8 additions & 0 deletions core/exception.rb
Original file line number Diff line number Diff line change
@@ -545,6 +545,14 @@ def message
end
end

class InterpreterError < Exception

end

class DeadlockError < Exception

end

# MRI has an Exception class named "fatal" that is raised
# by the rb_fatal function. The class is not accessible from
# ruby because the name is begins with a lower-case letter.
6 changes: 3 additions & 3 deletions gems_list.txt
Original file line number Diff line number Diff line change
@@ -9,16 +9,16 @@ rake-10.5.0.gem
rb-readline-0.5.3.gem
rdoc-4.2.2.gem
redcard-1.1.0.gem
rubinius-ast-3.6.gem
rubinius-ast-3.7.gem
rubinius-bridge-2.2.gem
rubinius-code-3.0.gem
rubinius-compiler-3.4.gem
rubinius-coverage-2.1.gem
rubinius-debugger-2.4.gem
rubinius-developer_tools-2.0.0.gem
rubinius-instructions-3.0.gem
rubinius-melbourne-3.6.gem
rubinius-processor-3.0.gem
rubinius-melbourne-3.7.gem
rubinius-processor-3.1.gem
rubinius-profiler-2.1.gem
rubinius-toolset-3.0.gem
rubysl-2.2.0.gem
3 changes: 3 additions & 0 deletions library/rubinius/configuration.rb
Original file line number Diff line number Diff line change
@@ -103,6 +103,9 @@

cs.vm_variable "limit", 3,
"Maximum number of caches at call sites"

cs.vm_variable "evictions", 10,
"Maximum number of cache evictions before disabling caching at the call site"
end

m.section "jit" do |j|
96 changes: 3 additions & 93 deletions machine/builtin/call_site.cpp
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@

namespace rubinius {
int CallSite::max_caches = 0;
int CallSite::max_evictions = 0;
CallSite::Executor CallSite::default_execute = CallSite::lookup_invoke_cache;

void CallSite::bootstrap(STATE) {
@@ -26,105 +27,14 @@ namespace rubinius {
}

max_caches = state->shared().config.machine_call_site_limit.value;
max_evictions = state->shared().config.machine_call_site_evictions.value;
}

void CallSite::Info::mark(Object* obj, memory::ObjectMark& mark) {
auto_mark(obj, mark);

CallSite* call_site = as<CallSite>(obj);

if(!call_site->caches()) return;

// 1. Check if individual caches should be evicted.
bool evict_p[call_site->depth()];

for(int i = 0; i < call_site->depth(); i++) {
evict_p[i] = call_site->caches()->cache[i].inefficient_p();
}

int evict_count = 0;
for(int i = 0; i < call_site->depth(); i++) {
if(evict_p[i]) evict_count++;
}

if(evict_count) {
VM::current()->metrics().machine.inline_cache_evicted += evict_count;

int new_size = call_site->depth() - evict_count;

if(new_size == 0) {
call_site->depth(0);
free(call_site->caches());
call_site->caches(NULL);

call_site->execute(CallSite::default_execute);
call_site->cache_miss(CallSite::default_execute);

return;
}

for(int i = 0, j = 0; i < call_site->depth() && j < new_size; i++) {
if(!evict_p[i]) {
call_site->caches()->cache[j++] = call_site->caches()->cache[i];
}
}

call_site->caches()->depth(new_size);
}

// 2. Attempt to re-order the caches by bubbling most hit forward.
bool reorder_p = false;
int indexes[call_site->depth()];

for(int i = 0; i < call_site->depth(); i++) {
indexes[i] = i;
}

InlineCaches* caches = call_site->caches();

for(int i = 0; i < call_site->depth() - 1; i++) {
if(caches->cache[i].hits() < caches->cache[i + 1].hits()) {
int tmp = indexes[i];
indexes[i] = indexes[i + 1];
indexes[i + 1] = tmp;
reorder_p = true;

// TODO: pass State through the GC!
VM::current()->metrics().machine.inline_cache_reordered++;
}
}

if(reorder_p) {
InlineCache* inline_caches = static_cast<InlineCache*>(
alloca(sizeof(CallSite) * call_site->depth()));

for(int i = 0; i < call_site->depth(); i++) {
inline_caches[i] = caches->cache[i];
}

for(int i = 0; i < call_site->depth(); i++) {
caches->cache[i] = inline_caches[indexes[i]];
}
}

// 3. Mark remaining caches.
for(int i = 0; i < call_site->depth(); i++) {
InlineCache* cache = &caches->cache[i];

if(Object* ref = mark.call(cache->receiver_class())) {
cache->receiver_class(as<Class>(ref));
mark.just_set(call_site, ref);
}

if(Object* ref = mark.call(cache->stored_module())) {
cache->stored_module(as<Module>(ref));
mark.just_set(call_site, ref);
}

if(Object* ref = mark.call(cache->executable())) {
cache->executable(as<Executable>(ref));
mark.just_set(call_site, ref);
}
}
call_site->evict_and_mark(mark);
}
}
Loading

0 comments on commit f7665ae

Please sign in to comment.