summaryrefslogtreecommitdiff
path: root/node.h
AgeCommit message (Collapse)Author
2017-12-14node.h: add nd_last_loc and nd_set_last_locmame
Just refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14node.[ch], parse.y, compile.c: rename nd_column to nd_first_columnmame
nd_set_column -> nd_first_set_column nd_lineno -> nd_first_lineno nd_set_lineno -> nd_first_set_lineno git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-24node.h: Remove not used macrosyui-knk
* node.h (nd_modl, nd_clss_, nd_tval, nd_visi_): Remove not used macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16Refactoring out the direct accesses of NODE's u1, u2, and u3mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-13Store last location of a node on RNodeyui-knk
* node.c (rb_node_init): Initialize last location with 0. * node.h (struct rb_code_range_struct): Define a structure which contains first location and last location of a node. * node.h (struct RNode): Use rb_code_range_t to store last location of a node. * node.h (nd_column, nd_set_column, nd_lineno, nd_set_lineno): Follow-up the change of struct RNode. * node.h (nd_last_column, nd_set_last_column, nd_last_lineno, nd_set_last_lineno): Define getter/setter macros for last location of RNode. * parse.y : Set last location of tokens. Thanks to Yusuke Endoh (mame) for design of data structures. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-08Omit first argument of NEW_CASE2yui-knk
* node.h (NEW_CASE2): Omit first argument of NEW_CASE2, bacause the first argument of NEW_CASE2 is always 0. * parse.y: Ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-05Revert "Introduce rb_code_range_t and replace YYLTYPE with it"mame
r60655 changed the usage of bison by defining a customized YYLTYPE, which seemed to cause a random stall at rb_thread_terminate_all. Kazuki Tsujimoto investigated the issue and pointed out the commit that caused it. Thanks! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Introduce rb_code_range_t and replace YYLTYPE with itmame
rb_code_range_t has two t_code_location_t, i.e., the first and last locations. This is used for YYLTYPE, tracked locations of bison, and will be also used for representing the "range", the first and the last locations of each NODE. Currently, each NODE keeps only the first location, though. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Introduce `rb_code_location_t`mame
`rb_code_location_t` has two integers, lineno and column, which point to one location on a code. Now `rb_code_location_t` is used instead of `VALUE nd_location`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Avoid usage of the magic number `(NODE*)-1`mame
This magic number has two meanings depending upon the context: * "required keyword argument (no name)" on NODE_LASGN (`def foo(x:)`) * "rest argument (no name)" on NODE_MASGN and NODE_POSTARG ('a, b, * = ary` or `a, b, *, z = ary`) To show this intention explicitly, two macros are introduced: NODE_SPECIAL_REQUIRED_KEYWORD and NODE_SPECIAL_NO_NAME_REST. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Remove RNODE cast from NODE utility functionsmame
Now, casting NODE to VALUE is not recommended. This change requires an explicit cast from VALUE to NODE to use the NODE utility functions such as `nd_type`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04Remove NODE-related pieces of code from GCmame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-03node.h: Remove obsolete commentyui-knk
* node.h: NODE_FL_CREF_PUSHED_BY_EVAL was defined as NODE_FL_NEWLINE by r25984, redefined by r40703 and removed by r49897. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31node.h: Rename nd_reserved to nd_locationyui-knk
* node.h (RNode): Now nd_reserved is used to store location information, so rename nd_reserved to nd_location. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31Use NODE_CASE2 if case expressions don't existyui-knk
When NODE_WHEN is compiled by iseq_compile_each0, the node passed to compile_when is NODE_WHEN (not NODE_CASE). So we can not handle the location of NODE_CASE of case statements which don't have case expressions. e.g. : ``` case; when 1; foo; when 2; bar; else baz; end ``` This commit adds NODE_CASE2, and compiles it by iseq_compile_each0. * compile.c (compile_case): Does not call COMPILE_ when NODE_CASE does not have case expressions. * compile.c (compile_case2): Compile NODE_CASE2 by compile_case2. * compile.c (compile_when): Delete an obsoleted function. * compile.c (iseq_compile_each0): Compile NODE_CASE2. * ext/objspace/objspace.c (count_nodes): Add NODE_CASE2 case. * node.c (dump_node, rb_gc_mark_node): Add NODE_CASE2 case. * node.h (node_type): Add NODE_CASE2. * node.h (NEW_CASE2): Add a macro which generates NODE_CASE2. * parse.y: Generate NODE_CASE2 if case expressions don't exist. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-30Store lineno on RNodeyui-knk
* node.c (A_NODE_HEADER): Print lineno. * node.h (nd_column, nd_set_column): Store column number with 16-bit. * node.h (nd_lineno, nd_set_lineno): Define getter/setter macros for lineno of RNode. * parse.y : Set first lineno of tokens. Thanks to takeshinoda for review. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29* node.h (ast_t): renamed to `rb_ast_t`.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Revert "Revert "Manage AST NODEs out of GC""mame
This re-introduces r60485. This reverts commit 5a176b75b1187cbd3861c387bde65ff66396a07c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Revert "Manage AST NODEs out of GC"mame
This reverts commit 620ba74778bfdbdc34ffbb142d49ce84a0ef58e9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Manage AST NODEs out of GCmame
NODEs in AST are no longer objects managed by GC. This change will remove the restriction imposed by the GC. For example, a NODE can use more than five words (this is my primary purpose; we want to store the position data for each NODE, for coverage library), or even a NODE can have variable length (some kinds of NODEs have unused fields). To do this, however, we need more work, since Ripper still uses T_NODE objects managed by the GC. The life time of NODEs is more obvious than other kinds of objects; they are created at parsing, and they become disused immediately after compilation. This change releases all NODEs by a few `xfree`s after compilation, so performance will be improved a bit. In extreme example, `eval("x=1;" * 10000000)` runs much faster (40 sec. -> 7.8 sec. on my machine). The most important part of this change is `ast_t` struct, which has three contents: (1) NODE buffer (malloc'ed memory), (2) a reference to the root NODE, and (3) an array that contains objects that must be marked during parsing (such as literal objects). Some functions that had received `NODE*` arguments, must now receive `ast_t*`. * node.c, node.h: defines `ast_t` struct and related operations. * gc.c, internal.h: defines `imemo_ast`. * parse.y: makes `parser_params` struct have a reference to `ast_t`. Instead of `rb_node_newnode`, use `rb_ast_newnode` to create a NODE. * iseq.c, load.c, ruby.c, template/prelude.c.tmpl: modifies some functions to handle `ast_t*` instead of `NODE*`. * test/ruby/test_gc.rb: ad-hoc fix for a failed test. The test assumes GC eden is increased at startup by NODE object creation. However, this change now create no NODE object, so GC eden is not necessarily increased. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24Removed NODE_OPT_Nnobu
* node.h (NODE_OPT_N): removed. * parse.y (parser_append_options): expand -n option loop to while gets loop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24parse.y: rb_parser_set_optionsnobu
* parse.y (yycompile0): append top-level addenda before appending prelude nodes. * parse.y (rb_parser_set_options): set top-level addendum options before parsing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24Remove dynamic NODE allocation out of parsermame
A temporary NODE object was allocated to create iseq. Instead, this patch allocates a dummy NODE as auto variable, and discard it soon. This change is intended as a preparation to manage AST NODEs out of GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22remove NODE_DREGX_ONCEnobu
* node.h (enum node_type): remove NODE_DREGX_ONCE which is not used anymore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Remove not used node_type NODE_BMETHODyui-knk
* ext/objspace/objspace.c (count_nodes): This node_type has not been used since r24128. * node.c (dump_node): ditto * node.h (node_type, NEW_BMETHOD): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Remove not used node_type NODE_BLOCK_ARGyui-knk
* ext/objspace/objspace.c (count_nodes): This node_type has not been used since r11840. * node.c (dump_node, rb_gc_mark_node): ditto * node.h (node_type, NEW_BLOCK_ARG): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22Remove not used node_type NODE_TO_ARYyui-knk
* ext/objspace/objspace.c (count_nodes): This node_type has not been used since r13236. * node.c (dump_node, rb_gc_mark_node): ditto * node.h (node_type, NEW_TO_ARY): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Remove not used node_type NODE_CVDECLyui-knk
* compile.c (defined_expr0): This node_type has not been used since r11614. * ext/objspace/objspace.c (count_nodes): ditto * node.c (dump_node): ditto * node.h (node_type, NEW_CVDECL): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Remove not used node_type NODE_IASGN2yui-knk
* compile.c (compile_massign_opt, iseq_compile_each0): This node_type has not been used since r11813. * ext/objspace/objspace.c (count_nodes): ditto * node.c (dump_node, rb_gc_mark_node): ditto * node.h (node_type, NEW_IASGN2): ditto * parse.y (node_assign_gen): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21node.h: Remove a not used function prototypeyui-knk
* node.h (rb_node_newnode_longlife): The definition of this function was deleted r24490. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21Replace NODE_ALLOCA with T_IMEMO (imemo_alloc)mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-20Store token first column number on RNodeyui-knk
* node.c (A_NODE_HEADER): Print column number. * node.h (nd_column, nd_set_column): Define getter/setter macros for column number of RNode. * parse.y: Set first column number of tokens. Notes: * Use `@n` to get the location of token in parse.y. * When we use `@n`, arguments of yyerror and yylex are changed. * Initialize column of nodes with -1 to make it easy to detect nodes which we forget to set a column number. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-17node.h: Remove a not used macroyui-knk
* node.h (nd_refinements_): nd_refinements_ was introduced on r49894. But this macro has not been used since r49897. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14Introduce NODE_UNLESS for branch coveragemame
`unless` statement was a syntactic sugar for `if` statement, which made the result of branch coverage hard to understand. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23parse.y: should not warn op method callnobu
* parse.y (void_expr_gen): should warn operator expression style calls only, but not method style calls. [Fix GH-1660] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-29node.h: sign-extendnobu
* node.h (nd_line): should sign-extend. shifting `VALUE` extends with zero bits if `sizeof(VALUE)` equals to `sizeof(int)`. the zero bits are truncated if `sizeof(VALUE)` is bigger enough. [ruby-core:80920] [Bug #13523] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14* compile.c: fix typos.hsbt
[ci skip][fix GH-1140] Patch by @jutaz * dir.c: ditto. * gc.c: ditto. * io.c: ditto. * node.h: ditto. * thread_pthread.c: ditto. * vm_insnhelper.c: ditto. * vsnprintf.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-13parse.y: lex_state trace by yydebugnobu
* parse.y (trace_lex_state): trace lex_state changes if yydebug is set, and send the messages to rb_stdout. * parse.y (rb_parser_printf): store YYPRINTF messages per lines so that lex_state traces do not mix. * tool/ytab.sed: add parser argument to yy_stack_print too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-13additional fix of comment lineko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-13* node.h: remove old comments.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22Safe navigation operatornobu
* compile.c (iseq_peephole_optimize): peephole optimization for branchnil jumps. * compile.c (iseq_compile_each): generate save navigation operator code. * insns.def (branchnil): new opcode to pop the tos and branch if it is nil. * parse.y (NEW_QCALL, call_op, parser_yylex): parse token '.?'. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12node.h: no attrset ID in NODEnobu
* compile.c (iseq_compile_each), node.h (NEW_OP_ASGN22): attrset ID no longer needs to be stored in a NODE, create at byte code generation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-27fronzen-string-literal pragmanobu
* compile.c (iseq_compile_each): override compile option by option given by pragma. * iseq.c (rb_iseq_make_compile_option): extract a function to overwrite rb_compile_option_t. * parse.y (parser_set_compile_option_flag): introduce pragma to override compile options. * parse.y (magic_comments): new pragma "fronzen-string-literal". [Feature #8976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11rb_parser_compile_*: remove volatile argnormal
RB_GC_GUARD is sufficient to prevent tail call optimization from making the object invisible from GC., and we don't need to encourage more volatile usage. * parse.y (rb_parser_compile_cstr): remove volatile arg (rb_parser_compile_string): ditto (rb_parser_compile_file): ditto (rb_parser_compile_string_path): ditto (rb_parser_compile_file_path): ditto [ruby-core:70323] [Misc #11431] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-12* internal.h, node.h: move a definition of `struct rb_global_entry'ko1
and related functions from node.h to internal.h. * variable.c: remove unused include pragma. * common.mk: remove unused dependency. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* internal.h: use T_IMEMO to represent `struct MEMO' value.ko1
memo->v1 and memo->v2 is WB protected values. So use MEMO_V1/V2_SET() macros to set these values. memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer value), so use gc_mark_maybe() in gc.c to mark it. Rename NEW_MEMO() to MEMO_NEW(). Move MEMO_FOR and NEW_MEMO_FOF macros from node.h. Export a rb_imemo_new() function for ext/ripper. * node.h: remove NODE_MEMO. * enum.c: catch up these change. * enumerator.c: ditto. * load.c: ditto. * ext/objspace/objspace.c (count_nodes): ditto. * gc.c (gc_mark_children): mark imemo_memo type. * parse.y (new_args_gen): use T_IMEMO. (I'm not sure it is working correctly...) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* node.h: remove NODE_IFUNC, NEW_IFUNC.ko1
* internal.h: use T_IMEMO for IFUNC. rename `struct IFUNC' to `struct vm_ifunc' and move the definition from vm_insnhelper.h. Add imemo_ifunc. * gc.c (gc_mark_children): mark imemo_ifunc type T_IMEMO object. * compile.c: catch up these changes. * proc.c: ditto. * vm_core.h (RUBY_VM_IFUNC_P): ditto. * vm_eval.c (rb_iterate): ditto. * vm_insnhelper.c: ditto. * ext/objspace/objspace.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* include/ruby/ruby.h: introduce new type T_IMEMO.ko1
T_IMEMO is Internal Memo type, internal use only. T_IMEMO has same purpose of NODE_MEMO. To insert T_IMEMO, type numbers are modified a little. * internal.h: define struct RIMemo. Each RIMemo objects has imemo_type. We can observe it by the imemo_type() function. * gc.c (rb_imemo_new): added. * node.h: remove NODE_CREF and NEW_CREF(). * node.c (rb_gc_mark_node): ditto. * vm.c (vm_cref_new): use rb_imem_new(). * vm_eval.c: ditto. * vm_eval.c (eval_string_with_cref): * vm_eval.c (rb_type_str): * vm_insnhelper.c: use RIMemo objects for CREF. * ext/objspace/objspace.c: support T_IMEMO. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11* internal.h: define struct MEMO.ko1
* enum.c: use MEMO. * enumerator.c: ditto. * load.c: ditto. * node.h: return (struct MEMO *) pointer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08* internal.h: define rb_cref_t and change to use it.ko1
rb_cref_t is data type of CREF. Now, the body is still NODE. It is easy to understand what is CREF and what is pure NODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e