41 function_info_index_(function_info_index),
44 id_(tree->next_node_id()) {
49 for (
int i = 0; i < children_.length(); i++)
delete children_[i];
54 unsigned function_info_index) {
55 for (
int i = 0; i < children_.length(); i++) {
64 unsigned function_info_index) {
81 OS::Print(
"%10u %10u %*c", total_size_, allocation_count_, indent,
' ');
82 if (tracker !=
NULL) {
87 OS::Print(
"%u #%u", function_info_index_, id_);
91 for (
int i = 0; i < children_.length(); i++) {
92 children_[i]->Print(indent, tracker);
110 for (
unsigned* entry = path.
start() + path.
length() - 1;
111 entry != path.
start() - 1;
121 OS::Print(
"Total size | Allocation count | Function id | id\n");
126 void AllocationTracker::DeleteUnresolvedLocation(
127 UnresolvedLocation** location) {
143 unsigned trace_node_id) {
145 RemoveRange(start, end);
147 RangeStack new_range(start, trace_node_id);
148 ranges_.insert(RangeMap::value_type(end, new_range));
153 RangeMap::const_iterator it = ranges_.upper_bound(addr);
154 if (it == ranges_.end())
return 0;
155 if (it->second.start <= addr) {
156 return it->second.trace_node_id;
163 unsigned trace_node_id = GetTraceNodeId(from);
164 if (trace_node_id == 0)
return;
165 RemoveRange(from, from + size);
177 for (RangeMap::iterator it = ranges_.begin(); it != ranges_.end(); ++it) {
178 PrintF(
"[%p - %p] => %u\n", it->second.start, it->first,
179 it->second.trace_node_id);
186 RangeMap::iterator it = ranges_.upper_bound(start);
187 if (it == ranges_.end())
return;
189 RangeStack prev_range(0, 0);
191 RangeMap::iterator to_remove_begin = it;
192 if (it->second.start < start) {
193 prev_range = it->second;
196 if (it->first > end) {
197 if (it->second.start < end) {
198 it->second.start = end;
204 while (it != ranges_.end());
206 ranges_.erase(to_remove_begin, it);
208 if (prev_range.start != 0) {
209 ranges_.insert(RangeMap::value_type(start, prev_range));
214 static bool AddressesMatch(
void* key1,
void* key2) {
219 void AllocationTracker::DeleteFunctionInfo(FunctionInfo**
info) {
228 id_to_function_info_index_(AddressesMatch),
229 info_index_for_other_state_(0) {
231 info->
name =
"(root)";
232 function_info_list_.Add(info);
237 unresolved_locations_.
Iterate(DeleteUnresolvedLocation);
238 function_info_list_.Iterate(&DeleteFunctionInfo);
244 copy.
AddAll(unresolved_locations_);
245 unresolved_locations_.Clear();
246 for (
int i = 0; i < copy.length(); i++) {
266 while (!it.done() && length < kMaxAllocationTraceLength) {
271 allocation_trace_buffer_[length++] = AddFunctionInfo(shared,
id);
275 unsigned index = functionInfoIndexForVMState(isolate->current_vm_state());
277 allocation_trace_buffer_[length++] = index;
284 address_to_trace_.
AddRange(addr, size, top_node->
id());
290 v8::internal::kZeroHashSeed);
294 unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared,
296 HashMap::Entry* entry = id_to_function_info_index_.
Lookup(
297 reinterpret_cast<void*>(
id), SnapshotObjectIdHash(
id),
true);
298 if (entry->value ==
NULL) {
299 FunctionInfo*
info =
new FunctionInfo();
301 info->function_id = id;
302 if (shared->script()->IsScript()) {
304 if (script->name()->IsName()) {
306 info->script_name = names_->
GetName(name);
308 info->script_id = script->id()->value();
311 unresolved_locations_.
Add(
new UnresolvedLocation(
313 shared->start_position(),
316 entry->value =
reinterpret_cast<void*
>(function_info_list_.length());
317 function_info_list_.Add(info);
319 return static_cast<unsigned>(
reinterpret_cast<intptr_t
>((entry->value)));
323 unsigned AllocationTracker::functionInfoIndexForVMState(
StateTag state) {
324 if (state !=
OTHER)
return 0;
325 if (info_index_for_other_state_ == 0) {
326 FunctionInfo* info =
new FunctionInfo();
327 info->name =
"(V8 API)";
328 info_index_for_other_state_ = function_info_list_.length();
329 function_info_list_.Add(info);
331 return info_index_for_other_state_;
335 AllocationTracker::UnresolvedLocation::UnresolvedLocation(
336 Script* script,
int start, FunctionInfo* info)
337 : start_position_(start),
340 script->GetIsolate()->global_handles()->Create(script));
347 AllocationTracker::UnresolvedLocation::~UnresolvedLocation() {
348 if (!script_.is_null()) {
354 void AllocationTracker::UnresolvedLocation::Resolve() {
355 if (script_.is_null())
return;
356 HandleScope scope(script_->GetIsolate());
362 void AllocationTracker::UnresolvedLocation::HandleWeakScript(
364 UnresolvedLocation* loc =
365 reinterpret_cast<UnresolvedLocation*
>(data.
GetParameter());
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 NULL
static void Destroy(Object **location)
void Print(AllocationTracker *tracker)
void set_size(Heap *heap, int size_in_bytes)
void PrintF(const char *format,...)
static Handle< T > cast(Handle< S > that)
SnapshotObjectId FindOrAddEntry(Address addr, unsigned int size, bool accessed=true)
AllocationTraceNode * FindChild(unsigned function_info_index)
const char * GetName(Name *name)
#define ASSERT(condition)
static Script * cast(Object *obj)
int GetScriptColumnNumber(Handle< Script > script, int code_pos)
void AddRange(Address addr, int size, unsigned node_id)
void AddAllocation(unsigned size)
AllocationTraceNode * AddPathFromEnd(const Vector< unsigned > &path)
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 size
const char * GetFunctionName(Name *name)
unsigned function_info_index() const
AllocationTraceNode * root()
void PrepareForSerialization()
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
AllocationTraceNode * FindOrAddChild(unsigned function_info_index)
unsigned GetTraceNodeId(Address addr)
void AllocationEvent(Address addr, int size)
const List< FunctionInfo * > & function_info_list() const
V8_INLINE P * GetParameter() const
static void Print(const char *format,...)
int GetScriptLineNumber(Handle< Script > script, int code_pos)
AllocationTracker(HeapObjectsMap *ids, StringsStorage *names)
void MoveObject(Address from, Address to, int size)
uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed)
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 info
uint32_t SnapshotObjectId
static void MakeWeak(Object **location, void *parameter, WeakCallback weak_callback)
static FreeListNode * FromAddress(Address address)
static Handle< T > null()
#define ASSERT_EQ(v1, v2)
static HeapObject * FromAddress(Address address)
ContainedInLattice AddRange(ContainedInLattice containment, const int *ranges, int ranges_length, Interval new_range)
void Add(const T &element, AllocationPolicy allocator=AllocationPolicy())
static Name * cast(Object *obj)
void Iterate(void(*callback)(T *x))
void Print(int indent, AllocationTracker *tracker)
static bool IsFreeListNode(HeapObject *object)
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
JSFunction * function() const
void AddAll(const List< T, AllocationPolicy > &other, AllocationPolicy allocator=AllocationPolicy())
AllocationTraceNode(AllocationTraceTree *tree, unsigned function_info_index)