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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // Use serialized scope information of functions and blocks to search | 138 // Use serialized scope information of functions and blocks to search |
139 // for the context index. | 139 // for the context index. |
140 Handle<SerializedScopeInfo> scope_info; | 140 Handle<SerializedScopeInfo> scope_info; |
141 if (context->IsFunctionContext()) { | 141 if (context->IsFunctionContext()) { |
142 scope_info = Handle<SerializedScopeInfo>( | 142 scope_info = Handle<SerializedScopeInfo>( |
143 context->closure()->shared()->scope_info(), isolate); | 143 context->closure()->shared()->scope_info(), isolate); |
144 } else { | 144 } else { |
145 scope_info = Handle<SerializedScopeInfo>( | 145 scope_info = Handle<SerializedScopeInfo>( |
146 SerializedScopeInfo::cast(context->extension()), isolate); | 146 SerializedScopeInfo::cast(context->extension()), isolate); |
147 } | 147 } |
148 Variable::Mode mode; | 148 VariableMode mode; |
149 int slot_index = scope_info->ContextSlotIndex(*name, &mode); | 149 int slot_index = scope_info->ContextSlotIndex(*name, &mode); |
150 ASSERT(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS); | 150 ASSERT(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS); |
151 if (slot_index >= 0) { | 151 if (slot_index >= 0) { |
152 if (FLAG_trace_contexts) { | 152 if (FLAG_trace_contexts) { |
153 PrintF("=> found local in context slot %d (mode = %d)\n", | 153 PrintF("=> found local in context slot %d (mode = %d)\n", |
154 slot_index, mode); | 154 slot_index, mode); |
155 } | 155 } |
156 *index = slot_index; | 156 *index = slot_index; |
157 // Note: Fixed context slots are statically allocated by the compiler. | 157 // Note: Fixed context slots are statically allocated by the compiler. |
158 // Statically allocated variables always have a statically known mode, | 158 // Statically allocated variables always have a statically known mode, |
159 // which is the mode with which they were declared when added to the | 159 // which is the mode with which they were declared when added to the |
160 // scope. Thus, the DYNAMIC mode (which corresponds to dynamically | 160 // scope. Thus, the DYNAMIC mode (which corresponds to dynamically |
161 // declared variables that were introduced through declaration nodes) | 161 // declared variables that were introduced through declaration nodes) |
162 // must not appear here. | 162 // must not appear here. |
163 switch (mode) { | 163 switch (mode) { |
164 case Variable::INTERNAL: // Fall through. | 164 case INTERNAL: // Fall through. |
165 case Variable::VAR: | 165 case VAR: |
166 *attributes = NONE; | 166 *attributes = NONE; |
167 *binding_flags = MUTABLE_IS_INITIALIZED; | 167 *binding_flags = MUTABLE_IS_INITIALIZED; |
168 break; | 168 break; |
169 case Variable::LET: | 169 case LET: |
170 *attributes = NONE; | 170 *attributes = NONE; |
171 *binding_flags = MUTABLE_CHECK_INITIALIZED; | 171 *binding_flags = MUTABLE_CHECK_INITIALIZED; |
172 break; | 172 break; |
173 case Variable::CONST: | 173 case CONST: |
174 *attributes = READ_ONLY; | 174 *attributes = READ_ONLY; |
175 *binding_flags = IMMUTABLE_CHECK_INITIALIZED; | 175 *binding_flags = IMMUTABLE_CHECK_INITIALIZED; |
176 break; | 176 break; |
177 case Variable::DYNAMIC: | 177 case DYNAMIC: |
178 case Variable::DYNAMIC_GLOBAL: | 178 case DYNAMIC_GLOBAL: |
179 case Variable::DYNAMIC_LOCAL: | 179 case DYNAMIC_LOCAL: |
180 case Variable::TEMPORARY: | 180 case TEMPORARY: |
181 UNREACHABLE(); | 181 UNREACHABLE(); |
182 break; | 182 break; |
183 } | 183 } |
184 return context; | 184 return context; |
185 } | 185 } |
186 | 186 |
187 // Check the slot corresponding to the intermediate context holding | 187 // Check the slot corresponding to the intermediate context holding |
188 // only the function name variable. | 188 // only the function name variable. |
189 if (follow_context_chain && context->IsFunctionContext()) { | 189 if (follow_context_chain && context->IsFunctionContext()) { |
190 int function_index = scope_info->FunctionContextSlotIndex(*name); | 190 int function_index = scope_info->FunctionContextSlotIndex(*name); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // Check if the context is a catch or with context, or has introduced | 238 // Check if the context is a catch or with context, or has introduced |
239 // bindings by calling non-strict eval. | 239 // bindings by calling non-strict eval. |
240 if (context->has_extension()) return false; | 240 if (context->has_extension()) return false; |
241 | 241 |
242 // Not a with context so it must be a function context. | 242 // Not a with context so it must be a function context. |
243 ASSERT(context->IsFunctionContext()); | 243 ASSERT(context->IsFunctionContext()); |
244 | 244 |
245 // Check non-parameter locals. | 245 // Check non-parameter locals. |
246 Handle<SerializedScopeInfo> scope_info( | 246 Handle<SerializedScopeInfo> scope_info( |
247 context->closure()->shared()->scope_info()); | 247 context->closure()->shared()->scope_info()); |
248 Variable::Mode mode; | 248 VariableMode mode; |
249 int index = scope_info->ContextSlotIndex(*name, &mode); | 249 int index = scope_info->ContextSlotIndex(*name, &mode); |
250 ASSERT(index < 0 || index >= MIN_CONTEXT_SLOTS); | 250 ASSERT(index < 0 || index >= MIN_CONTEXT_SLOTS); |
251 if (index >= 0) return false; | 251 if (index >= 0) return false; |
252 | 252 |
253 // Check parameter locals. | 253 // Check parameter locals. |
254 int param_index = scope_info->ParameterIndex(*name); | 254 int param_index = scope_info->ParameterIndex(*name); |
255 if (param_index >= 0) return false; | 255 if (param_index >= 0) return false; |
256 | 256 |
257 // Check context only holding the function name variable. | 257 // Check context only holding the function name variable. |
258 index = scope_info->FunctionContextSlotIndex(*name); | 258 index = scope_info->FunctionContextSlotIndex(*name); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // During bootstrapping we allow all objects to pass as global | 365 // During bootstrapping we allow all objects to pass as global |
366 // objects. This is necessary to fix circular dependencies. | 366 // objects. This is necessary to fix circular dependencies. |
367 Isolate* isolate = Isolate::Current(); | 367 Isolate* isolate = Isolate::Current(); |
368 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || | 368 return isolate->heap()->gc_state() != Heap::NOT_IN_GC || |
369 isolate->bootstrapper()->IsActive() || | 369 isolate->bootstrapper()->IsActive() || |
370 object->IsGlobalObject(); | 370 object->IsGlobalObject(); |
371 } | 371 } |
372 #endif | 372 #endif |
373 | 373 |
374 } } // namespace v8::internal | 374 } } // namespace v8::internal |
OLD | NEW |