Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rework to use handle methods directly

  • Loading branch information...
commit c6eac13c9001c590cd21efb27eb61aa59bffb33b 1 parent b94e5ed
@dbussink dbussink authored
View
4 vm/builtin/data.cpp
@@ -23,7 +23,7 @@ namespace rubinius {
// Data is just a heap alias for the handle, so go ahead and create
// the handle and populate it as an RData now.
- capi::Handle* handle = data->handle();
+ capi::Handle* handle = data->handle(state);
assert(!handle && "can't already have a handle, it's brand new!");
@@ -50,7 +50,7 @@ namespace rubinius {
}
RDataShadow* Data::slow_rdata(STATE) {
- capi::Handle* handle = this->handle();
+ capi::Handle* handle = this->handle(state);
assert(handle && handle->is_rdata() && "invalid initialized Data object");
View
10 vm/builtin/io.cpp
@@ -394,9 +394,8 @@ namespace rubinius {
// a lowlevel RIO struct using fdopen, then we MUST use fclose
// to close it.
- if(inflated_header_p()) {
- capi::Handle* hdl = inflated_header()->handle();
- if(hdl && hdl->is_rio()) {
+ if(capi::Handle* hdl = handle(state)) {
+ if(hdl->is_rio()) {
if(!hdl->rio_close()) {
Exception::errno_error(state);
}
@@ -532,9 +531,8 @@ namespace rubinius {
// a lowlevel RIO struct using fdopen, then we MUST use fclose
// to close it.
- if(io->inflated_header_p()) {
- capi::Handle* hdl = io->inflated_header()->handle();
- if(hdl && hdl->is_rio()) {
+ if(capi::Handle* hdl = io->handle(state)) {
+ if(hdl->is_rio()) {
hdl->rio_close();
return;
}
View
2  vm/builtin/nativemethod.cpp
@@ -63,7 +63,7 @@ namespace rubinius {
VALUE NativeMethodFrame::get_handle(STATE, Object* obj) {
- capi::Handle* handle = obj->handle();
+ capi::Handle* handle = obj->handle(state);
if(handle) {
if(handles_.add_if_absent(handle)) {
View
9 vm/builtin/string.cpp
@@ -156,10 +156,15 @@ namespace rubinius {
return s;
}
- void String::update_handle() {
+ void String::update_handle(VM* vm) {
+ State state(vm);
+ update_handle(&state);
+ }
+
+ void String::update_handle(STATE) {
if(!inflated_header_p()) return;
- capi::Handle* handle = inflated_header()->handle();
+ capi::Handle* handle = inflated_header()->handle(state);
if(!handle) return;
handle->update(NativeMethodEnvironment::get());
View
7 vm/builtin/string.hpp
@@ -56,13 +56,14 @@ namespace rubinius {
attr_reader(num_bytes, Fixnum);
attr_reader(data, ByteArray);
- void update_handle();
+ void update_handle(STATE);
+ void update_handle(VM* vm);
template <class T>
void num_bytes(T state, Fixnum* obj) {
num_bytes_ = obj;
num_chars_ = nil<Fixnum>();
- update_handle();
+ update_handle(state);
}
template <class T>
@@ -70,7 +71,7 @@ namespace rubinius {
data_ = obj;
if(mature_object_p()) this->write_barrier(state, obj);
- update_handle();
+ update_handle(state);
}
attr_accessor(num_chars, Fixnum);
View
10 vm/objectmemory.cpp
@@ -325,7 +325,7 @@ namespace rubinius {
// Handle in use so inflate and update handle
ih = inflated_headers_->allocate(obj);
// TODO: update with proper handle
- ih->set_handle(NULL);
+ ih->set_handle(state, obj->handle(state));
break;
}
@@ -980,9 +980,9 @@ namespace rubinius {
(*fi->finalizer)(state, fi->object);
// Unhook any handle used by fi->object so that we don't accidentally
// try and mark it later (after we've finalized it)
- if(capi::Handle* handle = fi->object->handle()) {
+ if(capi::Handle* handle = fi->object->handle(state)) {
handle->forget_object();
- fi->object->set_handle(0);
+ fi->object->clear_handle(state);
}
// If the object was remembered, unremember it.
@@ -1030,9 +1030,9 @@ namespace rubinius {
(*fi->finalizer)(state, fi->object);
// Unhook any handle used by fi->object so that we don't accidentally
// try and mark it later (after we've finalized it)
- if(capi::Handle* handle = fi->object->handle()) {
+ if(capi::Handle* handle = fi->object->handle(state)) {
handle->forget_object();
- fi->object->set_handle(0);
+ fi->object->clear_handle(state);
}
// If the object was remembered, unremember it.
View
18 vm/oop.hpp
@@ -292,11 +292,11 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
return flags_.Marked == which;
}
- capi::Handle* handle() const {
+ capi::Handle* handle(STATE) const {
return handle_;
}
- void set_handle(capi::Handle* handle) {
+ void set_handle(STATE, capi::Handle* handle) {
handle_ = handle;
}
@@ -394,17 +394,23 @@ Object* const cUndef = reinterpret_cast<Object*>(0x22L);
flags().obj_type = type;
}
- capi::Handle* handle() {
+ capi::Handle* handle(STATE) {
if(inflated_header_p()) {
- return inflated_header()->handle();
+ return inflated_header()->handle(state);
}
return NULL;
}
- void set_handle(capi::Handle* handle) {
+ void set_handle(STATE, capi::Handle* handle) {
assert(inflated_header_p());
if(inflated_header_p()) {
- inflated_header()->set_handle(handle);
+ inflated_header()->set_handle(state, handle);
+ }
+ }
+
+ void clear_handle(STATE) {
+ if(inflated_header_p()) {
+ inflated_header()->set_handle(state, NULL);
}
}
View
2  vm/shared_state.cpp
@@ -152,7 +152,7 @@ namespace rubinius {
SYNC(state);
InflatedHeader* ih = state->memory()->inflate_header(state, obj);
capi::Handle* handle = global_handles_->allocate(state, obj);
- ih->set_handle(handle);
+ ih->set_handle(state, handle);
return handle;
}

0 comments on commit c6eac13

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