Skip to content
Browse files

API cleanup: state->vm()->shared => state->shared()

  • Loading branch information...
1 parent 8bf4930 commit 2a3dcf38eb3e67745e0cd6d0a6b577d350a5a04f @evanphx evanphx committed Nov 2, 2011
View
4 vm/agent.cpp
@@ -617,8 +617,8 @@ namespace rubinius {
}
void QueryAgent::shutdown(STATE) {
- if(!state->vm()->shared.agent()) return;
- state->vm()->shared.agent()->shutdown_i();
+ if(!state->shared().agent()) return;
+ state->shared().agent()->shutdown_i();
}
void QueryAgent::shutdown_i() {
View
2 vm/builtin/block_environment.cpp
@@ -267,7 +267,7 @@ namespace rubinius {
#ifdef ENABLE_LLVM
if(vmm->call_count >= 0) {
- if(vmm->call_count >= state->vm()->shared.config.jit_call_til_compile) {
+ if(vmm->call_count >= state->shared().config.jit_call_til_compile) {
LLVMState* ls = LLVMState::get(state);
ls->compile_soon(state, env->code(), env, true);
View
12 vm/builtin/class.cpp
@@ -27,7 +27,7 @@ namespace rubinius {
Class* Class::create(STATE, Class* super) {
Class* cls = state->memory()->new_object_enduring<Class>(state, G(klass));
- cls->init(state->vm()->shared.inc_class_count(state));
+ cls->init(state->shared().inc_class_count(state));
cls->name(state, nil<Symbol>());
cls->instance_type(state, super->instance_type());
@@ -50,7 +50,7 @@ namespace rubinius {
Class* Class::s_allocate(STATE) {
Class* cls = as<Class>(state->memory()->new_object_enduring<Class>(state, G(klass)));
- cls->init(state->vm()->shared.inc_class_count(state));
+ cls->init(state->shared().inc_class_count(state));
cls->setup(state);
cls->set_type_info(state->memory()->type_info[ObjectType]);
@@ -66,7 +66,7 @@ namespace rubinius {
Object* collect_and_allocate(STATE, GCToken gct, Class* self,
CallFrame* calling_environment)
{
- state->vm()->shared.om->collect_young_now = true;
+ state->shared().om->collect_young_now = true;
OnStack<1> os(state, self);
@@ -108,7 +108,7 @@ namespace rubinius {
if(likely(obj)) {
obj->init_header(self, YoungObjectZone, PackedObject::type);
} else {
- if(state->vm()->shared.om->refill_slab(state, state->local_slab())) {
+ if(state->shared().om->refill_slab(state, state->local_slab())) {
obj = state->local_slab().allocate(size).as<PackedObject>();
if(likely(obj)) {
@@ -218,7 +218,7 @@ namespace rubinius {
LookupTable* lt = LookupTable::create(state);
// If autopacking is enabled, figure out how many slots to use.
- if(state->vm()->shared.config.gc_autopack) {
+ if(state->shared().config.gc_autopack) {
Module* mod = self;
int slot = 0;
@@ -272,7 +272,7 @@ namespace rubinius {
SingletonClass* SingletonClass::attach(STATE, Object* obj, Class* sup) {
SingletonClass *sc;
sc = state->memory()->new_object_enduring<SingletonClass>(state, G(klass));
- sc->init(state->vm()->shared.inc_class_count(state));
+ sc->init(state->shared().inc_class_count(state));
sc->attached_instance(state, obj);
sc->setup(state);
View
2 vm/builtin/compiledmethod.cpp
@@ -166,7 +166,7 @@ namespace rubinius {
Object* CompiledMethod::default_executor(STATE, CallFrame* call_frame,
Executable* exec, Module* mod, Arguments& args)
{
- LockableScopedLock lg(state, &state->vm()->shared, __FILE__, __LINE__);
+ LockableScopedLock lg(state, &state->shared(), __FILE__, __LINE__);
CompiledMethod* cm = as<CompiledMethod>(exec);
if(cm->execute == default_executor) {
View
2 vm/builtin/data.cpp
@@ -32,7 +32,7 @@ namespace rubinius {
// Don't call ->ref() on handle! We don't want the handle to keep the object
// alive by default. The handle needs to have the lifetime of the object.
- state->vm()->shared.add_global_handle(state, handle);
+ state->shared().add_global_handle(state, handle);
RDataShadow* rdata = reinterpret_cast<RDataShadow*>(handle->as_rdata(0));
View
4 vm/builtin/global_cache_entry.cpp
@@ -19,14 +19,14 @@ namespace rubinius {
}
bool GlobalCacheEntry::valid_p(STATE, StaticScope* scope) {
- return serial_ == state->vm()->shared.global_serial() &&
+ return serial_ == state->shared().global_serial() &&
scope_ == scope;
}
void GlobalCacheEntry::update(STATE, Object* val, StaticScope* sc) {
value(state, val);
scope(state, sc);
- serial_ = state->vm()->shared.global_serial();
+ serial_ = state->shared().global_serial();
}
}
View
4 vm/builtin/module.cpp
@@ -93,12 +93,12 @@ namespace rubinius {
void Module::set_const(STATE, Object* sym, Object* val) {
constants()->store(state, sym, val);
- state->vm()->shared.inc_global_serial(state);
+ state->shared().inc_global_serial(state);
}
void Module::del_const(STATE, Symbol* sym) {
constants()->remove(state, sym);
- state->vm()->shared.inc_global_serial(state);
+ state->shared().inc_global_serial(state);
}
void Module::set_const(STATE, std::string name, Object* val) {
View
44 vm/builtin/nativefunction.cpp
@@ -290,7 +290,7 @@ namespace rubinius {
sassert(status == FFI_OK);
}
- state->vm()->shared.om->add_code_resource(data);
+ state->shared().om->add_code_resource(data);
this->ffi_data = data;
}
@@ -370,7 +370,7 @@ namespace rubinius {
State* state = env->state();
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
Array* args = Array::create(state, stub->arg_count);
@@ -546,7 +546,7 @@ namespace rubinius {
break;
}
- state->vm()->shared.gc_independent(state);
+ state->shared().gc_independent(state);
}
@@ -899,109 +899,109 @@ namespace rubinius {
// a GC might move this and there ffi_data will
// point at the wrong place in memory
FFIData* ffi_data_local = ffi_data;
- state->vm()->shared.gc_independent(state);
+ state->shared().gc_independent(state);
switch(ffi_data_local->ret_type) {
case RBX_FFI_TYPE_CHAR: {
ffi_arg result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Fixnum::from((native_int)result);
break;
}
case RBX_FFI_TYPE_UCHAR: {
ffi_arg result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Fixnum::from((native_int)result);
break;
}
case RBX_FFI_TYPE_BOOL: {
ffi_arg result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = (result != 0) ? Qtrue : Qfalse;
break;
}
case RBX_FFI_TYPE_SHORT: {
ffi_arg result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Fixnum::from((native_int)result);
break;
}
case RBX_FFI_TYPE_USHORT: {
ffi_arg result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Fixnum::from((native_int)result);
break;
}
case RBX_FFI_TYPE_INT: {
ffi_arg result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Integer::from(state, (native_int)result);
break;
}
case RBX_FFI_TYPE_UINT: {
ffi_arg result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Integer::from(state, (unsigned int)result);
break;
}
case RBX_FFI_TYPE_LONG: {
long result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Integer::from(state, result);
break;
}
case RBX_FFI_TYPE_ULONG: {
unsigned long result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Integer::from(state, result);
break;
}
case RBX_FFI_TYPE_FLOAT: {
float result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Float::create(state, (double)result);
break;
}
case RBX_FFI_TYPE_DOUBLE: {
double result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Float::create(state, result);
break;
}
case RBX_FFI_TYPE_LONG_LONG: {
long long result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Integer::from(state, result);
break;
}
case RBX_FFI_TYPE_ULONG_LONG: {
unsigned long long result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Integer::from(state, result);
break;
}
case RBX_FFI_TYPE_OBJECT: {
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &ret, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
break;
}
case RBX_FFI_TYPE_PTR: {
void* result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
if(result == NULL) {
ret = Qnil;
} else {
@@ -1012,7 +1012,7 @@ namespace rubinius {
case RBX_FFI_TYPE_STRING: {
char* result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
if(result == NULL) {
ret = Qnil;
} else {
@@ -1027,7 +1027,7 @@ namespace rubinius {
Object* p;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
if(result == NULL) {
s = p = Qnil;
@@ -1047,7 +1047,7 @@ namespace rubinius {
case RBX_FFI_TYPE_VOID: {
ffi_arg result;
ffi_call(&ffi_data_local->cif, FFI_FN(ffi_data_local->ep), &result, values);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
ret = Qnil;
break;
}
View
10 vm/builtin/nativemethod.cpp
@@ -75,7 +75,7 @@ namespace rubinius {
handle = new capi::Handle(state, obj);
ih->set_handle(handle);
- state->vm()->shared.add_global_handle(state, handle);
+ state->shared().add_global_handle(state, handle);
handles_.add_if_absent(handle);
}
@@ -607,8 +607,8 @@ namespace rubinius {
NativeMethodEnvironment* env = native_method_environment.get();
// Optionally get the handles back to the proper state.
- if(state->vm()->shared.config.capi_global_flush) {
- capi::Handles* handles = state->vm()->shared.cached_handles();
+ if(state->shared().config.capi_global_flush) {
+ capi::Handles* handles = state->shared().cached_handles();
if(handles->size() > 0) {
for(capi::Handles::Iterator i(*handles); i.more(); i.advance()) {
@@ -642,7 +642,7 @@ namespace rubinius {
// We've got things setup (they can be GC'd properly), so we need to
// wait before entering the extension code.
- state->vm()->shared.enter_capi(state);
+ state->shared().enter_capi(state);
Object* ret;
ExceptionPoint ep(env);
@@ -668,7 +668,7 @@ namespace rubinius {
env->set_current_native_frame(nmf.previous());
ep.pop(env);
- state->vm()->shared.leave_capi(state);
+ state->shared().leave_capi(state);
// Handle any signals that occurred while the native method
// was running.
View
8 vm/builtin/regexp.cpp
@@ -72,7 +72,7 @@ namespace rubinius {
}
static OnigEncoding current_encoding(STATE) {
- switch(state->vm()->shared.kcode_page()) {
+ switch(state->shared().kcode_page()) {
default:
case kcode::eAscii:
return ONIG_ENCODING_ASCII;
@@ -267,7 +267,7 @@ namespace rubinius {
forced_encoding_ = true;
}
- thread::Mutex::LockGuard lg(state->vm()->shared.onig_lock());
+ thread::Mutex::LockGuard lg(state->shared().onig_lock());
err = onig_new(&this->onig_data, pat, end, opts, enc, ONIG_SYNTAX_RUBY, &err_info);
@@ -383,7 +383,7 @@ namespace rubinius {
Exception::argument_error(state, "Not properly initialized Regexp");
}
- // thread::Mutex::LockGuard lg(state->vm()->shared.onig_lock());
+ // thread::Mutex::LockGuard lg(state->shared().onig_lock());
max = string->size();
str = (UChar*)string->byte_address();
@@ -464,7 +464,7 @@ namespace rubinius {
Exception::argument_error(state, "Not properly initialized Regexp");
}
- // thread::Mutex::LockGuard lg(state->vm()->shared.onig_lock());
+ // thread::Mutex::LockGuard lg(state->shared().onig_lock());
max = string->size();
native_int pos = start->to_native();
View
4 vm/builtin/string.cpp
@@ -544,7 +544,7 @@ namespace rubinius {
kcode::table* kcode_tbl = 0;
if(RTEST(respect_kcode)) {
- kcode_tbl = state->vm()->shared.kcode_table();
+ kcode_tbl = state->shared().kcode_table();
} else {
kcode_tbl = kcode::null_table();
}
@@ -1116,7 +1116,7 @@ namespace rubinius {
String* output = 0;
- kcode::table* tbl = state->vm()->shared.kcode_table();
+ kcode::table* tbl = state->shared().kcode_table();
if(kcode::mbchar_p(tbl, *cur)) {
native_int clen = kcode::mbclen(tbl, *cur);
if(o + clen <= size()) {
View
14 vm/builtin/symbol.cpp
@@ -33,35 +33,35 @@ namespace rubinius {
}
String* Symbol::to_str(STATE) {
- return state->vm()->shared.symbols.lookup_string(state, this);
+ return state->shared().symbols.lookup_string(state, this);
}
std::string& Symbol::cpp_str(STATE) {
- return state->vm()->shared.symbols.lookup_cppstring(this);
+ return state->shared().symbols.lookup_cppstring(this);
}
std::string Symbol::debug_str(SharedState& shared) {
return shared.symbols.lookup_debug_string(this);
}
std::string Symbol::debug_str(STATE) {
- return debug_str(state->vm()->shared);
+ return debug_str(state->shared());
}
Array* Symbol::all_symbols(STATE) {
- return state->vm()->shared.symbols.all_as_array(state);
+ return state->shared().symbols.all_as_array(state);
}
Object* Symbol::is_ivar_p(STATE) {
- return state->vm()->shared.symbols.kind(state, this) == SymbolTable::IVar ? Qtrue : Qfalse;
+ return state->shared().symbols.kind(state, this) == SymbolTable::IVar ? Qtrue : Qfalse;
}
Object* Symbol::is_cvar_p(STATE) {
- return state->vm()->shared.symbols.kind(state, this) == SymbolTable::CVar ? Qtrue : Qfalse;
+ return state->shared().symbols.kind(state, this) == SymbolTable::CVar ? Qtrue : Qfalse;
}
Object* Symbol::is_constant_p(STATE) {
- return state->vm()->shared.symbols.kind(state, this) == SymbolTable::Constant ? Qtrue : Qfalse;
+ return state->shared().symbols.kind(state, this) == SymbolTable::Constant ? Qtrue : Qfalse;
}
void Symbol::Info::show(STATE, Object* self, int level) {
View
30 vm/builtin/system.cpp
@@ -191,7 +191,7 @@ namespace rubinius {
SignalHandler::shutdown();
QueryAgent::shutdown(state);
- state->vm()->shared.pre_exec();
+ state->shared().pre_exec();
// TODO Need to stop and kill off any ruby threads!
// We haven't run into this because exec is almost always called
@@ -452,8 +452,8 @@ namespace rubinius {
if(result == 0) {
/* @todo any other re-initialisation needed? */
- state->vm()->shared.reinit(state);
- state->vm()->shared.om->on_fork(state);
+ state->shared().reinit(state);
+ state->shared().om->on_fork(state);
SignalHandler::on_fork(state, false);
// Re-initialize LLVM
@@ -483,7 +483,7 @@ namespace rubinius {
// in File#ininitialize). If we decided to ignore some GC.start calls
// by usercode trying to be clever, we can use force to know that we
// should NOT ignore it.
- if(RTEST(force) || state->vm()->shared.config.gc_honor_start) {
+ if(RTEST(force) || state->shared().config.gc_honor_start) {
state->memory()->collect_young_now = true;
state->memory()->collect_mature_now = true;
state->vm()->interrupts.set_perform_gc();
@@ -492,7 +492,7 @@ namespace rubinius {
}
Object* System::vm_get_config_item(STATE, String* var) {
- ConfigParser::Entry* ent = state->vm()->shared.user_variables.find(var->c_str(state));
+ ConfigParser::Entry* ent = state->shared().user_variables.find(var->c_str(state));
if(!ent) return Qnil;
if(ent->is_number()) {
@@ -507,7 +507,7 @@ namespace rubinius {
Object* System::vm_get_config_section(STATE, String* section) {
ConfigParser::EntryList* list;
- list = state->vm()->shared.user_variables.get_section(
+ list = state->shared().user_variables.get_section(
reinterpret_cast<char*>(section->byte_address()));
Array* ary = Array::create(state, list->size());
@@ -527,7 +527,7 @@ namespace rubinius {
// 1. clear the global cache
state->vm()->global_cache()->clear(state, name);
- state->vm()->shared.ic_registry()->clear(state, name);
+ state->shared().ic_registry()->clear(state, name);
return name;
}
@@ -566,7 +566,7 @@ namespace rubinius {
Object* System::vm_tooling_available_p(STATE) {
#ifdef RBX_PROFILER
- return state->vm()->shared.tool_broker()->available(state) ? Qtrue : Qfalse;
+ return state->shared().tool_broker()->available(state) ? Qtrue : Qfalse;
#else
return Qfalse;
#endif
@@ -577,12 +577,12 @@ namespace rubinius {
}
Object* System::vm_tooling_enable(STATE) {
- state->vm()->shared.tool_broker()->enable(state);
+ state->shared().tool_broker()->enable(state);
return Qtrue;
}
Object* System::vm_tooling_disable(STATE) {
- return state->vm()->shared.tool_broker()->results(state);
+ return state->shared().tool_broker()->results(state);
}
Object* System::vm_load_tool(STATE, String* str) {
@@ -631,7 +631,7 @@ namespace rubinius {
}
Object* System::vm_jit_info(STATE) {
- if(state->vm()->shared.config.jit_disabled) return Qnil;
+ if(state->shared().config.jit_disabled) return Qnil;
#ifdef ENABLE_LLVM
LLVMState* ls = LLVMState::get(state);
@@ -650,7 +650,7 @@ namespace rubinius {
}
Object* System::vm_watch_signal(STATE, Fixnum* sig, Object* ignored) {
- SignalHandler* h = state->vm()->shared.signal_handler();
+ SignalHandler* h = state->shared().signal_handler();
if(h) {
native_int i = sig->to_native();
if(i < 0) {
@@ -940,7 +940,7 @@ namespace rubinius {
}
Object* System::vm_inc_global_serial(STATE) {
- return Fixnum::from(state->vm()->shared.inc_global_serial(state));
+ return Fixnum::from(state->shared().inc_global_serial(state));
}
Object* System::vm_jit_block(STATE, GCToken gct, BlockEnvironment* env,
@@ -1094,7 +1094,7 @@ namespace rubinius {
}
Symbol* System::vm_get_kcode(STATE) {
- switch(state->vm()->shared.kcode_page()) {
+ switch(state->shared().kcode_page()) {
case kcode::eEUC:
return state->symbol("EUC");
case kcode::eSJIS:
@@ -1249,7 +1249,7 @@ namespace rubinius {
}
IO* System::vm_agent_io(STATE) {
- QueryAgent* agent = state->vm()->shared.autostart_agent(state);
+ QueryAgent* agent = state->shared().autostart_agent(state);
int sock = agent->loopback_socket();
if(sock < 0) {
if(!agent->setup_local()) return nil<IO>();
View
10 vm/builtin/thread.cpp
@@ -82,7 +82,7 @@ namespace rubinius {
}
Thread* Thread::allocate(STATE, Object* self) {
- VM* vm = state->vm()->shared.new_vm();
+ VM* vm = state->shared().new_vm();
Thread* thread = Thread::create(state, vm, self, send_run);
return thread;
@@ -281,10 +281,10 @@ namespace rubinius {
init_lock_.unlock();
- state->vm()->shared.gc_independent(state);
+ state->shared().gc_independent(state);
void* val;
int err = pthread_join(id, &val);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
switch(err) {
case 0:
@@ -306,10 +306,10 @@ namespace rubinius {
Object* Thread::set_critical(STATE, Object* obj) {
if(RTEST(obj)) {
- state->vm()->shared.set_critical(state);
+ state->shared().set_critical(state);
return Qtrue;
} else {
- state->vm()->shared.clear_critical(state);
+ state->shared().clear_critical(state);
return Qfalse;
}
}
View
4 vm/capi/capi.cpp
@@ -315,7 +315,7 @@ namespace rubinius {
/** Make sure the name has the given prefix. */
Symbol* prefixed_by(STATE, const char* prefix, size_t len, ID name) {
Symbol* sym_obj = reinterpret_cast<Symbol*>(name);
- std::string& sym = state->vm()->shared.symbols.lookup_cppstring(sym_obj);
+ std::string& sym = state->shared().symbols.lookup_cppstring(sym_obj);
if(sym.compare(0UL, len, prefix) == 0) return sym_obj;
@@ -327,7 +327,7 @@ namespace rubinius {
Symbol* prefixed_by(STATE, const char prefix, ID name) {
Symbol* sym_obj = reinterpret_cast<Symbol*>(name);
- std::string& sym = state->vm()->shared.symbols.lookup_cppstring(sym_obj);
+ std::string& sym = state->shared().symbols.lookup_cppstring(sym_obj);
if(sym.c_str()[0] == prefix) return sym_obj;
View
4 vm/capi/handle.cpp
@@ -7,8 +7,8 @@ namespace rubinius {
namespace capi {
bool Handle::valid_handle_p(STATE, Handle* handle) {
- Handles* global_handles = state->vm()->shared.global_handles();
- Handles* cached_handles = state->vm()->shared.cached_handles();
+ Handles* global_handles = state->shared().global_handles();
+ Handles* cached_handles = state->shared().cached_handles();
for(Handles::Iterator i(*global_handles); i.more(); i.advance()) {
if(i.current() == handle) return true;
View
12 vm/environment.cpp
@@ -529,16 +529,16 @@ namespace rubinius {
}
void Environment::halt() {
- state->vm()->shared.tool_broker()->shutdown(state);
+ state->shared().tool_broker()->shutdown(state);
- if(state->vm()->shared.config.ic_stats) {
- state->vm()->shared.ic_registry()->print_stats(state);
+ if(state->shared().config.ic_stats) {
+ state->shared().ic_registry()->print_stats(state);
}
state->set_call_frame(0);
// Handle an edge case where another thread is waiting to stop the world.
- if(state->vm()->shared.should_stop()) {
+ if(state->shared().should_stop()) {
state->checkpoint();
}
@@ -649,8 +649,8 @@ namespace rubinius {
}
void Environment::load_tool() {
- if(!state->vm()->shared.config.tool_to_load.set_p()) return;
- std::string path = std::string(state->vm()->shared.config.tool_to_load.value) + ".";
+ if(!state->shared().config.tool_to_load.set_p()) return;
+ std::string path = std::string(state->shared().config.tool_to_load.value) + ".";
#ifdef _WIN32
path += "dll";
View
4 vm/instructions.cpp
@@ -228,8 +228,8 @@ Object* VMMethod::uncommon_interpreter(STATE,
VMMethod* method_vmm = method_call_frame->cm->backend_method();
- if(++method_vmm->uncommon_count > state->vm()->shared.config.jit_deoptimize_threshold) {
- if(state->vm()->shared.config.jit_uncommon_print) {
+ if(++method_vmm->uncommon_count > state->shared().config.jit_deoptimize_threshold) {
+ if(state->shared().config.jit_uncommon_print) {
std::cerr << "[[[ Deoptimizing uncommon method ]]]\n";
call_frame->print_backtrace(state);
View
4 vm/instruments/tooling.cpp
@@ -35,7 +35,7 @@ namespace tooling {
void ToolBroker::enable(STATE) {
if(!enable_func_) return;
- state->vm()->shared.config.jit_disabled.set("true");
+ state->shared().config.jit_disabled.set("true");
System::vm_deoptimize_all(state, Qtrue);
enable_func_(state->vm()->tooling_env());
@@ -49,7 +49,7 @@ namespace tooling {
Object* ToolBroker::results(STATE) {
if(!results_func_) return Qnil;
- state->vm()->shared.config.jit_disabled.set("false");
+ state->shared().config.jit_disabled.set("false");
Object* res = rbxti::s(results_func_(state->vm()->tooling_env()));
View
2 vm/instruments/tooling.hpp
@@ -101,7 +101,7 @@ namespace tooling {
public:
Entry(STATE)
: state_(state)
- , broker_(state->vm()->shared.tool_broker())
+ , broker_(state->shared().tool_broker())
{}
};
View
10 vm/kcode.cpp
@@ -104,22 +104,22 @@ namespace kcode {
};
void init(STATE) {
- state->vm()->shared.set_kcode_table(mbctab_ascii, kcode::eAscii);
+ state->shared().set_kcode_table(mbctab_ascii, kcode::eAscii);
}
void set(STATE, CodePage page) {
switch(page) {
case eAscii:
- state->vm()->shared.set_kcode_table(mbctab_ascii, kcode::eAscii);
+ state->shared().set_kcode_table(mbctab_ascii, kcode::eAscii);
break;
case eEUC:
- state->vm()->shared.set_kcode_table(mbctab_euc, kcode::eEUC);
+ state->shared().set_kcode_table(mbctab_euc, kcode::eEUC);
break;
case eSJIS:
- state->vm()->shared.set_kcode_table(mbctab_sjis, kcode::eSJIS);
+ state->shared().set_kcode_table(mbctab_sjis, kcode::eSJIS);
break;
case eUTF8:
- state->vm()->shared.set_kcode_table(mbctab_utf8, kcode::eUTF8);
+ state->shared().set_kcode_table(mbctab_utf8, kcode::eUTF8);
break;
}
}
View
4 vm/llvm/jit_util.cpp
@@ -947,13 +947,13 @@ extern "C" {
int rbx_enter_unmanaged(STATE, CallFrame* call_frame) {
state->set_call_frame(call_frame);
- state->vm()->shared.gc_independent(state);
+ state->shared().gc_independent(state);
return 0;
}
int rbx_exit_unmanaged(STATE, CallFrame* call_frame) {
state->set_call_frame(call_frame);
- state->vm()->shared.gc_dependent(state);
+ state->shared().gc_dependent(state);
return 0;
}
View
50 vm/llvm/state.cpp
@@ -65,36 +65,36 @@ using namespace llvm;
namespace rubinius {
LLVMState* LLVMState::get(STATE) {
- if(!state->vm()->shared.llvm_state) {
- state->vm()->shared.llvm_state = new LLVMState(state);
+ if(!state->shared().llvm_state) {
+ state->shared().llvm_state = new LLVMState(state);
}
- return state->vm()->shared.llvm_state;
+ return state->shared().llvm_state;
}
void LLVMState::shutdown(STATE) {
- if(!state->vm()->shared.llvm_state) return;
- state->vm()->shared.llvm_state->shutdown_i();
+ if(!state->shared().llvm_state) return;
+ state->shared().llvm_state->shutdown_i();
}
void LLVMState::start(STATE) {
- if(!state->vm()->shared.llvm_state) return;
- state->vm()->shared.llvm_state->start_i();
+ if(!state->shared().llvm_state) return;
+ state->shared().llvm_state->start_i();
}
void LLVMState::on_fork(STATE) {
- if(!state->vm()->shared.llvm_state) return;
- state->vm()->shared.llvm_state->on_fork_i();
+ if(!state->shared().llvm_state) return;
+ state->shared().llvm_state->on_fork_i();
}
void LLVMState::pause(STATE) {
- if(!state->vm()->shared.llvm_state) return;
- state->vm()->shared.llvm_state->pause_i();
+ if(!state->shared().llvm_state) return;
+ state->shared().llvm_state->pause_i();
}
void LLVMState::unpause(STATE) {
- if(!state->vm()->shared.llvm_state) return;
- state->vm()->shared.llvm_state->unpause_i();
+ if(!state->shared().llvm_state) return;
+ state->shared().llvm_state->unpause_i();
}
const llvm::Type* LLVMState::ptr_type(std::string name) {
@@ -484,31 +484,31 @@ namespace rubinius {
static const bool debug_search = false;
LLVMState::LLVMState(STATE)
- : ManagedThread(state->vm()->shared.new_thread_id(state->vm()),
- state->vm()->shared, ManagedThread::eSystem)
+ : ManagedThread(state->shared().new_thread_id(state->vm()),
+ state->shared(), ManagedThread::eSystem)
, ctx_(llvm::getGlobalContext())
- , config_(state->vm()->shared.config)
- , symbols_(state->vm()->shared.symbols)
+ , config_(state->shared().config)
+ , symbols_(state->shared().symbols)
, jitted_methods_(0)
, queued_methods_(0)
, accessors_inlined_(0)
, uncommons_taken_(0)
- , shared_(state->vm()->shared)
- , include_profiling_(state->vm()->shared.config.jit_profile)
+ , shared_(state->shared())
+ , include_profiling_(state->shared().config.jit_profile)
, code_bytes_(0)
, log_(0)
, time_spent(0)
{
set_name("Background Compiler");
- state->vm()->shared.add_managed_thread(this);
- state->vm()->shared.om->add_aux_barrier(state, &write_barrier_);
+ state->shared().add_managed_thread(this);
+ state->shared().om->add_aux_barrier(state, &write_barrier_);
- if(state->vm()->shared.config.jit_log.value.size() == 0) {
+ if(state->shared().config.jit_log.value.size() == 0) {
log_ = &std::cerr;
} else {
std::ofstream* s = new std::ofstream(
- state->vm()->shared.config.jit_log.value.c_str(), std::ios::out);
+ state->shared().config.jit_log.value.c_str(), std::ios::out);
if(s->fail()) {
delete s;
@@ -621,7 +621,7 @@ namespace rubinius {
symbol_class_id_ = G(symbol)->class_id();
string_class_id_ = G(string)->class_id();
- type_optz_ = state->vm()->shared.config.jit_type_optz;
+ type_optz_ = state->shared().config.jit_type_optz;
background_thread_ = new BackgroundCompilerThread(this);
background_thread_->run();
@@ -735,7 +735,7 @@ namespace rubinius {
} else {
background_thread_->add(req);
- if(state->vm()->shared.config.jit_show_compiling) {
+ if(state->shared().config.jit_show_compiling) {
llvm::outs() << "[[[ JIT Queued"
<< (is_block ? " block " : " method ")
<< queued_methods() << "/"
View
20 vm/objectmemory.cpp
@@ -496,7 +496,7 @@ namespace rubinius {
SYNC(state);
// If we were checkpointed, then someone else ran the GC, just return.
- if(state->vm()->shared.should_stop()) {
+ if(state->shared().should_stop()) {
UNSYNC;
state->checkpoint();
return;
@@ -509,7 +509,7 @@ namespace rubinius {
// Stops all other threads, so we're only here by ourselves.
//
// First, ask them to stop.
- state->vm()->shared.ask_for_stopage();
+ state->shared().ask_for_stopage();
// Now unlock ObjectMemory so that they can spin to any checkpoints.
UNSYNC;
@@ -547,7 +547,7 @@ namespace rubinius {
SYNC(state);
// If we were checkpointed, then someone else ran the GC, just return.
- if(state->vm()->shared.should_stop()) {
+ if(state->shared().should_stop()) {
UNSYNC;
state->checkpoint();
return;
@@ -560,7 +560,7 @@ namespace rubinius {
// Stops all other threads, so we're only here by ourselves.
//
// First, ask them to stop.
- state->vm()->shared.ask_for_stopage();
+ state->shared().ask_for_stopage();
// Now unlock ObjectMemory so that they can spin to any checkpoints.
UNSYNC;
@@ -576,7 +576,7 @@ namespace rubinius {
uint64_t start_time = 0;
if(collect_young_now) {
- if(state->vm()->shared.config.gc_show) {
+ if(state->shared().config.gc_show) {
start_time = get_current_time();
}
@@ -593,7 +593,7 @@ namespace rubinius {
collect_young(gc_data, &stats);
#endif
- if(state->vm()->shared.config.gc_show) {
+ if(state->shared().config.gc_show) {
uint64_t fin_time = get_current_time();
int diff = (fin_time - start_time) / 1000000;
@@ -606,7 +606,7 @@ namespace rubinius {
if(collect_mature_now) {
size_t before_kb = 0;
- if(state->vm()->shared.config.gc_show) {
+ if(state->shared().config.gc_show) {
start_time = get_current_time();
before_kb = mature_bytes_allocated() / 1024;
}
@@ -622,7 +622,7 @@ namespace rubinius {
collect_mature(gc_data);
#endif
- if(state->vm()->shared.config.gc_show) {
+ if(state->shared().config.gc_show) {
uint64_t fin_time = get_current_time();
int diff = (fin_time - start_time) / 1000000;
size_t kb = mature_bytes_allocated() / 1024;
@@ -1310,12 +1310,12 @@ namespace rubinius {
}
Object* in_finalizer(STATE) {
- state->vm()->shared.om->in_finalizer_thread(state);
+ state->shared().om->in_finalizer_thread(state);
return Qnil;
}
void ObjectMemory::start_finalizer_thread(STATE) {
- VM* vm = state->vm()->shared.new_vm();
+ VM* vm = state->shared().new_vm();
Thread* thr = Thread::create(state, vm, G(thread), in_finalizer);
finalizer_thread_.set(thr);
thr->fork(state);
View
6 vm/oop.cpp
@@ -359,7 +359,7 @@ namespace rubinius {
case eAuxWordEmpty:
case eAuxWordObjID:
// Um. well geez. We don't have this object locked.
- if(state->vm()->shared.config.thread_debug) {
+ if(state->shared().config.thread_debug) {
std::cerr << "[THREAD] Attempted to unlock an unlocked object.\n";
}
@@ -383,7 +383,7 @@ namespace rubinius {
<< "]\n";
}
- if(state->vm()->shared.config.thread_debug) {
+ if(state->shared().config.thread_debug) {
std::cerr
<< "[THREAD] Attempted to unlock an object locked by other thread."
<< "locker=" << locker_tid
@@ -442,7 +442,7 @@ namespace rubinius {
}
// We shouldn't even get here, all cases are handled.
- if(state->vm()->shared.config.thread_debug) {
+ if(state->shared().config.thread_debug) {
std::cerr << "[THREAD] Detected unknown header lock state.\n";
}
return eLockError;
View
4 vm/primitives.cpp
@@ -33,8 +33,8 @@ namespace rubinius {
static inline void check_counter(STATE, CallFrame* call_frame, int which) {
#ifdef ENABLE_LLVM
- int& hits = state->vm()->shared.primitive_hits(which);
- if(hits >= 0 && ++hits >= state->vm()->shared.config.jit_call_til_compile) {
+ int& hits = state->shared().primitive_hits(which);
+ if(hits >= 0 && ++hits >= state->shared().config.jit_call_til_compile) {
hits = -1;
Primitives::queue_for_jit(state, call_frame, which);
}
View
4 vm/signal.cpp
@@ -46,7 +46,7 @@ namespace rubinius {
reopen_pipes();
- self_ = state->vm()->shared.new_vm();
+ self_ = state->shared().new_vm();
thread_.set(Thread::create(state, self_, G(thread), handle_tramp, false));
}
@@ -70,7 +70,7 @@ namespace rubinius {
if(full && self_) rubinius::bug("signal thread restart issue");
- self_ = state->vm()->shared.new_vm();
+ self_ = state->shared().new_vm();
thread_.set(Thread::create(state, self_, G(thread), handle_tramp, false));
run(state);
View
4 vm/state.hpp
@@ -63,6 +63,10 @@ namespace rubinius {
return shared_.memory();
}
+ SharedState& shared() {
+ return shared_;
+ }
+
bool detect_stack_condition(void* end) {
return vm_->detect_stack_condition(end);
}
View
2 vm/test/test_symbol.hpp
@@ -29,6 +29,6 @@ class TestSymbol : public CxxTest::TestSuite, public VMTest {
Array* symbols = Symbol::all_symbols(state);
TS_ASSERT(kind_of<Array>(symbols));
- TS_ASSERT(state->vm()->shared.symbols.size() > 0);
+ TS_ASSERT(state->shared().symbols.size() > 0);
}
};
View
4 vm/vm.hpp
@@ -451,9 +451,9 @@ namespace rubinius {
: thread::LockGuardTemplate<T>(in_lock, false)
, state_(state)
{
- state_->vm()->shared.gc_independent(state_);
+ state_->shared().gc_independent(state_);
this->lock();
- state->vm()->shared.gc_dependent(state_);
+ state->shared().gc_dependent(state_);
}
~GCIndependentLockGuard() {
View
12 vm/vmmethod.cpp
@@ -59,7 +59,7 @@ namespace rubinius {
, caches(0)
, execute_status_(eInterpret)
, name_(meth->name())
- , method_id_(state->vm()->shared.inc_method_count(state))
+ , method_id_(state->shared().inc_method_count(state))
, debugging(false)
, flags(0)
{
@@ -84,8 +84,8 @@ namespace rubinius {
// Disable JIT for large methods
if(meth->primitive()->nil_p() &&
- !state->vm()->shared.config.jit_disabled &&
- total < (size_t)state->vm()->shared.config.jit_max_method_size) {
+ !state->shared().config.jit_disabled &&
+ total < (size_t)state->shared().config.jit_max_method_size) {
call_count = 0;
} else {
call_count = -1;
@@ -100,7 +100,7 @@ namespace rubinius {
specializations[i].jit_data = 0;
}
- state->vm()->shared.om->add_code_resource(this);
+ state->shared().om->add_code_resource(this);
}
VMMethod::~VMMethod() {
@@ -250,7 +250,7 @@ namespace rubinius {
}
}
- state->vm()->shared.ic_registry()->add_cache(state, name, cache);
+ state->shared().ic_registry()->add_cache(state, name, cache);
opcodes[ip + 1] = reinterpret_cast<intptr_t>(cache);
update_addresses(ip, 1);
@@ -594,7 +594,7 @@ namespace rubinius {
// A negative call_count means we've disabled usage based JIT
// for this method.
if(vmm->call_count >= 0) {
- if(vmm->call_count >= state->vm()->shared.config.jit_call_til_compile) {
+ if(vmm->call_count >= state->shared().config.jit_call_til_compile) {
LLVMState* ls = LLVMState::get(state);
ls->compile_callframe(state, cm, frame);
} else {

0 comments on commit 2a3dcf3

Please sign in to comment.
Something went wrong with that request. Please try again.