| OLD | NEW |
| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 // | 326 // |
| 327 // [ closure ] This is the current function. It is the same for all | 327 // [ closure ] This is the current function. It is the same for all |
| 328 // contexts inside a function. It provides access to the | 328 // contexts inside a function. It provides access to the |
| 329 // incoming context (i.e., the outer context, which may | 329 // incoming context (i.e., the outer context, which may |
| 330 // or may not become the current function's context), and | 330 // or may not become the current function's context), and |
| 331 // it provides access to the functions code and thus it's | 331 // it provides access to the functions code and thus it's |
| 332 // scope information, which in turn contains the names of | 332 // scope information, which in turn contains the names of |
| 333 // statically allocated context slots. The names are needed | 333 // statically allocated context slots. The names are needed |
| 334 // for dynamic lookups in the presence of 'with' or 'eval'. | 334 // for dynamic lookups in the presence of 'with' or 'eval'. |
| 335 // | 335 // |
| 336 // [ previous ] A pointer to the previous context. It is NULL for | 336 // [ previous ] A pointer to the previous context. |
| 337 // function contexts, and non-NULL for 'with' contexts. | |
| 338 // Used to implement the 'with' statement. | |
| 339 // | 337 // |
| 340 // [ extension ] A pointer to an extension JSObject, or "the hole". Used to | 338 // [ extension ] A pointer to an extension JSObject, or "the hole". Used to |
| 341 // implement 'with' statements and dynamic declarations | 339 // implement 'with' statements and dynamic declarations |
| 342 // (through 'eval'). The object in a 'with' statement is | 340 // (through 'eval'). The object in a 'with' statement is |
| 343 // stored in the extension slot of a 'with' context. | 341 // stored in the extension slot of a 'with' context. |
| 344 // Dynamically declared variables/functions are also added | 342 // Dynamically declared variables/functions are also added |
| 345 // to lazily allocated extension object. Context::Lookup | 343 // to lazily allocated extension object. Context::Lookup |
| 346 // searches the extension object for properties. | 344 // searches the extension object for properties. |
| 347 // For script and block contexts, contains the respective | 345 // For script and block contexts, contains the respective |
| 348 // ScopeInfo. For block contexts representing sloppy declaration | 346 // ScopeInfo. For block contexts representing sloppy declaration |
| 349 // block scopes, it may also be a struct being a | 347 // block scopes, it may also be a struct being a |
| 350 // SloppyBlockWithEvalContextExtension, pairing the ScopeInfo | 348 // SloppyBlockWithEvalContextExtension, pairing the ScopeInfo |
| 351 // with an extension object. | 349 // with an extension object. |
| 352 // | 350 // |
| 353 // [ global_object ] A pointer to the global object. Provided for quick | 351 // [ native_context ] A pointer to the native context. |
| 354 // access to the global object from inside the code (since | |
| 355 // we always have a context pointer). | |
| 356 // | 352 // |
| 357 // In addition, function contexts may have statically allocated context slots | 353 // In addition, function contexts may have statically allocated context slots |
| 358 // to store local variables/functions that are accessed from inner functions | 354 // to store local variables/functions that are accessed from inner functions |
| 359 // (via static context addresses) or through 'eval' (dynamic context lookups). | 355 // (via static context addresses) or through 'eval' (dynamic context lookups). |
| 360 // The native context contains additional slots for fast access to native | 356 // The native context contains additional slots for fast access to native |
| 361 // properties. | 357 // properties. |
| 362 // | 358 // |
| 363 // Finally, with Harmony scoping, the JSFunction representing a top level | 359 // Finally, with Harmony scoping, the JSFunction representing a top level |
| 364 // script will have the ScriptContext rather than a FunctionContext. | 360 // script will have the ScriptContext rather than a FunctionContext. |
| 365 // Script contexts from all top-level scripts are gathered in | 361 // Script contexts from all top-level scripts are gathered in |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 #endif | 568 #endif |
| 573 | 569 |
| 574 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); | 570 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); |
| 575 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); | 571 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); |
| 576 }; | 572 }; |
| 577 | 573 |
| 578 } // namespace internal | 574 } // namespace internal |
| 579 } // namespace v8 | 575 } // namespace v8 |
| 580 | 576 |
| 581 #endif // V8_CONTEXTS_H_ | 577 #endif // V8_CONTEXTS_H_ |
| OLD | NEW |