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

Commits on Jul 7, 2015

  1. Added Rubinius::Diagnostics.

    brixen committed Jul 7, 2015
    Copy the full SHA
    dff4b12 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c660bba View commit details
3 changes: 3 additions & 0 deletions library/rubinius/configuration.rb
Original file line number Diff line number Diff line change
@@ -173,6 +173,9 @@
s.vm_variable "log.archives", 5,
"The number of prior logs that will be saved as '$(system.log).N.Z' zip files"

s.vm_variable "log.access", 0600,
"Permissions on the log file"

s.vm_variable "log.level", "warn",
"Logging level: fatal, error, warn, info, debug"

1 change: 1 addition & 0 deletions rakelib/vm.rake
Original file line number Diff line number Diff line change
@@ -124,6 +124,7 @@ field_extract_headers = %w[
vm/builtin/character.hpp
vm/builtin/thread_state.hpp
vm/builtin/jit.hpp
vm/builtin/diagnostics.hpp
]

transcoders_src_dir = File.expand_path "../../vendor/oniguruma/enc/trans", __FILE__
4 changes: 3 additions & 1 deletion vm/builtin/bignum.hpp
Original file line number Diff line number Diff line change
@@ -2,12 +2,14 @@
#define RBX_BUILTIN_BIGNUM_HPP

#include "tommath.h"

#include "builtin/integer.hpp"

namespace rubinius {
class Array;
class String;
class Fixnum;
class Float;
class String;

class Bignum : public Integer {
public:
12 changes: 12 additions & 0 deletions vm/builtin/diagnostics.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "builtin/class.hpp"
#include "builtin/diagnostics.hpp"
#include "builtin/lookup_table.hpp"

namespace rubinius {
void Diagnostics::init(STATE) {
Module* diagnostics = state->new_object<Diagnostics>(G(module));
diagnostics->setup(state, "Diagnostics", G(rubinius));

diagnostics->set_const(state, "Map", LookupTable::create(state));
}
}
35 changes: 35 additions & 0 deletions vm/builtin/diagnostics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef RBX_BUILTIN_DIAGNOSTICS_HPP
#define RBX_BUILTIN_DIAGNOSTICS_HPP

#include "builtin/class.hpp"
#include "builtin/module.hpp"
#include "builtin/object.hpp"

#include "object_utils.hpp"
#include "diagnostics.hpp"

namespace rubinius {
class LookupTable;

class Diagnostics : public Module {
public:
const static object_type type = DiagnosticsType;

private:
LookupTable* map_; // slot

public:
attr_accessor(map, LookupTable);

public:
static void init(STATE);


class Info : public Module::Info {
public:
BASIC_TYPEINFO(Module::Info)
};
};
}

#endif
23 changes: 22 additions & 1 deletion vm/capi/handles.cpp
Original file line number Diff line number Diff line change
@@ -3,18 +3,30 @@
#include "gc/baker.hpp"
#include "capi/capi.hpp"
#include "capi/handles.hpp"
#include "util/logger.hpp"

namespace rubinius {
namespace capi {
void Handles::Diagnostics::log() {
if(!modified_p()) return;

diagnostics::Diagnostics::log();

utilities::logger::write("C-API handles: diagnostics: " \
"objects: %ld, bytes: %ld, collections: %ld\n",
objects_, bytes_, collections_);
}

Handle* Handles::allocate(STATE, Object* obj) {
bool needs_gc = false;
Handle* handle = allocator_->allocate(&needs_gc);
handle->set_object(obj);
handle->validate();
if(needs_gc) {
diagnostics_.collections_++;
state->memory()->collect_mature_now = true;
}
diagnostics_.objects_++;
atomic::memory_barrier();
return handle;
}
@@ -29,8 +41,10 @@ namespace rubinius {
handle->set_object(obj);
handle->validate();
if(needs_gc) {
diagnostics_.collections_++;
state->memory()->collect_mature_now = true;
}
diagnostics_.objects_++;
atomic::memory_barrier();

if(handle_index > UINT32_MAX) {
@@ -58,7 +72,9 @@ namespace rubinius {
delete allocator_;
}

void Handles::deallocate_handles(std::list<Handle*>* cached, unsigned int mark, BakerGC* young) {
void Handles::deallocate_handles(std::list<Handle*>* cached,
unsigned int mark, BakerGC* young)
{
std::vector<bool> chunk_marks(allocator_->chunks_.size(), false);

for(std::vector<int>::size_type i = 0; i < allocator_->chunks_.size(); ++i) {
@@ -94,6 +110,7 @@ namespace rubinius {
// A weakref pointing to a dead young object
} else {
handle->clear();
diagnostics_.objects_--;
}
} else {
// Not a young object, so won't be GC'd so mark
@@ -104,6 +121,7 @@ namespace rubinius {
// A weakref pointing to a dead mature object
} else if(!obj->marked_p(mark)) {
handle->clear();
diagnostics_.objects_--;
} else {
chunk_marks[i] = true;
}
@@ -122,6 +140,9 @@ namespace rubinius {
}

allocator_->rebuild_freelist(&chunk_marks);

diagnostics_.bytes_ = allocator_->in_use_;
diagnostics_.modify();
}
}
}
21 changes: 20 additions & 1 deletion vm/capi/handles.hpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
#ifndef RBX_CAPI_HANDLES_HPP
#define RBX_CAPI_HANDLES_HPP

#include "diagnostics.hpp"
#include "vm.hpp"
#include "gc/root.hpp"
#include "util/allocator.hpp"
#include "capi/handle.hpp"

#include <vector>
#include <stdint.h>

namespace rubinius {
class BakerGC;

namespace capi {

class Handles {
public:
class Diagnostics : public diagnostics::MemoryDiagnostics {
public:
int64_t collections_;

Diagnostics()
: diagnostics::MemoryDiagnostics()
, collections_(0)
{ }

void log();
};

private:
Allocator<Handle>* allocator_;

Diagnostics diagnostics_;

public:

Handles()
: allocator_(new Allocator<Handle>())
, diagnostics_(Diagnostics())
{}

~Handles();
@@ -48,6 +64,9 @@ namespace rubinius {
return allocator_->in_use_;
}

Diagnostics& diagnostics() {
return diagnostics_;
}
};
}
}
2 changes: 1 addition & 1 deletion vm/codegen/field_extract.rb
Original file line number Diff line number Diff line change
@@ -744,7 +744,7 @@ def generate_marks(cpp)
if(target->#{name}()->reference_p()) {
Object* old = target->#{name}();
Object* cur = mark.call(old);
if(cur && cur != old) target->#{name}(mark.state(), force_as<#{type}>(cur));
if(cur && cur != old) target->#{name}(mark.vm(), force_as<#{type}>(cur));
}
}
42 changes: 42 additions & 0 deletions vm/diagnostics.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#ifndef RBX_DIAGNOSTICS_HPP
#define RBX_DIAGNOSTICS_HPP

#include <stdint.h>

namespace rubinius {
namespace diagnostics {
class Diagnostics {
bool modified_;

public:
Diagnostics() : modified_(false) { }
virtual ~Diagnostics() { }

virtual void log() {
modified_ = false;
}

bool modified_p() {
return modified_;
}

void modify() {
modified_ = true;
}
};

class MemoryDiagnostics : public Diagnostics {
public:
int64_t objects_;
int64_t bytes_;

MemoryDiagnostics()
: Diagnostics()
, objects_(0)
, bytes_(0)
{ }
};
}
}

#endif
11 changes: 9 additions & 2 deletions vm/environment.cpp
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@
#include "config_parser.hpp"
#include "compiled_file.hpp"
#include "object_memory.hpp"

#include "exception.hpp"
#include "system_diagnostics.hpp"

#include "builtin/array.hpp"
#include "builtin/class.hpp"
@@ -208,6 +208,11 @@ namespace rubinius {
finalizer_thread_->start(state);
}

void Environment::start_diagnostics(STATE) {
diagnostics_ = new diagnostics::SystemDiagnostics(
state->shared().memory()->diagnostics());
}

void Environment::start_logging(STATE) {
utilities::logger::logger_level level = utilities::logger::eWarn;

@@ -235,7 +240,8 @@ namespace rubinius {
utilities::logger::open(utilities::logger::eFileLogger,
config.system_log.value.c_str(), level,
config.system_log_limit.value,
config.system_log_archives.value);
config.system_log_archives.value,
config.system_log_access.value);
}
}

@@ -841,6 +847,7 @@ namespace rubinius {
load_platform_conf(runtime);
boot_vm();

start_diagnostics(state);
start_finalizer(state);

load_argv(argc_, argv_);
12 changes: 11 additions & 1 deletion vm/environment.hpp
Original file line number Diff line number Diff line change
@@ -12,6 +12,10 @@

namespace rubinius {

namespace diagnostics {
class SystemDiagnostics;
}

class ConfigParser;
class QueryAgent;
class SignalThread;
@@ -65,6 +69,8 @@ namespace rubinius {

TypedRoot<Object*>* loader_;

diagnostics::SystemDiagnostics* diagnostics_;

public:
SharedState* shared;
VM* root_vm;
@@ -89,6 +95,10 @@ namespace rubinius {
return loader_->get();
}

diagnostics::SystemDiagnostics* diagnostics() {
return diagnostics_;
}

void set_root_vm(VM* vm) {
root_vm = vm;
state->set_vm(vm);
@@ -130,6 +140,7 @@ namespace rubinius {
void atexit();

void start_finalizer(STATE);
void start_diagnostics(STATE);

void start_signals(STATE);
void stop_signals(STATE);
@@ -140,7 +151,6 @@ namespace rubinius {
void start_jit(STATE);
void stop_jit(STATE);
};

}

#endif
Loading