1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm_core.h: constify rb_iseq_t::parent_iseq.

rb_iseq_t::local_iseq is not constant data because
  local_iseq::flip_cnt can be modified (commentted).
* compile.c: catch up this fix.
* iseq.c: ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2015-07-16 13:13:50 +00:00
parent f242e17f9b
commit c3e8cca950
5 changed files with 36 additions and 22 deletions

View file

@ -1,3 +1,16 @@
Thu Jul 16 22:05:29 2015 Koichi Sasada <ko1@atdot.net>
* vm_core.h: constify rb_iseq_t::parent_iseq.
rb_iseq_t::local_iseq is not constant data because
local_iseq::flip_cnt can be modified (commentted).
* compile.c: catch up this fix.
* iseq.c: ditto.
* vm_insnhelper.c: ditto.
Thu Jul 16 21:47:47 2015 Naohisa Goto <ngotogenome@gmail.com>
* process.c (redirect_dup2): when the new FD of dup2() coflicts

View file

@ -1068,7 +1068,7 @@ iseq_set_exception_local_table(rb_iseq_t *iseq)
}
static int
get_lvar_level(rb_iseq_t *iseq)
get_lvar_level(const rb_iseq_t *iseq)
{
int lev = 0;
while (iseq != iseq->local_iseq) {
@ -1079,7 +1079,7 @@ get_lvar_level(rb_iseq_t *iseq)
}
static int
get_dyna_var_idx_at_raw(rb_iseq_t *iseq, ID id)
get_dyna_var_idx_at_raw(const rb_iseq_t *iseq, ID id)
{
int i;
@ -1092,7 +1092,7 @@ get_dyna_var_idx_at_raw(rb_iseq_t *iseq, ID id)
}
static int
get_local_var_idx(rb_iseq_t *iseq, ID id)
get_local_var_idx(const rb_iseq_t *iseq, ID id)
{
int idx = get_dyna_var_idx_at_raw(iseq->local_iseq, id);
@ -1104,7 +1104,7 @@ get_local_var_idx(rb_iseq_t *iseq, ID id)
}
static int
get_dyna_var_idx(rb_iseq_t *iseq, ID id, int *level, int *ls)
get_dyna_var_idx(const rb_iseq_t *iseq, ID id, int *level, int *ls)
{
int lv = 0, idx = -1;
@ -3124,10 +3124,10 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
}
static VALUE
make_name_for_block(rb_iseq_t *iseq)
make_name_for_block(const rb_iseq_t *iseq)
{
int level = 1;
rb_iseq_t *ip = iseq;
const rb_iseq_t *ip = iseq;
if (iseq->parent_iseq != 0) {
while (ip->local_iseq != ip) {
@ -3716,7 +3716,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with break"));
}
else {
rb_iseq_t *ip = iseq->parent_iseq;
const rb_iseq_t *ip = iseq->parent_iseq;
while (ip) {
if (!ip->compile_data) {
ip = 0;
@ -3781,8 +3781,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
COMPILE_ERROR((ERROR_ARGS "Can't escape from eval with next"));
}
else {
rb_iseq_t *ip;
ip = iseq;
const rb_iseq_t *ip = iseq;
while (ip) {
if (!ip->compile_data) {
ip = 0;
@ -3849,10 +3849,10 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
}
}
else {
rb_iseq_t *ip;
const rb_iseq_t *ip = iseq;
unsigned long level;
level = 0x8000 | 0x4000;
ip = iseq;
while (ip) {
if (!ip->compile_data) {
ip = 0;
@ -4639,7 +4639,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
else {
/* NODE_ZSUPER */
int i;
rb_iseq_t *liseq = iseq->local_iseq;
const rb_iseq_t *liseq = iseq->local_iseq;
int lvar_level = get_lvar_level(iseq);
argc = liseq->param.lead_num;
@ -5382,7 +5382,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN2(ret, line, getlocal, INT2FIX(2), INT2FIX(0));
}
else {
rb_iseq_t *ip = iseq;
const rb_iseq_t *ip = iseq;
int level = 0;
while (ip) {
if (ip->type == ISEQ_TYPE_RESCUE) {
@ -6253,7 +6253,8 @@ int
rb_dvar_defined(ID id)
{
rb_thread_t *th = GET_THREAD();
rb_iseq_t *iseq;
const rb_iseq_t *iseq;
if (th->base_block && (iseq = th->base_block->iseq)) {
while (iseq->type == ISEQ_TYPE_BLOCK ||
iseq->type == ISEQ_TYPE_RESCUE ||
@ -6278,7 +6279,7 @@ int
rb_local_defined(ID id)
{
rb_thread_t *th = GET_THREAD();
rb_iseq_t *iseq;
const rb_iseq_t *iseq;
if (th->base_block && th->base_block->iseq) {
int i;

6
iseq.c
View file

@ -102,7 +102,7 @@ iseq_free(void *ptr)
static void
iseq_mark(void *ptr)
{
rb_iseq_t *iseq = ptr;
const rb_iseq_t *iseq = ptr;
RUBY_MARK_ENTER("iseq");
@ -915,7 +915,7 @@ rb_iseq_base_label(VALUE self)
VALUE
rb_iseq_first_lineno(VALUE self)
{
rb_iseq_t *iseq;
const rb_iseq_t *iseq;
GetISeqPtr(self, iseq);
return iseq->location.first_lineno;
}
@ -923,7 +923,7 @@ rb_iseq_first_lineno(VALUE self)
VALUE
rb_iseq_method_name(VALUE self)
{
rb_iseq_t *iseq, *local_iseq;
const rb_iseq_t *iseq, *local_iseq;
GetISeqPtr(self, iseq);
local_iseq = iseq->local_iseq;
if (local_iseq->type == ISEQ_TYPE_METHOD) {

View file

@ -336,8 +336,8 @@ struct rb_iseq_struct {
struct iseq_catch_table *catch_table;
/* for child iseq */
struct rb_iseq_struct *parent_iseq;
struct rb_iseq_struct *local_iseq;
const struct rb_iseq_struct *parent_iseq;
struct rb_iseq_struct *local_iseq; /* local_iseq->flip_cnt can be modified */
/****************/
/* dynamic data */

View file

@ -841,7 +841,7 @@ vm_throw_start(rb_thread_t * const th, rb_control_frame_t * const reg_cfp, int s
else if (state == TAG_BREAK) {
int is_orphan = 1;
VALUE *ep = GET_EP();
rb_iseq_t *base_iseq = GET_ISEQ();
const rb_iseq_t *base_iseq = GET_ISEQ();
escape_cfp = reg_cfp;
while (base_iseq->type != ISEQ_TYPE_BLOCK) {
@ -1869,7 +1869,7 @@ current_method_entry(rb_thread_t *th, rb_control_frame_t *cfp)
rb_control_frame_t *top_cfp = cfp;
if (cfp->iseq && cfp->iseq->type == ISEQ_TYPE_BLOCK) {
rb_iseq_t *local_iseq = cfp->iseq->local_iseq;
const rb_iseq_t *local_iseq = cfp->iseq->local_iseq;
do {
cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
if (RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) {