V8 Project
transitions-inl.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_TRANSITIONS_INL_H_
6 #define V8_TRANSITIONS_INL_H_
7 
8 #include "src/transitions.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 
14 #define FIELD_ADDR(p, offset) \
15  (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
16 
17 #define WRITE_FIELD(p, offset, value) \
18  (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value)
19 
20 #define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode) \
21  if (mode == UPDATE_WRITE_BARRIER) { \
22  heap->incremental_marking()->RecordWrite( \
23  object, HeapObject::RawField(object, offset), value); \
24  if (heap->InNewSpace(value)) { \
25  heap->RecordWrite(object->address(), offset); \
26  } \
27  }
28 
29 
31  DCHECK(object->IsTransitionArray());
32  return reinterpret_cast<TransitionArray*>(object);
33 }
34 
35 
37  return Search(GetHeap()->elements_transition_symbol()) != kNotFound;
38 }
39 
40 
43 }
44 
45 
48  Heap* heap = GetHeap();
49  WRITE_FIELD(this, kBackPointerStorageOffset, back_pointer);
51  heap, this, kBackPointerStorageOffset, back_pointer, mode);
52 }
53 
54 
56  return IsFullTransitionArray() &&
58 }
59 
60 
63  Object* prototype_transitions = get(kPrototypeTransitionsIndex);
64  return FixedArray::cast(prototype_transitions);
65 }
66 
67 
71  DCHECK(transitions->IsFixedArray());
72  Heap* heap = GetHeap();
73  WRITE_FIELD(this, kPrototypeTransitionsOffset, transitions);
75  heap, this, kPrototypeTransitionsOffset, transitions, mode);
76 }
77 
78 
80  return HeapObject::RawField(reinterpret_cast<HeapObject*>(this),
82 }
83 
84 
85 Object** TransitionArray::GetKeySlot(int transition_number) {
87  DCHECK(transition_number < number_of_transitions());
88  return RawFieldOfElementAt(ToKeyIndex(transition_number));
89 }
90 
91 
92 Name* TransitionArray::GetKey(int transition_number) {
93  if (IsSimpleTransition()) {
95  int descriptor = target->LastAdded();
96  Name* key = target->instance_descriptors()->GetKey(descriptor);
97  return key;
98  }
99  DCHECK(transition_number < number_of_transitions());
100  return Name::cast(get(ToKeyIndex(transition_number)));
101 }
102 
103 
104 void TransitionArray::SetKey(int transition_number, Name* key) {
106  DCHECK(transition_number < number_of_transitions());
107  set(ToKeyIndex(transition_number), key);
108 }
109 
110 
111 Map* TransitionArray::GetTarget(int transition_number) {
112  if (IsSimpleTransition()) {
113  DCHECK(transition_number == kSimpleTransitionIndex);
114  return Map::cast(get(kSimpleTransitionTarget));
115  }
116  DCHECK(transition_number < number_of_transitions());
117  return Map::cast(get(ToTargetIndex(transition_number)));
118 }
119 
120 
121 void TransitionArray::SetTarget(int transition_number, Map* value) {
122  if (IsSimpleTransition()) {
123  DCHECK(transition_number == kSimpleTransitionIndex);
124  return set(kSimpleTransitionTarget, value);
125  }
126  DCHECK(transition_number < number_of_transitions());
127  set(ToTargetIndex(transition_number), value);
128 }
129 
130 
131 PropertyDetails TransitionArray::GetTargetDetails(int transition_number) {
132  Map* map = GetTarget(transition_number);
133  return map->GetLastDescriptorDetails();
134 }
135 
136 
138  if (IsSimpleTransition()) {
140  if (key->Equals(name)) return kSimpleTransitionIndex;
141  return kNotFound;
142  }
143  return internal::Search<ALL_ENTRIES>(this, name);
144 }
145 
146 
148  Name* key,
149  Map* target) {
151  this, ToKeyIndex(transition_number), key);
153  this, ToTargetIndex(transition_number), target);
154 }
155 
156 
157 #undef FIELD_ADDR
158 #undef WRITE_FIELD
159 #undef CONDITIONAL_WRITE_BARRIER
160 
161 
162 } } // namespace v8::internal
163 
164 #endif // V8_TRANSITIONS_INL_H_
Object ** RawFieldOfElementAt(int index)
Definition: objects.h:2458
Object * get(int index)
Definition: objects-inl.h:2165
static void NoIncrementalWriteBarrierSet(FixedArray *array, int index, Object *value)
Definition: objects-inl.h:2680
void set(int index, Object *value)
Definition: objects-inl.h:2190
Heap * GetHeap() const
Definition: objects-inl.h:1379
static Object ** RawField(HeapObject *obj, int offset)
Definition: objects-inl.h:1311
PropertyDetails GetLastDescriptorDetails()
Definition: objects-inl.h:2867
bool Equals(Name *other)
Definition: objects-inl.h:3309
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
static int ToKeyIndex(int transition_number)
Definition: transitions.h:158
static const int kSimpleTransitionIndex
Definition: transitions.h:127
static TransitionArray * cast(Object *obj)
void set_back_pointer_storage(Object *back_pointer, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
static const int kBackPointerStorageOffset
Definition: transitions.h:130
Object ** GetKeySlot(int transition_number)
static const int kNotFound
Definition: transitions.h:116
Name * GetKey(int transition_number)
PropertyDetails GetTargetDetails(int transition_number)
void SetKey(int transition_number, Name *value)
static const int kBackPointerStorageIndex
Definition: transitions.h:118
static const int kSimpleTransitionTarget
Definition: transitions.h:125
void SetPrototypeTransitions(FixedArray *prototype_transitions, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
static int ToTargetIndex(int transition_number)
Definition: transitions.h:164
static const int kPrototypeTransitionsOffset
Definition: transitions.h:133
Map * GetTarget(int transition_number)
void SetTarget(int transition_number, Map *target)
FixedArray * GetPrototypeTransitions()
void NoIncrementalWriteBarrierSet(int transition_number, Name *key, Map *target)
static const int kPrototypeTransitionsIndex
Definition: transitions.h:121
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 DCHECK(condition)
Definition: logging.h:205
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
#define WRITE_FIELD(p, offset, value)
#define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode)