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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \ | 220 V(SYMBOL_FUNCTION_INDEX, JSFunction, symbol_function) \ |
221 V(TYPED_ARRAY_FUN_INDEX, JSFunction, typed_array_function) \ | 221 V(TYPED_ARRAY_FUN_INDEX, JSFunction, typed_array_function) \ |
222 V(TYPED_ARRAY_PROTOTYPE_INDEX, JSObject, typed_array_prototype) \ | 222 V(TYPED_ARRAY_PROTOTYPE_INDEX, JSObject, typed_array_prototype) \ |
223 V(UINT16_ARRAY_FUN_INDEX, JSFunction, uint16_array_fun) \ | 223 V(UINT16_ARRAY_FUN_INDEX, JSFunction, uint16_array_fun) \ |
224 V(UINT16X8_FUNCTION_INDEX, JSFunction, uint16x8_function) \ | 224 V(UINT16X8_FUNCTION_INDEX, JSFunction, uint16x8_function) \ |
225 V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \ | 225 V(UINT32_ARRAY_FUN_INDEX, JSFunction, uint32_array_fun) \ |
226 V(UINT32X4_FUNCTION_INDEX, JSFunction, uint32x4_function) \ | 226 V(UINT32X4_FUNCTION_INDEX, JSFunction, uint32x4_function) \ |
227 V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \ | 227 V(UINT8_ARRAY_FUN_INDEX, JSFunction, uint8_array_fun) \ |
228 V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \ | 228 V(UINT8_CLAMPED_ARRAY_FUN_INDEX, JSFunction, uint8_clamped_array_fun) \ |
229 V(UINT8X16_FUNCTION_INDEX, JSFunction, uint8x16_function) \ | 229 V(UINT8X16_FUNCTION_INDEX, JSFunction, uint8x16_function) \ |
| 230 V(CURRENT_MODULE_INDEX, JSModule, current_module)
\ |
230 NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \ | 231 NATIVE_CONTEXT_INTRINSIC_FUNCTIONS(V) \ |
231 NATIVE_CONTEXT_IMPORTED_FIELDS(V) | 232 NATIVE_CONTEXT_IMPORTED_FIELDS(V) |
232 | 233 |
233 // A table of all script contexts. Every loaded top-level script with top-level | 234 // A table of all script contexts. Every loaded top-level script with top-level |
234 // lexical declarations contributes its ScriptContext into this table. | 235 // lexical declarations contributes its ScriptContext into this table. |
235 // | 236 // |
236 // The table is a fixed array, its first slot is the current used count and | 237 // The table is a fixed array, its first slot is the current used count and |
237 // the subsequent slots 1..used contain ScriptContexts. | 238 // the subsequent slots 1..used contain ScriptContexts. |
238 class ScriptContextTable : public FixedArray { | 239 class ScriptContextTable : public FixedArray { |
239 public: | 240 public: |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // (through 'eval'). The object in a 'with' statement is | 304 // (through 'eval'). The object in a 'with' statement is |
304 // stored in the extension slot of a 'with' context. | 305 // stored in the extension slot of a 'with' context. |
305 // Dynamically declared variables/functions are also added | 306 // Dynamically declared variables/functions are also added |
306 // to lazily allocated extension object. Context::Lookup | 307 // to lazily allocated extension object. Context::Lookup |
307 // searches the extension object for properties. | 308 // searches the extension object for properties. |
308 // For script and block contexts, contains the respective | 309 // For script and block contexts, contains the respective |
309 // ScopeInfo. For block contexts representing sloppy declaration | 310 // ScopeInfo. For block contexts representing sloppy declaration |
310 // block scopes, it may also be a struct being a | 311 // block scopes, it may also be a struct being a |
311 // SloppyBlockWithEvalContextExtension, pairing the ScopeInfo | 312 // SloppyBlockWithEvalContextExtension, pairing the ScopeInfo |
312 // with an extension object. | 313 // with an extension object. |
| 314 // XXX module |
313 // | 315 // |
314 // [ native_context ] A pointer to the native context. | 316 // [ native_context ] A pointer to the native context. |
315 // | 317 // |
316 // In addition, function contexts may have statically allocated context slots | 318 // In addition, function contexts may have statically allocated context slots |
317 // to store local variables/functions that are accessed from inner functions | 319 // to store local variables/functions that are accessed from inner functions |
318 // (via static context addresses) or through 'eval' (dynamic context lookups). | 320 // (via static context addresses) or through 'eval' (dynamic context lookups). |
319 // The native context contains additional slots for fast access to native | 321 // The native context contains additional slots for fast access to native |
320 // properties. | 322 // properties. |
321 // | 323 // |
322 // Finally, with Harmony scoping, the JSFunction representing a top level | 324 // Finally, with Harmony scoping, the JSFunction representing a top level |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 inline Object* next_context_link(); | 382 inline Object* next_context_link(); |
381 | 383 |
382 inline bool has_extension(); | 384 inline bool has_extension(); |
383 inline HeapObject* extension(); | 385 inline HeapObject* extension(); |
384 inline void set_extension(HeapObject* object); | 386 inline void set_extension(HeapObject* object); |
385 JSObject* extension_object(); | 387 JSObject* extension_object(); |
386 JSReceiver* extension_receiver(); | 388 JSReceiver* extension_receiver(); |
387 ScopeInfo* scope_info(); | 389 ScopeInfo* scope_info(); |
388 String* catch_name(); | 390 String* catch_name(); |
389 | 391 |
| 392 // Find the module context (assuming there is one) and return the associated |
| 393 // module object. |
| 394 JSModule* module(); |
| 395 |
390 // Get the context where var declarations will be hoisted to, which | 396 // Get the context where var declarations will be hoisted to, which |
391 // may be the context itself. | 397 // may be the context itself. |
392 Context* declaration_context(); | 398 Context* declaration_context(); // XXX should this return a module context? |
393 bool is_declaration_context(); | 399 bool is_declaration_context(); |
394 | 400 |
395 // Get the next closure's context on the context chain. | 401 // Get the next closure's context on the context chain. |
396 Context* closure_context(); | 402 Context* closure_context(); |
397 | 403 |
398 // Returns a JSGlobalProxy object or null. | 404 // Returns a JSGlobalProxy object or null. |
399 JSObject* global_proxy(); | 405 JSObject* global_proxy(); |
400 void set_global_proxy(JSObject* global); | 406 void set_global_proxy(JSObject* global); |
401 | 407 |
402 // Get the JSGlobalObject object. | 408 // Get the JSGlobalObject object. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 #endif | 533 #endif |
528 | 534 |
529 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); | 535 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); |
530 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); | 536 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); |
531 }; | 537 }; |
532 | 538 |
533 } // namespace internal | 539 } // namespace internal |
534 } // namespace v8 | 540 } // namespace v8 |
535 | 541 |
536 #endif // V8_CONTEXTS_H_ | 542 #endif // V8_CONTEXTS_H_ |
OLD | NEW |