int TokenEnumerator::GetTokenId(Object* token) {
- if (token == NULL) return CodeEntry::kNoSecurityToken;
+ if (token == NULL) return TokenEnumerator::kNoSecurityToken;
for (int i = 0; i < token_locations_.length(); ++i) {
if (*token_locations_[i] == token && !token_removed_[i]) return i;
}
"(root)",
"",
0,
- CodeEntry::kNoSecurityToken),
+ TokenEnumerator::kNoSecurityToken),
root_(new ProfileNode(this, &root_entry_)) {
}
private:
bool IsTokenAcceptable(int token, int parent_token) {
- if (token == CodeEntry::kNoSecurityToken
+ if (token == TokenEnumerator::kNoSecurityToken
|| token == security_token_id_) return true;
- if (token == CodeEntry::kInheritsSecurityToken) {
- ASSERT(parent_token != CodeEntry::kInheritsSecurityToken);
- return parent_token == CodeEntry::kNoSecurityToken
+ if (token == TokenEnumerator::kInheritsSecurityToken) {
+ ASSERT(parent_token != TokenEnumerator::kInheritsSecurityToken);
+ return parent_token == TokenEnumerator::kNoSecurityToken
|| parent_token == security_token_id_;
}
return false;
CpuProfile* CpuProfile::FilteredClone(int security_token_id) {
- ASSERT(security_token_id != CodeEntry::kNoSecurityToken);
+ ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken);
CpuProfile* clone = new CpuProfile(title_, uid_);
clone->top_down_.FilteredClone(&top_down_, security_token_id);
clone->bottom_up_.FilteredClone(&bottom_up_, security_token_id);
profile->CalculateTotalTicks();
profile->SetActualSamplingRate(actual_sampling_rate);
List<CpuProfile*>* unabridged_list =
- profiles_by_token_[TokenToIndex(CodeEntry::kNoSecurityToken)];
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
unabridged_list->Add(profile);
HashMap::Entry* entry =
profiles_uids_.Lookup(reinterpret_cast<void*>(profile->uid()),
return NULL;
}
List<CpuProfile*>* unabridged_list =
- profiles_by_token_[TokenToIndex(CodeEntry::kNoSecurityToken)];
- if (security_token_id == CodeEntry::kNoSecurityToken) {
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
+ if (security_token_id == TokenEnumerator::kNoSecurityToken) {
return unabridged_list->at(index);
}
List<CpuProfile*>* list = GetProfilesList(security_token_id);
int CpuProfilesCollection::TokenToIndex(int security_token_id) {
- ASSERT(CodeEntry::kNoSecurityToken == -1);
+ ASSERT(TokenEnumerator::kNoSecurityToken == -1);
return security_token_id + 1; // kNoSecurityToken -> 0, 0 -> 1, ...
}
const int lists_to_add = index - profiles_by_token_.length() + 1;
if (lists_to_add > 0) profiles_by_token_.AddBlock(NULL, lists_to_add);
List<CpuProfile*>* unabridged_list =
- profiles_by_token_[TokenToIndex(CodeEntry::kNoSecurityToken)];
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
const int current_count = unabridged_list->length();
if (profiles_by_token_[index] == NULL) {
profiles_by_token_[index] = new List<CpuProfile*>(current_count);
List<CpuProfile*>* CpuProfilesCollection::Profiles(int security_token_id) {
List<CpuProfile*>* unabridged_list =
- profiles_by_token_[TokenToIndex(CodeEntry::kNoSecurityToken)];
- if (security_token_id == CodeEntry::kNoSecurityToken) {
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
+ if (security_token_id == TokenEnumerator::kNoSecurityToken) {
return unabridged_list;
}
List<CpuProfile*>* list = GetProfilesList(security_token_id);
GetFunctionName(name),
GetName(resource_name),
line_number,
- CodeEntry::kNoSecurityToken);
+ TokenEnumerator::kNoSecurityToken);
code_entries_.Add(entry);
return entry;
}
GetFunctionName(name),
"",
v8::CpuProfileNode::kNoLineNumberInfo,
- CodeEntry::kNoSecurityToken);
+ TokenEnumerator::kNoSecurityToken);
code_entries_.Add(entry);
return entry;
}
GetName(name),
"",
v8::CpuProfileNode::kNoLineNumberInfo,
- CodeEntry::kInheritsSecurityToken);
+ TokenEnumerator::kInheritsSecurityToken);
code_entries_.Add(entry);
return entry;
}
GetName(args_count),
"",
v8::CpuProfileNode::kNoLineNumberInfo,
- CodeEntry::kInheritsSecurityToken);
+ TokenEnumerator::kInheritsSecurityToken);
code_entries_.Add(entry);
return entry;
}
TEST(TokenEnumerator) {
TokenEnumerator te;
- CHECK_EQ(CodeEntry::kNoSecurityToken, te.GetTokenId(NULL));
+ CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL));
v8::HandleScope hs;
v8::Local<v8::String> token1(v8::String::New("1"));
CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1)));
TEST(ProfileNodeFindOrAddChild) {
ProfileNode node(NULL, NULL);
- CodeEntry entry1(
- i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+ TokenEnumerator::kNoSecurityToken);
ProfileNode* childNode1 = node.FindOrAddChild(&entry1);
CHECK_NE(NULL, childNode1);
CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
- CodeEntry entry2(
- i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0,
+ TokenEnumerator::kNoSecurityToken);
ProfileNode* childNode2 = node.FindOrAddChild(&entry2);
CHECK_NE(NULL, childNode2);
CHECK_NE(childNode1, childNode2);
CHECK_EQ(childNode1, node.FindOrAddChild(&entry1));
CHECK_EQ(childNode2, node.FindOrAddChild(&entry2));
- CodeEntry entry3(
- i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0,
+ TokenEnumerator::kNoSecurityToken);
ProfileNode* childNode3 = node.FindOrAddChild(&entry3);
CHECK_NE(NULL, childNode3);
CHECK_NE(childNode1, childNode3);
} // namespace
TEST(ProfileTreeAddPathFromStart) {
- CodeEntry entry1(
- i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken);
- CodeEntry entry2(
- i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken);
- CodeEntry entry3(
- i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+ TokenEnumerator::kNoSecurityToken);
+ CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0,
+ TokenEnumerator::kNoSecurityToken);
+ CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0,
+ TokenEnumerator::kNoSecurityToken);
ProfileTree tree;
ProfileTreeTestHelper helper(&tree);
CHECK_EQ(NULL, helper.Walk(&entry1));
TEST(ProfileTreeAddPathFromEnd) {
- CodeEntry entry1(
- i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken);
- CodeEntry entry2(
- i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken);
- CodeEntry entry3(
- i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+ TokenEnumerator::kNoSecurityToken);
+ CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0,
+ TokenEnumerator::kNoSecurityToken);
+ CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0,
+ TokenEnumerator::kNoSecurityToken);
ProfileTree tree;
ProfileTreeTestHelper helper(&tree);
CHECK_EQ(NULL, helper.Walk(&entry1));
CHECK_EQ(1, empty_tree.root()->total_ticks());
CHECK_EQ(1, empty_tree.root()->self_ticks());
- CodeEntry entry1(
- i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+ TokenEnumerator::kNoSecurityToken);
CodeEntry* e1_path[] = {&entry1};
Vector<CodeEntry*> e1_path_vec(
e1_path, sizeof(e1_path) / sizeof(e1_path[0]));
CHECK_EQ(1, node1->total_ticks());
CHECK_EQ(1, node1->self_ticks());
- CodeEntry entry2(
- i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0,
+ TokenEnumerator::kNoSecurityToken);
CodeEntry* e1_e2_path[] = {&entry1, &entry2};
Vector<CodeEntry*> e1_e2_path_vec(
e1_e2_path, sizeof(e1_e2_path) / sizeof(e1_e2_path[0]));
CodeEntry* e2_path[] = {&entry2};
Vector<CodeEntry*> e2_path_vec(
e2_path, sizeof(e2_path) / sizeof(e2_path[0]));
- CodeEntry entry3(
- i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0,
+ TokenEnumerator::kNoSecurityToken);
CodeEntry* e3_path[] = {&entry3};
Vector<CodeEntry*> e3_path_vec(
e3_path, sizeof(e3_path) / sizeof(e3_path[0]));
CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0, token0);
CodeEntry entry4(
i::Logger::FUNCTION_TAG, "", "ddd", "", 0,
- CodeEntry::kInheritsSecurityToken);
+ TokenEnumerator::kInheritsSecurityToken);
{
CodeEntry* e1_e2_path[] = {&entry1, &entry2};
TEST(CodeMapAddCode) {
CodeMap code_map;
- CodeEntry entry1(
- i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken);
- CodeEntry entry2(
- i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken);
- CodeEntry entry3(
- i::Logger::FUNCTION_TAG, "", "ccc", "", 0, CodeEntry::kNoSecurityToken);
- CodeEntry entry4(
- i::Logger::FUNCTION_TAG, "", "ddd", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+ TokenEnumerator::kNoSecurityToken);
+ CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0,
+ TokenEnumerator::kNoSecurityToken);
+ CodeEntry entry3(i::Logger::FUNCTION_TAG, "", "ccc", "", 0,
+ TokenEnumerator::kNoSecurityToken);
+ CodeEntry entry4(i::Logger::FUNCTION_TAG, "", "ddd", "", 0,
+ TokenEnumerator::kNoSecurityToken);
code_map.AddCode(ToAddress(0x1500), &entry1, 0x200);
code_map.AddCode(ToAddress(0x1700), &entry2, 0x100);
code_map.AddCode(ToAddress(0x1900), &entry3, 0x50);
TEST(CodeMapMoveAndDeleteCode) {
CodeMap code_map;
- CodeEntry entry1(
- i::Logger::FUNCTION_TAG, "", "aaa", "", 0, CodeEntry::kNoSecurityToken);
- CodeEntry entry2(
- i::Logger::FUNCTION_TAG, "", "bbb", "", 0, CodeEntry::kNoSecurityToken);
+ CodeEntry entry1(i::Logger::FUNCTION_TAG, "", "aaa", "", 0,
+ TokenEnumerator::kNoSecurityToken);
+ CodeEntry entry2(i::Logger::FUNCTION_TAG, "", "bbb", "", 0,
+ TokenEnumerator::kNoSecurityToken);
code_map.AddCode(ToAddress(0x1500), &entry1, 0x200);
code_map.AddCode(ToAddress(0x1700), &entry2, 0x100);
CHECK_EQ(&entry1, code_map.FindEntry(ToAddress(0x1500)));
generator.RecordTickSample(sample3);
CpuProfile* profile =
- profiles.StopProfiling(CodeEntry::kNoSecurityToken, "", 1);
+ profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
CHECK_NE(NULL, profile);
ProfileTreeTestHelper top_down_test_helper(profile->top_down());
CHECK_EQ(NULL, top_down_test_helper.Walk(entry2));