Revision: 4819
Author: [email protected]
Date: Tue Jun 8 04:27:00 2010
Log: Move token-related constants from CodeEntry to TokenEnumerator.
Review URL: http://codereview.chromium.org/2745002
http://code.google.com/p/v8/source/detail?r=4819
Modified:
/branches/bleeding_edge/src/cpu-profiler.cc
/branches/bleeding_edge/src/profile-generator.cc
/branches/bleeding_edge/src/profile-generator.h
/branches/bleeding_edge/test/cctest/test-cpu-profiler.cc
/branches/bleeding_edge/test/cctest/test-profile-generator.cc
=======================================
--- /branches/bleeding_edge/src/cpu-profiler.cc Tue Jun 1 06:52:49 2010
+++ /branches/bleeding_edge/src/cpu-profiler.cc Tue Jun 8 04:27:00 2010
@@ -294,7 +294,8 @@
int CpuProfiler::GetProfilesCount() {
ASSERT(singleton_ != NULL);
// The count of profiles doesn't depend on a security token.
- return
singleton_->profiles_->Profiles(CodeEntry::kNoSecurityToken)->length();
+ return singleton_->profiles_->Profiles(
+ TokenEnumerator::kNoSecurityToken)->length();
}
@@ -380,7 +381,7 @@
void CpuProfiler::FunctionCreateEvent(JSFunction* function) {
- int security_token_id = CodeEntry::kNoSecurityToken;
+ int security_token_id = TokenEnumerator::kNoSecurityToken;
if (function->unchecked_context()->IsContext()) {
security_token_id = singleton_->token_enumerator_->GetTokenId(
function->context()->global_context()->security_token());
@@ -476,9 +477,10 @@
CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) {
const double actual_sampling_rate = generator_->actual_sampling_rate();
StopProcessorIfLastProfile();
- CpuProfile* result =
profiles_->StopProfiling(CodeEntry::kNoSecurityToken,
- title,
- actual_sampling_rate);
+ CpuProfile* result =
+ profiles_->StopProfiling(TokenEnumerator::kNoSecurityToken,
+ title,
+ actual_sampling_rate);
if (result != NULL) {
result->Print();
}
=======================================
--- /branches/bleeding_edge/src/profile-generator.cc Tue Jun 1 06:42:48
2010
+++ /branches/bleeding_edge/src/profile-generator.cc Tue Jun 8 04:27:00
2010
@@ -55,7 +55,7 @@
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;
}
@@ -171,7 +171,7 @@
"(root)",
"",
0,
- CodeEntry::kNoSecurityToken),
+ TokenEnumerator::kNoSecurityToken),
root_(new ProfileNode(this, &root_entry_)) {
}
@@ -248,11 +248,11 @@
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;
@@ -373,7 +373,7 @@
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);
@@ -517,7 +517,7 @@
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()),
@@ -550,8 +550,8 @@
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);
@@ -564,7 +564,7 @@
int CpuProfilesCollection::TokenToIndex(int security_token_id) {
- ASSERT(CodeEntry::kNoSecurityToken == -1);
+ ASSERT(TokenEnumerator::kNoSecurityToken == -1);
return security_token_id + 1; // kNoSecurityToken -> 0, 0 -> 1, ...
}
@@ -575,7 +575,7 @@
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);
@@ -589,8 +589,8 @@
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);
@@ -613,7 +613,7 @@
GetFunctionName(name),
GetName(resource_name),
line_number,
- CodeEntry::kNoSecurityToken);
+ TokenEnumerator::kNoSecurityToken);
code_entries_.Add(entry);
return entry;
}
@@ -626,7 +626,7 @@
GetFunctionName(name),
"",
v8::CpuProfileNode::kNoLineNumberInfo,
- CodeEntry::kNoSecurityToken);
+ TokenEnumerator::kNoSecurityToken);
code_entries_.Add(entry);
return entry;
}
@@ -640,7 +640,7 @@
GetName(name),
"",
v8::CpuProfileNode::kNoLineNumberInfo,
- CodeEntry::kInheritsSecurityToken);
+
TokenEnumerator::kInheritsSecurityToken);
code_entries_.Add(entry);
return entry;
}
@@ -653,7 +653,7 @@
GetName(args_count),
"",
v8::CpuProfileNode::kNoLineNumberInfo,
- CodeEntry::kInheritsSecurityToken);
+
TokenEnumerator::kInheritsSecurityToken);
code_entries_.Add(entry);
return entry;
}
=======================================
--- /branches/bleeding_edge/src/profile-generator.h Tue Jun 1 06:52:49 2010
+++ /branches/bleeding_edge/src/profile-generator.h Tue Jun 8 04:27:00 2010
@@ -41,6 +41,9 @@
~TokenEnumerator();
int GetTokenId(Object* token);
+ static const int kNoSecurityToken = -1;
+ static const int kInheritsSecurityToken = -2;
+
private:
static void TokenRemovedCallback(v8::Persistent<v8::Value> handle,
void* parameter);
@@ -78,8 +81,6 @@
void CopyData(const CodeEntry& source);
static const char* kEmptyNamePrefix;
- static const int kNoSecurityToken = -1;
- static const int kInheritsSecurityToken = -2;
private:
unsigned call_uid_;
=======================================
--- /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc Tue May 18
07:19:33 2010
+++ /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc Tue Jun 8
04:27:00 2010
@@ -16,6 +16,7 @@
using i::ProfileGenerator;
using i::ProfileNode;
using i::ProfilerEventsProcessor;
+using i::TokenEnumerator;
TEST(StartStop) {
@@ -115,7 +116,7 @@
processor.CodeCreateEvent(i::Logger::STUB_TAG, 3, ToAddress(0x1600),
0x10);
processor.CodeDeleteEvent(ToAddress(0x1600));
processor.FunctionCreateEvent(ToAddress(0x1700), ToAddress(0x1000),
- CodeEntry::kNoSecurityToken);
+ TokenEnumerator::kNoSecurityToken);
// Enqueue a tick event to enable code events processing.
EnqueueTickSampleEvent(&processor, ToAddress(0x1000));
@@ -178,7 +179,7 @@
processor.Stop();
processor.Join();
CpuProfile* profile =
- profiles.StopProfiling(CodeEntry::kNoSecurityToken, "", 1);
+ profiles.StopProfiling(TokenEnumerator::kNoSecurityToken, "", 1);
CHECK_NE(NULL, profile);
// Check call trees.
=======================================
--- /branches/bleeding_edge/test/cctest/test-profile-generator.cc Tue Jun
1 06:52:49 2010
+++ /branches/bleeding_edge/test/cctest/test-profile-generator.cc Tue Jun
8 04:27:00 2010
@@ -39,7 +39,7 @@
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)));
@@ -65,20 +65,20 @@
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);
@@ -119,12 +119,12 @@
} // 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));
@@ -189,12 +189,12 @@
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));
@@ -272,8 +272,8 @@
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]));
@@ -294,8 +294,8 @@
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]));
@@ -330,8 +330,8 @@
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]));
@@ -394,7 +394,7 @@
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};
@@ -491,14 +491,14 @@
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);
@@ -525,10 +525,10 @@
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)));
@@ -601,7 +601,7 @@
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));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev