Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/contexts.h

Issue 2303113004: Improve the explanation of a context's extension slot. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_CONTEXTS_H_ 5 #ifndef V8_CONTEXTS_H_
6 #define V8_CONTEXTS_H_ 6 #define V8_CONTEXTS_H_
7 7
8 #include "src/heap/heap.h" 8 #include "src/heap/heap.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 10
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // contexts inside a function. It provides access to the 291 // contexts inside a function. It provides access to the
292 // incoming context (i.e., the outer context, which may 292 // incoming context (i.e., the outer context, which may
293 // or may not become the current function's context), and 293 // or may not become the current function's context), and
294 // it provides access to the functions code and thus it's 294 // it provides access to the functions code and thus it's
295 // scope information, which in turn contains the names of 295 // scope information, which in turn contains the names of
296 // statically allocated context slots. The names are needed 296 // statically allocated context slots. The names are needed
297 // for dynamic lookups in the presence of 'with' or 'eval'. 297 // for dynamic lookups in the presence of 'with' or 'eval'.
298 // 298 //
299 // [ previous ] A pointer to the previous context. 299 // [ previous ] A pointer to the previous context.
300 // 300 //
301 // [ extension ] A pointer to a ContextExtension object, or "the hole". Used 301 // [ extension ] Additional data.
302 // to implement 'with' statements and dynamic declarations 302 //
303 // (through 'eval'). The object in a 'with' statement is 303 // For script contexts, it contains the respective ScopeInfo.
304 // stored in the extension slot of a 'with' context. 304 //
305 // Dynamically declared variables/functions are also added 305 // For catch contexts, it contains a ContextExtension object
306 // to lazily allocated extension object. Context::Lookup 306 // consisting of the ScopeInfo and the name of the catch
307 // searches the extension object for properties. 307 // variable.
308 // For script and block contexts, contains the respective 308 //
309 // ScopeInfo. For block contexts representing sloppy declaration 309 // For module contexts, it contains the module object.
310 // block scopes, it may also be a struct being a 310 //
311 // ContextExtension, pairing the ScopeInfo with an extension 311 // For block contexts, it contains either the respective
312 // object. 312 // ScopeInfo or a ContextExtension object consisting of the
313 // ScopeInfo and an "extension object" (see below).
314 //
315 // For with contexts, it contains a ContextExtension object
316 // consisting of the ScopeInfo and an "extension object".
317 //
318 // An "extension object" is used to dynamically extend a context
319 // with additional variables, namely in the implementation of the
320 // 'with' construct and the 'eval' construct. For instance,
321 // Context::Lookup also searches the extension object for
322 // properties. (Storing the extension object is the original
323 // purpose of this context slot, hence the name.)
313 // 324 //
314 // [ native_context ] A pointer to the native context. 325 // [ native_context ] A pointer to the native context.
315 // 326 //
316 // In addition, function contexts may have statically allocated context slots 327 // In addition, function contexts may have statically allocated context slots
317 // to store local variables/functions that are accessed from inner functions 328 // to store local variables/functions that are accessed from inner functions
318 // (via static context addresses) or through 'eval' (dynamic context lookups). 329 // (via static context addresses) or through 'eval' (dynamic context lookups).
319 // The native context contains additional slots for fast access to native 330 // The native context contains additional slots for fast access to native
320 // properties. 331 // properties.
321 // 332 //
322 // Finally, with Harmony scoping, the JSFunction representing a top level 333 // Finally, with Harmony scoping, the JSFunction representing a top level
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 #endif 538 #endif
528 539
529 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); 540 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize);
530 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); 541 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex);
531 }; 542 };
532 543
533 } // namespace internal 544 } // namespace internal
534 } // namespace v8 545 } // namespace v8
535 546
536 #endif // V8_CONTEXTS_H_ 547 #endif // V8_CONTEXTS_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698