[前][次][番号順一覧][スレッド一覧]

ruby-changes:39221

From: normal <ko1@a...>
Date: Mon, 20 Jul 2015 12:22:17 +0900 (JST)
Subject: [ruby-changes:39221] normal:r51302 (trunk): parse.y (struct parser_params): pack to 4 cache lines on x86-64

normal	2015-07-20 12:21:58 +0900 (Mon, 20 Jul 2015)

  New Revision: 51302

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51302

  Log:
    parse.y (struct parser_params): pack to 4 cache lines on x86-64
    
    This reduces the struct from 256 (from 288) bytes on my x86-64
    system, allowing the struct to fit cleanly into 4 cache lines
    (if a malloc implementation allows it).
    
    * parse.y (struct parser_params): pack: 88 => 256 bytes on 64-bit
      [ruby-core:70034] [Feature #11371]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51301)
+++ ChangeLog	(revision 51302)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jul 20 12:12:05 2015  Eric Wong  <e@8...>
+
+	* parse.y (struct parser_params): pack: 88 => 256 bytes on 64-bit
+	  [ruby-core:70034] [Feature #11371]
+
 Sun Jul 19 14:29:18 2015  windwiny  <windwiny.ubt@g...>
 
 	* ext/pty/pty.c: [DOC] fix example typo, an old name at move from
Index: parse.y
===================================================================
--- parse.y	(revision 51301)
+++ parse.y	(revision 51302)
@@ -229,7 +229,6 @@ struct parser_params { https://github.com/ruby/ruby/blob/trunk/parse.y#L229
     NODE *heap;
 
     YYSTYPE *parser_yylval;
-    VALUE eofp;
 
     NODE *parser_lex_strterm;
     stack_type parser_cond_stack;
@@ -237,15 +236,13 @@ struct parser_params { https://github.com/ruby/ruby/blob/trunk/parse.y#L236
     enum lex_state_e parser_lex_state;
     int parser_paren_nest;
     int parser_lpar_beg;
-    int parser_in_single;
-    int parser_in_def;
+    int parser_in_single; /* counter */
+    int parser_in_def; /* counter */
     int parser_brace_nest;
-    int parser_compile_for_eval;
-    int parser_in_kwarg;
-    int parser_in_defined;
     int parser_tokidx;
     int parser_toksiz;
     int parser_tokline;
+    int parser_heredoc_end;
     char *parser_tokenbuf;
     VALUE parser_lex_input;
     VALUE parser_lex_lastline;
@@ -253,8 +250,6 @@ struct parser_params { https://github.com/ruby/ruby/blob/trunk/parse.y#L250
     const char *parser_lex_pbeg;
     const char *parser_lex_p;
     const char *parser_lex_pend;
-    int parser_heredoc_end;
-    int parser_command_start;
     NODE *parser_deferred_nodes;
     long parser_lex_gets_ptr;
     VALUE (*parser_lex_gets)(struct parser_params*,VALUE);
@@ -269,9 +264,14 @@ struct parser_params { https://github.com/ruby/ruby/blob/trunk/parse.y#L264
 
     int last_cr_line;
 
+    unsigned int parser_command_start:1;
+    unsigned int eofp: 1;
     unsigned int parser_ruby__end__seen: 1;
     unsigned int parser_yydebug: 1;
     unsigned int has_shebang: 1;
+    unsigned int parser_in_defined: 1;
+    unsigned int parser_compile_for_eval: 1;
+    unsigned int parser_in_kwarg: 1;
 
 #ifndef RIPPER
     /* Ruby core only */
@@ -279,7 +279,7 @@ struct parser_params { https://github.com/ruby/ruby/blob/trunk/parse.y#L279
 # if WARN_PAST_SCOPE
     unsigned int parser_past_scope_enabled: 1;
 # endif
-    int nerr;
+    unsigned int has_err: 1;
 
     NODE *parser_eval_tree_begin;
     NODE *parser_eval_tree;
@@ -708,7 +708,7 @@ static void ripper_compile_error(struct https://github.com/ruby/ruby/blob/trunk/parse.y#L708
 # define PARSER_ARG parser,
 #else
 # define rb_compile_error rb_compile_error_with_enc
-# define compile_error parser->nerr++,rb_compile_error_with_enc
+# define compile_error (parser->has_err = 1),rb_compile_error_with_enc
 # define PARSER_ARG ruby_sourcefile, ruby_sourceline, (void *)current_enc,
 #endif
 
@@ -4507,7 +4507,7 @@ f_arglist	: '(' f_args rparen https://github.com/ruby/ruby/blob/trunk/parse.y#L4507
 		    }
 		    f_args term
 		    {
-			parser->parser_in_kwarg = $<num>1;
+			parser->parser_in_kwarg = !!$<num>1;
 			$$ = $2;
 			lex_state = EXPR_BEG;
 			command_start = TRUE;
@@ -5512,7 +5512,7 @@ yycompile0(VALUE arg) https://github.com/ruby/ruby/blob/trunk/parse.y#L5512
     lex_strterm = 0;
     lex_p = lex_pbeg = lex_pend = 0;
     lex_lastline = lex_nextline = 0;
-    if (parser->nerr) {
+    if (parser->has_err) {
 	return 0;
     }
     tree = ruby_eval_tree;
@@ -5597,7 +5597,7 @@ parser_compile_string(volatile VALUE vpa https://github.com/ruby/ruby/blob/trunk/parse.y#L5597
     lex_gets_ptr = 0;
     lex_input = rb_str_new_frozen(s);
     lex_pbeg = lex_p = lex_pend = 0;
-    compile_for_eval = rb_parse_in_eval();
+    compile_for_eval = !!rb_parse_in_eval();
 
     node = yycompile(parser, fname, line);
     RB_GC_GUARD(vparser); /* prohibit tail call optimization */
@@ -5669,7 +5669,7 @@ rb_parser_compile_file_path(volatile VAL https://github.com/ruby/ruby/blob/trunk/parse.y#L5669
     lex_gets = lex_io_gets;
     lex_input = file;
     lex_pbeg = lex_p = lex_pend = 0;
-    compile_for_eval = rb_parse_in_eval();
+    compile_for_eval = !!rb_parse_in_eval();
 
     node = yycompile(parser, fname, start);
     RB_GC_GUARD(vparser); /* prohibit tail call optimization */
@@ -5734,7 +5734,7 @@ parser_nextc(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L5734
 		return -1;
 
 	    if (!lex_input || NIL_P(v = lex_getline(parser))) {
-		parser->eofp = Qtrue;
+		parser->eofp = 1;
 		lex_goto_eol(parser);
 		return -1;
 	    }
@@ -8500,7 +8500,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8500
       case '_':
 	if (was_bol() && whole_match_p("__END__", 7, 0)) {
 	    ruby__end__seen = 1;
-	    parser->eofp = Qtrue;
+	    parser->eofp = 1;
 #ifndef RIPPER
 	    return -1;
 #else
@@ -10547,7 +10547,7 @@ internal_id_gen(struct parser_params *pa https://github.com/ruby/ruby/blob/trunk/parse.y#L10547
 static void
 parser_initialize(struct parser_params *parser)
 {
-    parser->eofp = Qfalse;
+    parser->eofp = 0;
 
     parser->parser_lex_strterm = 0;
     parser->parser_cond_stack = 0;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]