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