OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 V(STRICT_MODE_FUNCTION_MAP_INDEX, Map, strict_mode_function_map) \ | 81 V(STRICT_MODE_FUNCTION_MAP_INDEX, Map, strict_mode_function_map) \ |
82 V(FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, function_without_prototype_map) \ | 82 V(FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, function_without_prototype_map) \ |
83 V(STRICT_MODE_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ | 83 V(STRICT_MODE_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ |
84 strict_mode_function_without_prototype_map) \ | 84 strict_mode_function_without_prototype_map) \ |
85 V(FUNCTION_INSTANCE_MAP_INDEX, Map, function_instance_map) \ | 85 V(FUNCTION_INSTANCE_MAP_INDEX, Map, function_instance_map) \ |
86 V(STRICT_MODE_FUNCTION_INSTANCE_MAP_INDEX, Map, \ | 86 V(STRICT_MODE_FUNCTION_INSTANCE_MAP_INDEX, Map, \ |
87 strict_mode_function_instance_map) \ | 87 strict_mode_function_instance_map) \ |
88 V(JS_ARRAY_MAP_INDEX, Map, js_array_map)\ | 88 V(JS_ARRAY_MAP_INDEX, Map, js_array_map)\ |
89 V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map)\ | 89 V(REGEXP_RESULT_MAP_INDEX, Map, regexp_result_map)\ |
90 V(ARGUMENTS_BOILERPLATE_INDEX, JSObject, arguments_boilerplate) \ | 90 V(ARGUMENTS_BOILERPLATE_INDEX, JSObject, arguments_boilerplate) \ |
91 V(ALIASED_ARGUMENTS_BOILERPLATE_INDEX, JSObject, \ | |
92 aliased_arguments_boilerplate) \ | |
93 V(STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX, JSObject, \ | 91 V(STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX, JSObject, \ |
94 strict_mode_arguments_boilerplate) \ | 92 strict_mode_arguments_boilerplate) \ |
95 V(MESSAGE_LISTENERS_INDEX, JSObject, message_listeners) \ | 93 V(MESSAGE_LISTENERS_INDEX, JSObject, message_listeners) \ |
96 V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \ | 94 V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \ |
97 V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \ | 95 V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \ |
98 V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \ | 96 V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \ |
99 V(FUNCTION_CACHE_INDEX, JSObject, function_cache) \ | 97 V(FUNCTION_CACHE_INDEX, JSObject, function_cache) \ |
100 V(JSFUNCTION_RESULT_CACHES_INDEX, FixedArray, jsfunction_result_caches) \ | 98 V(JSFUNCTION_RESULT_CACHES_INDEX, FixedArray, jsfunction_result_caches) \ |
101 V(NORMALIZED_MAP_CACHE_INDEX, NormalizedMapCache, normalized_map_cache) \ | 99 V(NORMALIZED_MAP_CACHE_INDEX, NormalizedMapCache, normalized_map_cache) \ |
102 V(RUNTIME_CONTEXT_INDEX, Context, runtime_context) \ | 100 V(RUNTIME_CONTEXT_INDEX, Context, runtime_context) \ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 ASSERT(context->IsContext()); | 174 ASSERT(context->IsContext()); |
177 return reinterpret_cast<Context*>(context); | 175 return reinterpret_cast<Context*>(context); |
178 } | 176 } |
179 | 177 |
180 // The default context slot layout; indices are FixedArray slot indices. | 178 // The default context slot layout; indices are FixedArray slot indices. |
181 enum { | 179 enum { |
182 // These slots are in all contexts. | 180 // These slots are in all contexts. |
183 CLOSURE_INDEX, | 181 CLOSURE_INDEX, |
184 FCONTEXT_INDEX, | 182 FCONTEXT_INDEX, |
185 PREVIOUS_INDEX, | 183 PREVIOUS_INDEX, |
| 184 // The extension slot is used for either the global object (in global |
| 185 // contexts), eval extension object (function contexts), subject of with |
| 186 // (with contexts), or the variable name (catch contexts). |
186 EXTENSION_INDEX, | 187 EXTENSION_INDEX, |
187 GLOBAL_INDEX, | 188 GLOBAL_INDEX, |
188 MIN_CONTEXT_SLOTS, | 189 MIN_CONTEXT_SLOTS, |
189 | 190 |
| 191 // This slot holds the thrown value in catch contexts. |
| 192 THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS, |
| 193 |
190 // These slots are only in global contexts. | 194 // These slots are only in global contexts. |
191 GLOBAL_PROXY_INDEX = MIN_CONTEXT_SLOTS, | 195 GLOBAL_PROXY_INDEX = MIN_CONTEXT_SLOTS, |
192 SECURITY_TOKEN_INDEX, | 196 SECURITY_TOKEN_INDEX, |
193 ARGUMENTS_BOILERPLATE_INDEX, | 197 ARGUMENTS_BOILERPLATE_INDEX, |
194 ALIASED_ARGUMENTS_BOILERPLATE_INDEX, | |
195 STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX, | 198 STRICT_MODE_ARGUMENTS_BOILERPLATE_INDEX, |
196 JS_ARRAY_MAP_INDEX, | 199 JS_ARRAY_MAP_INDEX, |
197 REGEXP_RESULT_MAP_INDEX, | 200 REGEXP_RESULT_MAP_INDEX, |
198 FUNCTION_MAP_INDEX, | 201 FUNCTION_MAP_INDEX, |
199 STRICT_MODE_FUNCTION_MAP_INDEX, | 202 STRICT_MODE_FUNCTION_MAP_INDEX, |
200 FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, | 203 FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, |
201 STRICT_MODE_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, | 204 STRICT_MODE_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, |
202 FUNCTION_INSTANCE_MAP_INDEX, | 205 FUNCTION_INSTANCE_MAP_INDEX, |
203 STRICT_MODE_FUNCTION_INSTANCE_MAP_INDEX, | 206 STRICT_MODE_FUNCTION_INSTANCE_MAP_INDEX, |
204 INITIAL_OBJECT_PROTOTYPE_INDEX, | 207 INITIAL_OBJECT_PROTOTYPE_INDEX, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 Context* fcontext() { return Context::cast(get(FCONTEXT_INDEX)); } | 264 Context* fcontext() { return Context::cast(get(FCONTEXT_INDEX)); } |
262 void set_fcontext(Context* context) { set(FCONTEXT_INDEX, context); } | 265 void set_fcontext(Context* context) { set(FCONTEXT_INDEX, context); } |
263 | 266 |
264 Context* previous() { | 267 Context* previous() { |
265 Object* result = unchecked_previous(); | 268 Object* result = unchecked_previous(); |
266 ASSERT(IsBootstrappingOrContext(result)); | 269 ASSERT(IsBootstrappingOrContext(result)); |
267 return reinterpret_cast<Context*>(result); | 270 return reinterpret_cast<Context*>(result); |
268 } | 271 } |
269 void set_previous(Context* context) { set(PREVIOUS_INDEX, context); } | 272 void set_previous(Context* context) { set(PREVIOUS_INDEX, context); } |
270 | 273 |
271 bool has_extension() { return unchecked_extension() != NULL; } | 274 bool has_extension() { return extension() != NULL; } |
272 JSObject* extension() { return JSObject::cast(unchecked_extension()); } | 275 Object* extension() { return get(EXTENSION_INDEX); } |
273 void set_extension(JSObject* object) { set(EXTENSION_INDEX, object); } | 276 void set_extension(Object* object) { set(EXTENSION_INDEX, object); } |
274 | 277 |
275 GlobalObject* global() { | 278 GlobalObject* global() { |
276 Object* result = get(GLOBAL_INDEX); | 279 Object* result = get(GLOBAL_INDEX); |
277 ASSERT(IsBootstrappingOrGlobalObject(result)); | 280 ASSERT(IsBootstrappingOrGlobalObject(result)); |
278 return reinterpret_cast<GlobalObject*>(result); | 281 return reinterpret_cast<GlobalObject*>(result); |
279 } | 282 } |
280 void set_global(GlobalObject* global) { set(GLOBAL_INDEX, global); } | 283 void set_global(GlobalObject* global) { set(GLOBAL_INDEX, global); } |
281 | 284 |
282 // Returns a JSGlobalProxy object or null. | 285 // Returns a JSGlobalProxy object or null. |
283 JSObject* global_proxy(); | 286 JSObject* global_proxy(); |
284 void set_global_proxy(JSObject* global); | 287 void set_global_proxy(JSObject* global); |
285 | 288 |
286 // The builtins object. | 289 // The builtins object. |
287 JSBuiltinsObject* builtins(); | 290 JSBuiltinsObject* builtins(); |
288 | 291 |
289 // Compute the global context by traversing the context chain. | 292 // Compute the global context by traversing the context chain. |
290 Context* global_context(); | 293 Context* global_context(); |
291 | 294 |
292 // Predicates for context types. IsGlobalContext is defined on Object | 295 // Predicates for context types. IsGlobalContext is defined on Object |
293 // because we frequently have to know if arbitrary objects are global | 296 // because we frequently have to know if arbitrary objects are global |
294 // contexts. | 297 // contexts. |
295 bool IsFunctionContext() { | 298 bool IsFunctionContext() { |
296 Map* map = this->map(); | 299 Map* map = this->map(); |
297 return map == map->GetHeap()->function_context_map(); | 300 return map == map->GetHeap()->function_context_map(); |
298 } | 301 } |
299 bool IsCatchContext() { | 302 bool IsCatchContext() { |
300 Map* map = this->map(); | 303 Map* map = this->map(); |
301 return map == map->GetHeap()->catch_context_map(); | 304 return map == map->GetHeap()->catch_context_map(); |
302 } | 305 } |
| 306 bool IsWithContext() { |
| 307 Map* map = this->map(); |
| 308 return map == map->GetHeap()->with_context_map(); |
| 309 } |
303 | 310 |
304 // Tells whether the global context is marked with out of memory. | 311 // Tells whether the global context is marked with out of memory. |
305 inline bool has_out_of_memory(); | 312 inline bool has_out_of_memory(); |
306 | 313 |
307 // Mark the global context with out of memory. | 314 // Mark the global context with out of memory. |
308 inline void mark_out_of_memory(); | 315 inline void mark_out_of_memory(); |
309 | 316 |
310 // The exception holder is the object used as a with object in | 317 // The exception holder is the object used as a with object in |
311 // the implementation of a catch block. | 318 // the implementation of a catch block. |
312 bool is_exception_holder(Object* object) { | 319 bool is_exception_holder(Object* object) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor; | 388 kHeaderSize, kSize, kSize> ScavengeBodyDescriptor; |
382 | 389 |
383 typedef FixedBodyDescriptor< | 390 typedef FixedBodyDescriptor< |
384 kHeaderSize, | 391 kHeaderSize, |
385 kHeaderSize + FIRST_WEAK_SLOT * kPointerSize, | 392 kHeaderSize + FIRST_WEAK_SLOT * kPointerSize, |
386 kSize> MarkCompactBodyDescriptor; | 393 kSize> MarkCompactBodyDescriptor; |
387 | 394 |
388 private: | 395 private: |
389 // Unchecked access to the slots. | 396 // Unchecked access to the slots. |
390 Object* unchecked_previous() { return get(PREVIOUS_INDEX); } | 397 Object* unchecked_previous() { return get(PREVIOUS_INDEX); } |
391 Object* unchecked_extension() { return get(EXTENSION_INDEX); } | |
392 | 398 |
393 #ifdef DEBUG | 399 #ifdef DEBUG |
394 // Bootstrapping-aware type checks. | 400 // Bootstrapping-aware type checks. |
395 static bool IsBootstrappingOrContext(Object* object); | 401 static bool IsBootstrappingOrContext(Object* object); |
396 static bool IsBootstrappingOrGlobalObject(Object* object); | 402 static bool IsBootstrappingOrGlobalObject(Object* object); |
397 #endif | 403 #endif |
398 }; | 404 }; |
399 | 405 |
400 } } // namespace v8::internal | 406 } } // namespace v8::internal |
401 | 407 |
402 #endif // V8_CONTEXTS_H_ | 408 #endif // V8_CONTEXTS_H_ |
OLD | NEW |