V8 Project
v8::internal::Context Class Reference

#include <contexts.h>

+ Inheritance diagram for v8::internal::Context:
+ Collaboration diagram for v8::internal::Context:

Public Types

enum  {
  CLOSURE_INDEX , PREVIOUS_INDEX , EXTENSION_INDEX , GLOBAL_OBJECT_INDEX ,
  MIN_CONTEXT_SLOTS , THROWN_OBJECT_INDEX = MIN_CONTEXT_SLOTS , GLOBAL_PROXY_INDEX = MIN_CONTEXT_SLOTS , SECURITY_TOKEN_INDEX ,
  SLOPPY_ARGUMENTS_MAP_INDEX , ALIASED_ARGUMENTS_MAP_INDEX , STRICT_ARGUMENTS_MAP_INDEX , REGEXP_RESULT_MAP_INDEX ,
  SLOPPY_FUNCTION_MAP_INDEX , SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX , STRICT_FUNCTION_MAP_INDEX , SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX ,
  STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX , BOUND_FUNCTION_MAP_INDEX , INITIAL_OBJECT_PROTOTYPE_INDEX , INITIAL_ARRAY_PROTOTYPE_INDEX ,
  BOOLEAN_FUNCTION_INDEX , NUMBER_FUNCTION_INDEX , STRING_FUNCTION_INDEX , STRING_FUNCTION_PROTOTYPE_MAP_INDEX ,
  SYMBOL_FUNCTION_INDEX , OBJECT_FUNCTION_INDEX , INTERNAL_ARRAY_FUNCTION_INDEX , ARRAY_FUNCTION_INDEX ,
  JS_ARRAY_MAPS_INDEX , DATE_FUNCTION_INDEX , JSON_OBJECT_INDEX , REGEXP_FUNCTION_INDEX ,
  CREATE_DATE_FUN_INDEX , TO_NUMBER_FUN_INDEX , TO_STRING_FUN_INDEX , TO_DETAIL_STRING_FUN_INDEX ,
  TO_OBJECT_FUN_INDEX , TO_INTEGER_FUN_INDEX , TO_UINT32_FUN_INDEX , TO_INT32_FUN_INDEX ,
  TO_BOOLEAN_FUN_INDEX , GLOBAL_EVAL_FUN_INDEX , INSTANTIATE_FUN_INDEX , CONFIGURE_INSTANCE_FUN_INDEX ,
  MATH_ABS_FUN_INDEX , MATH_ACOS_FUN_INDEX , MATH_ASIN_FUN_INDEX , MATH_ATAN_FUN_INDEX ,
  MATH_ATAN2_FUN_INDEX , MATH_CEIL_FUN_INDEX , MATH_COS_FUN_INDEX , MATH_EXP_FUN_INDEX ,
  MATH_FLOOR_FUN_INDEX , MATH_IMUL_FUN_INDEX , MATH_LOG_FUN_INDEX , MATH_MAX_FUN_INDEX ,
  MATH_MIN_FUN_INDEX , MATH_POW_FUN_INDEX , MATH_RANDOM_FUN_INDEX , MATH_ROUND_FUN_INDEX ,
  MATH_SIN_FUN_INDEX , MATH_SQRT_FUN_INDEX , MATH_TAN_FUN_INDEX , ARRAY_BUFFER_FUN_INDEX ,
  UINT8_ARRAY_FUN_INDEX , INT8_ARRAY_FUN_INDEX , UINT16_ARRAY_FUN_INDEX , INT16_ARRAY_FUN_INDEX ,
  UINT32_ARRAY_FUN_INDEX , INT32_ARRAY_FUN_INDEX , FLOAT32_ARRAY_FUN_INDEX , FLOAT64_ARRAY_FUN_INDEX ,
  UINT8_CLAMPED_ARRAY_FUN_INDEX , INT8_ARRAY_EXTERNAL_MAP_INDEX , UINT8_ARRAY_EXTERNAL_MAP_INDEX , INT16_ARRAY_EXTERNAL_MAP_INDEX ,
  UINT16_ARRAY_EXTERNAL_MAP_INDEX , INT32_ARRAY_EXTERNAL_MAP_INDEX , UINT32_ARRAY_EXTERNAL_MAP_INDEX , FLOAT32_ARRAY_EXTERNAL_MAP_INDEX ,
  FLOAT64_ARRAY_EXTERNAL_MAP_INDEX , UINT8_CLAMPED_ARRAY_EXTERNAL_MAP_INDEX , DATA_VIEW_FUN_INDEX , MESSAGE_LISTENERS_INDEX ,
  MAKE_MESSAGE_FUN_INDEX , GET_STACK_TRACE_LINE_INDEX , CONFIGURE_GLOBAL_INDEX , FUNCTION_CACHE_INDEX ,
  JSFUNCTION_RESULT_CACHES_INDEX , NORMALIZED_MAP_CACHE_INDEX , RUNTIME_CONTEXT_INDEX , CALL_AS_FUNCTION_DELEGATE_INDEX ,
  CALL_AS_CONSTRUCTOR_DELEGATE_INDEX , SCRIPT_FUNCTION_INDEX , OPAQUE_REFERENCE_FUNCTION_INDEX , CONTEXT_EXTENSION_FUNCTION_INDEX ,
  OUT_OF_MEMORY_INDEX , EMBEDDER_DATA_INDEX , ALLOW_CODE_GEN_FROM_STRINGS_INDEX , ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX ,
  RUN_MICROTASKS_INDEX , ENQUEUE_MICROTASK_INDEX , IS_PROMISE_INDEX , PROMISE_CREATE_INDEX ,
  PROMISE_RESOLVE_INDEX , PROMISE_REJECT_INDEX , PROMISE_CHAIN_INDEX , PROMISE_CATCH_INDEX ,
  PROMISE_THEN_INDEX , TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX , DERIVED_HAS_TRAP_INDEX , DERIVED_GET_TRAP_INDEX ,
  DERIVED_SET_TRAP_INDEX , PROXY_ENUMERATE_INDEX , OBSERVERS_NOTIFY_CHANGE_INDEX , OBSERVERS_ENQUEUE_SPLICE_INDEX ,
  OBSERVERS_BEGIN_SPLICE_INDEX , OBSERVERS_END_SPLICE_INDEX , NATIVE_OBJECT_OBSERVE_INDEX , NATIVE_OBJECT_GET_NOTIFIER_INDEX ,
  NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE , SLOPPY_GENERATOR_FUNCTION_MAP_INDEX , STRICT_GENERATOR_FUNCTION_MAP_INDEX , GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX ,
  ITERATOR_RESULT_MAP_INDEX , MAP_ITERATOR_MAP_INDEX , SET_ITERATOR_MAP_INDEX , ITERATOR_SYMBOL_INDEX ,
  UNSCOPABLES_SYMBOL_INDEX , ARRAY_VALUES_ITERATOR_INDEX , OPTIMIZED_FUNCTIONS_LIST , OPTIMIZED_CODE_LIST ,
  DEOPTIMIZED_CODE_LIST , MAP_CACHE_INDEX , NEXT_CONTEXT_LINK , NATIVE_CONTEXT_SLOTS ,
  FIRST_WEAK_SLOT = OPTIMIZED_FUNCTIONS_LIST
}
 
typedef FixedBodyDescriptor< kHeaderSize, kSize, kSizeScavengeBodyDescriptor
 
typedef FixedBodyDescriptor< kHeaderSize, kHeaderSize+FIRST_WEAK_SLOT *kPointerSize, kSizeMarkCompactBodyDescriptor
 
- Public Types inherited from v8::internal::Object
enum  StoreFromKeyed { MAY_BE_STORE_FROM_KEYED , CERTAINLY_NOT_STORE_FROM_KEYED }
 
enum  StorePropertyMode { NORMAL_PROPERTY , SUPER_PROPERTY }
 

Public Member Functions

JSFunctionclosure ()
 
void set_closure (JSFunction *closure)
 
Contextprevious ()
 
void set_previous (Context *context)
 
bool has_extension ()
 
Objectextension ()
 
void set_extension (Object *object)
 
JSModulemodule ()
 
void set_module (JSModule *module)
 
Contextdeclaration_context ()
 
GlobalObjectglobal_object ()
 
void set_global_object (GlobalObject *object)
 
JSObjectglobal_proxy ()
 
void set_global_proxy (JSObject *global)
 
JSBuiltinsObjectbuiltins ()
 
Contextglobal_context ()
 
Contextnative_context ()
 
bool IsNativeContext ()
 
bool IsFunctionContext ()
 
bool IsCatchContext ()
 
bool IsWithContext ()
 
bool IsBlockContext ()
 
bool IsModuleContext ()
 
bool IsGlobalContext ()
 
bool HasSameSecurityTokenAs (Context *that)
 
void AddOptimizedFunction (JSFunction *function)
 
void RemoveOptimizedFunction (JSFunction *function)
 
void SetOptimizedFunctionsListHead (Object *head)
 
ObjectOptimizedFunctionsListHead ()
 
void AddOptimizedCode (Code *code)
 
void SetOptimizedCodeListHead (Object *head)
 
ObjectOptimizedCodeListHead ()
 
void SetDeoptimizedCodeListHead (Object *head)
 
ObjectDeoptimizedCodeListHead ()
 
Handle< ObjectErrorMessageForCodeGenerationFromStrings ()
 
Handle< ObjectLookup (Handle< String > name, ContextLookupFlags flags, int *index, PropertyAttributes *attributes, BindingFlags *binding_flags)
 
- Public Member Functions inherited from v8::internal::FixedArray
Objectget (int index)
 
void set (int index, Object *value)
 
bool is_the_hole (int index)
 
void set (int index, Smi *value)
 
void set (int index, Object *value, WriteBarrierMode mode)
 
void set_undefined (int index)
 
void set_null (int index)
 
void set_the_hole (int index)
 
Object ** GetFirstElementAddress ()
 
bool ContainsOnlySmisOrHoles ()
 
Object ** data_start ()
 
void FillWithHoles (int from, int to)
 
void Shrink (int length)
 
void CopyTo (int pos, FixedArray *dest, int dest_pos, int len)
 
Object ** RawFieldOfElementAt (int index)
 
void SwapPairs (FixedArray *numbers, int i, int j)
 
void SortPairs (FixedArray *numbers, uint32_t len)
 
- Public Member Functions inherited from v8::internal::FixedArrayBase
int length () const
 
void set_length (int value)
 
int synchronized_length () const
 
void synchronized_set_length (int value)
 
- Public Member Functions inherited from v8::internal::HeapObject
Mapmap () const
 
void set_map (Map *value)
 
void set_map_no_write_barrier (Map *value)
 
Mapsynchronized_map ()
 
MapWord synchronized_map_word () const
 
void synchronized_set_map (Map *value)
 
void synchronized_set_map_no_write_barrier (Map *value)
 
void synchronized_set_map_word (MapWord map_word)
 
MapWord map_word () const
 
void set_map_word (MapWord map_word)
 
HeapGetHeap () const
 
IsolateGetIsolate () const
 
Address address ()
 
void Iterate (ObjectVisitor *v)
 
void IterateBody (InstanceType type, int object_size, ObjectVisitor *v)
 
int Size ()
 
bool MayContainRawValues ()
 
int SizeFromMap (Map *map)
 
WriteBarrierMode GetWriteBarrierMode (const DisallowHeapAllocation &promise)
 
void HeapObjectShortPrint (OStream &os)
 
 STATIC_ASSERT (kMapOffset==Internals::kHeapObjectMapOffset)
 
- Public Member Functions inherited from v8::internal::Object
bool IsObject () const
 
 INLINE (bool IsFixedArrayBase() const)
 
 INLINE (bool IsExternal() const)
 
 INLINE (bool IsAccessorInfo() const)
 
 INLINE (bool IsStruct() const)
 
 INLINE (bool IsSpecObject()) const
 
 INLINE (bool IsSpecFunction()) const
 
 INLINE (bool IsTemplateInfo()) const
 
 INLINE (bool IsNameDictionary() const)
 
 INLINE (bool IsSeededNumberDictionary() const)
 
 INLINE (bool IsUnseededNumberDictionary() const)
 
 INLINE (bool IsOrderedHashSet() const)
 
 INLINE (bool IsOrderedHashMap() const)
 
bool IsCallable () const
 
 INLINE (bool IsUndefined() const)
 
 INLINE (bool IsNull() const)
 
 INLINE (bool IsTheHole() const)
 
 INLINE (bool IsException() const)
 
 INLINE (bool IsUninitialized() const)
 
 INLINE (bool IsTrue() const)
 
 INLINE (bool IsFalse() const)
 
 INLINE (bool IsArgumentsMarker() const)
 
 INLINE (bool IsFiller() const)
 
double Number ()
 
 INLINE (bool IsNaN() const)
 
 INLINE (bool IsMinusZero() const)
 
bool ToInt32 (int32_t *value)
 
bool ToUint32 (uint32_t *value)
 
Representation OptimalRepresentation ()
 
bool FitsRepresentation (Representation representation)
 
Handle< HeapTypeOptimalType (Isolate *isolate, Representation representation)
 
bool HasValidElements ()
 
bool HasSpecificClassOf (String *name)
 
bool BooleanValue ()
 
ObjectGetHash ()
 
bool SameValue (Object *other)
 
bool SameValueZero (Object *other)
 
bool ToArrayIndex (uint32_t *index)
 
bool IsStringObjectWithCharacterAt (uint32_t index)
 
void VerifyApiCallResultType ()
 
void ShortPrint (FILE *out=stdout)
 
void ShortPrint (StringStream *accumulator)
 

Static Public Member Functions

static Contextcast (Object *context)
 
static int SlotOffset (int index)
 
static int FunctionMapIndex (StrictMode strict_mode, FunctionKind kind)
 
- Static Public Member Functions inherited from v8::internal::FixedArray
static Handle< Objectget (Handle< FixedArray > array, int index)
 
static Handle< FixedArrayCopySize (Handle< FixedArray > array, int new_length, PretenureFlag pretenure=NOT_TENURED)
 
static MUST_USE_RESULT MaybeHandle< FixedArrayAddKeysFromArrayLike (Handle< FixedArray > content, Handle< JSObject > array)
 
static MUST_USE_RESULT MaybeHandle< FixedArrayUnionOfKeys (Handle< FixedArray > first, Handle< FixedArray > second)
 
static int SizeFor (int length)
 
static int OffsetOfElementAt (int index)
 
- Static Public Member Functions inherited from v8::internal::HeapObject
static HeapObjectFromAddress (Address address)
 
static Object ** RawField (HeapObject *obj, int offset)
 
static void UpdateMapCodeCache (Handle< HeapObject > object, Handle< Name > name, Handle< Code > code)
 
- Static Public Member Functions inherited from v8::internal::Object
static Handle< ObjectNewStorageFor (Isolate *isolate, Handle< Object > object, Representation representation)
 
static Handle< ObjectWrapForRead (Isolate *isolate, Handle< Object > object, Representation representation)
 
static MaybeHandle< JSReceiverToObject (Isolate *isolate, Handle< Object > object)
 
static MaybeHandle< JSReceiverToObject (Isolate *isolate, Handle< Object > object, Handle< Context > context)
 
static MUST_USE_RESULT MaybeHandle< SmiToSmi (Isolate *isolate, Handle< Object > object)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (LookupIterator *it)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetProperty (Handle< Object > object, Handle< Name > key, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetProperty (LookupIterator *it, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode, StorePropertyMode data_store_mode=NORMAL_PROPERTY)
 
static MUST_USE_RESULT MaybeHandle< ObjectWriteToReadOnlyProperty (LookupIterator *it, Handle< Object > value, StrictMode strict_mode)
 
static Handle< ObjectSetDataProperty (LookupIterator *it, Handle< Object > value)
 
static MUST_USE_RESULT MaybeHandle< ObjectAddDataProperty (LookupIterator *it, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyOrElement (Handle< Object > object, Handle< Name > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (Isolate *isolate, Handle< Object > object, const char *key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (Handle< Object > object, Handle< Name > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyWithAccessor (Handle< Object > receiver, Handle< Name > name, Handle< JSObject > holder, Handle< Object > structure)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetPropertyWithAccessor (Handle< Object > receiver, Handle< Name > name, Handle< Object > value, Handle< JSObject > holder, Handle< Object > structure, StrictMode strict_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyWithDefinedGetter (Handle< Object > receiver, Handle< JSReceiver > getter)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetPropertyWithDefinedSetter (Handle< Object > receiver, Handle< JSReceiver > setter, Handle< Object > value)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElement (Isolate *isolate, Handle< Object > object, uint32_t index)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElementWithReceiver (Isolate *isolate, Handle< Object > object, Handle< Object > receiver, uint32_t index)
 
static Handle< SmiGetOrCreateHash (Isolate *isolate, Handle< Object > object)
 

Static Public Attributes

static const int kSize = kHeaderSize + NATIVE_CONTEXT_SLOTS * kPointerSize
 
- Static Public Attributes inherited from v8::internal::FixedArray
static const int kMaxSize = 128 * MB * kPointerSize
 
static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize
 
- Static Public Attributes inherited from v8::internal::FixedArrayBase
static const int kLengthOffset = HeapObject::kHeaderSize
 
static const int kHeaderSize = kLengthOffset + kPointerSize
 
- Static Public Attributes inherited from v8::internal::HeapObject
static const int kMapOffset = Object::kHeaderSize
 
static const int kHeaderSize = kMapOffset + kPointerSize
 
- Static Public Attributes inherited from v8::internal::Object
static const int kHeaderSize = 0
 

Private Member Functions

Objectunchecked_previous ()
 
 STATIC_ASSERT (kHeaderSize==Internals::kContextHeaderSize)
 
 STATIC_ASSERT (EMBEDDER_DATA_INDEX==Internals::kContextEmbedderDataIndex)
 

Additional Inherited Members

- Protected Member Functions inherited from v8::internal::HeapObject
void IteratePointers (ObjectVisitor *v, int start, int end)
 
void IteratePointer (ObjectVisitor *v, int offset)
 
void IterateNextCodeLink (ObjectVisitor *v, int offset)
 
- Static Protected Member Functions inherited from v8::internal::FixedArray
static void NoWriteBarrierSet (FixedArray *array, int index, Object *value)
 
static void NoIncrementalWriteBarrierSet (FixedArray *array, int index, Object *value)
 

Detailed Description

Definition at line 252 of file contexts.h.

Member Typedef Documentation

◆ MarkCompactBodyDescriptor

◆ ScavengeBodyDescriptor

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
CLOSURE_INDEX 
PREVIOUS_INDEX 
EXTENSION_INDEX 
GLOBAL_OBJECT_INDEX 
MIN_CONTEXT_SLOTS 
THROWN_OBJECT_INDEX 
GLOBAL_PROXY_INDEX 
SECURITY_TOKEN_INDEX 
SLOPPY_ARGUMENTS_MAP_INDEX 
ALIASED_ARGUMENTS_MAP_INDEX 
STRICT_ARGUMENTS_MAP_INDEX 
REGEXP_RESULT_MAP_INDEX 
SLOPPY_FUNCTION_MAP_INDEX 
SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX 
STRICT_FUNCTION_MAP_INDEX 
SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX 
STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX 
BOUND_FUNCTION_MAP_INDEX 
INITIAL_OBJECT_PROTOTYPE_INDEX 
INITIAL_ARRAY_PROTOTYPE_INDEX 
BOOLEAN_FUNCTION_INDEX 
NUMBER_FUNCTION_INDEX 
STRING_FUNCTION_INDEX 
STRING_FUNCTION_PROTOTYPE_MAP_INDEX 
SYMBOL_FUNCTION_INDEX 
OBJECT_FUNCTION_INDEX 
INTERNAL_ARRAY_FUNCTION_INDEX 
ARRAY_FUNCTION_INDEX 
JS_ARRAY_MAPS_INDEX 
DATE_FUNCTION_INDEX 
JSON_OBJECT_INDEX 
REGEXP_FUNCTION_INDEX 
CREATE_DATE_FUN_INDEX 
TO_NUMBER_FUN_INDEX 
TO_STRING_FUN_INDEX 
TO_DETAIL_STRING_FUN_INDEX 
TO_OBJECT_FUN_INDEX 
TO_INTEGER_FUN_INDEX 
TO_UINT32_FUN_INDEX 
TO_INT32_FUN_INDEX 
TO_BOOLEAN_FUN_INDEX 
GLOBAL_EVAL_FUN_INDEX 
INSTANTIATE_FUN_INDEX 
CONFIGURE_INSTANCE_FUN_INDEX 
MATH_ABS_FUN_INDEX 
MATH_ACOS_FUN_INDEX 
MATH_ASIN_FUN_INDEX 
MATH_ATAN_FUN_INDEX 
MATH_ATAN2_FUN_INDEX 
MATH_CEIL_FUN_INDEX 
MATH_COS_FUN_INDEX 
MATH_EXP_FUN_INDEX 
MATH_FLOOR_FUN_INDEX 
MATH_IMUL_FUN_INDEX 
MATH_LOG_FUN_INDEX 
MATH_MAX_FUN_INDEX 
MATH_MIN_FUN_INDEX 
MATH_POW_FUN_INDEX 
MATH_RANDOM_FUN_INDEX 
MATH_ROUND_FUN_INDEX 
MATH_SIN_FUN_INDEX 
MATH_SQRT_FUN_INDEX 
MATH_TAN_FUN_INDEX 
ARRAY_BUFFER_FUN_INDEX 
UINT8_ARRAY_FUN_INDEX 
INT8_ARRAY_FUN_INDEX 
UINT16_ARRAY_FUN_INDEX 
INT16_ARRAY_FUN_INDEX 
UINT32_ARRAY_FUN_INDEX 
INT32_ARRAY_FUN_INDEX 
FLOAT32_ARRAY_FUN_INDEX 
FLOAT64_ARRAY_FUN_INDEX 
UINT8_CLAMPED_ARRAY_FUN_INDEX 
INT8_ARRAY_EXTERNAL_MAP_INDEX 
UINT8_ARRAY_EXTERNAL_MAP_INDEX 
INT16_ARRAY_EXTERNAL_MAP_INDEX 
UINT16_ARRAY_EXTERNAL_MAP_INDEX 
INT32_ARRAY_EXTERNAL_MAP_INDEX 
UINT32_ARRAY_EXTERNAL_MAP_INDEX 
FLOAT32_ARRAY_EXTERNAL_MAP_INDEX 
FLOAT64_ARRAY_EXTERNAL_MAP_INDEX 
UINT8_CLAMPED_ARRAY_EXTERNAL_MAP_INDEX 
DATA_VIEW_FUN_INDEX 
MESSAGE_LISTENERS_INDEX 
MAKE_MESSAGE_FUN_INDEX 
GET_STACK_TRACE_LINE_INDEX 
CONFIGURE_GLOBAL_INDEX 
FUNCTION_CACHE_INDEX 
JSFUNCTION_RESULT_CACHES_INDEX 
NORMALIZED_MAP_CACHE_INDEX 
RUNTIME_CONTEXT_INDEX 
CALL_AS_FUNCTION_DELEGATE_INDEX 
CALL_AS_CONSTRUCTOR_DELEGATE_INDEX 
SCRIPT_FUNCTION_INDEX 
OPAQUE_REFERENCE_FUNCTION_INDEX 
CONTEXT_EXTENSION_FUNCTION_INDEX 
OUT_OF_MEMORY_INDEX 
EMBEDDER_DATA_INDEX 
ALLOW_CODE_GEN_FROM_STRINGS_INDEX 
ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX 
RUN_MICROTASKS_INDEX 
ENQUEUE_MICROTASK_INDEX 
IS_PROMISE_INDEX 
PROMISE_CREATE_INDEX 
PROMISE_RESOLVE_INDEX 
PROMISE_REJECT_INDEX 
PROMISE_CHAIN_INDEX 
PROMISE_CATCH_INDEX 
PROMISE_THEN_INDEX 
TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX 
DERIVED_HAS_TRAP_INDEX 
DERIVED_GET_TRAP_INDEX 
DERIVED_SET_TRAP_INDEX 
PROXY_ENUMERATE_INDEX 
OBSERVERS_NOTIFY_CHANGE_INDEX 
OBSERVERS_ENQUEUE_SPLICE_INDEX 
OBSERVERS_BEGIN_SPLICE_INDEX 
OBSERVERS_END_SPLICE_INDEX 
NATIVE_OBJECT_OBSERVE_INDEX 
NATIVE_OBJECT_GET_NOTIFIER_INDEX 
NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE 
SLOPPY_GENERATOR_FUNCTION_MAP_INDEX 
STRICT_GENERATOR_FUNCTION_MAP_INDEX 
GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX 
ITERATOR_RESULT_MAP_INDEX 
MAP_ITERATOR_MAP_INDEX 
SET_ITERATOR_MAP_INDEX 
ITERATOR_SYMBOL_INDEX 
UNSCOPABLES_SYMBOL_INDEX 
ARRAY_VALUES_ITERATOR_INDEX 
OPTIMIZED_FUNCTIONS_LIST 
OPTIMIZED_CODE_LIST 
DEOPTIMIZED_CODE_LIST 
MAP_CACHE_INDEX 
NEXT_CONTEXT_LINK 
NATIVE_CONTEXT_SLOTS 
FIRST_WEAK_SLOT 

Definition at line 261 of file contexts.h.

261  {
262  // These slots are in all contexts.
265  // The extension slot is used for either the global object (in global
266  // contexts), eval extension object (function contexts), subject of with
267  // (with contexts), or the variable name (catch contexts), the serialized
268  // scope info (block contexts), or the module instance (module contexts).
272 
273  // This slot holds the thrown value in catch contexts.
275 
276  // These slots are only in native contexts.
401 
402  // Properties from here are treated as weak references by the full GC.
403  // Scavenge treats them as strong references.
404  OPTIMIZED_FUNCTIONS_LIST, // Weak.
405  OPTIMIZED_CODE_LIST, // Weak.
406  DEOPTIMIZED_CODE_LIST, // Weak.
407  MAP_CACHE_INDEX, // Weak.
408  NEXT_CONTEXT_LINK, // Weak.
409 
410  // Total number of slots.
413  };
@ CONTEXT_EXTENSION_FUNCTION_INDEX
Definition: contexts.h:366
@ UINT8_CLAMPED_ARRAY_EXTERNAL_MAP_INDEX
Definition: contexts.h:352
@ SLOPPY_GENERATOR_FUNCTION_MAP_INDEX
Definition: contexts.h:392
@ ERROR_MESSAGE_FOR_CODE_GEN_FROM_STRINGS_INDEX
Definition: contexts.h:370
@ STRING_FUNCTION_PROTOTYPE_MAP_INDEX
Definition: contexts.h:294
@ STRICT_GENERATOR_FUNCTION_MAP_INDEX
Definition: contexts.h:393
@ GENERATOR_OBJECT_PROTOTYPE_MAP_INDEX
Definition: contexts.h:394
@ SLOPPY_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX
Definition: contexts.h:284
@ STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX
Definition: contexts.h:287
@ TO_COMPLETE_PROPERTY_DESCRIPTOR_INDEX
Definition: contexts.h:380
@ ALLOW_CODE_GEN_FROM_STRINGS_INDEX
Definition: contexts.h:369
@ NATIVE_OBJECT_NOTIFIER_PERFORM_CHANGE
Definition: contexts.h:391
@ CALL_AS_CONSTRUCTOR_DELEGATE_INDEX
Definition: contexts.h:363
@ NATIVE_OBJECT_GET_NOTIFIER_INDEX
Definition: contexts.h:390
@ SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX
Definition: contexts.h:286
@ FLOAT32_ARRAY_EXTERNAL_MAP_INDEX
Definition: contexts.h:350
@ FLOAT64_ARRAY_EXTERNAL_MAP_INDEX
Definition: contexts.h:351

Member Function Documentation

◆ AddOptimizedCode()

void v8::internal::Context::AddOptimizedCode ( Code code)

Definition at line 354 of file contexts.cc.

354  {
356  DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION);
357  DCHECK(code->next_code_link()->IsUndefined());
358  code->set_next_code_link(get(OPTIMIZED_CODE_LIST));
359  set(OPTIMIZED_CODE_LIST, code);
360 }
Object * get(int index)
Definition: objects-inl.h:2165
void set(int index, Object *value)
Definition: objects-inl.h:2190
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, v8::internal::FixedArray::get(), IsNativeContext(), v8::internal::Code::kind(), OPTIMIZED_CODE_LIST, and v8::internal::FixedArray::set().

+ Here is the call graph for this function:

◆ AddOptimizedFunction()

void v8::internal::Context::AddOptimizedFunction ( JSFunction function)

Definition at line 280 of file contexts.cc.

280  {
282 #ifdef ENABLE_SLOW_DCHECKS
284  Object* element = get(OPTIMIZED_FUNCTIONS_LIST);
285  while (!element->IsUndefined()) {
286  CHECK(element != function);
287  element = JSFunction::cast(element)->next_function_link();
288  }
289  }
290 
291  // Check that the context belongs to the weak native contexts list.
292  bool found = false;
293  Object* context = GetHeap()->native_contexts_list();
294  while (!context->IsUndefined()) {
295  if (context == this) {
296  found = true;
297  break;
298  }
299  context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
300  }
301  CHECK(found);
302 #endif
303 
304  // If the function link field is already used then the function was
305  // enqueued as a code flushing candidate and we remove it now.
306  if (!function->next_function_link()->IsUndefined()) {
307  CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher();
308  flusher->EvictCandidate(function);
309  }
310 
311  DCHECK(function->next_function_link()->IsUndefined());
312 
313  function->set_next_function_link(get(OPTIMIZED_FUNCTIONS_LIST));
314  set(OPTIMIZED_FUNCTIONS_LIST, function);
315 }
void EvictCandidate(SharedFunctionInfo *shared_info)
static Context * cast(Object *context)
Definition: contexts.h:255
Heap * GetHeap() const
Definition: objects-inl.h:1379
Object * native_contexts_list() const
Definition: heap.h:793
MarkCompactCollector * mark_compact_collector()
Definition: heap.h:1197
#define CHECK(condition)
Definition: logging.h:36
kSerializedDataOffset Object
Definition: objects-inl.h:5322
const bool FLAG_enable_slow_asserts
Definition: checks.h:31

References cast(), CHECK, v8::internal::MarkCompactCollector::code_flusher(), DCHECK, v8::internal::CodeFlusher::EvictCandidate(), v8::internal::FLAG_enable_slow_asserts, v8::internal::FixedArray::get(), v8::internal::HeapObject::GetHeap(), IsNativeContext(), v8::internal::Heap::mark_compact_collector(), v8::internal::Heap::native_contexts_list(), NEXT_CONTEXT_LINK, OPTIMIZED_FUNCTIONS_LIST, and v8::internal::FixedArray::set().

Referenced by v8::internal::JSFunction::ReplaceCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ builtins()

JSBuiltinsObject * v8::internal::Context::builtins ( )

Definition at line 24 of file contexts.cc.

24  {
25  GlobalObject* object = global_object();
26  if (object->IsJSGlobalObject()) {
27  return JSGlobalObject::cast(object)->builtins();
28  } else {
29  DCHECK(object->IsJSBuiltinsObject());
30  return JSBuiltinsObject::cast(object);
31  }
32 }
GlobalObject * global_object()
Definition: contexts.h:437

References DCHECK, and global_object().

Referenced by v8::internal::TypeFeedbackOracle::CanRetainOtherContext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cast()

static Context* v8::internal::Context::cast ( Object context)
inlinestatic

Definition at line 255 of file contexts.h.

255  {
256  DCHECK(context->IsContext());
257  return reinterpret_cast<Context*>(context);
258  }

References DCHECK.

Referenced by AddOptimizedFunction(), v8::internal::Heap::ClearJSFunctionResultCaches(), v8::internal::Heap::ClearNormalizedMapCaches(), v8::internal::JSFunction::context(), v8::internal::Deoptimizer::DeoptimizeAll(), v8::internal::Deoptimizer::DeoptimizeMarkedCode(), v8::internal::V8HeapExplorer::ExtractReferencesPass2(), v8::internal::Isolate::GetCallingNativeContext(), v8::internal::Deoptimizer::GetDeoptimizedCodeCount(), v8::internal::SloppyArgumentsElementsAccessor::GetImpl(), v8::internal::IncrementalMarking::Hurry(), v8::internal::IsValidNonBuiltinContext(), v8::internal::LoadLookupSlotHelper(), v8::internal::MaterializeLocalContext(), v8::internal::MayAccessPreCheck(), v8::internal::ModuleGetExport(), v8::internal::ModuleSetExport(), native_context(), v8::internal::JSFunction::NativeContextFromLiterals(), v8::internal::Snapshot::NewContextFromSnapshot(), v8::internal::JavaScriptFrame::Print(), v8::internal::RUNTIME_FUNCTION(), v8::internal::JSObject::SetDictionaryElement(), v8::internal::JSObject::SetElementWithoutInterceptor(), v8::internal::V8HeapExplorer::SetGcSubrootReference(), v8::internal::SetLocalVariableValue(), v8::internal::Deoptimizer::VisitAllOptimizedFunctions(), v8::internal::IncrementalMarkingMarkingVisitor::VisitNativeContextIncremental(), and v8::internal::GlobalObjectsEnumerator::VisitPointers().

+ Here is the caller graph for this function:

◆ closure()

JSFunction* v8::internal::Context::closure ( )
inline

Definition at line 416 of file contexts.h.

416 { return JSFunction::cast(get(CLOSURE_INDEX)); }

References CLOSURE_INDEX, and v8::internal::FixedArray::get().

Referenced by declaration_context(), v8::internal::Scope::DeserializeScopeChain(), v8::internal::V8HeapExplorer::ExtractContextReferences(), native_context(), v8::internal::RUNTIME_FUNCTION(), and set_closure().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ declaration_context()

Context * v8::internal::Context::declaration_context ( )

Definition at line 14 of file contexts.cc.

14  {
15  Context* current = this;
16  while (!current->IsFunctionContext() && !current->IsNativeContext()) {
17  current = current->previous();
18  DCHECK(current->closure() == closure());
19  }
20  return current;
21 }
JSFunction * closure()
Definition: contexts.h:416

References closure(), DCHECK, IsFunctionContext(), IsNativeContext(), and previous().

Referenced by v8::internal::V8HeapExplorer::ExtractContextReferences(), and v8::internal::RUNTIME_FUNCTION().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeoptimizedCodeListHead()

Object * v8::internal::Context::DeoptimizedCodeListHead ( )

Definition at line 381 of file contexts.cc.

381  {
383  return get(DEOPTIMIZED_CODE_LIST);
384 }

References DCHECK, DEOPTIMIZED_CODE_LIST, v8::internal::FixedArray::get(), and IsNativeContext().

Referenced by v8::internal::Deoptimizer::DeoptimizeMarkedCodeForContext(), v8::internal::Deoptimizer::FindDeoptimizingCode(), and v8::internal::Deoptimizer::GetDeoptimizedCodeCount().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ErrorMessageForCodeGenerationFromStrings()

Handle< Object > v8::internal::Context::ErrorMessageForCodeGenerationFromStrings ( )

Definition at line 387 of file contexts.cc.

387  {
388  Isolate* isolate = GetIsolate();
389  Handle<Object> result(error_message_for_code_gen_from_strings(), isolate);
390  if (!result->IsUndefined()) return result;
391  return isolate->factory()->NewStringFromStaticChars(
392  "Code generation from strings disallowed for this context");
393 }
Isolate * GetIsolate() const
Definition: objects-inl.h:1387

References v8::internal::Isolate::factory(), and v8::internal::HeapObject::GetIsolate().

+ Here is the call graph for this function:

◆ extension()

Object* v8::internal::Context::extension ( )
inline

Definition at line 427 of file contexts.h.

427 { return get(EXTENSION_INDEX); }

References EXTENSION_INDEX, and v8::internal::FixedArray::get().

Referenced by v8::internal::Scope::DeserializeScopeChain(), has_extension(), and v8::internal::JSObject::ReferencesObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FunctionMapIndex()

static int v8::internal::Context::FunctionMapIndex ( StrictMode  strict_mode,
FunctionKind  kind 
)
inlinestatic

Definition at line 556 of file contexts.h.

556  {
557  if (IsGeneratorFunction(kind)) {
558  return strict_mode == SLOPPY ? SLOPPY_GENERATOR_FUNCTION_MAP_INDEX
560  }
561 
562  if (IsArrowFunction(kind) || IsConciseMethod(kind)) {
563  return strict_mode == SLOPPY
566  }
567 
568  return strict_mode == SLOPPY ? SLOPPY_FUNCTION_MAP_INDEX
570  }
bool IsArrowFunction(FunctionKind kind)
Definition: globals.h:793
bool IsGeneratorFunction(FunctionKind kind)
Definition: globals.h:799
bool IsConciseMethod(FunctionKind kind)
Definition: globals.h:805

References v8::internal::IsArrowFunction(), v8::internal::IsConciseMethod(), v8::internal::IsGeneratorFunction(), v8::internal::SLOPPY, SLOPPY_FUNCTION_MAP_INDEX, SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, SLOPPY_GENERATOR_FUNCTION_MAP_INDEX, STRICT_FUNCTION_MAP_INDEX, STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, and STRICT_GENERATOR_FUNCTION_MAP_INDEX.

Referenced by v8::internal::CodeStubGraphBuilder< Stub >::BuildCodeStub().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ global_context()

Context * v8::internal::Context::global_context ( )

Definition at line 35 of file contexts.cc.

35  {
36  Context* current = this;
37  while (!current->IsGlobalContext()) {
38  current = current->previous();
39  }
40  return current;
41 }

References IsGlobalContext(), and previous().

Referenced by v8::internal::RUNTIME_FUNCTION().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ global_object()

GlobalObject* v8::internal::Context::global_object ( )
inline

Definition at line 437 of file contexts.h.

437  {
438  Object* result = get(GLOBAL_OBJECT_INDEX);
439  DCHECK(IsBootstrappingOrGlobalObject(this->GetIsolate(), result));
440  return reinterpret_cast<GlobalObject*>(result);
441  }

References DCHECK, v8::internal::FixedArray::get(), v8::internal::HeapObject::GetIsolate(), and GLOBAL_OBJECT_INDEX.

Referenced by builtins(), v8::internal::TypeFeedbackOracle::CanRetainOtherContext(), HasSameSecurityTokenAs(), v8::internal::JSFunction::IsBuiltin(), v8::internal::IsValidNonBuiltinContext(), v8::internal::MayAccessPreCheck(), native_context(), v8::internal::RUNTIME_FUNCTION(), and v8::internal::V8HeapExplorer::SetGcSubrootReference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ global_proxy()

JSObject * v8::internal::Context::global_proxy ( )

Definition at line 64 of file contexts.cc.

64  {
65  return native_context()->global_proxy_object();
66 }
Context * native_context()
Definition: contexts.cc:44

References native_context().

Referenced by v8::internal::Isolate::global_proxy(), v8::internal::JSFunction::global_proxy(), and v8::internal::GlobalObjectsEnumerator::VisitPointers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has_extension()

bool v8::internal::Context::has_extension ( )
inline

Definition at line 426 of file contexts.h.

426 { return extension() != NULL; }
Object * extension()
Definition: contexts.h:427
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL

References extension(), and NULL.

Referenced by v8::internal::JSObject::ReferencesObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasSameSecurityTokenAs()

bool v8::internal::Context::HasSameSecurityTokenAs ( Context that)
inline

Definition at line 491 of file contexts.h.

491  {
492  return this->global_object()->native_context()->security_token() ==
493  that->global_object()->native_context()->security_token();
494  }

References global_object().

Referenced by v8::internal::AllowAccessToFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsBlockContext()

bool v8::internal::Context::IsBlockContext ( )
inline

Definition at line 478 of file contexts.h.

478  {
479  Map* map = this->map();
480  return map == map->GetHeap()->block_context_map();
481  }

References v8::internal::HeapObject::GetHeap(), and v8::internal::HeapObject::map().

Referenced by v8::internal::Scope::DeserializeScopeChain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsCatchContext()

bool v8::internal::Context::IsCatchContext ( )
inline

Definition at line 470 of file contexts.h.

470  {
471  Map* map = this->map();
472  return map == map->GetHeap()->catch_context_map();
473  }

References v8::internal::HeapObject::GetHeap(), and v8::internal::HeapObject::map().

Referenced by v8::internal::Scope::DeserializeScopeChain(), and v8::internal::JSObject::ReferencesObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsFunctionContext()

bool v8::internal::Context::IsFunctionContext ( )
inline

Definition at line 466 of file contexts.h.

466  {
467  Map* map = this->map();
468  return map == map->GetHeap()->function_context_map();
469  }

References v8::internal::HeapObject::GetHeap(), and v8::internal::HeapObject::map().

Referenced by declaration_context(), and v8::internal::Scope::DeserializeScopeChain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsGlobalContext()

bool v8::internal::Context::IsGlobalContext ( )
inline

Definition at line 486 of file contexts.h.

486  {
487  Map* map = this->map();
488  return map == map->GetHeap()->global_context_map();
489  }

References v8::internal::HeapObject::GetHeap(), and v8::internal::HeapObject::map().

Referenced by v8::internal::Scope::DeserializeScopeChain(), global_context(), and v8::internal::JSObject::ReferencesObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsModuleContext()

bool v8::internal::Context::IsModuleContext ( )
inline

Definition at line 482 of file contexts.h.

482  {
483  Map* map = this->map();
484  return map == map->GetHeap()->module_context_map();
485  }

References v8::internal::HeapObject::GetHeap(), and v8::internal::HeapObject::map().

Referenced by v8::internal::Scope::DeserializeScopeChain(), v8::internal::ModuleGetExport(), and v8::internal::ModuleSetExport().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsNativeContext()

bool v8::internal::Context::IsNativeContext ( )
inline

Definition at line 462 of file contexts.h.

462  {
463  Map* map = this->map();
464  return map == map->GetHeap()->native_context_map();
465  }

References v8::internal::HeapObject::GetHeap(), and v8::internal::HeapObject::map().

Referenced by AddOptimizedCode(), AddOptimizedFunction(), v8::internal::AddToWeakNativeContextList(), declaration_context(), DeoptimizedCodeListHead(), v8::internal::Scope::DeserializeScopeChain(), v8::internal::V8HeapExplorer::ExtractContextReferences(), native_context(), OptimizedCodeListHead(), OptimizedFunctionsListHead(), v8::internal::JSObject::ReferencesObject(), RemoveOptimizedFunction(), v8::internal::SharedFunctionInfo::SearchOptimizedCodeMap(), SetDeoptimizedCodeListHead(), SetOptimizedCodeListHead(), SetOptimizedFunctionsListHead(), and v8::internal::Deoptimizer::VisitAllOptimizedFunctionsForContext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWithContext()

bool v8::internal::Context::IsWithContext ( )
inline

Definition at line 474 of file contexts.h.

474  {
475  Map* map = this->map();
476  return map == map->GetHeap()->with_context_map();
477  }

References v8::internal::HeapObject::GetHeap(), and v8::internal::HeapObject::map().

Referenced by v8::internal::Scope::DeserializeScopeChain(), and v8::internal::JavaScriptFrame::Print().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Lookup()

Handle< Object > v8::internal::Context::Lookup ( Handle< String name,
ContextLookupFlags  flags,
int index,
PropertyAttributes attributes,
BindingFlags binding_flags 
)

Definition at line 106 of file contexts.cc.

110  {
111  Isolate* isolate = GetIsolate();
112  Handle<Context> context(this, isolate);
113 
114  bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
115  *index = -1;
116  *attributes = ABSENT;
117  *binding_flags = MISSING_BINDING;
118 
119  if (FLAG_trace_contexts) {
120  PrintF("Context::Lookup(");
121  name->ShortPrint();
122  PrintF(")\n");
123  }
124 
125  do {
126  if (FLAG_trace_contexts) {
127  PrintF(" - looking in context %p", reinterpret_cast<void*>(*context));
128  if (context->IsNativeContext()) PrintF(" (native context)");
129  PrintF("\n");
130  }
131 
132  // 1. Check global objects, subjects of with, and extension objects.
133  if (context->IsNativeContext() ||
134  context->IsWithContext() ||
135  (context->IsFunctionContext() && context->has_extension())) {
136  Handle<JSReceiver> object(
137  JSReceiver::cast(context->extension()), isolate);
138  // Context extension objects needs to behave as if they have no
139  // prototype. So even if we want to follow prototype chains, we need
140  // to only do a local lookup for context extension objects.
141  Maybe<PropertyAttributes> maybe;
142  if ((flags & FOLLOW_PROTOTYPE_CHAIN) == 0 ||
143  object->IsJSContextExtensionObject()) {
145  } else if (context->IsWithContext()) {
146  LookupIterator it(object, name);
147  maybe = UnscopableLookup(&it);
148  } else {
150  }
151 
152  if (!maybe.has_value) return Handle<Object>();
153  DCHECK(!isolate->has_pending_exception());
154  *attributes = maybe.value;
155 
156  if (maybe.value != ABSENT) {
157  if (FLAG_trace_contexts) {
158  PrintF("=> found property in context object %p\n",
159  reinterpret_cast<void*>(*object));
160  }
161  return object;
162  }
163  }
164 
165  // 2. Check the context proper if it has slots.
166  if (context->IsFunctionContext() || context->IsBlockContext()) {
167  // Use serialized scope information of functions and blocks to search
168  // for the context index.
169  Handle<ScopeInfo> scope_info;
170  if (context->IsFunctionContext()) {
171  scope_info = Handle<ScopeInfo>(
172  context->closure()->shared()->scope_info(), isolate);
173  } else {
174  scope_info = Handle<ScopeInfo>(
175  ScopeInfo::cast(context->extension()), isolate);
176  }
178  InitializationFlag init_flag;
179  // TODO(sigurds) Figure out whether maybe_assigned_flag should
180  // be used to compute binding_flags.
181  MaybeAssignedFlag maybe_assigned_flag;
182  int slot_index = ScopeInfo::ContextSlotIndex(
183  scope_info, name, &mode, &init_flag, &maybe_assigned_flag);
184  DCHECK(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS);
185  if (slot_index >= 0) {
186  if (FLAG_trace_contexts) {
187  PrintF("=> found local in context slot %d (mode = %d)\n",
188  slot_index, mode);
189  }
190  *index = slot_index;
191  // Note: Fixed context slots are statically allocated by the compiler.
192  // Statically allocated variables always have a statically known mode,
193  // which is the mode with which they were declared when added to the
194  // scope. Thus, the DYNAMIC mode (which corresponds to dynamically
195  // declared variables that were introduced through declaration nodes)
196  // must not appear here.
197  switch (mode) {
198  case INTERNAL: // Fall through.
199  case VAR:
200  *attributes = NONE;
201  *binding_flags = MUTABLE_IS_INITIALIZED;
202  break;
203  case LET:
204  *attributes = NONE;
205  *binding_flags = (init_flag == kNeedsInitialization)
207  break;
208  case CONST_LEGACY:
209  *attributes = READ_ONLY;
210  *binding_flags = (init_flag == kNeedsInitialization)
212  break;
213  case CONST:
214  *attributes = READ_ONLY;
215  *binding_flags = (init_flag == kNeedsInitialization)
218  break;
219  case MODULE:
220  *attributes = READ_ONLY;
221  *binding_flags = IMMUTABLE_IS_INITIALIZED_HARMONY;
222  break;
223  case DYNAMIC:
224  case DYNAMIC_GLOBAL:
225  case DYNAMIC_LOCAL:
226  case TEMPORARY:
227  UNREACHABLE();
228  break;
229  }
230  return context;
231  }
232 
233  // Check the slot corresponding to the intermediate context holding
234  // only the function name variable.
235  if (follow_context_chain && context->IsFunctionContext()) {
237  int function_index = scope_info->FunctionContextSlotIndex(*name, &mode);
238  if (function_index >= 0) {
239  if (FLAG_trace_contexts) {
240  PrintF("=> found intermediate function in context slot %d\n",
241  function_index);
242  }
243  *index = function_index;
244  *attributes = READ_ONLY;
245  DCHECK(mode == CONST_LEGACY || mode == CONST);
246  *binding_flags = (mode == CONST_LEGACY)
248  return context;
249  }
250  }
251 
252  } else if (context->IsCatchContext()) {
253  // Catch contexts have the variable name in the extension slot.
254  if (String::Equals(name, handle(String::cast(context->extension())))) {
255  if (FLAG_trace_contexts) {
256  PrintF("=> found in catch context\n");
257  }
259  *attributes = NONE;
260  *binding_flags = MUTABLE_IS_INITIALIZED;
261  return context;
262  }
263  }
264 
265  // 3. Prepare to continue with the previous (next outermost) context.
266  if (context->IsNativeContext()) {
267  follow_context_chain = false;
268  } else {
269  context = Handle<Context>(context->previous(), isolate);
270  }
271  } while (follow_context_chain);
272 
273  if (FLAG_trace_contexts) {
274  PrintF("=> no property/slot found\n");
275  }
276  return Handle<Object>::null();
277 }
static Handle< T > null()
Definition: handles.h:123
static MUST_USE_RESULT Maybe< PropertyAttributes > GetPropertyAttributes(Handle< JSReceiver > object, Handle< Name > name)
Definition: objects-inl.h:6670
static MUST_USE_RESULT Maybe< PropertyAttributes > GetOwnPropertyAttributes(Handle< JSReceiver > object, Handle< Name > name)
Definition: objects.cc:3983
friend class LookupIterator
Definition: objects.h:1226
static int ContextSlotIndex(Handle< ScopeInfo > scope_info, Handle< String > name, VariableMode *mode, InitializationFlag *init_flag, MaybeAssignedFlag *maybe_assigned_flag)
Definition: scopeinfo.cc:296
bool Equals(String *other)
Definition: objects-inl.h:3336
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
#define UNREACHABLE()
Definition: logging.h:30
InitializationFlag
Definition: globals.h:751
@ kNeedsInitialization
Definition: globals.h:752
@ IMMUTABLE_CHECK_INITIALIZED
Definition: contexts.h:60
@ MUTABLE_IS_INITIALIZED
Definition: contexts.h:57
@ MISSING_BINDING
Definition: contexts.h:63
@ IMMUTABLE_CHECK_INITIALIZED_HARMONY
Definition: contexts.h:62
@ MUTABLE_CHECK_INITIALIZED
Definition: contexts.h:58
@ IMMUTABLE_IS_INITIALIZED_HARMONY
Definition: contexts.h:61
@ IMMUTABLE_IS_INITIALIZED
Definition: contexts.h:59
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146
@ DYNAMIC_GLOBAL
Definition: globals.h:689
@ DYNAMIC_LOCAL
Definition: globals.h:693
@ CONST_LEGACY
Definition: globals.h:671
void PrintF(const char *format,...)
Definition: utils.cc:80
@ FOLLOW_CONTEXT_CHAIN
Definition: contexts.h:16
@ FOLLOW_PROTOTYPE_CHAIN
Definition: contexts.h:17
static Maybe< PropertyAttributes > UnscopableLookup(LookupIterator *it)
Lookups a property in an object environment, taking the unscopables into account.
Definition: contexts.cc:78
Maybe< T > maybe(T t)
Definition: v8.h:902
@ ABSENT
@ NONE
@ READ_ONLY

References ABSENT, v8::internal::CONST, v8::internal::CONST_LEGACY, v8::internal::ScopeInfo::ContextSlotIndex(), DCHECK, v8::internal::DYNAMIC, v8::internal::DYNAMIC_GLOBAL, v8::internal::DYNAMIC_LOCAL, v8::internal::String::Equals(), v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::FOLLOW_CONTEXT_CHAIN, v8::internal::FOLLOW_PROTOTYPE_CHAIN, v8::internal::HeapObject::GetIsolate(), v8::internal::JSReceiver::GetOwnPropertyAttributes(), v8::internal::JSReceiver::GetPropertyAttributes(), v8::internal::handle(), v8::internal::Isolate::has_pending_exception(), v8::internal::IMMUTABLE_CHECK_INITIALIZED, v8::internal::IMMUTABLE_CHECK_INITIALIZED_HARMONY, v8::internal::IMMUTABLE_IS_INITIALIZED, v8::internal::IMMUTABLE_IS_INITIALIZED_HARMONY, v8::internal::INTERNAL, v8::internal::kNeedsInitialization, v8::internal::LET, v8::internal::Object::LookupIterator, v8::maybe(), MIN_CONTEXT_SLOTS, v8::internal::MISSING_BINDING, mode(), v8::internal::MODULE, v8::internal::MUTABLE_CHECK_INITIALIZED, v8::internal::MUTABLE_IS_INITIALIZED, name, NONE, v8::internal::Handle< T >::null(), v8::internal::PrintF(), READ_ONLY, v8::internal::TEMPORARY, THROWN_OBJECT_INDEX, UNREACHABLE, v8::internal::UnscopableLookup(), and v8::internal::VAR.

+ Here is the call graph for this function:

◆ module()

JSModule* v8::internal::Context::module ( )
inline

Definition at line 430 of file contexts.h.

430 { return JSModule::cast(get(EXTENSION_INDEX)); }

References EXTENSION_INDEX, and v8::internal::FixedArray::get().

Referenced by v8::internal::Scope::DeserializeScopeChain(), and set_module().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ native_context()

Context * v8::internal::Context::native_context ( )

Definition at line 44 of file contexts.cc.

44  {
45  // Fast case: the global object for this context has been set. In
46  // that case, the global object has a direct pointer to the global
47  // context.
48  if (global_object()->IsGlobalObject()) {
49  return global_object()->native_context();
50  }
51 
52  // During bootstrapping, the global object might not be set and we
53  // have to search the context chain to find the native context.
54  DCHECK(this->GetIsolate()->bootstrapper()->IsActive());
55  Context* current = this;
56  while (!current->IsNativeContext()) {
57  JSFunction* closure = JSFunction::cast(current->closure());
58  current = Context::cast(closure->context());
59  }
60  return current;
61 }

References cast(), closure(), v8::internal::JSFunction::context(), DCHECK, v8::internal::HeapObject::GetIsolate(), global_object(), and IsNativeContext().

Referenced by v8::internal::BUILTIN(), v8::internal::ComputeReceiverForNonGlobal(), v8::internal::Runtime::CreateArrayLiteralBoilerplate(), v8::internal::Deoptimizer::DeoptimizeGlobalObject(), v8::internal::Deoptimizer::FindDeoptimizingCode(), v8::internal::Isolate::get_initial_js_array_map(), v8::internal::Isolate::GetCallingNativeContext(), v8::Isolate::GetCurrentContext(), v8::internal::Object::GetRootMap(), v8::internal::GetTypedArrayFun(), global_proxy(), v8::internal::IsJSArrayFastElementMovingAllowed(), v8::internal::JSObject::ReferencesObject(), v8::internal::JSFunction::RemovePrototype(), v8::internal::JSFunction::ReplaceCode(), v8::internal::RUNTIME_FUNCTION(), set_global_proxy(), v8::internal::JSFunction::SetInstancePrototype(), v8::internal::JSFunction::SetPrototype(), v8::internal::Object::ToObject(), and v8::internal::Map::TransitionElementsTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OptimizedCodeListHead()

Object * v8::internal::Context::OptimizedCodeListHead ( )

Definition at line 369 of file contexts.cc.

369  {
371  return get(OPTIMIZED_CODE_LIST);
372 }

References DCHECK, v8::internal::FixedArray::get(), IsNativeContext(), and OPTIMIZED_CODE_LIST.

Referenced by v8::internal::Deoptimizer::DeoptimizeMarkedCodeForContext(), and v8::internal::Deoptimizer::MarkAllCodeForContext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ OptimizedFunctionsListHead()

Object * v8::internal::Context::OptimizedFunctionsListHead ( )

Definition at line 348 of file contexts.cc.

348  {
351 }

References DCHECK, v8::internal::FixedArray::get(), IsNativeContext(), and OPTIMIZED_FUNCTIONS_LIST.

Referenced by v8::internal::Deoptimizer::VisitAllOptimizedFunctionsForContext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ previous()

Context* v8::internal::Context::previous ( )
inline

Definition at line 419 of file contexts.h.

419  {
420  Object* result = unchecked_previous();
421  DCHECK(IsBootstrappingOrValidParentContext(result, this));
422  return reinterpret_cast<Context*>(result);
423  }
Object * unchecked_previous()
Definition: contexts.h:585

References DCHECK, and unchecked_previous().

Referenced by declaration_context(), v8::internal::Scope::DeserializeScopeChain(), global_context(), v8::internal::compiler::JSContextSpecializer::ReduceJSLoadContext(), v8::internal::compiler::JSContextSpecializer::ReduceJSStoreContext(), and v8::internal::RUNTIME_FUNCTION().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveOptimizedFunction()

void v8::internal::Context::RemoveOptimizedFunction ( JSFunction function)

Definition at line 318 of file contexts.cc.

318  {
320  Object* element = get(OPTIMIZED_FUNCTIONS_LIST);
321  JSFunction* prev = NULL;
322  while (!element->IsUndefined()) {
323  JSFunction* element_function = JSFunction::cast(element);
324  DCHECK(element_function->next_function_link()->IsUndefined() ||
325  element_function->next_function_link()->IsJSFunction());
326  if (element_function == function) {
327  if (prev == NULL) {
328  set(OPTIMIZED_FUNCTIONS_LIST, element_function->next_function_link());
329  } else {
330  prev->set_next_function_link(element_function->next_function_link());
331  }
332  element_function->set_next_function_link(GetHeap()->undefined_value());
333  return;
334  }
335  prev = element_function;
336  element = element_function->next_function_link();
337  }
338  UNREACHABLE();
339 }

References DCHECK, v8::internal::FixedArray::get(), v8::internal::HeapObject::GetHeap(), IsNativeContext(), NULL, OPTIMIZED_FUNCTIONS_LIST, v8::internal::FixedArray::set(), and UNREACHABLE.

Referenced by v8::internal::JSFunction::ReplaceCode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_closure()

void v8::internal::Context::set_closure ( JSFunction closure)
inline

Definition at line 417 of file contexts.h.

References closure(), CLOSURE_INDEX, and v8::internal::FixedArray::set().

+ Here is the call graph for this function:

◆ set_extension()

void v8::internal::Context::set_extension ( Object object)
inline

Definition at line 428 of file contexts.h.

428 { set(EXTENSION_INDEX, object); }

References EXTENSION_INDEX, and v8::internal::FixedArray::set().

+ Here is the call graph for this function:

◆ set_global_object()

void v8::internal::Context::set_global_object ( GlobalObject object)
inline

Definition at line 442 of file contexts.h.

442  {
443  set(GLOBAL_OBJECT_INDEX, object);
444  }

References GLOBAL_OBJECT_INDEX, and v8::internal::FixedArray::set().

+ Here is the call graph for this function:

◆ set_global_proxy()

void v8::internal::Context::set_global_proxy ( JSObject global)

Definition at line 69 of file contexts.cc.

69  {
70  native_context()->set_global_proxy_object(object);
71 }

References native_context().

+ Here is the call graph for this function:

◆ set_module()

void v8::internal::Context::set_module ( JSModule module)
inline

Definition at line 431 of file contexts.h.

JSModule * module()
Definition: contexts.h:430

References EXTENSION_INDEX, module(), and v8::internal::FixedArray::set().

+ Here is the call graph for this function:

◆ set_previous()

void v8::internal::Context::set_previous ( Context context)
inline

Definition at line 424 of file contexts.h.

424 { set(PREVIOUS_INDEX, context); }

References PREVIOUS_INDEX, and v8::internal::FixedArray::set().

+ Here is the call graph for this function:

◆ SetDeoptimizedCodeListHead()

void v8::internal::Context::SetDeoptimizedCodeListHead ( Object head)

Definition at line 375 of file contexts.cc.

375  {
377  set(DEOPTIMIZED_CODE_LIST, head);
378 }

References DCHECK, DEOPTIMIZED_CODE_LIST, IsNativeContext(), and v8::internal::FixedArray::set().

Referenced by v8::internal::Deoptimizer::DeoptimizeMarkedCodeForContext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetOptimizedCodeListHead()

void v8::internal::Context::SetOptimizedCodeListHead ( Object head)

Definition at line 363 of file contexts.cc.

363  {
365  set(OPTIMIZED_CODE_LIST, head);
366 }

References DCHECK, IsNativeContext(), OPTIMIZED_CODE_LIST, and v8::internal::FixedArray::set().

Referenced by v8::internal::Deoptimizer::DeoptimizeMarkedCodeForContext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetOptimizedFunctionsListHead()

void v8::internal::Context::SetOptimizedFunctionsListHead ( Object head)

Definition at line 342 of file contexts.cc.

342  {
345 }

References DCHECK, IsNativeContext(), OPTIMIZED_FUNCTIONS_LIST, and v8::internal::FixedArray::set().

Referenced by v8::internal::Deoptimizer::VisitAllOptimizedFunctionsForContext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SlotOffset()

static int v8::internal::Context::SlotOffset ( int  index)
inlinestatic

Definition at line 552 of file contexts.h.

552  {
553  return kHeaderSize + index * kPointerSize - kHeapObjectTag;
554  }
static const int kHeaderSize
Definition: objects.h:2393
const int kPointerSize
Definition: globals.h:129
const int kHeapObjectTag
Definition: v8.h:5737

References v8::internal::FixedArrayBase::kHeaderSize, v8::internal::kHeapObjectTag, and v8::internal::kPointerSize.

Referenced by v8::internal::ContextMemOperand(), and v8::internal::ContextOperand().

+ Here is the caller graph for this function:

◆ STATIC_ASSERT() [1/2]

v8::internal::Context::STATIC_ASSERT ( EMBEDDER_DATA_INDEX  = =Internals::kContextEmbedderDataIndex)
private

◆ STATIC_ASSERT() [2/2]

v8::internal::Context::STATIC_ASSERT ( kHeaderSize  = =Internals::kContextHeaderSize)
private

◆ unchecked_previous()

Object* v8::internal::Context::unchecked_previous ( )
inlineprivate

Definition at line 585 of file contexts.h.

585 { return get(PREVIOUS_INDEX); }

References v8::internal::FixedArray::get(), and PREVIOUS_INDEX.

Referenced by previous().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ kSize


The documentation for this class was generated from the following files: