Backport #8014

Add missing node types to ObjectSpace.count_nodes

Added by Aman Gupta over 2 years ago. Updated over 2 years ago.

[ruby-core:53130]
Status:Closed
Priority:Normal
Assignee:Usaku NAKAMURA

Description

diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index b8f524c..5857327 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -469,6 +469,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_OP_ASGN2);
COUNT_NODE(NODE_OP_ASGN_AND);
COUNT_NODE(NODE_OP_ASGN_OR);
+ COUNT_NODE(NODE_OP_CDECL);
COUNT_NODE(NODE_CALL);
COUNT_NODE(NODE_FCALL);
COUNT_NODE(NODE_VCALL);
@@ -502,6 +503,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_ARGS);
COUNT_NODE(NODE_ARGS_AUX);
COUNT_NODE(NODE_OPT_ARG);
+ COUNT_NODE(NODE_KW_ARG);
COUNT_NODE(NODE_POSTARG);
COUNT_NODE(NODE_ARGSCAT);
COUNT_NODE(NODE_ARGSPUSH);
@@ -519,6 +521,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_SCLASS);
COUNT_NODE(NODE_COLON2);
COUNT_NODE(NODE_COLON3);
+ COUNT_NODE(NODE_CREF);
COUNT_NODE(NODE_DOT2);
COUNT_NODE(NODE_DOT3);
COUNT_NODE(NODE_FLIP2);
@@ -539,7 +542,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_PRELUDE);
COUNT_NODE(NODE_LAMBDA);
#undef COUNT_NODE
- default: node = INT2FIX(nodes[i]);
+ default: node = INT2FIX(i);
}
rb_hash_aset(hash, node, SIZET2NUM(nodes[i]));
}

Associated revisions

Revision 39595
Added by Nobuyoshi Nakada over 2 years ago

objspace.c: newly added nodes

  • ext/objspace/objspace.c (count_nodes): count also newly added nodes, and fix key for unknown node. patch by tmm1 (Aman Gupta) in [Bug #8014]

Revision 40099
Added by Usaku NAKAMURA over 2 years ago

  • ext/objspace/objspace.c (count_nodes): fix key for unknown node. based on a patch by tmm1 (Aman Gupta) in [Bug #8014]

History

#1 Updated by Nobuyoshi Nakada over 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39595.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


objspace.c: newly added nodes

  • ext/objspace/objspace.c (count_nodes): count also newly added nodes, and fix key for unknown node. patch by tmm1 (Aman Gupta) in [Bug #8014]

#2 Updated by Tomoyuki Chikanaga over 2 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport200
  • Status changed from Closed to Assigned
  • Assignee set to Tomoyuki Chikanaga

I believe this is definitely a bug fix. I will merge r39595.

#3 Updated by Tomoyuki Chikanaga over 2 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r39913.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 39595: [Backport #8014]

* ext/objspace/objspace.c (count_nodes): count also newly added nodes,
  and fix key for unknown node.  patch by tmm1 (Aman Gupta) in
   [Bug #8014]

#4 Updated by Tomoyuki Chikanaga over 2 years ago

  • Project changed from Backport200 to Backport193
  • Status changed from Closed to Assigned
  • Assignee changed from Tomoyuki Chikanaga to Usaku NAKAMURA

I think r39595 need to backport partially (for NODE_OP_CDECL) to ruby_1_9_3.

#5 Updated by Usaku NAKAMURA over 2 years ago

  • Status changed from Assigned to Closed

1.9.3 doesn't have NODE_OP_CDECL. so, this issue is closed.

#6 Updated by Aman Gupta over 2 years ago

1.9.3 still contains this bug:

@@ -539,7 +542,7 @@ count_nodes(int argc, VALUE *argv, VALUE os)
COUNT_NODE(NODE_PRELUDE);
COUNT_NODE(NODE_LAMBDA);
#undef COUNT_NODE
- default: node = INT2FIX(nodes[i]);
+ default: node = INT2FIX(i);
}
rb_hash_aset(hash, node, SIZET2NUM(nodes[i]));
}

#7 Updated by Usaku NAKAMURA over 2 years ago

  • Status changed from Closed to Assigned

#8 Updated by Usaku NAKAMURA over 2 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r40099.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/objspace/objspace.c (count_nodes): fix key for unknown node. based on a patch by tmm1 (Aman Gupta) in [Bug #8014]

Also available in: Atom PDF