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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 Map* map = this->map(); | 323 Map* map = this->map(); |
324 return map == map->GetHeap()->block_context_map(); | 324 return map == map->GetHeap()->block_context_map(); |
325 } | 325 } |
326 | 326 |
327 // Tells whether the global context is marked with out of memory. | 327 // Tells whether the global context is marked with out of memory. |
328 inline bool has_out_of_memory(); | 328 inline bool has_out_of_memory(); |
329 | 329 |
330 // Mark the global context with out of memory. | 330 // Mark the global context with out of memory. |
331 inline void mark_out_of_memory(); | 331 inline void mark_out_of_memory(); |
332 | 332 |
| 333 // The exception holder is the object used as a with object in |
| 334 // the implementation of a catch block. |
| 335 bool is_exception_holder(Object* object) { |
| 336 return IsCatchContext() && extension() == object; |
| 337 } |
| 338 |
333 // A global context hold a list of all functions which have been optimized. | 339 // A global context hold a list of all functions which have been optimized. |
334 void AddOptimizedFunction(JSFunction* function); | 340 void AddOptimizedFunction(JSFunction* function); |
335 void RemoveOptimizedFunction(JSFunction* function); | 341 void RemoveOptimizedFunction(JSFunction* function); |
336 Object* OptimizedFunctionsListHead(); | 342 Object* OptimizedFunctionsListHead(); |
337 void ClearOptimizedFunctions(); | 343 void ClearOptimizedFunctions(); |
338 | 344 |
339 #define GLOBAL_CONTEXT_FIELD_ACCESSORS(index, type, name) \ | 345 #define GLOBAL_CONTEXT_FIELD_ACCESSORS(index, type, name) \ |
340 void set_##name(type* value) { \ | 346 void set_##name(type* value) { \ |
341 ASSERT(IsGlobalContext()); \ | 347 ASSERT(IsGlobalContext()); \ |
342 set(index, value); \ | 348 set(index, value); \ |
343 } \ | 349 } \ |
344 type* name() { \ | 350 type* name() { \ |
345 ASSERT(IsGlobalContext()); \ | 351 ASSERT(IsGlobalContext()); \ |
346 return type::cast(get(index)); \ | 352 return type::cast(get(index)); \ |
347 } | 353 } |
348 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSORS) | 354 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSORS) |
349 #undef GLOBAL_CONTEXT_FIELD_ACCESSORS | 355 #undef GLOBAL_CONTEXT_FIELD_ACCESSORS |
350 | 356 |
351 // Lookup the the slot called name, starting with the current context. | 357 // Lookup the the slot called name, starting with the current context. |
352 // There are three possibilities: | 358 // There are 4 possible outcomes: |
353 // | 359 // |
354 // 1) result->IsContext(): | 360 // 1) index_ >= 0 && result->IsContext(): |
355 // The binding was found in a context. *index is always the | 361 // most common case, the result is a Context, and index is the |
356 // non-negative slot index. *attributes is NONE for var and let | 362 // context slot index, and the slot exists. |
357 // declarations, READ_ONLY for const declarations (never ABSENT). | 363 // attributes == READ_ONLY for the function name variable, NONE otherwise. |
358 // | 364 // |
359 // 2) result->IsJSObject(): | 365 // 2) index_ >= 0 && result->IsJSObject(): |
360 // The binding was found as a named property in a context extension | 366 // the result is the JSObject arguments object, the index is the parameter |
361 // object (i.e., was introduced via eval), as a property on the subject | 367 // index, i.e., key into the arguments object, and the property exists. |
362 // of with, or as a property of the global object. *index is -1 and | 368 // attributes != ABSENT. |
363 // *attributes is not ABSENT. | |
364 // | 369 // |
365 // 3) result.is_null(): | 370 // 3) index_ < 0 && result->IsJSObject(): |
366 // There was no binding found, *index is always -1 and *attributes is | 371 // the result is the JSObject extension context or the global object, |
367 // always ABSENT. | 372 // and the name is the property name, and the property exists. |
| 373 // attributes != ABSENT. |
| 374 // |
| 375 // 4) index_ < 0 && result.is_null(): |
| 376 // there was no context found with the corresponding property. |
| 377 // attributes == ABSENT. |
368 Handle<Object> Lookup(Handle<String> name, | 378 Handle<Object> Lookup(Handle<String> name, |
369 ContextLookupFlags flags, | 379 ContextLookupFlags flags, |
370 int* index, | 380 int* index_, |
371 PropertyAttributes* attributes, | 381 PropertyAttributes* attributes, |
372 BindingFlags* binding_flags); | 382 BindingFlags* binding_flags); |
373 | 383 |
374 // Determine if a local variable with the given name exists in a | 384 // Determine if a local variable with the given name exists in a |
375 // context. Do not consider context extension objects. This is | 385 // context. Do not consider context extension objects. This is |
376 // used for compiling code using eval. If the context surrounding | 386 // used for compiling code using eval. If the context surrounding |
377 // the eval call does not have a local variable with this name and | 387 // the eval call does not have a local variable with this name and |
378 // does not contain a with statement the property is global unless | 388 // does not contain a with statement the property is global unless |
379 // it is shadowed by a property in an extension object introduced by | 389 // it is shadowed by a property in an extension object introduced by |
380 // eval. | 390 // eval. |
(...skipping 27 matching lines...) Expand all Loading... |
408 #ifdef DEBUG | 418 #ifdef DEBUG |
409 // Bootstrapping-aware type checks. | 419 // Bootstrapping-aware type checks. |
410 static bool IsBootstrappingOrContext(Object* object); | 420 static bool IsBootstrappingOrContext(Object* object); |
411 static bool IsBootstrappingOrGlobalObject(Object* object); | 421 static bool IsBootstrappingOrGlobalObject(Object* object); |
412 #endif | 422 #endif |
413 }; | 423 }; |
414 | 424 |
415 } } // namespace v8::internal | 425 } } // namespace v8::internal |
416 | 426 |
417 #endif // V8_CONTEXTS_H_ | 427 #endif // V8_CONTEXTS_H_ |
OLD | NEW |