Exemplo n.º 1
0
 void create() {
   config_parser = new ConfigParser;
   shared = new SharedState(0, config, *config_parser);
   VM* vm = shared->thread_nexus()->new_vm(shared);
   state = new State(vm);
   initialize_as_root(state);
 }
Exemplo n.º 2
0
int main(int argc, char **argv) {
  JITCompiler compiler;
  VMManager * manager = new VMManager;
  SharedState * shared = manager->create_shared_state();
  ConfigParser * config = new ConfigParser;
  shared->user_config = config;
  VM* state = shared->thread_nexus()->new_vm();

  state->initialize(VM::default_bytes);
  state->boot();

  state->global_lock().lock();

  std::ifstream stream(argv[1]);
  if(!stream) {
    cout << "Can't open ' " << argv[1] << "'\n";
    return 1;
  }

  CompiledFile* cf = CompiledFile::load(state, stream);
  if(cf->magic != "!RBIX") {
    cout << "Invalid file.\n";
  }

  MachineCode* mcode = as<CompiledCode>(cf->body(state))->formalize(state, false);

  delete cf;

  compiler.compile(state, mcode);
  MachineMethod* mm = MachineMethod::create(state, mcode, compiler);
  mm->show();
  return 0;
}
Exemplo n.º 3
0
  VM::VM(uint32_t id, SharedState& shared, const char* name)
    : memory::ManagedThread(id, shared, memory::ManagedThread::eRuby, name)
    , call_frame_(NULL)
    , thread_nexus_(shared.thread_nexus())
    , saved_call_site_information_(NULL)
    , fiber_stacks_(this, shared)
    , park_(new Park)
    , stack_start_(0)
    , stack_size_(0)
    , current_stack_start_(0)
    , current_stack_size_(0)
    , interrupt_with_signal_(false)
    , interrupt_by_kill_(false)
    , check_local_interrupts_(false)
    , thread_step_(false)
    , interrupt_lock_()
    , method_missing_reason_(eNone)
    , constant_missing_reason_(vFound)
    , zombie_(false)
    , main_thread_(false)
    , thread_phase_(ThreadNexus::cUnmanaged)
    , profile_interval_(0)
    , profile_counter_(0)
    , shared(shared)
    , waiting_channel_(this, nil<Channel>())
    , interrupted_exception_(this, nil<Exception>())
    , thread(this, nil<Thread>())
    , current_fiber(this, nil<Fiber>())
    , root_fiber(this, nil<Fiber>())
    , waiting_object_(this, cNil)
    , profile_(this, nil<Tuple>())
    , profile_sample_count_(0)
    , max_profile_entries_(15)
    , min_profile_call_count_(0)
    , native_method_environment(NULL)
    , custom_wakeup_(NULL)
    , custom_wakeup_data_(NULL)
    , thread_state_(this)
  {
    if(memory()) {
      local_slab_.refill(0, 0);
    }

    set_profile_interval();

    allocation_tracking_ = shared.config.allocation_tracking;
  }