diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index c85bb3133e8..cab5cd55dbd 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -534,11 +534,11 @@ msgarg	:	name ':' exp
 exp	:	exp '('
 			/* This is to save the value of arglist_len
 			   being accumulated by an outer function call.  */
-			{ start_arglist (); }
+			{ pstate->start_arglist (); }
 		arglist ')'	%prec ARROW
 			{ write_exp_elt_opcode (pstate, OP_FUNCALL);
 			  write_exp_elt_longcst (pstate,
-						 (LONGEST) end_arglist ());
+						 pstate->end_arglist ());
 			  write_exp_elt_opcode (pstate, OP_FUNCALL); }
 	;
 
@@ -546,10 +546,10 @@ exp	:	exp '('
    "func()::static_var" further below, which uses
    function_method_void.  */
 exp	:	exp '(' ')' %prec ARROW
-			{ start_arglist ();
+			{ pstate->start_arglist ();
 			  write_exp_elt_opcode (pstate, OP_FUNCALL);
 			  write_exp_elt_longcst (pstate,
-						 (LONGEST) end_arglist ());
+						 pstate->end_arglist ());
 			  write_exp_elt_opcode (pstate, OP_FUNCALL); }
 	;
 
@@ -569,30 +569,30 @@ exp	:	UNKNOWN_CPP_NAME '('
 			/* This is to save the value of arglist_len
 			   being accumulated by an outer function call.  */
 
-			  start_arglist ();
+			  pstate->start_arglist ();
 			}
 		arglist ')'	%prec ARROW
 			{
 			  write_exp_elt_opcode (pstate, OP_FUNCALL);
 			  write_exp_elt_longcst (pstate,
-						 (LONGEST) end_arglist ());
+						 pstate->end_arglist ());
 			  write_exp_elt_opcode (pstate, OP_FUNCALL);
 			}
 	;
 
 lcurly	:	'{'
-			{ start_arglist (); }
+			{ pstate->start_arglist (); }
 	;
 
 arglist	:
 	;
 
 arglist	:	exp
-			{ arglist_len = 1; }
+			{ pstate->arglist_len = 1; }
 	;
 
 arglist	:	arglist ',' exp   %prec ABOVE_COMMA
-			{ arglist_len++; }
+			{ pstate->arglist_len++; }
 	;
 
 function_method:       exp '(' parameter_typelist ')' const_or_volatile
@@ -645,7 +645,7 @@ exp     :       function_method_void_or_typelist COLONCOLON name
 	;
 
 rcurly	:	'}'
-			{ $$ = end_arglist () - 1; }
+			{ $$ = pstate->end_arglist () - 1; }
 	;
 exp	:	lcurly arglist rcurly	%prec ARROW
 			{ write_exp_elt_opcode (pstate, OP_ARRAY);
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 9addf6c0410..c14c2d6fd6f 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -366,32 +366,32 @@ PostfixExpression:
 
 ArgumentList:
 	AssignExpression
-		{ arglist_len = 1; }
+		{ pstate->arglist_len = 1; }
 |	ArgumentList ',' AssignExpression
-		{ arglist_len++; }
+		{ pstate->arglist_len++; }
 ;
 
 ArgumentList_opt:
 	/* EMPTY */
-		{ arglist_len = 0; }
+		{ pstate->arglist_len = 0; }
 |	ArgumentList
 ;
 
 CallExpression:
 	PostfixExpression '('
-		{ start_arglist (); }
+		{ pstate->start_arglist (); }
 	ArgumentList_opt ')'
 		{ write_exp_elt_opcode (pstate, OP_FUNCALL);
-		  write_exp_elt_longcst (pstate, (LONGEST) end_arglist ());
+		  write_exp_elt_longcst (pstate, pstate->end_arglist ());
 		  write_exp_elt_opcode (pstate, OP_FUNCALL); }
 ;
 
 IndexExpression:
 	PostfixExpression '[' ArgumentList ']'
-		{ if (arglist_len > 0)
+		{ if (pstate->arglist_len > 0)
 		    {
 		      write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
-		      write_exp_elt_longcst (pstate, (LONGEST) arglist_len);
+		      write_exp_elt_longcst (pstate, pstate->arglist_len);
 		      write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
 		    }
 		  else
@@ -558,7 +558,7 @@ PrimaryExpression:
 
 ArrayLiteral:
 	'[' ArgumentList_opt ']'
-		{ $$ = arglist_len; }
+		{ $$ = pstate->arglist_len; }
 ;
 
 IdentifierExp:
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index fce90b48ef5..da4732237d3 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -245,12 +245,12 @@ exp	:	KIND '(' exp ')'       %prec UNARY
    later in eval.c.  */
 
 exp	:	exp '(' 
-			{ start_arglist (); }
+			{ pstate->start_arglist (); }
 		arglist ')'	
 			{ write_exp_elt_opcode (pstate,
 						OP_F77_UNDETERMINED_ARGLIST);
 			  write_exp_elt_longcst (pstate,
-						 (LONGEST) end_arglist ());
+						 pstate->end_arglist ());
 			  write_exp_elt_opcode (pstate,
 					      OP_F77_UNDETERMINED_ARGLIST); }
 	;
@@ -263,15 +263,15 @@ arglist	:
 	;
 
 arglist	:	exp
-			{ arglist_len = 1; }
+			{ pstate->arglist_len = 1; }
 	;
 
 arglist :	subrange
-			{ arglist_len = 1; }
+			{ pstate->arglist_len = 1; }
 	;
    
 arglist	:	arglist ',' exp   %prec ABOVE_COMMA
-			{ arglist_len++; }
+			{ pstate->arglist_len++; }
 	;
 
 /* There are four sorts of subrange types in F90.  */
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 6754d5217e5..358fd530918 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -269,31 +269,31 @@ exp	:	exp '[' exp1 ']'
 exp	:	exp '('
 			/* This is to save the value of arglist_len
 			   being accumulated by an outer function call.  */
-			{ start_arglist (); }
+			{ pstate->start_arglist (); }
 		arglist ')'	%prec LEFT_ARROW
 			{ write_exp_elt_opcode (pstate, OP_FUNCALL);
 			  write_exp_elt_longcst (pstate,
-						 (LONGEST) end_arglist ());
+						 pstate->end_arglist ());
 			  write_exp_elt_opcode (pstate, OP_FUNCALL); }
 	;
 
 lcurly	:	'{'
-			{ start_arglist (); }
+			{ pstate->start_arglist (); }
 	;
 
 arglist	:
 	;
 
 arglist	:	exp
-			{ arglist_len = 1; }
+			{ pstate->arglist_len = 1; }
 	;
 
 arglist	:	arglist ',' exp   %prec ABOVE_COMMA
-			{ arglist_len++; }
+			{ pstate->arglist_len++; }
 	;
 
 rcurly	:	'}'
-			{ $$ = end_arglist () - 1; }
+			{ $$ = pstate->end_arglist () - 1; }
 	;
 
 exp	:	lcurly type rcurly exp  %prec UNARY
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 6ba8eaf8554..3e4bc073801 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -298,11 +298,11 @@ exp     :       exp '['
                         /* This function just saves the number of arguments
 			   that follow in the list.  It is *not* specific to
 			   function types */
-                        { start_arglist(); }
+                        { pstate->start_arglist(); }
                 non_empty_arglist ']'  %prec DOT
                         { write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
 			  write_exp_elt_longcst (pstate,
-						 (LONGEST) end_arglist());
+						 pstate->end_arglist());
 			  write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT); }
         ;
 
@@ -313,11 +313,11 @@ exp	:	exp '[' exp ']'
 exp	:	exp '('
 			/* This is to save the value of arglist_len
 			   being accumulated by an outer function call.  */
-			{ start_arglist (); }
+			{ pstate->start_arglist (); }
 		arglist ')'	%prec DOT
 			{ write_exp_elt_opcode (pstate, OP_FUNCALL);
 			  write_exp_elt_longcst (pstate,
-						 (LONGEST) end_arglist ());
+						 pstate->end_arglist ());
 			  write_exp_elt_opcode (pstate, OP_FUNCALL); }
 	;
 
@@ -325,21 +325,21 @@ arglist	:
 	;
 
 arglist	:	exp
-			{ arglist_len = 1; }
+			{ pstate->arglist_len = 1; }
 	;
 
 arglist	:	arglist ',' exp   %prec ABOVE_COMMA
-			{ arglist_len++; }
+			{ pstate->arglist_len++; }
 	;
 
 non_empty_arglist
         :       exp
-                        { arglist_len = 1; }
+                        { pstate->arglist_len = 1; }
 	;
 
 non_empty_arglist
         :       non_empty_arglist ',' exp %prec ABOVE_COMMA
-     	       	    	{ arglist_len++; }
+     	       	    	{ pstate->arglist_len++; }
      	;
 
 /* GDB construct */
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 4487899ead9..0f78126222c 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -334,11 +334,11 @@ exp	:	exp '('
 			/* This is to save the value of arglist_len
 			   being accumulated by an outer function call.  */
 			{ push_current_type ();
-			  start_arglist (); }
+			  pstate->start_arglist (); }
 		arglist ')'	%prec ARROW
 			{ write_exp_elt_opcode (pstate, OP_FUNCALL);
 			  write_exp_elt_longcst (pstate,
-						 (LONGEST) end_arglist ());
+						 pstate->end_arglist ());
 			  write_exp_elt_opcode (pstate, OP_FUNCALL);
 			  pop_current_type ();
 			  if (current_type)
@@ -348,9 +348,9 @@ exp	:	exp '('
 
 arglist	:
          | exp
-			{ arglist_len = 1; }
+			{ pstate->arglist_len = 1; }
 	 | arglist ',' exp   %prec ABOVE_COMMA
-			{ arglist_len++; }
+			{ pstate->arglist_len++; }
 	;
 
 exp	:	type '(' exp ')' %prec UNARY
diff --git a/gdb/parse.c b/gdb/parse.c
index 5692e23386b..6ee61577068 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -67,7 +67,6 @@ const struct exp_descriptor exp_descriptor_standard =
 
 /* Global variables declared in parser-defs.h (and commented there).  */
 innermost_block_tracker innermost_block;
-int arglist_len;
 static struct type_stack type_stack;
 
 /* True if parsing an expression to attempt completion.  */
@@ -128,33 +127,6 @@ innermost_block_tracker::update (const struct block *b,
     m_innermost_block = b;
 }
 
-/* Data structure for saving values of arglist_len for function calls whose
-   arguments contain other function calls.  */
-
-static std::vector<int> *funcall_chain;
-
-/* Begin counting arguments for a function call,
-   saving the data about any containing call.  */
-
-void
-start_arglist (void)
-{
-  funcall_chain->push_back (arglist_len);
-  arglist_len = 0;
-}
-
-/* Return the number of arguments in a function call just terminated,
-   and restore the data for the containing function call.  */
-
-int
-end_arglist (void)
-{
-  int val = arglist_len;
-  arglist_len = funcall_chain->back ();
-  funcall_chain->pop_back ();
-  return val;
-}
-
 
 
 /* See definition in parser-defs.h.  */
@@ -1119,10 +1091,6 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
   if (*stringptr == 0 || **stringptr == 0)
     error_no_arg (_("expression to compute"));
 
-  std::vector<int> funcalls;
-  scoped_restore save_funcall_chain = make_scoped_restore (&funcall_chain,
-							   &funcalls);
-
   const struct block *expression_context_block = block;
   CORE_ADDR expression_context_pc = 0;
 
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 66828e0f772..a01511584d7 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -101,6 +101,27 @@ struct parser_state : public expr_builder
 
   DISABLE_COPY_AND_ASSIGN (parser_state);
 
+  /* Begin counting arguments for a function call,
+     saving the data about any containing call.  */
+
+  void start_arglist ()
+  {
+    m_funcall_chain.push_back (arglist_len);
+    arglist_len = 0;
+  }
+
+  /* Return the number of arguments in a function call just terminated,
+     and restore the data for the containing function call.  */
+
+  int end_arglist ()
+  {
+    int val = arglist_len;
+    arglist_len = m_funcall_chain.back ();
+    m_funcall_chain.pop_back ();
+    return val;
+  }
+
+
   /* If this is nonzero, this block is used as the lexical context for
      symbol names.  */
 
@@ -125,6 +146,17 @@ struct parser_state : public expr_builder
   /* After a token has been recognized, this variable points to it.
      Currently used only for error reporting.  */
   const char *prev_lexptr = nullptr;
+
+  /* Number of arguments seen so far in innermost function call.  */
+
+  int arglist_len = 0;
+
+private:
+
+  /* Data structure for saving values of arglist_len for function calls whose
+     arguments contain other function calls.  */
+
+  std::vector<int> m_funcall_chain;
 };
 
 /* When parsing expressions we track the innermost block that was
@@ -185,9 +217,6 @@ private:
    once the parse is complete.  */
 extern innermost_block_tracker innermost_block;
 
-/* Number of arguments seen so far in innermost function call.  */
-extern int arglist_len;
-
 /* A string token, either a char-string or bit-string.  Char-strings are
    used, for example, for the names of symbols.  */
 
@@ -311,10 +340,6 @@ extern void mark_struct_expression (struct expr_builder *);
 
 extern const char *find_template_name_end (const char *);
 
-extern void start_arglist (void);
-
-extern int end_arglist (void);
-
 extern char *copy_name (struct stoken);
 
 extern void insert_type (enum type_pieces);
