OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 V(DEBUG_EVENT_LISTENERS_INDEX, JSObject, debug_event_listeners) \ | 84 V(DEBUG_EVENT_LISTENERS_INDEX, JSObject, debug_event_listeners) \ |
85 V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \ | 85 V(MAKE_MESSAGE_FUN_INDEX, JSFunction, make_message_fun) \ |
86 V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \ | 86 V(GET_STACK_TRACE_LINE_INDEX, JSFunction, get_stack_trace_line_fun) \ |
87 V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \ | 87 V(CONFIGURE_GLOBAL_INDEX, JSFunction, configure_global_fun) \ |
88 V(FUNCTION_CACHE_INDEX, JSObject, function_cache) \ | 88 V(FUNCTION_CACHE_INDEX, JSObject, function_cache) \ |
89 V(RUNTIME_CONTEXT_INDEX, Context, runtime_context) \ | 89 V(RUNTIME_CONTEXT_INDEX, Context, runtime_context) \ |
90 V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \ | 90 V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \ |
91 V(EMPTY_SCRIPT_INDEX, Script, empty_script) \ | 91 V(EMPTY_SCRIPT_INDEX, Script, empty_script) \ |
92 V(SCRIPT_FUNCTION_INDEX, JSFunction, script_function) \ | 92 V(SCRIPT_FUNCTION_INDEX, JSFunction, script_function) \ |
93 V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \ | 93 V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \ |
94 V(OUT_OF_MEMORY_INDEX, Object, out_of_memory) | 94 V(OUT_OF_MEMORY_INDEX, Object, out_of_memory) \ |
| 95 V(MAP_CACHE_INDEX, Object, map_cache) |
95 | 96 |
96 // JSFunctions are pairs (context, function code), sometimes also called | 97 // JSFunctions are pairs (context, function code), sometimes also called |
97 // closures. A Context object is used to represent function contexts and | 98 // closures. A Context object is used to represent function contexts and |
98 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). | 99 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). |
99 // | 100 // |
100 // At runtime, the contexts build a stack in parallel to the execution | 101 // At runtime, the contexts build a stack in parallel to the execution |
101 // stack, with the top-most context being the current context. All contexts | 102 // stack, with the top-most context being the current context. All contexts |
102 // have the following slots: | 103 // have the following slots: |
103 // | 104 // |
104 // [ closure ] This is the current function. It is the same for all | 105 // [ closure ] This is the current function. It is the same for all |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 MAKE_MESSAGE_FUN_INDEX, | 201 MAKE_MESSAGE_FUN_INDEX, |
201 GET_STACK_TRACE_LINE_INDEX, | 202 GET_STACK_TRACE_LINE_INDEX, |
202 CONFIGURE_GLOBAL_INDEX, | 203 CONFIGURE_GLOBAL_INDEX, |
203 FUNCTION_CACHE_INDEX, | 204 FUNCTION_CACHE_INDEX, |
204 RUNTIME_CONTEXT_INDEX, | 205 RUNTIME_CONTEXT_INDEX, |
205 CALL_AS_FUNCTION_DELEGATE_INDEX, | 206 CALL_AS_FUNCTION_DELEGATE_INDEX, |
206 EMPTY_SCRIPT_INDEX, | 207 EMPTY_SCRIPT_INDEX, |
207 SCRIPT_FUNCTION_INDEX, | 208 SCRIPT_FUNCTION_INDEX, |
208 CONTEXT_EXTENSION_FUNCTION_INDEX, | 209 CONTEXT_EXTENSION_FUNCTION_INDEX, |
209 OUT_OF_MEMORY_INDEX, | 210 OUT_OF_MEMORY_INDEX, |
| 211 MAP_CACHE_INDEX, |
210 GLOBAL_CONTEXT_SLOTS | 212 GLOBAL_CONTEXT_SLOTS |
211 }; | 213 }; |
212 | 214 |
213 // Direct slot access. | 215 // Direct slot access. |
214 JSFunction* closure() { return JSFunction::cast(get(CLOSURE_INDEX)); } | 216 JSFunction* closure() { return JSFunction::cast(get(CLOSURE_INDEX)); } |
215 void set_closure(JSFunction* closure) { set(CLOSURE_INDEX, closure); } | 217 void set_closure(JSFunction* closure) { set(CLOSURE_INDEX, closure); } |
216 | 218 |
217 Context* fcontext() { | 219 Context* fcontext() { |
218 return reinterpret_cast<Context*>(get(FCONTEXT_INDEX)); | 220 return reinterpret_cast<Context*>(get(FCONTEXT_INDEX)); |
219 } | 221 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 293 |
292 // Code generation support. | 294 // Code generation support. |
293 static int SlotOffset(int index) { | 295 static int SlotOffset(int index) { |
294 return kHeaderSize + index * kPointerSize - kHeapObjectTag; | 296 return kHeaderSize + index * kPointerSize - kHeapObjectTag; |
295 } | 297 } |
296 }; | 298 }; |
297 | 299 |
298 } } // namespace v8::internal | 300 } } // namespace v8::internal |
299 | 301 |
300 #endif // V8_CONTEXTS_H_ | 302 #endif // V8_CONTEXTS_H_ |
OLD | NEW |