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: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 377d5c958bc8
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f52e57fe8c4f
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 11, 2016

  1. Copy the full SHA
    a932b23 View commit details
  2. Copy the full SHA
    f52e57f View commit details
Showing with 29 additions and 34 deletions.
  1. +23 −33 machine/builtin/compiled_code.cpp
  2. +6 −1 machine/builtin/system.cpp
56 changes: 23 additions & 33 deletions machine/builtin/compiled_code.cpp
Original file line number Diff line number Diff line change
@@ -116,43 +116,37 @@ namespace rubinius {
timer::StopWatch<timer::microseconds> timer(
state->vm()->metrics().machine.bytecode_internalizer_us);

MachineCode* mcode = machine_code();

atomic::memory_barrier();

if(mcode) return mcode;

CompiledCode* self = this;
OnStack<1> os(state, self);

self->hard_lock(state);
MachineCode* mcode = machine_code();

mcode = self->machine_code();
if(!mcode) {
{
BytecodeVerifier bytecode_verifier(self);
bytecode_verifier.verify(state);
}
if(mcode) return mcode;

mcode = new MachineCode(state, self);
{
BytecodeVerifier bytecode_verifier(this);
bytecode_verifier.verify(state);
}

if(self->resolve_primitive(state)) {
mcode->fallback = execute;
} else {
mcode->setup_argument_handler();
}
mcode = new MachineCode(state, this);

// We need to have an explicit memory barrier here, because we need to
// be sure that mcode is completely initialized before it's set.
// Otherwise another thread might see a partially initialized
// MachineCode.
atomic::write(&self->_machine_code_, mcode);
if(resolve_primitive(state)) {
mcode->fallback = execute;
} else {
mcode->setup_argument_handler();
}

/* There is a race here because another Thread may have run this
* CompiledCode instance and internalized it. We attempt to store our
* version assuming that we are the only ones to do so and throw away our
* work if someone else has beat us to it.
*/
MachineCode** mcode_ptr = &_machine_code_;
if(atomic::compare_and_swap(reinterpret_cast<void**>(mcode_ptr), 0, mcode)) {
set_executor(mcode->fallback);
return mcode;
} else {
return machine_code();
}

self->hard_unlock(state);
return mcode;
}

Object* CompiledCode::primitive_failed(STATE,
@@ -192,12 +186,8 @@ namespace rubinius {
Executable* exec, Module* mod, Arguments& args)
{
CompiledCode* code = as<CompiledCode>(exec);
if(code->execute == default_executor) {
OnStack<5> os(state, code, exec, mod, args.recv_location(), args.block_location());

memory::VariableRootBuffer vrb(state->vm()->current_root_buffers(),
&args.arguments_location(), args.total());

if(code->execute == default_executor) {
if(!code->internalize(state)) return 0;
}

7 changes: 6 additions & 1 deletion machine/builtin/system.cpp
Original file line number Diff line number Diff line change
@@ -418,7 +418,12 @@ namespace rubinius {
Object* System::vm_spawn(STATE, Object* spawn_state, String* path,
Array* args)
{
OnStack<1> os(state, spawn_state);
/* TODO: The spawn_state reference is reachable and the GC is not moving
* objects right now and there are sporadic failures in the spawn specs
* related to corruption of the structure used by OnStack, so this is
* temporarily disabled.
* OnStack<1> os(state, spawn_state);
*/

/* Setting up the command and arguments may raise an exception so do it
* before everything else.