Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into mcjit
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Mar 30, 2016
2 parents 1a0d3cb + 40f0f30 commit d348367
Show file tree
Hide file tree
Showing 137 changed files with 1,817 additions and 2,389 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -20,7 +20,7 @@ if [ $TRAVIS_OS_NAME == linux ]; then travis_retry ./configure --llvm-config=llv
if [ $TRAVIS_OS_NAME == osx ]; then travis_retry ./configure; fi
script: rake ci
after_success:
- if [ $TRAVIS_BRANCH == $TRAVIS_TAG ]; then ./scripts/deploy.sh release github website triggers; fi
- if [ $TRAVIS_BRANCH == $TRAVIS_TAG ]; then ./scripts/deploy.sh release github website triggers docker; fi
branches:
only:
- master
Expand Down
6 changes: 3 additions & 3 deletions core/constant_cache.rb
Expand Up @@ -2,8 +2,8 @@ module Rubinius
class ConstantCache
attr_reader :name
attr_reader :value
attr_reader :under
attr_reader :scope
attr_reader :module
attr_reader :constant_scope
attr_reader :executable

def ip
Expand All @@ -21,7 +21,7 @@ def location
end

def inspect
"#<#{self.class.name}:0x#{self.object_id.to_s(16)} #{location}##{@name} constant=#{@value} under=#{@under}>"
"#<#{self.class.name}:0x#{self.object_id.to_s(16)} #{location}##{@name} constant=#{@value} module=#{@module} constant_scope=#{@constant_scope}>"
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions machine/arguments.hpp
Expand Up @@ -58,6 +58,14 @@ namespace rubinius {
, argument_container_(0)
{}

Arguments(Symbol* name, Object* recv, Array* ary)
: name_(name)
, recv_(recv)
, block_(cNil)
{
use_array(ary);
}

Arguments(Symbol* name, Array* ary)
: name_(name)
, recv_(cNil)
Expand Down
13 changes: 2 additions & 11 deletions machine/builtin/access_variable.hpp
Expand Up @@ -13,24 +13,15 @@ namespace rubinius {
public:
const static object_type type = AccessVariableType;

private:
Symbol* name_; // slot
Object* write_; // slot

public:
/* accessors */

attr_accessor(name, Symbol);
attr_accessor(write, Object);

/* interface */

static void bootstrap(STATE);
static void initialize(STATE, AccessVariable* av) {
Executable::initialize(state, av, AccessVariable::access_execute);

av->name_ = nil<Symbol>();
av->write_ = nil<Object>();
av->name(nil<Symbol>());
av->write(nil<Object>());
}

// Rubinius.primitive :accessvariable_allocate
Expand Down
12 changes: 3 additions & 9 deletions machine/builtin/alias.hpp
Expand Up @@ -10,12 +10,6 @@ namespace rubinius {
public:
const static object_type type = AliasType;

private:
Symbol* original_name_; // slot
Module* original_module_; // slot
Executable* original_exec_; // slot

public:
attr_accessor(original_name, Symbol);
attr_accessor(original_module, Module);
attr_accessor(original_exec, Executable);
Expand All @@ -27,9 +21,9 @@ namespace rubinius {
static void initialize(STATE, Alias* alias) {
Executable::initialize(state, alias, Alias::executor);

alias->original_name_ = nil<Symbol>();
alias->original_module_ = nil<Module>();
alias->original_exec_ = nil<Executable>();
alias->original_name(nil<Symbol>());
alias->original_module(nil<Module>());
alias->original_exec(nil<Executable>());
}

static Alias* create(STATE, Symbol* name, Module* mod, Executable* exec);
Expand Down
100 changes: 50 additions & 50 deletions machine/builtin/array.cpp
Expand Up @@ -22,23 +22,23 @@ namespace rubinius {
}

native_int Array::size() {
return total_->to_native();
return total()->to_native();
}

void Array::set_size(native_int size) {
total_ = Fixnum::from(size);
total(Fixnum::from(size));
}

native_int Array::offset() {
return start_->to_native();
return start()->to_native();
}

Array* Array::create(STATE, native_int size) {
Array* ary = state->memory()->new_object<Array>(state, G(array));
Tuple* tup = Tuple::create(state, size);

if(ary->young_object_p()) {
ary->tuple_ = tup;
ary->tuple(tup);
} else {
ary->tuple(state, tup);
}
Expand All @@ -51,7 +51,7 @@ namespace rubinius {
Tuple* tup = state->memory()->new_fields<Tuple>(state, G(tuple), size);

if(ary->young_object_p()) {
ary->tuple_ = tup;
ary->tuple(tup);
} else {
ary->tuple(state, tup);
}
Expand Down Expand Up @@ -95,16 +95,16 @@ namespace rubinius {

if(tup->young_object_p()) {
for(native_int i = 0, j = start->to_native(); i < total; i++, j++) {
tup->field[i] = tuple_->field[j];
tup->field[i] = tuple()->field[j];
}
} else {
for(native_int i = 0, j = start->to_native(); i < total; i++, j++) {
tup->put(state, i, tuple_->field[j]);
tup->put(state, i, tuple()->field[j]);
}
}

if(ary->young_object_p()) {
ary->tuple_ = tup;
ary->tuple(tup);
} else {
ary->tuple(state, tup);
}
Expand All @@ -126,7 +126,7 @@ namespace rubinius {
Array* Array::from_tuple(STATE, Tuple* tup) {
native_int length = tup->num_fields();
Array* ary = Array::create(state, length);
ary->tuple_->copy_from(state, tup,
ary->tuple()->copy_from(state, tup,
Fixnum::from(0), Fixnum::from(length),
Fixnum::from(0));

Expand Down Expand Up @@ -165,20 +165,20 @@ namespace rubinius {
// fully handle.
Object* Array::aref(STATE, Fixnum* idx) {
native_int index = idx->to_native();
const native_int start = start_->to_native();
const native_int total = start + total_->to_native();
const native_int s = start()->to_native();
const native_int t = s + total()->to_native();

// Handle negative indexes
if(index < 0) {
index += total;
index += t;
} else {
index += start;
index += s;
}

// Off either end, return nil
if(index >= total || index < start) return cNil;
if(index >= t || index < s) return cNil;

return tuple_->at(state, index);
return tuple()->at(state, index);
}

Object* Array::aset(STATE, Fixnum* idx, Object* val) {
Expand All @@ -187,7 +187,7 @@ namespace rubinius {
native_int index = idx->to_native();

if(index < 0) {
index += total_->to_native();
index += total()->to_native();
if(index < 0) return Primitives::failure();
}

Expand All @@ -208,14 +208,14 @@ namespace rubinius {
}

native_int new_size = size + osize;
if(new_size <= tuple_->num_fields()) {
if(new_size <= tuple()->num_fields()) {
// We have enough space, but may need to shift elements.
if(start_->to_native() + new_size <= tuple_->num_fields()) {
tuple_->copy_from(state, other->tuple(), other->start(), other->total(),
Fixnum::from(start_->to_native() + total_->to_native()));
if(start()->to_native() + new_size <= tuple()->num_fields()) {
tuple()->copy_from(state, other->tuple(), other->start(), other->total(),
Fixnum::from(start()->to_native() + total()->to_native()));
} else {
tuple_->copy_from(state, tuple_, start_, total_, Fixnum::from(0));
tuple_->copy_from(state, other->tuple(), other->start(), other->total(), total_);
tuple()->copy_from(state, tuple(), start(), total(), Fixnum::from(0));
tuple()->copy_from(state, other->tuple(), other->start(), other->total(), total());
start(state, Fixnum::from(0));
}
} else {
Expand All @@ -224,46 +224,46 @@ namespace rubinius {
while(size <= new_size) size *= 2;

Tuple* nt = state->memory()->new_fields<Tuple>(state, G(tuple), size);
nt->copy_from(state, tuple_, start_, total_, Fixnum::from(0));
nt->copy_from(state, other->tuple(), other->start(), other->total(), total_);
nt->copy_from(state, tuple(), start(), total(), Fixnum::from(0));
nt->copy_from(state, other->tuple(), other->start(), other->total(), total());

for(native_int i = new_size; i < size; i++) {
nt->field[i] = cNil;
}

if(young_object_p()) {
tuple_ = nt;
tuple(nt);
} else {
tuple(state, nt);
}

start_ = Fixnum::from(0);
start(Fixnum::from(0));
}

total_ = Fixnum::from(new_size);
total(Fixnum::from(new_size));

return this;
}

Object* Array::get(STATE, native_int idx) {
if(idx >= total_->to_native()) {
if(idx >= total()->to_native()) {
return cNil;
}

idx += start_->to_native();
idx += start()->to_native();

return tuple_->at(state, idx);
return tuple()->at(state, idx);
}

Object* Array::set(STATE, native_int idx, Object* val) {
native_int tuple_size = tuple_->num_fields();
native_int tuple_size = tuple()->num_fields();
native_int oidx = idx;
idx += start_->to_native();
idx += start()->to_native();

if(idx >= tuple_size) {
if(oidx < tuple_size) {
// There is enough space in the tuple for this element
tuple_->lshift_inplace(state, start_);
tuple()->lshift_inplace(state, start());
} else {
// Uses the same algo as 1.8 to resize the tuple
native_int new_size = tuple_size / 2;
Expand All @@ -272,61 +272,61 @@ namespace rubinius {
}

Tuple* nt = Tuple::create(state, new_size+idx);
nt->copy_from(state, tuple_, start_, total_, Fixnum::from(0));
nt->copy_from(state, tuple(), start(), total(), Fixnum::from(0));
tuple(state, nt);
}
start(state, Fixnum::from(0));
idx = oidx;
}

tuple_->put(state, idx, val);
if(total_->to_native() <= oidx) {
tuple()->put(state, idx, val);
if(total()->to_native() <= oidx) {
total(state, Fixnum::from(oidx+1));
}
return val;
}

void Array::unshift(STATE, Object* val) {
native_int new_size = total_->to_native() + 1;
native_int lend = start_->to_native();
native_int new_size = total()->to_native() + 1;
native_int lend = start()->to_native();

if(lend > 0) {
tuple_->put(state, lend-1, val);
start_ = Fixnum::from(lend-1);
total_ = Fixnum::from(new_size);
tuple()->put(state, lend-1, val);
start(Fixnum::from(lend-1));
total(Fixnum::from(new_size));
} else {
Tuple* nt = state->memory()->new_fields<Tuple>(state, G(tuple), new_size);

nt->copy_from(state, tuple_, start_, total_, Fixnum::from(1));
nt->copy_from(state, tuple(), start(), total(), Fixnum::from(1));
nt->put(state, 0, val);

total_ = Fixnum::from(new_size);
start_ = Fixnum::from(0);
total(Fixnum::from(new_size));
start(Fixnum::from(0));

tuple(state, nt);
}
}

Object* Array::shift(STATE) {
native_int cnt = total_->to_native();
native_int cnt = total()->to_native();

if(cnt == 0) return cNil;

Object* obj = get(state, 0);
set(state, 0, cNil);
start_ = Fixnum::from(start_->to_native() + 1);
total_ = Fixnum::from(cnt - 1);
start(Fixnum::from(start()->to_native() + 1));
total(Fixnum::from(cnt - 1));

return obj;
}

Object* Array::append(STATE, Object* val) {
set(state, total_->to_native(), val);
set(state, total()->to_native(), val);
return val;
}

bool Array::includes_p(STATE, Object* val) {
native_int cnt = total_->to_native();
native_int cnt = total()->to_native();

for(native_int i = 0; i < cnt; i++) {
if(get(state, i) == val) return true;
Expand All @@ -336,7 +336,7 @@ namespace rubinius {
}

Object* Array::pop(STATE) {
native_int cnt = total_->to_native();
native_int cnt = total()->to_native();

if(cnt == 0) return cNil;
Object *obj = get(state, cnt - 1);
Expand Down
16 changes: 3 additions & 13 deletions machine/builtin/array.hpp
Expand Up @@ -15,29 +15,19 @@ namespace rubinius {
public:
const static object_type type = ArrayType;

private:
Fixnum* total_; // slot
Tuple* tuple_; // slot
Fixnum* start_; // slot

public:
/* accessors */

attr_accessor(total, Fixnum);
attr_accessor(tuple, Tuple);
attr_accessor(start, Fixnum);

/* interface */

native_int size();
native_int offset();
void set_size(native_int size);

static void bootstrap(STATE);
static void initialize(STATE, Array* array) {
array->total_ = Fixnum::from(0);
array->tuple_ = nil<Tuple>();
array->start_ = Fixnum::from(0);
array->total(Fixnum::from(0));
array->tuple(nil<Tuple>());
array->start(Fixnum::from(0));
}

static Array* create(STATE, native_int size);
Expand Down

0 comments on commit d348367

Please sign in to comment.