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

Commits on Jun 6, 2016

  1. Copy the full SHA
    687bacc View commit details
  2. Cleaned up passing STATE to logger.

    The logging facility is intentially highly decoupled from Rubinius so that it
    can be used through the entire process lifetime without depending on
    structures that need to be constructed and destructed. The STATE dependency
    was added to try to synchronize logging across fork() calls, but that wasn't a
    good architecture choice.
    brixen committed Jun 6, 2016
    Copy the full SHA
    529d61d View commit details
  3. Copy the full SHA
    984a835 View commit details
Showing with 29 additions and 98 deletions.
  1. +3 −2 machine/builtin/system.cpp
  2. +18 −77 machine/logger.cpp
  3. +6 −17 machine/logger.hpp
  4. +2 −2 machine/spinlock.hpp
5 changes: 3 additions & 2 deletions machine/builtin/system.cpp
Original file line number Diff line number Diff line change
@@ -393,10 +393,10 @@ namespace rubinius {

int pid = ::fork();

logger::reset_lock();
state->vm()->thread_nexus()->unlock();

if(pid == 0) {
logger::reset_lock();
state->vm()->after_fork_child(state);
} else if(pid > 0) {
state->shared().machine_threads()->after_fork_exec_parent(state);
@@ -837,7 +837,6 @@ namespace rubinius {

int pid = ::fork();

logger::reset_lock();
state->vm()->thread_nexus()->unlock();

if(pid > 0) {
@@ -855,6 +854,8 @@ namespace rubinius {
}
} else if(pid == 0) {
// We're in the child...
logger::reset_lock();

state->vm()->after_fork_child(state);

state->vm()->thread->init_lock();
95 changes: 18 additions & 77 deletions machine/logger.cpp
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
#include "logger.hpp"
#include "vm.hpp"
#include "spinlock.hpp"
#include "state.hpp"
#include "thread_phase.hpp"

#include <stdarg.h>
@@ -56,7 +55,7 @@ namespace rubinius {
}

void reset_lock() {
if(logger_) logger_->reset_lock();
logger_lock_.unlock();
}

#define LOGGER_MSG_SIZE 1024
@@ -82,102 +81,48 @@ namespace rubinius {
}

void write(const char* message, ...) {
State state(VM::current());
va_list varargs;

va_start(varargs, message);
write(&state, message, varargs);
va_end(varargs);
}

void fatal(const char* message, ...) {
State state(VM::current());
va_list varargs;

va_start(varargs, message);
fatal(&state, message, varargs);
va_end(varargs);
}

void error(const char* message, ...) {
State state(VM::current());
va_list varargs;

va_start(varargs, message);
error(&state, message, varargs);
va_end(varargs);
}

void warn(const char* message, ...) {
State state(VM::current());
va_list varargs;

va_start(varargs, message);
warn(&state, message, varargs);
va_end(varargs);
}

void info(const char* message, ...) {
State state(VM::current());
va_list varargs;

va_start(varargs, message);
info(&state, message, varargs);
va_end(varargs);
}

void debug(const char* message, ...) {
State state(VM::current());
va_list varargs;

va_start(varargs, message);
debug(&state, message, varargs);
va_end(varargs);
}

void write(STATE, const char* message, ...) {
va_list args;
va_start(args, message);
write(state, message, args);
write(message, args);
va_end(args);
}

void fatal(STATE, const char* message, ...) {
void fatal(const char* message, ...) {
va_list args;
va_start(args, message);
fatal(state, message, args);
fatal(message, args);
va_end(args);
}

void error(STATE, const char* message, ...) {
void error(const char* message, ...) {
va_list args;
va_start(args, message);
error(state, message, args);
error(message, args);
va_end(args);
}

void warn(STATE, const char* message, ...) {
void warn(const char* message, ...) {
va_list args;
va_start(args, message);
warn(state, message, args);
warn(message, args);
va_end(args);
}

void info(STATE, const char* message, ...) {
void info(const char* message, ...) {
va_list args;
va_start(args, message);
info(state, message, args);
info(message, args);
va_end(args);
}

void debug(STATE, const char* message, ...) {
void debug(const char* message, ...) {
va_list args;
va_start(args, message);
debug(state, message, args);
debug(message, args);
va_end(args);
}

void write(STATE, const char* message, va_list args) {
void write(const char* message, va_list args) {
if(logger_) {
std::lock_guard<locks::spinlock_mutex> guard(logger_lock_);

@@ -189,7 +134,7 @@ namespace rubinius {
}
}

void fatal(STATE, const char* message, va_list args) {
void fatal(const char* message, va_list args) {
if(logger_) {
std::lock_guard<locks::spinlock_mutex> guard(logger_lock_);

@@ -203,7 +148,7 @@ namespace rubinius {
}
}

void error(STATE, const char* message, va_list args) {
void error(const char* message, va_list args) {
if(logger_) {
std::lock_guard<locks::spinlock_mutex> guard(logger_lock_);

@@ -217,7 +162,7 @@ namespace rubinius {
}
}

void warn(STATE, const char* message, va_list args) {
void warn(const char* message, va_list args) {
if(logger_) {
std::lock_guard<locks::spinlock_mutex> guard(logger_lock_);

@@ -231,7 +176,7 @@ namespace rubinius {
}
}

void info(STATE, const char* message, va_list args) {
void info(const char* message, va_list args) {
if(logger_) {
std::lock_guard<locks::spinlock_mutex> guard(logger_lock_);

@@ -245,7 +190,7 @@ namespace rubinius {
}
}

void debug(STATE, const char* message, va_list args) {
void debug(const char* message, va_list args) {
if(logger_) {
std::lock_guard<locks::spinlock_mutex> guard(logger_lock_);

@@ -259,10 +204,6 @@ namespace rubinius {
}
}

void Logger::reset_lock() {
logger_lock_.unlock();
}

char* Logger::timestamp() {
time_t clock;

23 changes: 6 additions & 17 deletions machine/logger.hpp
Original file line number Diff line number Diff line change
@@ -26,29 +26,19 @@ namespace rubinius {
void open(logger_type type, const char* identifier, logger_level level=eWarn, ...);
void close();

/* The API without passing STATE as the first argument must retrieve the
* current thread's VM* from a thread local variable.
*/
void write(const char* message, ...);
void fatal(const char* message, ...);
void error(const char* message, ...);
void warn(const char* message, ...);
void info(const char* message, ...);
void debug(const char* message, ...);

void write(STATE, const char* message, ...);
void fatal(STATE, const char* message, ...);
void error(STATE, const char* message, ...);
void warn(STATE, const char* message, ...);
void info(STATE, const char* message, ...);
void debug(STATE, const char* message, ...);

void write(STATE, const char* message, va_list args);
void fatal(STATE, const char* message, va_list args);
void error(STATE, const char* message, va_list args);
void warn(STATE, const char* message, va_list args);
void info(STATE, const char* message, va_list args);
void debug(STATE, const char* message, va_list args);
void write(const char* message, va_list args);
void fatal(const char* message, va_list args);
void error(const char* message, va_list args);
void warn(const char* message, va_list args);
void info(const char* message, va_list args);
void debug(const char* message, va_list args);

void set_label();
void set_loglevel(logger_level level);
@@ -73,7 +63,6 @@ namespace rubinius {

virtual void set_label() = 0;

void reset_lock();
char* timestamp();
};

4 changes: 2 additions & 2 deletions machine/spinlock.hpp
Original file line number Diff line number Diff line change
@@ -14,13 +14,13 @@ namespace rubinius {
}

void lock() {
while(flag.test_and_set(std::memory_order_acquire)) {
while(flag.test_and_set(std::memory_order_seq_cst)) {
; // spin
}
}

void unlock() {
flag.clear(std::memory_order_release);
flag.clear(std::memory_order_seq_cst);
}
};
}