blob: 53b40f127d8efac2f45ebfdca2dd55d116cf945b [file] [log] [blame]
Ben Murdoch257744e2011-11-30 15:57:28 +00001// Copyright 2011 the V8 project authors. All rights reserved.
Steve Blocka7e24c12009-10-30 11:49:00 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef V8_CONTEXTS_H_
29#define V8_CONTEXTS_H_
30
Kristian Monsen80d68ea2010-09-08 11:05:35 +010031#include "heap.h"
32#include "objects.h"
33
Steve Blocka7e24c12009-10-30 11:49:00 +000034namespace v8 {
35namespace internal {
36
37
38enum ContextLookupFlags {
39 FOLLOW_CONTEXT_CHAIN = 1,
40 FOLLOW_PROTOTYPE_CHAIN = 2,
41
42 DONT_FOLLOW_CHAINS = 0,
43 FOLLOW_CHAINS = FOLLOW_CONTEXT_CHAIN | FOLLOW_PROTOTYPE_CHAIN
44};
45
46
47// Heap-allocated activation contexts.
48//
49// Contexts are implemented as FixedArray objects; the Context
50// class is a convenience interface casted on a FixedArray object.
51//
52// Note: Context must have no virtual functions and Context objects
53// must always be allocated via Heap::AllocateContext() or
54// Factory::NewContext.
55
Steve Blocka7e24c12009-10-30 11:49:00 +000056#define GLOBAL_CONTEXT_FIELDS(V) \
57 V(GLOBAL_PROXY_INDEX, JSObject, global_proxy_object) \
58 V(SECURITY_TOKEN_INDEX, Object, security_token) \
59 V(BOOLEAN_FUNCTION_INDEX, JSFunction, boolean_function) \
60 V(NUMBER_FUNCTION_INDEX, JSFunction, number_function) \
61 V(STRING_FUNCTION_INDEX, JSFunction, string_function) \
Iain Merrick75681382010-08-19 15:07:18 +010062 V(STRING_FUNCTION_PROTOTYPE_MAP_INDEX, Map, string_function_prototype_map) \
Steve Blocka7e24c12009-10-30 11:49:00 +000063 V(OBJECT_FUNCTION_INDEX, JSFunction, object_function) \
64 V(ARRAY_FUNCTION_INDEX, JSFunction, array_function) \
65 V(DATE_FUNCTION_INDEX, JSFunction, date_function) \
66 V(JSON_OBJECT_INDEX, JSObject, json_object) \
67 V(REGEXP_FUNCTION_INDEX, JSFunction, regexp_function) \
68 V(INITIAL_OBJECT_PROTOTYPE_INDEX, JSObject, initial_object_prototype) \
69 V(CREATE_DATE_FUN_INDEX, JSFunction, create_date_fun) \
70 V(TO_NUMBER_FUN_INDEX, JSFunction, to_number_fun) \
71 V(TO_STRING_FUN_INDEX, JSFunction, to_string_fun) \
72 V(TO_DETAIL_STRING_FUN_INDEX, JSFunction, to_detail_string_fun) \
73 V(TO_OBJECT_FUN_INDEX, JSFunction, to_object_fun) \
74 V(TO_INTEGER_FUN_INDEX, JSFunction, to_integer_fun) \
75 V(TO_UINT32_FUN_INDEX, JSFunction, to_uint32_fun) \
76 V(TO_INT32_FUN_INDEX, JSFunction, to_int32_fun) \
Leon Clarkee46be812010-01-19 14:06:41 +000077 V(GLOBAL_EVAL_FUN_INDEX, JSFunction, global_eval_fun) \
Steve Blocka7e24c12009-10-30 11:49:00 +000078 V(INSTANTIATE_FUN_INDEX, JSFunction, instantiate_fun) \
79 V(CONFIGURE_INSTANCE_FUN_INDEX, JSFunction, configure_instance_fun) \
80 V(FUNCTION_MAP_INDEX, Map, function_map) \
Steve Block44f0eee2011-05-26 01:26:41 +010081 V(STRICT_MODE_FUNCTION_MAP_INDEX, Map, strict_mode_function_map) \
Steve Block6ded16b2010-05-10 14:33:55 +010082 V(FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, function_without_prototype_map) \
Steve Block44f0eee2011-05-26 01:26:41 +010083 V(STRICT_MODE_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \
84 strict_mode_function_without_prototype_map) \
Steve Blocka7e24c12009-10-30 11:49:00 +000085 V(FUNCTION_INSTANCE_MAP_INDEX, Map, function_instance_map) \
Steve Block44f0eee2011-05-26 01:26:41 +010086 V(STRICT_MODE_FUNCTION_INSTANCE_MAP_INDEX, Map, \
87 strict_mode_function_instance_map) \
Steve Blocka7e24c12009-10-30 11:49:00 +000088 V(JS_ARRAY_MAP_INDEX, Map, js_array_map)\
Steve Block6ded16b2010-05-10 14:33:55 +010089 V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map)\
Steve Blocka7e24c12009-10-30 11:49:00 +000090 V(ARGUMENTS_BOILERPLATE_INDEX, JSObject, arguments_boilerplate) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +000091 V(ALIASED_ARGUMENTS_BOILERPLATE_INDEX, JSObject, \
92 aliased_arguments_boilerplate) \
Steve Block44f0eee2011-05-26 01:26:41 +010093 V(STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX, JSObject, \
94 strict_mode_arguments_boilerplate) \
Steve Blocka7e24c12009-10-30 11:49:00 +000095 V(MESSAGE_LISTENERS_INDEX, JSObject, message_listeners) \
96 V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \
97 V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \
98 V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \
99 V(FUNCTION_CACHE_INDEX, JSObject, function_cache) \
Steve Block6ded16b2010-05-10 14:33:55 +0100100 V(JSFUNCTION_RESULT_CACHES_INDEX, FixedArray, jsfunction_result_caches) \
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100101 V(NORMALIZED_MAP_CACHE_INDEX, NormalizedMapCache, normalized_map_cache) \
Steve Blocka7e24c12009-10-30 11:49:00 +0000102 V(RUNTIME_CONTEXT_INDEX, Context, runtime_context) \
103 V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \
104 V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction, \
105 call_as_constructor_delegate) \
Steve Blocka7e24c12009-10-30 11:49:00 +0000106 V(SCRIPT_FUNCTION_INDEX, JSFunction, script_function) \
Steve Block6ded16b2010-05-10 14:33:55 +0100107 V(OPAQUE_REFERENCE_FUNCTION_INDEX, JSFunction, opaque_reference_function) \
Steve Blocka7e24c12009-10-30 11:49:00 +0000108 V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \
109 V(OUT_OF_MEMORY_INDEX, Object, out_of_memory) \
110 V(MAP_CACHE_INDEX, Object, map_cache) \
Ben Murdoch257744e2011-11-30 15:57:28 +0000111 V(CONTEXT_DATA_INDEX, Object, data) \
112 V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000113 V(DERIVED_HAS_TRAP_INDEX, JSFunction, derived_has_trap) \
114 V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \
115 V(DERIVED_SET_TRAP_INDEX, JSFunction, derived_set_trap)
Steve Blocka7e24c12009-10-30 11:49:00 +0000116
117// JSFunctions are pairs (context, function code), sometimes also called
118// closures. A Context object is used to represent function contexts and
119// dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak).
120//
121// At runtime, the contexts build a stack in parallel to the execution
122// stack, with the top-most context being the current context. All contexts
123// have the following slots:
124//
125// [ closure ] This is the current function. It is the same for all
126// contexts inside a function. It provides access to the
127// incoming context (i.e., the outer context, which may
128// or may not become the current function's context), and
129// it provides access to the functions code and thus it's
130// scope information, which in turn contains the names of
131// statically allocated context slots. The names are needed
132// for dynamic lookups in the presence of 'with' or 'eval'.
133//
Steve Blocka7e24c12009-10-30 11:49:00 +0000134// [ previous ] A pointer to the previous context. It is NULL for
135// function contexts, and non-NULL for 'with' contexts.
136// Used to implement the 'with' statement.
137//
138// [ extension ] A pointer to an extension JSObject, or NULL. Used to
139// implement 'with' statements and dynamic declarations
140// (through 'eval'). The object in a 'with' statement is
141// stored in the extension slot of a 'with' context.
142// Dynamically declared variables/functions are also added
143// to lazily allocated extension object. Context::Lookup
144// searches the extension object for properties.
145//
146// [ global ] A pointer to the global object. Provided for quick
147// access to the global object from inside the code (since
148// we always have a context pointer).
149//
150// In addition, function contexts may have statically allocated context slots
151// to store local variables/functions that are accessed from inner functions
152// (via static context addresses) or through 'eval' (dynamic context lookups).
153// Finally, the global context contains additional slots for fast access to
154// global properties.
Steve Blocka7e24c12009-10-30 11:49:00 +0000155
156class Context: public FixedArray {
157 public:
158 // Conversions.
159 static Context* cast(Object* context) {
160 ASSERT(context->IsContext());
161 return reinterpret_cast<Context*>(context);
162 }
163
164 // The default context slot layout; indices are FixedArray slot indices.
165 enum {
166 // These slots are in all contexts.
167 CLOSURE_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000168 PREVIOUS_INDEX,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000169 // The extension slot is used for either the global object (in global
170 // contexts), eval extension object (function contexts), subject of with
171 // (with contexts), or the variable name (catch contexts).
Steve Blocka7e24c12009-10-30 11:49:00 +0000172 EXTENSION_INDEX,
173 GLOBAL_INDEX,
174 MIN_CONTEXT_SLOTS,
175
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000176 // This slot holds the thrown value in catch contexts.
177 THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS,
178
Steve Blocka7e24c12009-10-30 11:49:00 +0000179 // These slots are only in global contexts.
180 GLOBAL_PROXY_INDEX = MIN_CONTEXT_SLOTS,
181 SECURITY_TOKEN_INDEX,
182 ARGUMENTS_BOILERPLATE_INDEX,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000183 ALIASED_ARGUMENTS_BOILERPLATE_INDEX,
Steve Block44f0eee2011-05-26 01:26:41 +0100184 STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000185 JS_ARRAY_MAP_INDEX,
Steve Block6ded16b2010-05-10 14:33:55 +0100186 REGEXP_RESULT_MAP_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000187 FUNCTION_MAP_INDEX,
Steve Block44f0eee2011-05-26 01:26:41 +0100188 STRICT_MODE_FUNCTION_MAP_INDEX,
Steve Block6ded16b2010-05-10 14:33:55 +0100189 FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
Steve Block44f0eee2011-05-26 01:26:41 +0100190 STRICT_MODE_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000191 FUNCTION_INSTANCE_MAP_INDEX,
Steve Block44f0eee2011-05-26 01:26:41 +0100192 STRICT_MODE_FUNCTION_INSTANCE_MAP_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000193 INITIAL_OBJECT_PROTOTYPE_INDEX,
194 BOOLEAN_FUNCTION_INDEX,
195 NUMBER_FUNCTION_INDEX,
196 STRING_FUNCTION_INDEX,
Iain Merrick75681382010-08-19 15:07:18 +0100197 STRING_FUNCTION_PROTOTYPE_MAP_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000198 OBJECT_FUNCTION_INDEX,
199 ARRAY_FUNCTION_INDEX,
200 DATE_FUNCTION_INDEX,
201 JSON_OBJECT_INDEX,
202 REGEXP_FUNCTION_INDEX,
203 CREATE_DATE_FUN_INDEX,
204 TO_NUMBER_FUN_INDEX,
205 TO_STRING_FUN_INDEX,
206 TO_DETAIL_STRING_FUN_INDEX,
207 TO_OBJECT_FUN_INDEX,
208 TO_INTEGER_FUN_INDEX,
209 TO_UINT32_FUN_INDEX,
210 TO_INT32_FUN_INDEX,
211 TO_BOOLEAN_FUN_INDEX,
Leon Clarkee46be812010-01-19 14:06:41 +0000212 GLOBAL_EVAL_FUN_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000213 INSTANTIATE_FUN_INDEX,
214 CONFIGURE_INSTANCE_FUN_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000215 MESSAGE_LISTENERS_INDEX,
216 MAKE_MESSAGE_FUN_INDEX,
217 GET_STACK_TRACE_LINE_INDEX,
218 CONFIGURE_GLOBAL_INDEX,
219 FUNCTION_CACHE_INDEX,
Steve Block6ded16b2010-05-10 14:33:55 +0100220 JSFUNCTION_RESULT_CACHES_INDEX,
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100221 NORMALIZED_MAP_CACHE_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000222 RUNTIME_CONTEXT_INDEX,
223 CALL_AS_FUNCTION_DELEGATE_INDEX,
224 CALL_AS_CONSTRUCTOR_DELEGATE_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000225 SCRIPT_FUNCTION_INDEX,
Steve Block6ded16b2010-05-10 14:33:55 +0100226 OPAQUE_REFERENCE_FUNCTION_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000227 CONTEXT_EXTENSION_FUNCTION_INDEX,
228 OUT_OF_MEMORY_INDEX,
Steve Blocka7e24c12009-10-30 11:49:00 +0000229 CONTEXT_DATA_INDEX,
Ben Murdoch257744e2011-11-30 15:57:28 +0000230 ALLOW_CODE_GEN_FROM_STRINGS_INDEX,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000231 DERIVED_HAS_TRAP_INDEX,
Ben Murdoch257744e2011-11-30 15:57:28 +0000232 DERIVED_GET_TRAP_INDEX,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000233 DERIVED_SET_TRAP_INDEX,
Ben Murdochf87a2032010-10-22 12:50:53 +0100234
235 // Properties from here are treated as weak references by the full GC.
236 // Scavenge treats them as strong references.
Ben Murdochb0fe1622011-05-05 13:52:32 +0100237 OPTIMIZED_FUNCTIONS_LIST, // Weak.
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000238 MAP_CACHE_INDEX, // Weak.
Ben Murdochb0fe1622011-05-05 13:52:32 +0100239 NEXT_CONTEXT_LINK, // Weak.
Ben Murdochf87a2032010-10-22 12:50:53 +0100240
241 // Total number of slots.
242 GLOBAL_CONTEXT_SLOTS,
243
Ben Murdochb0fe1622011-05-05 13:52:32 +0100244 FIRST_WEAK_SLOT = OPTIMIZED_FUNCTIONS_LIST
Steve Blocka7e24c12009-10-30 11:49:00 +0000245 };
246
247 // Direct slot access.
248 JSFunction* closure() { return JSFunction::cast(get(CLOSURE_INDEX)); }
249 void set_closure(JSFunction* closure) { set(CLOSURE_INDEX, closure); }
250
Steve Blocka7e24c12009-10-30 11:49:00 +0000251 Context* previous() {
252 Object* result = unchecked_previous();
253 ASSERT(IsBootstrappingOrContext(result));
254 return reinterpret_cast<Context*>(result);
255 }
256 void set_previous(Context* context) { set(PREVIOUS_INDEX, context); }
257
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000258 bool has_extension() { return extension() != NULL; }
259 Object* extension() { return get(EXTENSION_INDEX); }
260 void set_extension(Object* object) { set(EXTENSION_INDEX, object); }
261
262 // Get the context where var declarations will be hoisted to, which
263 // may be the context itself.
264 Context* declaration_context();
Steve Blocka7e24c12009-10-30 11:49:00 +0000265
266 GlobalObject* global() {
267 Object* result = get(GLOBAL_INDEX);
Steve Block44f0eee2011-05-26 01:26:41 +0100268 ASSERT(IsBootstrappingOrGlobalObject(result));
Steve Blocka7e24c12009-10-30 11:49:00 +0000269 return reinterpret_cast<GlobalObject*>(result);
270 }
271 void set_global(GlobalObject* global) { set(GLOBAL_INDEX, global); }
272
273 // Returns a JSGlobalProxy object or null.
274 JSObject* global_proxy();
275 void set_global_proxy(JSObject* global);
276
277 // The builtins object.
278 JSBuiltinsObject* builtins();
279
280 // Compute the global context by traversing the context chain.
281 Context* global_context();
282
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000283 // Predicates for context types. IsGlobalContext is defined on Object
284 // because we frequently have to know if arbitrary objects are global
285 // contexts.
286 bool IsFunctionContext() {
287 Map* map = this->map();
288 return map == map->GetHeap()->function_context_map();
289 }
290 bool IsCatchContext() {
291 Map* map = this->map();
292 return map == map->GetHeap()->catch_context_map();
293 }
294 bool IsWithContext() {
295 Map* map = this->map();
296 return map == map->GetHeap()->with_context_map();
297 }
Steve Blocka7e24c12009-10-30 11:49:00 +0000298
299 // Tells whether the global context is marked with out of memory.
Steve Block44f0eee2011-05-26 01:26:41 +0100300 inline bool has_out_of_memory();
Steve Blocka7e24c12009-10-30 11:49:00 +0000301
302 // Mark the global context with out of memory.
Steve Block44f0eee2011-05-26 01:26:41 +0100303 inline void mark_out_of_memory();
Steve Blocka7e24c12009-10-30 11:49:00 +0000304
305 // The exception holder is the object used as a with object in
306 // the implementation of a catch block.
307 bool is_exception_holder(Object* object) {
308 return IsCatchContext() && extension() == object;
309 }
310
Ben Murdochb0fe1622011-05-05 13:52:32 +0100311 // A global context hold a list of all functions which have been optimized.
312 void AddOptimizedFunction(JSFunction* function);
313 void RemoveOptimizedFunction(JSFunction* function);
314 Object* OptimizedFunctionsListHead();
315 void ClearOptimizedFunctions();
316
Steve Blocka7e24c12009-10-30 11:49:00 +0000317#define GLOBAL_CONTEXT_FIELD_ACCESSORS(index, type, name) \
318 void set_##name(type* value) { \
319 ASSERT(IsGlobalContext()); \
320 set(index, value); \
321 } \
322 type* name() { \
323 ASSERT(IsGlobalContext()); \
324 return type::cast(get(index)); \
325 }
326 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSORS)
327#undef GLOBAL_CONTEXT_FIELD_ACCESSORS
328
329 // Lookup the the slot called name, starting with the current context.
330 // There are 4 possible outcomes:
331 //
332 // 1) index_ >= 0 && result->IsContext():
333 // most common case, the result is a Context, and index is the
334 // context slot index, and the slot exists.
335 // attributes == READ_ONLY for the function name variable, NONE otherwise.
336 //
337 // 2) index_ >= 0 && result->IsJSObject():
338 // the result is the JSObject arguments object, the index is the parameter
339 // index, i.e., key into the arguments object, and the property exists.
340 // attributes != ABSENT.
341 //
342 // 3) index_ < 0 && result->IsJSObject():
343 // the result is the JSObject extension context or the global object,
344 // and the name is the property name, and the property exists.
345 // attributes != ABSENT.
346 //
347 // 4) index_ < 0 && result.is_null():
348 // there was no context found with the corresponding property.
349 // attributes == ABSENT.
350 Handle<Object> Lookup(Handle<String> name, ContextLookupFlags flags,
351 int* index_, PropertyAttributes* attributes);
352
353 // Determine if a local variable with the given name exists in a
354 // context. Do not consider context extension objects. This is
355 // used for compiling code using eval. If the context surrounding
356 // the eval call does not have a local variable with this name and
357 // does not contain a with statement the property is global unless
358 // it is shadowed by a property in an extension object introduced by
359 // eval.
360 bool GlobalIfNotShadowedByEval(Handle<String> name);
361
Ben Murdoch257744e2011-11-30 15:57:28 +0000362 // Determine if any function scope in the context call eval and if
363 // any of those calls are in non-strict mode.
364 void ComputeEvalScopeInfo(bool* outer_scope_calls_eval,
365 bool* outer_scope_calls_non_strict_eval);
366
Steve Blocka7e24c12009-10-30 11:49:00 +0000367 // Code generation support.
368 static int SlotOffset(int index) {
369 return kHeaderSize + index * kPointerSize - kHeapObjectTag;
370 }
371
Ben Murdochf87a2032010-10-22 12:50:53 +0100372 static const int kSize = kHeaderSize + GLOBAL_CONTEXT_SLOTS * kPointerSize;
373
374 // GC support.
375 typedef FixedBodyDescriptor<
376 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor;
377
378 typedef FixedBodyDescriptor<
379 kHeaderSize,
380 kHeaderSize + FIRST_WEAK_SLOT * kPointerSize,
381 kSize> MarkCompactBodyDescriptor;
382
Steve Blocka7e24c12009-10-30 11:49:00 +0000383 private:
384 // Unchecked access to the slots.
385 Object* unchecked_previous() { return get(PREVIOUS_INDEX); }
Steve Blocka7e24c12009-10-30 11:49:00 +0000386
387#ifdef DEBUG
388 // Bootstrapping-aware type checks.
389 static bool IsBootstrappingOrContext(Object* object);
390 static bool IsBootstrappingOrGlobalObject(Object* object);
391#endif
392};
393
394} } // namespace v8::internal
395
396#endif // V8_CONTEXTS_H_