| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "src/v8.h" | 5 #include "src/v8.h" | 
| 6 | 6 | 
| 7 #include "src/profile-generator-inl.h" | 7 #include "src/profile-generator-inl.h" | 
| 8 | 8 | 
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" | 
| 10 #include "src/debug.h" | 10 #include "src/debug.h" | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 45 | 45 | 
| 46 const char* const CodeEntry::kEmptyNamePrefix = ""; | 46 const char* const CodeEntry::kEmptyNamePrefix = ""; | 
| 47 const char* const CodeEntry::kEmptyResourceName = ""; | 47 const char* const CodeEntry::kEmptyResourceName = ""; | 
| 48 const char* const CodeEntry::kEmptyBailoutReason = ""; | 48 const char* const CodeEntry::kEmptyBailoutReason = ""; | 
| 49 const char* const CodeEntry::kNoDeoptReason = ""; | 49 const char* const CodeEntry::kNoDeoptReason = ""; | 
| 50 | 50 | 
| 51 | 51 | 
| 52 CodeEntry::~CodeEntry() { | 52 CodeEntry::~CodeEntry() { | 
| 53   delete no_frame_ranges_; | 53   delete no_frame_ranges_; | 
| 54   delete line_info_; | 54   delete line_info_; | 
|  | 55   delete inlined_function_infos_; | 
| 55 } | 56 } | 
| 56 | 57 | 
| 57 | 58 | 
| 58 uint32_t CodeEntry::GetHash() const { | 59 uint32_t CodeEntry::GetHash() const { | 
| 59   uint32_t hash = ComputeIntegerHash(tag(), v8::internal::kZeroHashSeed); | 60   uint32_t hash = ComputeIntegerHash(tag(), v8::internal::kZeroHashSeed); | 
| 60   if (script_id_ != v8::UnboundScript::kNoScriptId) { | 61   if (script_id_ != v8::UnboundScript::kNoScriptId) { | 
| 61     hash ^= ComputeIntegerHash(static_cast<uint32_t>(script_id_), | 62     hash ^= ComputeIntegerHash(static_cast<uint32_t>(script_id_), | 
| 62                                v8::internal::kZeroHashSeed); | 63                                v8::internal::kZeroHashSeed); | 
| 63     hash ^= ComputeIntegerHash(static_cast<uint32_t>(position_), | 64     hash ^= ComputeIntegerHash(static_cast<uint32_t>(position_), | 
| 64                                v8::internal::kZeroHashSeed); | 65                                v8::internal::kZeroHashSeed); | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 105 | 106 | 
| 106 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { | 107 void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) { | 
| 107   if (!shared->script()->IsScript()) return; | 108   if (!shared->script()->IsScript()) return; | 
| 108   Script* script = Script::cast(shared->script()); | 109   Script* script = Script::cast(shared->script()); | 
| 109   set_script_id(script->id()->value()); | 110   set_script_id(script->id()->value()); | 
| 110   set_position(shared->start_position()); | 111   set_position(shared->start_position()); | 
| 111   set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); | 112   set_bailout_reason(GetBailoutReason(shared->disable_optimization_reason())); | 
| 112 } | 113 } | 
| 113 | 114 | 
| 114 | 115 | 
|  | 116 DeoptInfo CodeEntry::GetDeoptInfo() { | 
|  | 117   DCHECK(has_deopt_info()); | 
|  | 118   DCHECK(inlined_function_infos_); | 
|  | 119 | 
|  | 120   DeoptInfo info; | 
|  | 121   info.deopt_reason = deopt_reason_; | 
|  | 122   if (inlined_function_infos_->empty()) { | 
|  | 123     info.AddInlineFrame(script_id_, position_ + deopt_position_.position()); | 
|  | 124     return info; | 
|  | 125   } | 
|  | 126   // Copy the only branch from the inlining tree where the deopt happened. | 
|  | 127   SourcePosition position = deopt_position_; | 
|  | 128   int inlining_id = InlinedFunctionInfo::kNoParentId; | 
|  | 129   for (size_t i = 0; i < inlined_function_infos_->size(); ++i) { | 
|  | 130     InlinedFunctionInfo& current_info = inlined_function_infos_->at(i); | 
|  | 131     if (std::binary_search(current_info.deopt_pc_offsets.begin(), | 
|  | 132                            current_info.deopt_pc_offsets.end(), pc_offset_)) { | 
|  | 133       inlining_id = i; | 
|  | 134       break; | 
|  | 135     } | 
|  | 136   } | 
|  | 137   while (inlining_id != InlinedFunctionInfo::kNoParentId) { | 
|  | 138     InlinedFunctionInfo& inlined_info = | 
|  | 139         inlined_function_infos_->at(inlining_id); | 
|  | 140     info.AddInlineFrame(inlined_info.script_id, | 
|  | 141                         inlined_info.start_position + position.raw()); | 
|  | 142     position = inlined_info.inline_position; | 
|  | 143     inlining_id = inlined_info.parent_id; | 
|  | 144   } | 
|  | 145   return info; | 
|  | 146 } | 
|  | 147 | 
|  | 148 | 
| 115 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { | 149 void ProfileNode::CollectDeoptInfo(CodeEntry* entry) { | 
| 116   deopt_infos_.Add(DeoptInfo(entry->deopt_reason(), entry->deopt_position())); | 150   deopt_infos_.push_back(entry->GetDeoptInfo()); | 
| 117   entry->clear_deopt_info(); | 151   entry->clear_deopt_info(); | 
| 118 } | 152 } | 
| 119 | 153 | 
| 120 | 154 | 
| 121 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) { | 155 ProfileNode* ProfileNode::FindChild(CodeEntry* entry) { | 
| 122   HashMap::Entry* map_entry = | 156   HashMap::Entry* map_entry = | 
| 123       children_.Lookup(entry, CodeEntryHash(entry), false); | 157       children_.Lookup(entry, CodeEntryHash(entry), false); | 
| 124   return map_entry != NULL ? | 158   return map_entry != NULL ? | 
| 125       reinterpret_cast<ProfileNode*>(map_entry->value) : NULL; | 159       reinterpret_cast<ProfileNode*>(map_entry->value) : NULL; | 
| 126 } | 160 } | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 174 } | 208 } | 
| 175 | 209 | 
| 176 | 210 | 
| 177 void ProfileNode::Print(int indent) { | 211 void ProfileNode::Print(int indent) { | 
| 178   base::OS::Print("%5u %*s %s%s %d #%d", self_ticks_, indent, "", | 212   base::OS::Print("%5u %*s %s%s %d #%d", self_ticks_, indent, "", | 
| 179                   entry_->name_prefix(), entry_->name(), entry_->script_id(), | 213                   entry_->name_prefix(), entry_->name(), entry_->script_id(), | 
| 180                   id()); | 214                   id()); | 
| 181   if (entry_->resource_name()[0] != '\0') | 215   if (entry_->resource_name()[0] != '\0') | 
| 182     base::OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); | 216     base::OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); | 
| 183   base::OS::Print("\n"); | 217   base::OS::Print("\n"); | 
| 184   for (auto info : deopt_infos_) { | 218   for (size_t i = 0; i < deopt_infos_.size(); ++i) { | 
| 185     if (FLAG_hydrogen_track_positions) { | 219     DeoptInfo& info = deopt_infos_[i]; | 
| 186       base::OS::Print("%*s deopted at %d_%d with reason '%s'\n", indent + 10, | 220     base::OS::Print( | 
| 187                       "", info.deopt_position.inlining_id(), | 221         "%*s;;; deopted at script_id: %d position: %d with reason '%s'.\n", | 
| 188                       info.deopt_position.position(), info.deopt_reason); | 222         indent + 10, "", info.stack[0].script_id, info.stack[0].position, | 
| 189     } else { | 223         info.deopt_reason); | 
| 190       base::OS::Print("%*s deopted at %d with reason '%s'\n", indent + 10, "", | 224     for (size_t i = 1; i < info.stack.size(); ++i) { | 
| 191                       info.deopt_position.raw(), info.deopt_reason); | 225       base::OS::Print("%*s;;;%*s Inline point: script_id %d position: %d.\n", | 
|  | 226                       indent + 10, "", 4, "", info.stack[i].script_id, | 
|  | 227                       info.stack[i].position); | 
| 192     } | 228     } | 
| 193   } | 229   } | 
| 194   const char* bailout_reason = entry_->bailout_reason(); | 230   const char* bailout_reason = entry_->bailout_reason(); | 
| 195   if (bailout_reason != GetBailoutReason(BailoutReason::kNoReason) && | 231   if (bailout_reason != GetBailoutReason(BailoutReason::kNoReason) && | 
| 196       bailout_reason != CodeEntry::kEmptyBailoutReason) { | 232       bailout_reason != CodeEntry::kEmptyBailoutReason) { | 
| 197     base::OS::Print("%*s bailed out due to '%s'\n", indent + 10, "", | 233     base::OS::Print("%*s bailed out due to '%s'\n", indent + 10, "", | 
| 198                     bailout_reason); | 234                     bailout_reason); | 
| 199   } | 235   } | 
| 200   for (HashMap::Entry* p = children_.Start(); | 236   for (HashMap::Entry* p = children_.Start(); | 
| 201        p != NULL; | 237        p != NULL; | 
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 656     case OTHER: | 692     case OTHER: | 
| 657     case EXTERNAL: | 693     case EXTERNAL: | 
| 658       return program_entry_; | 694       return program_entry_; | 
| 659     case IDLE: | 695     case IDLE: | 
| 660       return idle_entry_; | 696       return idle_entry_; | 
| 661     default: return NULL; | 697     default: return NULL; | 
| 662   } | 698   } | 
| 663 } | 699 } | 
| 664 | 700 | 
| 665 } }  // namespace v8::internal | 701 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|