Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: src/contexts.h

Issue 8139027: Version 3.6.5 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler-intrinsics.h ('k') | src/contexts.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \ 127 V(CALL_AS_FUNCTION_DELEGATE_INDEX, JSFunction, call_as_function_delegate) \
128 V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction, \ 128 V(CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, JSFunction, \
129 call_as_constructor_delegate) \ 129 call_as_constructor_delegate) \
130 V(SCRIPT_FUNCTION_INDEX, JSFunction, script_function) \ 130 V(SCRIPT_FUNCTION_INDEX, JSFunction, script_function) \
131 V(OPAQUE_REFERENCE_FUNCTION_INDEX, JSFunction, opaque_reference_function) \ 131 V(OPAQUE_REFERENCE_FUNCTION_INDEX, JSFunction, opaque_reference_function) \
132 V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \ 132 V(CONTEXT_EXTENSION_FUNCTION_INDEX, JSFunction, context_extension_function) \
133 V(OUT_OF_MEMORY_INDEX, Object, out_of_memory) \ 133 V(OUT_OF_MEMORY_INDEX, Object, out_of_memory) \
134 V(MAP_CACHE_INDEX, Object, map_cache) \ 134 V(MAP_CACHE_INDEX, Object, map_cache) \
135 V(CONTEXT_DATA_INDEX, Object, data) \ 135 V(CONTEXT_DATA_INDEX, Object, data) \
136 V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \ 136 V(ALLOW_CODE_GEN_FROM_STRINGS_INDEX, Object, allow_code_gen_from_strings) \
137 V(TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX, JSFunction, \
138 to_complete_property_descriptor) \
137 V(DERIVED_HAS_TRAP_INDEX, JSFunction, derived_has_trap) \ 139 V(DERIVED_HAS_TRAP_INDEX, JSFunction, derived_has_trap) \
138 V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \ 140 V(DERIVED_GET_TRAP_INDEX, JSFunction, derived_get_trap) \
139 V(DERIVED_SET_TRAP_INDEX, JSFunction, derived_set_trap) 141 V(DERIVED_SET_TRAP_INDEX, JSFunction, derived_set_trap)
140 142
141 // JSFunctions are pairs (context, function code), sometimes also called 143 // JSFunctions are pairs (context, function code), sometimes also called
142 // closures. A Context object is used to represent function contexts and 144 // closures. A Context object is used to represent function contexts and
143 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak). 145 // dynamically pushed 'with' contexts (or 'scopes' in ECMA-262 speak).
144 // 146 //
145 // At runtime, the contexts build a stack in parallel to the execution 147 // At runtime, the contexts build a stack in parallel to the execution
146 // stack, with the top-most context being the current context. All contexts 148 // stack, with the top-most context being the current context. All contexts
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 NORMALIZED_MAP_CACHE_INDEX, 247 NORMALIZED_MAP_CACHE_INDEX,
246 RUNTIME_CONTEXT_INDEX, 248 RUNTIME_CONTEXT_INDEX,
247 CALL_AS_FUNCTION_DELEGATE_INDEX, 249 CALL_AS_FUNCTION_DELEGATE_INDEX,
248 CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, 250 CALL_AS_CONSTRUCTOR_DELEGATE_INDEX,
249 SCRIPT_FUNCTION_INDEX, 251 SCRIPT_FUNCTION_INDEX,
250 OPAQUE_REFERENCE_FUNCTION_INDEX, 252 OPAQUE_REFERENCE_FUNCTION_INDEX,
251 CONTEXT_EXTENSION_FUNCTION_INDEX, 253 CONTEXT_EXTENSION_FUNCTION_INDEX,
252 OUT_OF_MEMORY_INDEX, 254 OUT_OF_MEMORY_INDEX,
253 CONTEXT_DATA_INDEX, 255 CONTEXT_DATA_INDEX,
254 ALLOW_CODE_GEN_FROM_STRINGS_INDEX, 256 ALLOW_CODE_GEN_FROM_STRINGS_INDEX,
257 TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX,
255 DERIVED_HAS_TRAP_INDEX, 258 DERIVED_HAS_TRAP_INDEX,
256 DERIVED_GET_TRAP_INDEX, 259 DERIVED_GET_TRAP_INDEX,
257 DERIVED_SET_TRAP_INDEX, 260 DERIVED_SET_TRAP_INDEX,
258 261
259 // Properties from here are treated as weak references by the full GC. 262 // Properties from here are treated as weak references by the full GC.
260 // Scavenge treats them as strong references. 263 // Scavenge treats them as strong references.
261 OPTIMIZED_FUNCTIONS_LIST, // Weak. 264 OPTIMIZED_FUNCTIONS_LIST, // Weak.
262 MAP_CACHE_INDEX, // Weak. 265 MAP_CACHE_INDEX, // Weak.
263 NEXT_CONTEXT_LINK, // Weak. 266 NEXT_CONTEXT_LINK, // Weak.
264 267
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 Map* map = this->map(); 326 Map* map = this->map();
324 return map == map->GetHeap()->block_context_map(); 327 return map == map->GetHeap()->block_context_map();
325 } 328 }
326 329
327 // Tells whether the global context is marked with out of memory. 330 // Tells whether the global context is marked with out of memory.
328 inline bool has_out_of_memory(); 331 inline bool has_out_of_memory();
329 332
330 // Mark the global context with out of memory. 333 // Mark the global context with out of memory.
331 inline void mark_out_of_memory(); 334 inline void mark_out_of_memory();
332 335
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. 336 // A global context hold a list of all functions which have been optimized.
340 void AddOptimizedFunction(JSFunction* function); 337 void AddOptimizedFunction(JSFunction* function);
341 void RemoveOptimizedFunction(JSFunction* function); 338 void RemoveOptimizedFunction(JSFunction* function);
342 Object* OptimizedFunctionsListHead(); 339 Object* OptimizedFunctionsListHead();
343 void ClearOptimizedFunctions(); 340 void ClearOptimizedFunctions();
344 341
345 #define GLOBAL_CONTEXT_FIELD_ACCESSORS(index, type, name) \ 342 #define GLOBAL_CONTEXT_FIELD_ACCESSORS(index, type, name) \
346 void set_##name(type* value) { \ 343 void set_##name(type* value) { \
347 ASSERT(IsGlobalContext()); \ 344 ASSERT(IsGlobalContext()); \
348 set(index, value); \ 345 set(index, value); \
349 } \ 346 } \
350 type* name() { \ 347 type* name() { \
351 ASSERT(IsGlobalContext()); \ 348 ASSERT(IsGlobalContext()); \
352 return type::cast(get(index)); \ 349 return type::cast(get(index)); \
353 } 350 }
354 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSORS) 351 GLOBAL_CONTEXT_FIELDS(GLOBAL_CONTEXT_FIELD_ACCESSORS)
355 #undef GLOBAL_CONTEXT_FIELD_ACCESSORS 352 #undef GLOBAL_CONTEXT_FIELD_ACCESSORS
356 353
357 // Lookup the the slot called name, starting with the current context. 354 // Lookup the the slot called name, starting with the current context.
358 // There are 4 possible outcomes: 355 // There are three possibilities:
359 // 356 //
360 // 1) index_ >= 0 && result->IsContext(): 357 // 1) result->IsContext():
361 // most common case, the result is a Context, and index is the 358 // The binding was found in a context. *index is always the
362 // context slot index, and the slot exists. 359 // non-negative slot index. *attributes is NONE for var and let
363 // attributes == READ_ONLY for the function name variable, NONE otherwise. 360 // declarations, READ_ONLY for const declarations (never ABSENT).
364 // 361 //
365 // 2) index_ >= 0 && result->IsJSObject(): 362 // 2) result->IsJSObject():
366 // the result is the JSObject arguments object, the index is the parameter 363 // 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. 364 // object (i.e., was introduced via eval), as a property on the subject
368 // attributes != ABSENT. 365 // of with, or as a property of the global object. *index is -1 and
366 // *attributes is not ABSENT.
369 // 367 //
370 // 3) index_ < 0 && result->IsJSObject(): 368 // 3) result.is_null():
371 // the result is the JSObject extension context or the global object, 369 // There was no binding found, *index is always -1 and *attributes is
372 // and the name is the property name, and the property exists. 370 // 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, 371 Handle<Object> Lookup(Handle<String> name,
379 ContextLookupFlags flags, 372 ContextLookupFlags flags,
380 int* index_, 373 int* index,
381 PropertyAttributes* attributes, 374 PropertyAttributes* attributes,
382 BindingFlags* binding_flags); 375 BindingFlags* binding_flags);
383 376
384 // Determine if a local variable with the given name exists in a 377 // Determine if a local variable with the given name exists in a
385 // context. Do not consider context extension objects. This is 378 // context. Do not consider context extension objects. This is
386 // used for compiling code using eval. If the context surrounding 379 // used for compiling code using eval. If the context surrounding
387 // the eval call does not have a local variable with this name and 380 // 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 381 // does not contain a with statement the property is global unless
389 // it is shadowed by a property in an extension object introduced by 382 // it is shadowed by a property in an extension object introduced by
390 // eval. 383 // eval.
(...skipping 27 matching lines...) Expand all
418 #ifdef DEBUG 411 #ifdef DEBUG
419 // Bootstrapping-aware type checks. 412 // Bootstrapping-aware type checks.
420 static bool IsBootstrappingOrContext(Object* object); 413 static bool IsBootstrappingOrContext(Object* object);
421 static bool IsBootstrappingOrGlobalObject(Object* object); 414 static bool IsBootstrappingOrGlobalObject(Object* object);
422 #endif 415 #endif
423 }; 416 };
424 417
425 } } // namespace v8::internal 418 } } // namespace v8::internal
426 419
427 #endif // V8_CONTEXTS_H_ 420 #endif // V8_CONTEXTS_H_
OLDNEW
« no previous file with comments | « src/compiler-intrinsics.h ('k') | src/contexts.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698