When a context-allocated variable is written to, then the value stored in the context is modified.
Function calls themselves do not change the content of contexts. Contexts form a chain; when a function is called, its context is set as the current context, and it'll have a reference to its outer context. On Wed, Jun 20, 2018 at 12:14 PM <[email protected]> wrote: > With that considered, when a function with a closure is called, if there > are changes within the context are they altered in place or are new objects > stored? > > On Wednesday, June 20, 2018 at 11:58:07 AM UTC-7, Jakob Kummerow wrote: >> >> The "variable environment" of a closure is stored in a Context object on >> the heap. HandleScope has nothing to do with it. Where variables are stored >> depends on how they are used: variables local to a function are stored on >> the stack, variables used by closures are stored in the Context. >> >> On Wed, Jun 20, 2018 at 8:56 AM <[email protected]> wrote: >> >>> I have a question about how V8 deals with closures. I understand that >>> the variable environment becomes part of the function object, I dont know >>> if this is re-written in place when the variables in it's [[scope]] change, >>> and how these are dealt with in memory since the functions as they execute >>> are pushed on and popped off the stack. Does the handler (HandleScope I >>> believe has something to do with it) write a new definition with the new >>> environment variables? Sorry if this is an unclear question, Im a newer >>> developer and this is a curious behavior that I want to thoroughly >>> understand. This may actually be a behavior that isnt unique to closures >>> and perhaps all functions are treated the same in the heap, but Im truly >>> curious and cant figure this out looking through the V8 documentation. >>> >>> -- >>> -- >>> v8-dev mailing list >>> [email protected] >>> http://groups.google.com/group/v8-dev >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "v8-dev" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > -- > v8-dev mailing list > [email protected] > http://groups.google.com/group/v8-dev > --- > You received this message because you are subscribed to the Google Groups > "v8-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev --- You received this message because you are subscribed to the Google Groups "v8-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
