v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
transitions-inl.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_TRANSITIONS_INL_H_
29 #define V8_TRANSITIONS_INL_H_
30 
31 #include "transitions.h"
32 
33 namespace v8 {
34 namespace internal {
35 
36 
37 #define FIELD_ADDR(p, offset) \
38  (reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
39 
40 #define WRITE_FIELD(p, offset, value) \
41  (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value)
42 
43 #define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode) \
44  if (mode == UPDATE_WRITE_BARRIER) { \
45  heap->incremental_marking()->RecordWrite( \
46  object, HeapObject::RawField(object, offset), value); \
47  if (heap->InNewSpace(value)) { \
48  heap->RecordWrite(object->address(), offset); \
49  } \
50  }
51 
52 
54  ASSERT(object->IsTransitionArray());
55  return reinterpret_cast<TransitionArray*>(object);
56 }
57 
58 
60  return Search(GetHeap()->elements_transition_symbol()) != kNotFound;
61 }
62 
63 
65  return get(kBackPointerStorageIndex);
66 }
67 
68 
71  Heap* heap = GetHeap();
72  WRITE_FIELD(this, kBackPointerStorageOffset, back_pointer);
74  heap, this, kBackPointerStorageOffset, back_pointer, mode);
75 }
76 
77 
79  return IsFullTransitionArray() &&
81 }
82 
83 
86  Object* prototype_transitions = get(kPrototypeTransitionsIndex);
87  return FixedArray::cast(prototype_transitions);
88 }
89 
90 
93  return reinterpret_cast<HeapObject*>(get(kPrototypeTransitionsIndex));
94 }
95 
96 
100  ASSERT(transitions->IsFixedArray());
101  Heap* heap = GetHeap();
102  WRITE_FIELD(this, kPrototypeTransitionsOffset, transitions);
104  heap, this, kPrototypeTransitionsOffset, transitions, mode);
105 }
106 
107 
109  return HeapObject::RawField(reinterpret_cast<HeapObject*>(this),
111 }
112 
113 
114 Object** TransitionArray::GetKeySlot(int transition_number) {
116  ASSERT(transition_number < number_of_transitions());
117  return RawFieldOfElementAt(ToKeyIndex(transition_number));
118 }
119 
120 
121 Name* TransitionArray::GetKey(int transition_number) {
122  if (IsSimpleTransition()) {
124  int descriptor = target->LastAdded();
125  Name* key = target->instance_descriptors()->GetKey(descriptor);
126  return key;
127  }
128  ASSERT(transition_number < number_of_transitions());
129  return Name::cast(get(ToKeyIndex(transition_number)));
130 }
131 
132 
133 void TransitionArray::SetKey(int transition_number, Name* key) {
135  ASSERT(transition_number < number_of_transitions());
136  set(ToKeyIndex(transition_number), key);
137 }
138 
139 
140 Map* TransitionArray::GetTarget(int transition_number) {
141  if (IsSimpleTransition()) {
142  ASSERT(transition_number == kSimpleTransitionIndex);
143  return Map::cast(get(kSimpleTransitionTarget));
144  }
145  ASSERT(transition_number < number_of_transitions());
146  return Map::cast(get(ToTargetIndex(transition_number)));
147 }
148 
149 
150 void TransitionArray::SetTarget(int transition_number, Map* value) {
151  if (IsSimpleTransition()) {
152  ASSERT(transition_number == kSimpleTransitionIndex);
153  return set(kSimpleTransitionTarget, value);
154  }
155  ASSERT(transition_number < number_of_transitions());
156  set(ToTargetIndex(transition_number), value);
157 }
158 
159 
160 PropertyDetails TransitionArray::GetTargetDetails(int transition_number) {
161  Map* map = GetTarget(transition_number);
162  return map->GetLastDescriptorDetails();
163 }
164 
165 
167  if (IsSimpleTransition()) {
169  if (key->Equals(name)) return kSimpleTransitionIndex;
170  return kNotFound;
171  }
172  return internal::Search<ALL_ENTRIES>(this, name);
173 }
174 
175 
176 void TransitionArray::NoIncrementalWriteBarrierSet(int transition_number,
177  Name* key,
178  Map* target) {
180  this, ToKeyIndex(transition_number), key);
182  this, ToTargetIndex(transition_number), target);
183 }
184 
185 
186 #undef FIELD_ADDR
187 #undef WRITE_FIELD
188 #undef CONDITIONAL_WRITE_BARRIER
189 
190 
191 } } // namespace v8::internal
192 
193 #endif // V8_TRANSITIONS_INL_H_
Object ** RawFieldOfElementAt(int index)
Definition: objects.h:3073
void set(int index, Object *value)
Definition: objects-inl.h:2147
bool Equals(Name *other)
Definition: objects-inl.h:2954
static Smi * FromInt(int value)
Definition: objects-inl.h:1209
#define CONDITIONAL_WRITE_BARRIER(heap, object, offset, value, mode)
HeapObject * UncheckedPrototypeTransitions()
static Map * cast(Object *obj)
static const int kPrototypeTransitionsIndex
Definition: transitions.h:150
#define ASSERT(condition)
Definition: checks.h:329
static const int kSimpleTransitionTarget
Definition: transitions.h:154
Name * GetKey(int transition_number)
static Object ** RawField(HeapObject *obj, int offset)
Definition: objects-inl.h:1199
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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_string(expose_natives_as
static const int kNotFound
Definition: transitions.h:145
void SetPrototypeTransitions(FixedArray *prototype_transitions, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
static const int kSimpleTransitionIndex
Definition: transitions.h:156
static TransitionArray * cast(Object *obj)
static const int kBackPointerStorageOffset
Definition: transitions.h:159
Map * GetTarget(int transition_number)
static const int kBackPointerStorageIndex
Definition: transitions.h:147
void set_back_pointer_storage(Object *back_pointer, WriteBarrierMode mode=UPDATE_WRITE_BARRIER)
static void NoIncrementalWriteBarrierSet(FixedArray *array, int index, Object *value)
Definition: objects-inl.h:2370
#define WRITE_FIELD(p, offset, value)
PropertyDetails GetLastDescriptorDetails()
Definition: objects-inl.h:2555
static FixedArray * cast(Object *obj)
FixedArray * GetPrototypeTransitions()
static Name * cast(Object *obj)
static const int kPrototypeTransitionsOffset
Definition: transitions.h:162
Object ** GetKeySlot(int transition_number)
void SetKey(int transition_number, Name *value)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
Definition: flags.cc:505
void SetTarget(int transition_number, Map *target)
PropertyDetails GetTargetDetails(int transition_number)