Skip to content
Browse files

Renamed VMMethod to MachineCode.

This was a difficult name choice but it is consistent with CompiledCode
and (not yet used) SourceCode. The CompiledCode is an abstraction of
computation that is the focal point around which much revolves. MachineCode
is a representation of computation specialized for our (virtual) machine.

While there is possible ambiguity against the idea of JIT'd machine code,
our MachineCode is a proper data structure, not just the format of bits
resulting from the JIT compilation process. Also, our MachineCode is properly
scoped differently than any such class/concept in LLVM (or more generally,
the JIT).

Regarding naming of instances of MachineCode, the following rationale is used:

* parameters/variables have been named 'mcode' since the use of the variable
  is elaborated by the surrounding code (ie making ambiguity less an issue)
  and long variable names can sometimes make code unweildy.
* attributes/fields/accessors have been name 'machine_code' because they have
  less context to disambiguate.
  • Loading branch information...
1 parent 91f3cd2 commit 6fce2f693b62bc8b11e2f42711237c45346a98fd @brixen brixen committed Aug 28, 2012
Showing with 532 additions and 531 deletions.
  1. +2 −2 rakelib/instruction_parser.rb
  2. +1 −1 vm/builtin/access_variable.hpp
  3. +39 −39 vm/builtin/block_environment.cpp
  4. +3 −3 vm/builtin/block_environment.hpp
  5. +55 −55 vm/builtin/compiledcode.cpp
  6. +5 −5 vm/builtin/compiledcode.hpp
  7. +1 −1 vm/builtin/executable.cpp
  8. +1 −1 vm/builtin/executable.hpp
  9. +2 −2 vm/builtin/location.cpp
  10. +1 −1 vm/builtin/proc.cpp
  11. +7 −7 vm/builtin/system.cpp
  12. +1 −1 vm/bytecode_verification.cpp
  13. +2 −2 vm/call_frame.hpp
  14. +4 −4 vm/drivers/jit-test.cpp
  15. +1 −1 vm/gc/code_manager.hpp
  16. +1 −1 vm/gc/gc.cpp
  17. +6 −6 vm/inline_cache.hpp
  18. +22 −22 vm/instructions.cpp
  19. +10 −10 vm/instructions.def
  20. +1 −1 vm/instructions.hpp
  21. +4 −4 vm/instructions_util.hpp
  22. +3 −3 vm/instruments/rbxti.cpp
  23. +2 −2 vm/llvm/background_compile_request.hpp
  24. +8 −8 vm/llvm/cfg.hpp
  25. +7 −7 vm/llvm/control_flow.hpp
  26. +21 −21 vm/llvm/inline.cpp
  27. +2 −2 vm/llvm/inline.hpp
  28. +2 −2 vm/llvm/inline_block.cpp
  29. +5 −5 vm/llvm/inline_block.hpp
  30. +38 −38 vm/llvm/inline_policy.hpp
  31. +9 −9 vm/llvm/jit_block.cpp
  32. +9 −9 vm/llvm/jit_builder.cpp
  33. +2 −2 vm/llvm/jit_builder.hpp
  34. +6 −6 vm/llvm/jit_compiler.cpp
  35. +3 −3 vm/llvm/jit_compiler.hpp
  36. +1 −1 vm/llvm/jit_context.cpp
  37. +8 −8 vm/llvm/jit_inline_block.cpp
  38. +5 −5 vm/llvm/jit_inline_method.cpp
  39. +31 −30 vm/llvm/jit_method.cpp
  40. +12 −12 vm/llvm/jit_operations.hpp
  41. +22 −22 vm/llvm/jit_util.cpp
  42. +15 −15 vm/llvm/jit_visit.hpp
  43. +2 −2 vm/llvm/method_info.cpp
  44. +2 −2 vm/llvm/method_info.hpp
  45. +7 −7 vm/llvm/opcode_iter.hpp
  46. +37 −37 vm/llvm/state.cpp
  47. +67 −67 vm/{vmmethod.cpp → machine_code.cpp}
  48. +16 −16 vm/{vmmethod.hpp → machine_code.hpp}
  49. +1 −1 vm/objectmemory.hpp
  50. +1 −1 vm/primitives.hpp
  51. +4 −4 vm/stack_variables.cpp
  52. +14 −14 vm/test/{test_vmmethod.hpp → test_machine_code.hpp}
  53. +1 −1 vm/vm.cpp
View
4 rakelib/instruction_parser.rb
@@ -659,9 +659,9 @@ def opcode_width
def opcode_prototype
name = opcode_name
indent = " " * (name.size + 9)
- prototype = "Object* #{name}(rubinius::VM* state, rubinius::VMMethod* vmm,
+ prototype = "Object* #{name}(rubinius::VM* state, rubinius::MachineCode* code,
@arjen
arjen added a note Sep 3, 2012

Should

rubinius::MachineCode* code

be

rubinius::MachineCode* mcode

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
#{indent}rubinius::InterpreterCallFrame* const call_frame,
-#{indent}rubinius::VMMethod::InterpreterState& is"
+#{indent}rubinius::MachineCode::InterpreterState& is"
unless @arguments.empty?
prototype << ",\n#{indent}"
View
2 vm/builtin/access_variable.hpp
@@ -7,7 +7,7 @@
namespace rubinius {
class InstructionSequence;
- class VMMethod;
+ class MachineCode;
class ConstantScope;
class AccessVariable : public Executable {
View
78 vm/builtin/block_environment.cpp
@@ -52,29 +52,29 @@ namespace rubinius {
return env;
}
- VMMethod* BlockEnvironment::vmmethod(STATE, GCToken gct) {
+ MachineCode* BlockEnvironment::machine_code(STATE, GCToken gct) {
return code_->internalize(state, gct);
}
Object* BlockEnvironment::invoke(STATE, CallFrame* previous,
BlockEnvironment* env, Arguments& args,
BlockInvocation& invocation)
{
- VMMethod* vmm = env->code_->backend_method();
+ MachineCode* mcode = env->code_->machine_code();
- if(!vmm) {
+ if(!mcode) {
OnStack<2> os(state, env, args.argument_container_location());
GCTokenImpl gct;
- vmm = env->vmmethod(state, gct);
+ mcode = env->machine_code(state, gct);
- if(!vmm) {
+ if(!mcode) {
Exception::internal_error(state, previous, "invalid bytecode method");
return 0;
}
}
#ifdef ENABLE_LLVM
- if(executor ptr = vmm->unspecialized) {
+ if(executor ptr = mcode->unspecialized) {
return (*((BlockExecutor)ptr))(state, previous, env, args, invocation);
}
#endif
@@ -86,16 +86,16 @@ namespace rubinius {
class GenericArguments {
public:
static bool call(STATE, CallFrame* call_frame,
- VMMethod* vmm, StackVariables* scope,
+ MachineCode* mcode, StackVariables* scope,
Arguments& args, int flags)
{
- const bool has_splat = (vmm->splat_position >= 0);
+ const bool has_splat = (mcode->splat_position >= 0);
native_int total_args = args.total();
// expecting 0, got 0.
- if(vmm->total_args == 0 && total_args == 0) {
+ if(mcode->total_args == 0 && total_args == 0) {
if(has_splat) {
- scope->set_local(vmm->splat_position, Array::create(state, 0));
+ scope->set_local(mcode->splat_position, Array::create(state, 0));
}
return true;
@@ -119,9 +119,9 @@ namespace rubinius {
* the block's arguments.
*/
if(total_args == 1
- && (vmm->required_args > 1
- || (vmm->required_args == 1
- && (has_splat || vmm->splat_position < -2)))) {
+ && (mcode->required_args > 1
+ || (mcode->required_args == 1
+ && (has_splat || mcode->splat_position < -2)))) {
Object* obj = args.get_argument(0);
Array* ary = 0;
@@ -136,7 +136,7 @@ namespace rubinius {
}
if(ary) {
- if(vmm->splat_position == -4 && vmm->required_args == 1) {
+ if(mcode->splat_position == -4 && mcode->required_args == 1) {
args.use_argument(ary);
} else {
args.use_array(ary);
@@ -145,19 +145,19 @@ namespace rubinius {
}
}
- const native_int P = vmm->post_args;
- const native_int R = vmm->required_args;
+ const native_int P = mcode->post_args;
+ const native_int R = mcode->required_args;
// M is for mandatory
const native_int M = R - P;
const native_int T = args.total();
// DT is for declared total
- const native_int DT = vmm->total_args;
+ const native_int DT = mcode->total_args;
const native_int O = DT - R;
// HS is for has splat
- const native_int HS = vmm->splat_position >= 0 ? 1 : 0;
+ const native_int HS = mcode->splat_position >= 0 ? 1 : 0;
// CT is for clamped total
const native_int CT = HS ? T : MIN(T, DT);
@@ -243,7 +243,7 @@ namespace rubinius {
ary = Array::create(state, 0);
}
- scope->set_local(vmm->splat_position, ary);
+ scope->set_local(mcode->splat_position, ary);
}
return true;
@@ -259,39 +259,39 @@ namespace rubinius {
BlockEnvironment* env, Arguments& args,
BlockInvocation& invocation)
{
- // Don't use env->vmmethod() because it might lock and the work should already
- // be done.
- VMMethod* const vmm = env->code_->backend_method();
+ // Don't use env->machine_code() because it might lock and the work should
+ // already be done.
+ MachineCode* const mcode = env->code_->machine_code();
- if(!vmm) {
+ if(!mcode) {
Exception::internal_error(state, previous, "invalid bytecode method");
return 0;
}
#ifdef ENABLE_LLVM
- if(vmm->call_count >= 0) {
- if(vmm->call_count >= state->shared().config.jit_call_til_compile) {
+ if(mcode->call_count >= 0) {
+ if(mcode->call_count >= state->shared().config.jit_call_til_compile) {
LLVMState* ls = LLVMState::get(state);
ls->compile_soon(state, env->code(), env, true);
} else {
- vmm->call_count++;
+ mcode->call_count++;
}
}
#endif
- StackVariables* scope = ALLOCA_STACKVARIABLES(vmm->number_of_locals);
+ StackVariables* scope = ALLOCA_STACKVARIABLES(mcode->number_of_locals);
Module* mod = invocation.module;
if(!mod) mod = env->module();
scope->initialize(invocation.self, env->top_scope_->block(),
- mod, vmm->number_of_locals);
+ mod, mcode->number_of_locals);
scope->set_parent(env->scope_);
- InterpreterCallFrame* frame = ALLOCA_CALLFRAME(vmm->stack_size);
+ InterpreterCallFrame* frame = ALLOCA_CALLFRAME(mcode->stack_size);
- frame->prepare(vmm->stack_size);
+ frame->prepare(mcode->stack_size);
frame->previous = previous;
frame->constant_scope_ = invocation.constant_scope;
@@ -307,7 +307,7 @@ namespace rubinius {
// TODO: this is a quick hack to process block arguments in 1.9.
if(!LANGUAGE_18_ENABLED(state)) {
- if(!GenericArguments::call(state, frame, vmm, scope, args, invocation.flags)) {
+ if(!GenericArguments::call(state, frame, mcode, scope, args, invocation.flags)) {
return NULL;
}
}
@@ -333,12 +333,12 @@ namespace rubinius {
}
tooling::BlockEntry method(state, env, mod);
- return (*vmm->run)(state, vmm, frame);
+ return (*mcode->run)(state, mcode, frame);
} else {
- return (*vmm->run)(state, vmm, frame);
+ return (*mcode->run)(state, mcode, frame);
}
#else
- return (*vmm->run)(state, vmm, frame);
+ return (*mcode->run)(state, mcode, frame);
#endif
}
@@ -396,20 +396,20 @@ namespace rubinius {
BlockEnvironment* BlockEnvironment::under_call_frame(STATE, GCToken gct,
- CompiledCode* cm, VMMethod* caller,
+ CompiledCode* cm, MachineCode* caller,
CallFrame* call_frame)
{
OnStack<1> os(state, cm);
state->set_call_frame(call_frame);
- VMMethod* vmm = cm->internalize(state, gct);
- if(!vmm) {
+ MachineCode* mcode = cm->internalize(state, gct);
+ if(!mcode) {
Exception::internal_error(state, call_frame, "invalid bytecode method");
return 0;
}
- vmm->set_parent(caller);
+ mcode->set_parent(caller);
BlockEnvironment* be = state->new_object<BlockEnvironment>(G(blokenv));
be->scope(state, call_frame->promote_scope(state));
@@ -444,7 +444,7 @@ namespace rubinius {
return cNil;
}
- target->cm->backend_method()->set_no_inline();
+ target->cm->machine_code()->set_no_inline();
if(target->scope) {
return target->scope->block();
View
6 vm/builtin/block_environment.hpp
@@ -9,7 +9,7 @@ namespace rubinius {
class CompiledCode;
class VariableScope;
struct CallFrame;
- class VMMethod;
+ class MachineCode;
class VMExecutable;
class BlockEnvironment;
@@ -52,7 +52,7 @@ namespace rubinius {
/* interface */
static void init(STATE);
- VMMethod* vmmethod(STATE, GCToken gct);
+ MachineCode* machine_code(STATE, GCToken gct);
// Rubinius.primitive :blockenvironment_allocate
static BlockEnvironment* allocate(STATE);
@@ -62,7 +62,7 @@ namespace rubinius {
BlockInvocation& invocation);
static BlockEnvironment* under_call_frame(STATE, GCToken gct, CompiledCode* cm,
- VMMethod* caller, CallFrame* call_frame);
+ MachineCode* caller, CallFrame* call_frame);
static Object* execute_interpreter(STATE, CallFrame* previous,
BlockEnvironment* env, Arguments& args,
View
110 vm/builtin/compiledcode.cpp
@@ -49,7 +49,7 @@ namespace rubinius {
CompiledCode* cm = state->new_object<CompiledCode>(G(cmethod));
cm->local_count(state, Fixnum::from(0));
cm->set_executor(CompiledCode::default_executor);
- cm->backend_method_ = NULL;
+ cm->machine_code_ = NULL;
cm->inliners_ = 0;
cm->prim_index_ = -1;
@@ -66,7 +66,7 @@ namespace rubinius {
cm->set_executor(CompiledCode::default_executor);
cm->jit_data_ = NULL;
- cm->backend_method_ = NULL;
+ cm->machine_code_ = NULL;
return cm;
}
@@ -103,22 +103,22 @@ namespace rubinius {
return as<Fixnum>(lines_->at(state, fin+1))->to_native();
}
- VMMethod* CompiledCode::internalize(STATE, GCToken gct,
+ MachineCode* CompiledCode::internalize(STATE, GCToken gct,
const char** reason, int* ip)
{
- VMMethod* vmm = backend_method_;
+ MachineCode* mcode = machine_code_;
atomic::memory_barrier();
- if(vmm) return vmm;
+ if(mcode) return mcode;
CompiledCode* self = this;
OnStack<1> os(state, self);
self->hard_lock(state, gct);
- vmm = self->backend_method_;
- if(!vmm) {
+ mcode = self->machine_code_;
+ if(!mcode) {
{
BytecodeVerification bv(self);
if(!bv.verify(state)) {
@@ -129,30 +129,30 @@ namespace rubinius {
}
}
- vmm = new VMMethod(state, self);
+ mcode = new MachineCode(state, self);
if(self->resolve_primitive(state)) {
- vmm->fallback = execute;
+ mcode->fallback = execute;
} else {
- vmm->setup_argument_handler(self);
+ mcode->setup_argument_handler(self);
}
// We need to have an explicit memory barrier here, because we need to
- // be sure that vmm is completely initialized before it's set.
+ // be sure that mcode is completely initialized before it's set.
// Otherwise another thread might see a partially initialized
- // VMMethod.
- atomic::write(&backend_method_, vmm);
+ // MachineCode.
+ atomic::write(&machine_code_, mcode);
}
self->hard_unlock(state, gct);
- return vmm;
+ return mcode;
}
Object* CompiledCode::primitive_failed(STATE, CallFrame* call_frame,
Executable* exec, Module* mod, Arguments& args)
{
if(try_as<CompiledCode>(exec)) {
- return VMMethod::execute(state, call_frame, exec, mod, args);
+ return MachineCode::execute(state, call_frame, exec, mod, args);
}
// TODO fix me to raise an exception
@@ -161,7 +161,7 @@ namespace rubinius {
}
void CompiledCode::specialize(STATE, TypeInfo* ti) {
- backend_method_->specialize(state, this, ti);
+ machine_code_->specialize(state, this, ti);
}
Object* CompiledCode::default_executor(STATE, CallFrame* call_frame,
@@ -196,11 +196,11 @@ namespace rubinius {
Class* cls = args.recv()->class_object(state);
int id = cls->class_id();
- VMMethod* v = cm->backend_method();
+ MachineCode* v = cm->machine_code();
executor target = v->unspecialized;
- for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
+ for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
int c_id = v->specializations[i].class_id;
executor x = v->specializations[i].execute;
@@ -218,26 +218,26 @@ namespace rubinius {
}
bool CompiledCode::can_specialize_p() {
- if(!backend_method_) rubinius::bug("specializing with no backend");
+ if(!machine_code_) rubinius::bug("specializing with no backend");
- for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
- if(backend_method_->specializations[i].class_id == 0) return true;
+ for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
+ if(machine_code_->specializations[i].class_id == 0) return true;
}
return false;
}
void CompiledCode::set_unspecialized(executor exec, jit::RuntimeDataHolder* rd) {
- if(!backend_method_) rubinius::bug("specializing with no backend");
+ if(!machine_code_) rubinius::bug("specializing with no backend");
- backend_method_->set_execute_status(VMMethod::eJIT);
+ machine_code_->set_execute_status(MachineCode::eJIT);
jit_data_ = rd;
- backend_method_->unspecialized = exec;
+ machine_code_->unspecialized = exec;
// See if we can also just make this the normal execute
- for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
- if(backend_method_->specializations[i].class_id > 0) return;
+ for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
+ if(machine_code_->specializations[i].class_id > 0) return;
}
execute = exec;
@@ -246,9 +246,9 @@ namespace rubinius {
void CompiledCode::add_specialized(int spec_id, executor exec,
jit::RuntimeDataHolder* rd)
{
- if(!backend_method_) rubinius::bug("specializing with no backend");
+ if(!machine_code_) rubinius::bug("specializing with no backend");
- VMMethod* v = backend_method_;
+ MachineCode* v = machine_code_;
// Must happen only on the first specialization
if(!v->unspecialized) {
@@ -259,14 +259,14 @@ namespace rubinius {
v->unspecialized = execute;
}
- for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
+ for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
int id = v->specializations[i].class_id;
if(id == 0 || id == spec_id) {
v->specializations[i].class_id = spec_id;
v->specializations[i].execute = exec;
v->specializations[i].jit_data = rd;
- v->set_execute_status(VMMethod::eJIT);
+ v->set_execute_status(MachineCode::eJIT);
execute = specialized_executor;
return;
}
@@ -277,11 +277,11 @@ namespace rubinius {
}
executor CompiledCode::find_specialized(int spec_id) {
- VMMethod* v = backend_method_;
+ MachineCode* v = machine_code_;
if(!v) return 0;
- for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
+ for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
if(v->specializations[i].class_id == spec_id) {
return v->specializations[i].execute;
}
@@ -303,44 +303,44 @@ namespace rubinius {
void CompiledCode::set_interpreter(executor interp) {
set_executor(interp);
- backend_method_->fallback = interp;
+ machine_code_->fallback = interp;
}
Object* CompiledCode::set_breakpoint(STATE, GCToken gct, Fixnum* ip, Object* bp) {
CompiledCode* self = this;
OnStack<3> os(state, self, ip, bp);
int i = ip->to_native();
- if(self->backend_method_ == NULL) {
+ if(self->machine_code_ == NULL) {
if(!self->internalize(state, gct)) return Primitives::failure();
}
- if(!self->backend_method_->validate_ip(state, i)) return Primitives::failure();
+ if(!self->machine_code_->validate_ip(state, i)) return Primitives::failure();
if(self->breakpoints_->nil_p()) {
self->breakpoints(state, LookupTable::create(state));
}
self->breakpoints_->store(state, ip, bp);
- self->backend_method_->debugging = 1;
- self->backend_method_->run = VMMethod::debugger_interpreter;
+ self->machine_code_->debugging = 1;
+ self->machine_code_->run = MachineCode::debugger_interpreter;
return ip;
}
Object* CompiledCode::clear_breakpoint(STATE, Fixnum* ip) {
int i = ip->to_native();
- if(backend_method_ == NULL) return ip;
- if(!backend_method_->validate_ip(state, i)) return Primitives::failure();
+ if(machine_code_ == NULL) return ip;
+ if(!machine_code_->validate_ip(state, i)) return Primitives::failure();
bool removed = false;
if(!breakpoints_->nil_p()) {
breakpoints_->remove(state, ip, &removed);
// No more breakpoints, switch back to the normal interpreter
if(breakpoints_->entries()->to_native() == 0) {
- backend_method_->debugging = 0;
- backend_method_->run = VMMethod::interpreter;
+ machine_code_->debugging = 0;
+ machine_code_->run = MachineCode::interpreter;
}
}
@@ -349,8 +349,8 @@ namespace rubinius {
Object* CompiledCode::is_breakpoint(STATE, Fixnum* ip) {
int i = ip->to_native();
- if(backend_method_ == NULL) return cFalse;
- if(!backend_method_->validate_ip(state, i)) return Primitives::failure();
+ if(machine_code_ == NULL) return cFalse;
+ if(!machine_code_->validate_ip(state, i)) return Primitives::failure();
if(breakpoints_->nil_p()) return cFalse;
bool found = false;
@@ -381,10 +381,10 @@ namespace rubinius {
mark_inliners(obj, mark);
CompiledCode* cm = as<CompiledCode>(obj);
- if(!cm->backend_method_) return;
+ if(!cm->machine_code_) return;
- VMMethod* vmm = cm->backend_method_;
- vmm->set_mark();
+ MachineCode* mcode = cm->machine_code_;
+ mcode->set_mark();
Object* tmp;
@@ -395,16 +395,16 @@ namespace rubinius {
}
- for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
- if(vmm->specializations[i].jit_data) {
- vmm->specializations[i].jit_data->set_mark();
- vmm->specializations[i].jit_data->mark_all(cm, mark);
+ for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
+ if(mcode->specializations[i].jit_data) {
+ mcode->specializations[i].jit_data->set_mark();
+ mcode->specializations[i].jit_data->mark_all(cm, mark);
}
}
#endif
- for(size_t i = 0; i < vmm->inline_cache_count(); i++) {
- InlineCache* cache = &vmm->caches[i];
+ for(size_t i = 0; i < mcode->inline_cache_count(); i++) {
+ InlineCache* cache = &mcode->caches[i];
for(int i = 0; i < cTrackedICHits; ++i) {
MethodCacheEntry* mce = cache->cache_[i].entry();
@@ -445,15 +445,15 @@ namespace rubinius {
indent_attribute(level, "total_args"); cm->total_args()->show(state, level);
indent_attribute(level, "internalized");
- if(!cm->backend_method_) {
+ if(!cm->machine_code_) {
std::cout << "no\n";
} else {
std::cout << "yes\n";
#ifdef ENABLE_LLVM
- VMMethod* v = cm->backend_method();
+ MachineCode* v = cm->machine_code();
- for(int i = 0; i < VMMethod::cMaxSpecializations; i++) {
+ for(int i = 0; i < MachineCode::cMaxSpecializations; i++) {
if(!v->specializations[i].jit_data) continue;
llvm::Function* func = v->specializations[i].jit_data->llvm_function();
View
10 vm/builtin/compiledcode.hpp
@@ -9,7 +9,7 @@
namespace rubinius {
class InstructionSequence;
- class VMMethod;
+ class MachineCode;
class ConstantScope;
namespace jit {
@@ -36,7 +36,7 @@ namespace rubinius {
ConstantScope* scope_; // slot
LookupTable* breakpoints_; // slot
- VMMethod* backend_method_;
+ MachineCode* machine_code_;
jit::RuntimeDataHolder* jit_data_;
@@ -45,8 +45,8 @@ namespace rubinius {
Tuple* literals_; // slot
/* accessors */
- VMMethod* backend_method() {
- return backend_method_;
+ MachineCode* machine_code() {
+ return machine_code_;
}
#ifdef ENABLE_LLVM
@@ -95,7 +95,7 @@ namespace rubinius {
void post_marshal(STATE);
size_t number_of_locals();
- VMMethod* internalize(STATE, GCToken gct, const char** failure_reason=0, int* ip=0);
+ MachineCode* internalize(STATE, GCToken gct, const char** failure_reason=0, int* ip=0);
void specialize(STATE, TypeInfo* ti);
static Object* default_executor(STATE, CallFrame*, Executable* exec, Module* mod, Arguments& args);
View
2 vm/builtin/executable.cpp
@@ -80,7 +80,7 @@ namespace rubinius {
for(std::list<CompiledCode*>::const_iterator i = inliners_->inliners().begin();
i != inliners_->inliners().end();
++i) {
- (*i)->backend_method()->deoptimize(state, *i, 0);
+ (*i)->machine_code()->deoptimize(state, *i, 0);
}
inliners_->inliners().clear();
View
2 vm/builtin/executable.hpp
@@ -13,7 +13,7 @@
namespace rubinius {
class Arguments;
- class VMMethod;
+ class MachineCode;
class CompiledCode;
class ObjectMemory;
View
4 vm/builtin/location.cpp
@@ -42,8 +42,8 @@ namespace rubinius {
loc->name(state, call_frame->name());
}
- VMMethod* vmm = call_frame->cm->backend_method();
- if(vmm && vmm->jitted()) {
+ MachineCode* mcode = call_frame->cm->machine_code();
+ if(mcode && mcode->jitted()) {
loc->set_is_jit(state);
}
View
2 vm/builtin/proc.cpp
@@ -13,7 +13,7 @@
#include "arguments.hpp"
#include "on_stack.hpp"
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
#include "arguments.hpp"
#include "dispatch.hpp"
#include "call_frame.hpp"
View
14 vm/builtin/system.cpp
@@ -1051,10 +1051,10 @@ namespace rubinius {
OnStack<2> os(state, env, show);
- VMMethod* vmm = env->vmmethod(state, gct);
+ MachineCode* mcode = env->machine_code(state, gct);
jit::Compiler jit(ls);
- jit.compile_block(ls, env->code(), vmm);
+ jit.compile_block(ls, env->code(), mcode);
if(show->true_p()) {
jit.show_machine_code();
@@ -1084,8 +1084,8 @@ namespace rubinius {
while(obj) {
if(CompiledCode* cm = try_as<CompiledCode>(obj)) {
- if(VMMethod* vmm = cm->backend_method()) {
- vmm->deoptimize(state, cm, 0, disable);
+ if(MachineCode* mcode = cm->machine_code()) {
+ mcode->deoptimize(state, cm, 0, disable);
}
total++;
}
@@ -1583,12 +1583,12 @@ namespace rubinius {
#ifdef RBX_PROFILER
if(unlikely(state->vm()->tooling())) {
tooling::ScriptEntry me(state, cm);
- return cm->backend_method()->execute_as_script(state, cm, calling_environment);
+ return cm->machine_code()->execute_as_script(state, cm, calling_environment);
} else {
- return cm->backend_method()->execute_as_script(state, cm, calling_environment);
+ return cm->machine_code()->execute_as_script(state, cm, calling_environment);
}
#else
- return cm->backend_method()->execute_as_script(state, cm, calling_environment);
+ return cm->machine_code()->execute_as_script(state, cm, calling_environment);
#endif
}
View
2 vm/bytecode_verification.cpp
@@ -8,7 +8,7 @@
#include "builtin/fixnum.hpp"
#include "builtin/symbol.hpp"
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
#include "object_utils.hpp"
#include "instruments/timing.hpp"
View
4 vm/call_frame.hpp
@@ -1,7 +1,7 @@
#ifndef RBX_CALL_FRAME_HPP
#define RBX_CALL_FRAME_HPP
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
#include "unwind_info.hpp"
#include "stack_variables.hpp"
#include "builtin/variable_scope.hpp"
@@ -226,7 +226,7 @@ namespace rubinius {
}
void calculate_ip(void** pos) {
- ip_ = pos - cm->backend_method()->addresses;
+ ip_ = pos - cm->machine_code()->addresses;
}
VariableScope* promote_scope_full(STATE);
View
8 vm/drivers/jit-test.cpp
@@ -1,6 +1,6 @@
#include "prelude.hpp"
#include "object_utils.hpp"
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
#include "jit.hpp"
#include "environment.hpp"
#include "config_parser.hpp"
@@ -39,12 +39,12 @@ int main(int argc, char **argv) {
cout << "Invalid file.\n";
}
- VMMethod* vmm = as<CompiledCode>(cf->body(state))->formalize(state, false);
+ MachineCode* mcode = as<CompiledCode>(cf->body(state))->formalize(state, false);
delete cf;
- compiler.compile(state, vmm);
- MachineMethod* mm = MachineMethod::create(state, vmm, compiler);
+ compiler.compile(state, mcode);
+ MachineMethod* mm = MachineMethod::create(state, mcode, compiler);
mm->show();
return 0;
}
View
2 vm/gc/code_manager.hpp
@@ -10,7 +10,7 @@ namespace rubinius {
/**
* Manages memory for code-based resources that are owned by Ruby objects,
- * such as VMMethod instances, JIT code, FFI resources etc.
+ * such as MachineCode instances, JIT code, FFI resources etc.
*
* These objects are not directly accessible via Ruby code, but are used by
* the VM to support the running of Ruby code. As such, these objects also
View
2 vm/gc/gc.cpp
@@ -136,7 +136,7 @@ namespace rubinius {
scope->block_ = mark_object(scope->block());
scope->module_ = (Module*)mark_object(scope->module());
- int locals = call_frame->cm->backend_method()->number_of_locals;
+ int locals = call_frame->cm->machine_code()->number_of_locals;
for(int i = 0; i < locals; i++) {
Object* local = scope->get_local(i);
if(local->reference_p()) {
View
12 vm/inline_cache.hpp
@@ -68,7 +68,7 @@ namespace rubinius {
#ifdef TRACK_IC_LOCATION
int ip_;
- VMMethod* vmm_;
+ MachineCode* machine_code_;
#endif
int seen_classes_overflow_;
@@ -146,20 +146,20 @@ namespace rubinius {
}
#ifdef TRACK_IC_LOCATION
- void set_location(int ip, VMMethod* vmm) {
+ void set_location(int ip, MachineCode* mcode) {
ip_ = ip;
- vmm_ = vmm;
+ machine_code_ = mcode;
}
int ip() {
return ip_;
}
- VMMethod* vmmethod() {
- return vmm_;
+ MachineCode* machine_code() {
+ return machine_code_;
}
#else
- void set_location(int ip, VMMethod* vmm) { }
+ void set_location(int ip, MachineCode* mcode) { }
#endif
void print_location(STATE, std::ostream& stream);
View
44 vm/instructions.cpp
@@ -56,39 +56,39 @@ using namespace rubinius;
#define stack_calculate_sp() (STACK_PTR - call_frame->stk)
#define stack_back_position(count) (STACK_PTR - (count - 1))
-#define stack_local(which) call_frame->stk[vmm->stack_size - which - 1]
+#define stack_local(which) call_frame->stk[mcode->stack_size - which - 1]
#define both_fixnum_p(_p1, _p2) ((uintptr_t)(_p1) & (uintptr_t)(_p2) & TAG_FIXNUM)
#define JUMP_DEBUGGING \
- return VMMethod::debugger_interpreter_continue(state, vmm, call_frame, \
+ return MachineCode::debugger_interpreter_continue(state, mcode, call_frame, \
stack_calculate_sp(), is, current_unwind, unwinds)
#define CHECK_AND_PUSH(val) \
if(val == NULL) { goto exception; } \
- else { stack_push(val); if(vmm->debugging) JUMP_DEBUGGING; }
+ else { stack_push(val); if(mcode->debugging) JUMP_DEBUGGING; }
#define RUN_EXCEPTION() goto exception
#define SET_CALL_FLAGS(val) is.call_flags = (val)
#define CALL_FLAGS() is.call_flags
-Object* VMMethod::interpreter(STATE,
- VMMethod* const vmm,
+Object* MachineCode::interpreter(STATE,
+ MachineCode* const mcode,
InterpreterCallFrame* const call_frame)
{
#include "vm/gen/instruction_locations.hpp"
if(unlikely(state == 0)) {
- VMMethod::instructions = const_cast<void**>(insn_locations);
+ MachineCode::instructions = const_cast<void**>(insn_locations);
return NULL;
}
InterpreterState is;
GCTokenImpl gct;
- register void** ip_ptr = vmm->addresses;
+ register void** ip_ptr = mcode->addresses;
Object** stack_ptr = call_frame->stk - 1;
@@ -104,7 +104,7 @@ Object* VMMethod::interpreter(STATE,
#undef next_int
#define next_int ((opcode)(*ip_ptr++))
-#define cache_ip(which) ip_ptr = vmm->addresses + which
+#define cache_ip(which) ip_ptr = mcode->addresses + which
#define flush_ip() call_frame->calculate_ip(ip_ptr)
#include "vm/gen/instruction_implementations.hpp"
@@ -204,8 +204,8 @@ Object* VMMethod::interpreter(STATE,
return NULL;
}
-Object* VMMethod::uncommon_interpreter(STATE,
- VMMethod* const vmm,
+Object* MachineCode::uncommon_interpreter(STATE,
+ MachineCode* const mcode,
CallFrame* const call_frame,
int32_t entry_ip,
native_int sp,
@@ -215,9 +215,9 @@ Object* VMMethod::uncommon_interpreter(STATE,
int32_t* input_unwinds)
{
- VMMethod* method_vmm = method_call_frame->cm->backend_method();
+ MachineCode* mc = method_call_frame->cm->machine_code();
- if(++method_vmm->uncommon_count > state->shared().config.jit_deoptimize_threshold) {
+ if(++mc->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);
@@ -226,13 +226,13 @@ Object* VMMethod::uncommon_interpreter(STATE,
method_call_frame->print_backtrace(state);
}
- method_vmm->uncommon_count = 0;
- method_vmm->deoptimize(state, method_call_frame->cm, rd);
+ mc->uncommon_count = 0;
+ mc->deoptimize(state, method_call_frame->cm, rd);
}
#include "vm/gen/instruction_locations.hpp"
- opcode* stream = vmm->opcodes;
+ opcode* stream = mcode->opcodes;
InterpreterState is;
GCTokenImpl gct;
@@ -364,17 +364,17 @@ Object* VMMethod::uncommon_interpreter(STATE,
/* The debugger interpreter loop is used to run a method when a breakpoint
* has been set. It has additional overhead, since it needs to inspect
- * each opcode for the breakpoint flag. It is installed on the VMMethod when
+ * each opcode for the breakpoint flag. It is installed on the MachineCode when
* a breakpoint is set on compiled method.
*/
-Object* VMMethod::debugger_interpreter(STATE,
- VMMethod* const vmm,
+Object* MachineCode::debugger_interpreter(STATE,
+ MachineCode* const mcode,
InterpreterCallFrame* const call_frame)
{
#include "vm/gen/instruction_locations.hpp"
- opcode* stream = vmm->opcodes;
+ opcode* stream = mcode->opcodes;
InterpreterState is;
GCTokenImpl gct;
@@ -505,8 +505,8 @@ Object* VMMethod::debugger_interpreter(STATE,
return NULL;
}
-Object* VMMethod::debugger_interpreter_continue(STATE,
- VMMethod* const vmm,
+Object* MachineCode::debugger_interpreter_continue(STATE,
+ MachineCode* const mcode,
CallFrame* const call_frame,
int sp,
InterpreterState& is,
@@ -517,7 +517,7 @@ Object* VMMethod::debugger_interpreter_continue(STATE,
#include "vm/gen/instruction_locations.hpp"
GCTokenImpl gct;
- opcode* stream = vmm->opcodes;
+ opcode* stream = mcode->opcodes;
Object** stack_ptr = call_frame->stk + sp;
View
20 vm/instructions.def
@@ -408,7 +408,7 @@ instruction passed_arg(index) [ -- boolean ]
RUN_EXCEPTION();
}
- stack_push(RBOOL(index < (int)call_frame->arguments->total() - vmm->post_args));
+ stack_push(RBOOL(index < (int)call_frame->arguments->total() - mcode->post_args));
end
section "Manipulate exceptions"
@@ -1164,7 +1164,7 @@ instruction create_block(literal) [ -- block ]
// TODO: We do not need to be doing this everytime.
cm->scope(state, call_frame->constant_scope());
- Object* be = BlockEnvironment::under_call_frame(state, gct, cm, vmm, call_frame);
+ Object* be = BlockEnvironment::under_call_frame(state, gct, cm, mcode, call_frame);
CHECK_AND_PUSH(be);
end
@@ -1622,7 +1622,7 @@ instruction check_interrupts() [ -- ]
flush_ip();
// This is used in loops, and allows loops to heat a method up.
- if(vmm->call_count >= 0) vmm->call_count++;
+ if(mcode->call_count >= 0) mcode->call_count++;
if(!state->check_async(call_frame)) RUN_EXCEPTION();
@@ -2031,14 +2031,14 @@ instruction zsuper(literal) [ block -- value ]
VariableScope* scope = call_frame->method_scope(state);
interp_assert(scope);
- VMMethod* v = scope->method()->backend_method();
+ MachineCode* mc = scope->method()->machine_code();
Object* splat_obj = 0;
Array* splat = 0;
- size_t arg_count = v->total_args;
+ size_t arg_count = mc->total_args;
- if(v->splat_position >= 0) {
- splat_obj = scope->get_local(state, v->splat_position);
+ if(mc->splat_position >= 0) {
+ splat_obj = scope->get_local(state, mc->splat_position);
splat = try_as<Array>(splat_obj);
if(splat) {
arg_count += splat->size();
@@ -2048,16 +2048,16 @@ instruction zsuper(literal) [ block -- value ]
}
Tuple* tup = Tuple::create(state, arg_count);
- for(int i = 0; i < v->total_args; i++) {
+ for(int i = 0; i < mc->total_args; i++) {
tup->put(state, i, scope->get_local(state, i));
}
if(splat) {
for(size_t i = 0; i < splat->size(); i++) {
- tup->put(state, i + v->total_args, splat->get(state, i));
+ tup->put(state, i + mc->total_args, splat->get(state, i));
}
} else if(splat_obj) {
- tup->put(state, v->total_args, splat_obj);
+ tup->put(state, mc->total_args, splat_obj);
}
InlineCache* cache = reinterpret_cast<InlineCache*>(literal);
View
2 vm/instructions.hpp
@@ -1,7 +1,7 @@
#ifndef RBX_INSTR
#define RBX_INSTR
-#include "vm/vmmethod.hpp"
+#include "vm/machine_code.hpp"
namespace rubinius {
namespace instructions {
View
8 vm/instructions_util.hpp
@@ -18,8 +18,8 @@ namespace rubinius {
size_ = size;
}
- void set_stream(VMMethod* vmm) {
- set_stream(vmm->opcodes, vmm->total);
+ void set_stream(MachineCode* mcode) {
+ set_stream(mcode->opcodes, mcode->total);
}
void visit(opcode code, opcode arg1, opcode arg2) { }
@@ -122,8 +122,8 @@ namespace rubinius {
}
}
- void drive(VMMethod* vmm) {
- drive(vmm->opcodes, vmm->total);
+ void drive(MachineCode* mcode) {
+ drive(mcode->opcodes, mcode->total);
}
};
}
View
6 vm/instruments/rbxti.cpp
@@ -3,7 +3,7 @@
#include "rbxti-internal.hpp"
#include "vm/vm.hpp"
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
#include "configuration.hpp"
#include "config_parser.hpp"
@@ -223,8 +223,8 @@ namespace rbxti {
r_mint Env::method_id(rmethod meth) {
CompiledCode* cm = i(meth);
- if(VMMethod* vmm = cm->backend_method()) {
- return (vmm->method_id() << 1) | 1;
+ if(MachineCode* mcode = cm->machine_code()) {
+ return (mcode->method_id() << 1) | 1;
}
return 0;
View
4 vm/llvm/background_compile_request.hpp
@@ -27,8 +27,8 @@ namespace rubinius {
, waiter_(0)
{}
- VMMethod* vmmethod() {
- return method_->backend_method();
+ MachineCode* machine_code() {
+ return method_->machine_code();
}
CompiledCode* method() {
View
16 vm/llvm/cfg.hpp
@@ -1,5 +1,5 @@
#include <list>
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
namespace rubinius {
namespace jit {
@@ -89,11 +89,11 @@ namespace jit {
, stream_size_(size)
{}
- CFGCalculator(VMMethod* vmm)
+ CFGCalculator(MachineCode* mcode)
: root_(0)
, current_(0)
- , stream_(vmm->opcodes)
- , stream_size_(vmm->total)
+ , stream_(mcode->opcodes)
+ , stream_size_(mcode->total)
{}
~CFGCalculator() {
@@ -142,7 +142,7 @@ namespace jit {
}
void find_backward_gotos() {
- VMMethod::Iterator iter(stream_, stream_size_);
+ MachineCode::Iterator iter(stream_, stream_size_);
while(!iter.end()) {
switch(iter.op()) {
@@ -162,13 +162,13 @@ namespace jit {
}
}
- void close_current(VMMethod::Iterator& iter, CFGBlock* next) {
+ void close_current(MachineCode::Iterator& iter, CFGBlock* next) {
current_->set_end_ip(iter.position());
current_->add_child(next);
current_ = next;
}
- CFGBlock* start_new_block(VMMethod::Iterator& iter) {
+ CFGBlock* start_new_block(MachineCode::Iterator& iter) {
if(!iter.last_instruction()) {
CFGBlock* blk = add_block(iter.next_position());
close_current(iter, blk);
@@ -191,7 +191,7 @@ namespace jit {
current_ = root_;
- VMMethod::Iterator iter(stream_, stream_size_);
+ MachineCode::Iterator iter(stream_, stream_size_);
for(;;) {
if(CFGBlock* next_block = find_block(iter.position())) {
if(next_block->loop_p() && current_ != next_block) {
View
14 vm/llvm/control_flow.hpp
@@ -10,16 +10,16 @@ namespace rubinius {
typedef std::list<int> SectionList;
private:
- VMMethod* vmm_;
+ MachineCode* machine_code_;
uint8_t* seen_;
SectionList work_list_;
public:
- ControlFlowWalker(VMMethod* vmm)
- : vmm_(vmm)
+ ControlFlowWalker(MachineCode* mcode)
+ : machine_code_(mcode)
{
- seen_ = new uint8_t[vmm->total];
- memset(seen_, 0, vmm->total);
+ seen_ = new uint8_t[mcode->total];
+ memset(seen_, 0, mcode->total);
}
~ControlFlowWalker() {
@@ -35,7 +35,7 @@ namespace rubinius {
void run(EI& each) {
work_list_.push_back(0);
- OpcodeIterator iter(vmm_);
+ OpcodeIterator iter(machine_code_);
while(!work_list_.empty()) {
int ip = work_list_.back();
@@ -50,7 +50,7 @@ namespace rubinius {
if(iter.goto_p()) {
opcode target = iter.goto_target();
- assert(target < vmm_->total);
+ assert(target < machine_code_->total);
add_section(target);
View
42 vm/llvm/inline.cpp
@@ -125,7 +125,7 @@ namespace rubinius {
inline_ivar_access(klass, acc);
}
} else if(CompiledCode* cm = try_as<CompiledCode>(meth)) {
- VMMethod* vmm = cm->backend_method();
+ MachineCode* mcode = cm->machine_code();
if(!cm->primitive()->nil_p()) {
if(!inline_primitive(klass, cm, meth->execute)) return false;
@@ -134,9 +134,9 @@ namespace rubinius {
// Not yet sure why we'd hit a CompiledCode that hasn't been
// internalized, but protect against that case none the less.
- if(!vmm) return false;
+ if(!mcode) return false;
- if(detect_trivial_method(vmm, cm)) {
+ if(detect_trivial_method(mcode, cm)) {
inline_trivial_method(klass, cm);
} else if(int which = detect_jit_intrinsic(klass, cm)) {
inline_intrinsic(klass, cm, which);
@@ -147,10 +147,10 @@ namespace rubinius {
InlinePolicy* policy = ops_.inline_policy();
assert(policy);
- if(vmm->no_inline_p()) {
+ if(mcode->no_inline_p()) {
decision = cInlineDisabled;
} else {
- decision = policy->inline_p(vmm, opts);
+ decision = policy->inline_p(mcode, opts);
}
if(decision != cInline) {
@@ -170,7 +170,7 @@ namespace rubinius {
break;
case cTooBig:
ops_.state()->log() << policy->current_size() << " + "
- << vmm->total << " > "
+ << mcode->total << " > "
<< policy->max_size();
break;
case cTooComplex:
@@ -182,7 +182,7 @@ namespace rubinius {
default:
ops_.state()->log() << "no policy";
}
- if(vmm->jitted()) {
+ if(mcode->jitted()) {
ops_.state()->log() << " (jitted)\n";
} else {
ops_.state()->log() << " (interp)\n";
@@ -212,10 +212,10 @@ namespace rubinius {
ops_.state()->log() << "\n";
}
- policy->increase_size(vmm);
+ policy->increase_size(mcode);
meth->add_inliner(ops_.state()->shared().om, ops_.root_method_info()->method());
- inline_generic_method(klass, defined_in, cm, vmm);
+ inline_generic_method(klass, defined_in, cm, mcode);
return true;
} else {
if(ops_.state()->config().jit_inline_debug) {
@@ -272,8 +272,8 @@ namespace rubinius {
emit_inline_block(ib, self);
}
- bool Inliner::detect_trivial_method(VMMethod* vmm, CompiledCode* cm) {
- opcode* stream = vmm->opcodes;
+ bool Inliner::detect_trivial_method(MachineCode* mcode, CompiledCode* cm) {
+ opcode* stream = mcode->opcodes;
size_t size_max = 2;
switch(stream[0]) {
case InstructionSequence::insn_push_int:
@@ -296,10 +296,10 @@ namespace rubinius {
return false;
}
- if(vmm->total == size_max &&
+ if(mcode->total == size_max &&
count_ == 0 &&
- vmm->required_args == vmm->total_args &&
- vmm->total_args == 0) return true;
+ mcode->required_args == mcode->total_args &&
+ mcode->total_args == 0) return true;
return false;
}
@@ -314,14 +314,14 @@ namespace rubinius {
<< " (" << ops_.state()->symbol_debug_str(klass->module_name()) << ") trivial\n";
}
- VMMethod* vmm = cm->backend_method();
+ MachineCode* mcode = cm->machine_code();
if(klass) check_recv(klass);
Value* val = 0;
/////
- opcode* stream = vmm->opcodes;
+ opcode* stream = mcode->opcodes;
switch(stream[0]) {
case InstructionSequence::insn_push_int:
val = ops_.constant(Fixnum::from(stream[1]));
@@ -514,12 +514,12 @@ namespace rubinius {
}
void Inliner::inline_generic_method(Class* klass, Module* defined_in,
- CompiledCode* cm, VMMethod* vmm) {
+ CompiledCode* cm, MachineCode* mcode) {
context_.enter_inline();
check_recv(klass);
- JITMethodInfo info(context_, cm, vmm);
+ JITMethodInfo info(context_, cm, mcode);
prime_info(info);
@@ -548,7 +548,7 @@ namespace rubinius {
}
}
- if(vmm->call_count >= 0) vmm->call_count /= 2;
+ if(mcode->call_count >= 0) mcode->call_count /= 2;
BasicBlock* entry = work.setup_inline(recv(), blk, args);
@@ -572,7 +572,7 @@ namespace rubinius {
void Inliner::emit_inline_block(JITInlineBlock* ib, Value* self) {
context_.enter_inline();
- JITMethodInfo info(context_, ib->method(), ib->code());
+ JITMethodInfo info(context_, ib->method(), ib->machine_code());
prime_info(info);
@@ -597,7 +597,7 @@ namespace rubinius {
info.stack_args = &args;
- if(ib->code()->call_count >= 0) ib->code()->call_count /= 2;
+ if(ib->machine_code()->call_count >= 0) ib->machine_code()->call_count /= 2;
BasicBlock* entry = work.setup_inline_block(self,
ops_.constant(cNil, ops_.state()->ptr_type("Module")), args);
View
4 vm/llvm/inline.hpp
@@ -150,9 +150,9 @@ namespace rubinius {
void inline_block(JITInlineBlock* ib, Value* self);
- void inline_generic_method(Class* klass, Module* mod, CompiledCode* cm, VMMethod* vmm);
+ void inline_generic_method(Class* klass, Module* mod, CompiledCode* cm, MachineCode* mcode);
- bool detect_trivial_method(VMMethod* vmm, CompiledCode* cm = 0);
+ bool detect_trivial_method(MachineCode* mcode, CompiledCode* cm = 0);
void inline_trivial_method(Class* klass, CompiledCode* cm);
View
4 vm/llvm/inline_block.cpp
@@ -7,11 +7,11 @@
namespace rubinius {
JITInlineBlock::JITInlineBlock(LLVMState* ls, llvm::PHINode* phi, llvm::BasicBlock* brk,
- CompiledCode* cm, VMMethod* code,
+ CompiledCode* cm, MachineCode* mcode,
JITMethodInfo* scope, int which)
: block_break_result_(phi)
, block_break_loc_(brk)
- , code_(code)
+ , machine_code_(mcode)
, method_(&ls->roots())
, scope_(scope)
, which_(which)
View
10 vm/llvm/inline_block.hpp
@@ -5,20 +5,20 @@
namespace rubinius {
class JITMethodInfo;
- class VMMethod;
+ class MachineCode;
class JITInlineBlock {
llvm::PHINode* block_break_result_;
llvm::BasicBlock* block_break_loc_;
- VMMethod* code_;
+ MachineCode* machine_code_;
TypedRoot<CompiledCode*> method_;
JITMethodInfo* scope_;
int which_;
bool created_object_;
public:
JITInlineBlock(LLVMState* ls, llvm::PHINode* phi, llvm::BasicBlock* brk,
- CompiledCode* cm, VMMethod* code,
+ CompiledCode* cm, MachineCode* mcode,
JITMethodInfo* scope, int which);
llvm::PHINode* block_break_result() {
@@ -29,8 +29,8 @@ namespace rubinius {
return block_break_loc_;
}
- VMMethod* code() {
- return code_;
+ MachineCode* machine_code() {
+ return machine_code_;
}
CompiledCode* method() {
View
76 vm/llvm/inline_policy.hpp
@@ -1,7 +1,7 @@
#ifndef RBX_LLVM_INLINE_POLICY_HPP
#define RBX_LLVM_INLINE_POLICY_HPP
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
#include "instructions_util.hpp"
namespace rubinius {
@@ -44,15 +44,15 @@ namespace rubinius {
class Unsupported {};
- static bool can_inline_p(VMMethod* vmm, InlineOptions& opts) {
+ static bool can_inline_p(MachineCode* mcode, InlineOptions& opts) {
// Reject methods with splat arguments
- if(!opts.allow_splat && vmm->splat_position >= 0) return false;
- if(vmm->post_args > 0) return false;
+ if(!opts.allow_splat && mcode->splat_position >= 0) return false;
+ if(mcode->post_args > 0) return false;
InlineEvaluator eval(opts);
try {
- eval.drive(vmm);
+ eval.drive(mcode);
} catch(Unsupported& e) {
return false;
}
@@ -121,16 +121,16 @@ namespace rubinius {
class InlinePolicy {
protected:
- VMMethod* vmm_;
+ MachineCode* machine_code_;
size_t current_size_;
size_t max_size_;
public:
- static InlinePolicy* create_policy(VMMethod* vmm);
+ static InlinePolicy* create_policy(MachineCode* mcode);
- InlinePolicy(VMMethod* vmm, int max)
- : vmm_(vmm)
- , current_size_(vmm->total)
+ InlinePolicy(MachineCode* mcode, int max)
+ : machine_code_(mcode)
+ , current_size_(mcode->total)
, max_size_(max)
{}
@@ -144,79 +144,79 @@ namespace rubinius {
return max_size_;
}
- bool check_size_p(VMMethod* other) {
+ bool check_size_p(MachineCode* other) {
if(other->total + current_size_ > max_size_) return false;
return true;
}
- InlineDecision inline_p(VMMethod* vmm, InlineOptions& opts) {
- if(!InlineEvaluator::can_inline_p(vmm, opts)) {
+ InlineDecision inline_p(MachineCode* mcode, InlineOptions& opts) {
+ if(!InlineEvaluator::can_inline_p(mcode, opts)) {
return cTooComplex;
}
- if(opts.check_size && !check_size_p(vmm)) return cTooBig;
+ if(opts.check_size && !check_size_p(mcode)) return cTooBig;
return cInline;
}
- void increase_size(VMMethod* vmm) {
- current_size_ += vmm->total;
+ void increase_size(MachineCode* mcode) {
+ current_size_ += mcode->total;
}
};
class SmallMethodInlinePolicy : public InlinePolicy {
public:
- static bool is_small_p(VMMethod* vmm) {
- if(vmm->total < 100) return true;
+ static bool is_small_p(MachineCode* mcode) {
+ if(mcode->total < 100) return true;
return false;
}
- SmallMethodInlinePolicy(VMMethod* vmm)
- : InlinePolicy(vmm, 300) // Random number!
+ SmallMethodInlinePolicy(MachineCode* mcode)
+ : InlinePolicy(mcode, 300) // Random number!
{}
};
class NormalMethodInlinePolicy : public InlinePolicy {
public:
- static bool is_normal_p(VMMethod* vmm) {
- if(vmm->total < 300) return true;
+ static bool is_normal_p(MachineCode* mcode) {
+ if(mcode->total < 300) return true;
return false;
}
- NormalMethodInlinePolicy(VMMethod* vmm)
- : InlinePolicy(vmm, vmm->total * 3)
+ NormalMethodInlinePolicy(MachineCode* mcode)
+ : InlinePolicy(mcode, mcode->total * 3)
{}
};
class LargeMethodInlinePolicy : public InlinePolicy {
public:
- static bool is_large_p(VMMethod* vmm) {
- if(vmm->total < 2000) return true;
+ static bool is_large_p(MachineCode* mcode) {
+ if(mcode->total < 2000) return true;
return false;
}
- LargeMethodInlinePolicy(VMMethod* vmm)
- : InlinePolicy(vmm, vmm->total * 2)
+ LargeMethodInlinePolicy(MachineCode* mcode)
+ : InlinePolicy(mcode, mcode->total * 2)
{}
};
class NoChangeInlinePolicy : public InlinePolicy {
public:
- NoChangeInlinePolicy(VMMethod* vmm)
- : InlinePolicy(vmm, vmm->total)
+ NoChangeInlinePolicy(MachineCode* mcode)
+ : InlinePolicy(mcode, mcode->total)
{}
};
- inline InlinePolicy* InlinePolicy::create_policy(VMMethod* vmm) {
- if(SmallMethodInlinePolicy::is_small_p(vmm)) {
- return new SmallMethodInlinePolicy(vmm);
- } else if(NormalMethodInlinePolicy::is_normal_p(vmm)) {
- return new NormalMethodInlinePolicy(vmm);
- } else if(LargeMethodInlinePolicy::is_large_p(vmm)) {
- return new LargeMethodInlinePolicy(vmm);
+ inline InlinePolicy* InlinePolicy::create_policy(MachineCode* mcode) {
+ if(SmallMethodInlinePolicy::is_small_p(mcode)) {
+ return new SmallMethodInlinePolicy(mcode);
+ } else if(NormalMethodInlinePolicy::is_normal_p(mcode)) {
+ return new NormalMethodInlinePolicy(mcode);
+ } else if(LargeMethodInlinePolicy::is_large_p(mcode)) {
+ return new LargeMethodInlinePolicy(mcode);
} else {
- return new NoChangeInlinePolicy(vmm);
+ return new NoChangeInlinePolicy(mcode);
}
return NULL;
View
18 vm/llvm/jit_block.cpp
@@ -55,9 +55,9 @@ namespace jit {
alloc_frame("block_body");
- initialize_frame(vmm_->stack_size);
+ initialize_frame(machine_code_->stack_size);
- nil_stack(vmm_->stack_size, constant(cNil, obj_type));
+ nil_stack(machine_code_->stack_size, constant(cNil, obj_type));
setup_block_scope();
@@ -208,7 +208,7 @@ namespace jit {
}
void BlockBuilder::import_args_19_style() {
- if(vmm_->required_args > 1) {
+ if(machine_code_->required_args > 1) {
Value* lambda_check =
b().CreateICmpEQ(
b().CreateAnd(
@@ -249,10 +249,10 @@ namespace jit {
"arg_ary");
// The variables used in the 4 phases.
- int P = vmm_->post_args;
+ int P = machine_code_->post_args;
Value* Pv = cint(P);
- int R = vmm_->required_args;
+ int R = machine_code_->required_args;
int M = R - P;
Value* Mv = cint(M);
@@ -261,13 +261,13 @@ namespace jit {
b().CreateConstGEP2_32(info_.args(), 0, offset::args_total),
"args.total");
- int DT = vmm_->total_args;
+ int DT = machine_code_->total_args;
Value* DTv = cint(DT);
int O = DT - R;
Value* Ov = cint(O);
- int HS = vmm_->splat_position > 0 ? 1 : 0;
+ int HS = machine_code_->splat_position > 0 ? 1 : 0;
Value* CT = HS ? T
: b().CreateSelect(b().CreateICmpSLT(T, DTv), T, DTv);
@@ -445,7 +445,7 @@ namespace jit {
}
// Phase 4 - splat
- if(vmm_->splat_position >= 0) {
+ if(machine_code_->splat_position >= 0) {
Signature sig(ls_, "Object");
sig << "State";
sig << "Arguments";
@@ -471,7 +471,7 @@ namespace jit {
Value* idx3[] = {
cint(0),
cint(offset::vars_tuple),
- cint(vmm_->splat_position)
+ cint(machine_code_->splat_position)
};
Value* pos = b().CreateGEP(vars, idx3, "splat_pos");
View
18 vm/llvm/jit_builder.cpp
@@ -2,7 +2,7 @@
#include "llvm/jit_builder.hpp"
#include "call_frame.hpp"
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
#include "llvm/jit_visit.hpp"
#include "llvm/control_flow.hpp"
@@ -16,7 +16,7 @@ namespace jit {
Builder::Builder(LLVMState* ls, JITMethodInfo& i)
: ls_(ls)
- , vmm_(i.vmm)
+ , machine_code_(i.machine_code)
, builder_(ls->ctx())
, use_full_scope_(false)
, import_args_(0)
@@ -73,7 +73,7 @@ namespace jit {
void Builder::nil_locals() {
Value* nil = constant(cNil, obj_type);
- int size = vmm_->number_of_locals;
+ int size = machine_code_->number_of_locals;
if(size == 0) return;
// Stack size 5 or less, do 5 stores in a row rather than
@@ -470,12 +470,12 @@ namespace jit {
};
void Builder::pass_one(BasicBlock* body) {
- CFGCalculator cfg(vmm_);
+ CFGCalculator cfg(machine_code_);
cfg.build();
// Pass 1, detect BasicBlock boundaries
PassOne finder(ls_, block_map_, info_.function(), body, cfg, info_);
- finder.drive(vmm_);
+ finder.drive(machine_code_);
if(finder.creates_blocks() || finder.calls_evalish()) {
info_.set_use_full_scope();
@@ -526,11 +526,11 @@ namespace jit {
if(use_full_scope_) visitor.use_full_scope();
visitor.initialize();
- visitor.set_stream(info_.vmm);
+ visitor.set_stream(info_.machine_code);
// Pass 2, compile!
// Drive by following the control flow.
- jit::ControlFlowWalker walker(info_.vmm);
+ jit::ControlFlowWalker walker(info_.machine_code);
Walker cb(visitor, block_map_);
try {
@@ -604,11 +604,11 @@ namespace jit {
valid_flag = b().CreateAlloca(ls_->Int1Ty, 0, "valid_flag");
Value* cfstk = b().CreateAlloca(obj_type,
- cint((sizeof(CallFrame) / sizeof(Object*)) + vmm_->stack_size),
+ cint((sizeof(CallFrame) / sizeof(Object*)) + machine_code_->stack_size),
"cfstk");
Value* var_mem = b().CreateAlloca(obj_type,
- cint((sizeof(StackVariables) / sizeof(Object*)) + vmm_->number_of_locals),
+ cint((sizeof(StackVariables) / sizeof(Object*)) + machine_code_->number_of_locals),
"var_mem");
call_frame = b().CreateBitCast(
View
4 vm/llvm/jit_builder.hpp
@@ -9,7 +9,7 @@
namespace rubinius {
class InlinePolicy;
- class VMMethod;
+ class MachineCode;
class JITMethodInfo;
namespace jit {
@@ -18,7 +18,7 @@ namespace jit {
class Builder {
public:
LLVMState* ls_;
- VMMethod* vmm_;
+ MachineCode* machine_code_;
llvm::Type* cf_type;
llvm::Type* vars_type;
llvm::Type* stack_vars_type;
View
12 vm/llvm/jit_compiler.cpp
@@ -1,6 +1,6 @@
#ifdef ENABLE_LLVM
-#include "vmmethod.hpp"
+#include "machine_code.hpp"
#include "llvm/jit_context.hpp"
#include "builtin/fixnum.hpp"
@@ -136,15 +136,15 @@ namespace jit {
void Compiler::compile(LLVMState* ls, BackgroundCompileRequest* req) {
if(req->is_block()) {
- compile_block(ls, req->method(), req->vmmethod());
+ compile_block(ls, req->method(), req->machine_code());
} else {
compile_method(ls, req);
}
}
- void Compiler::compile_block(LLVMState* ls, CompiledCode* cm, VMMethod* vmm) {
+ void Compiler::compile_block(LLVMState* ls, CompiledCode* cm, MachineCode* mcode) {
if(ls->config().jit_inline_debug) {
- assert(vmm->parent());
+ assert(mcode->parent());
struct timeval tv;
gettimeofday(&tv, NULL);
@@ -157,7 +157,7 @@ namespace jit {
<< " (" << tv.tv_sec << "." << tv.tv_usec << ")\n";
}
- JITMethodInfo info(ctx_, cm, vmm);
+ JITMethodInfo info(ctx_, cm, mcode);
info.is_block = true;
ctx_.set_root(&info);
@@ -182,7 +182,7 @@ namespace jit {
<< " (" << tv.tv_sec << "." << tv.tv_usec << ")\n";
}
- JITMethodInfo info(ctx_, cm, cm->backend_method());
+ JITMethodInfo info(ctx_, cm, cm->machine_code());
info.is_block = false;
if(Class* cls = req->receiver_class()) {
View
6 vm/llvm/jit_compiler.hpp
@@ -15,7 +15,7 @@ namespace llvm {
namespace rubinius {
class LLVMState;
class JITMethodInfo;
- class VMMethod;
+ class MachineCode;
class BackgroundCompileRequest;
@@ -61,15 +61,15 @@ namespace jit {
void compile(LLVMState* state, BackgroundCompileRequest* req);
void compile_method(LLVMState*, BackgroundCompileRequest* req);
- void compile_block(LLVMState*, CompiledCode* cm, VMMethod* vmm);
+ void compile_block(LLVMState*, CompiledCode* cm, MachineCode* mcode);
void compile_builder(jit::Context& ctx, LLVMState*, JITMethodInfo&, rubinius::jit::Builder&);
void* function_pointer();
void* generate_function(LLVMState* ls, bool indy=true);
void show_machine_code();
void import_args(LLVMState* ls, llvm::Function* func,
- llvm::BasicBlock*& block, VMMethod* vmm,
+ llvm::BasicBlock*& block, MachineCode* mcode,
llvm::Value* vars, llvm::Value* call_frame);
};
}