unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Why do Fdefvar not protect its argument and temporaries with GCPRO?
@ 2014-11-19  2:48 Lee Duhem
  2014-11-19  9:44 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Lee Duhem @ 2014-11-19  2:48 UTC (permalink / raw)
  To: emacs-devel

Hi all,

In the definition of `Fdefvar`, it calls `eval_sub`, and its temporary
variable `tail` is used after that call. So why do `Fdefvar` not protect
`tail` and other temporaries from GC with GCPRO? As other functions in
`src/eval.c` did.

Is this a bug? Or did I overlook something?

Sincerely,
lee



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why do Fdefvar not protect its argument and temporaries with GCPRO?
  2014-11-19  2:48 Why do Fdefvar not protect its argument and temporaries with GCPRO? Lee Duhem
@ 2014-11-19  9:44 ` Andreas Schwab
  2014-11-19 13:51   ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2014-11-19  9:44 UTC (permalink / raw)
  To: Lee Duhem; +Cc: emacs-devel

Lee Duhem <lee.duhem@gmail.com> writes:

> In the definition of `Fdefvar`, it calls `eval_sub`, and its temporary
> variable `tail` is used after that call. So why do `Fdefvar` not protect
> `tail` and other temporaries from GC with GCPRO? As other functions in
> `src/eval.c` did.

I think a few of them do too much GCPRO, since arguments of lisp
functions are protected by the caller (and conses are not relocated).
In the initial version of Fdefvar no intermediate values were stored in
variables, instead they were recomputed by calling Fcdr/Fcar on the
function argument, which is ok protection-wise.

> Is this a bug?

In this case, I think it is.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why do Fdefvar not protect its argument and temporaries with GCPRO?
  2014-11-19  9:44 ` Andreas Schwab
@ 2014-11-19 13:51   ` Stefan Monnier
  2014-11-20  2:59     ` Lee Duhem
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2014-11-19 13:51 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Lee Duhem, emacs-devel

> I think a few of them do too much GCPRO, since arguments of lisp
> functions are protected by the caller (and conses are not relocated).

Maybe I'm misunderstanding what you're saying, but to clarify:
The calling convention we use does not require the caller to
gcprotect the arguments, instead it's the callee who should protect its
own arguments, if and when needed.

>> Is this a bug?
> In this case, I think it is.

Agreed.


        Stefan



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Why do Fdefvar not protect its argument and temporaries with GCPRO?
  2014-11-19 13:51   ` Stefan Monnier
@ 2014-11-20  2:59     ` Lee Duhem
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Duhem @ 2014-11-20  2:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Andreas Schwab, emacs-devel

On Wed, Nov 19, 2014 at 5:51 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>> I think a few of them do too much GCPRO, since arguments of lisp
>> functions are protected by the caller (and conses are not relocated).
>
> Maybe I'm misunderstanding what you're saying, but to clarify:
> The calling convention we use does not require the caller to
> gcprotect the arguments, instead it's the callee who should protect its
> own arguments, if and when needed.

Thank both of you for your explanation.

>
>>> Is this a bug?
>> In this case, I think it is.
>
> Agreed.
>

I have send a patch for this.

Sincerely,
lee



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-20  2:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-19  2:48 Why do Fdefvar not protect its argument and temporaries with GCPRO? Lee Duhem
2014-11-19  9:44 ` Andreas Schwab
2014-11-19 13:51   ` Stefan Monnier
2014-11-20  2:59     ` Lee Duhem

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).