OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests of profiles generator and utilities. | 3 // Tests of profiles generator and utilities. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 #include "profile-generator-inl.h" | 6 #include "profile-generator-inl.h" |
7 #include "cctest.h" | 7 #include "cctest.h" |
8 #include "../include/v8-profiler.h" | 8 #include "../include/v8-profiler.h" |
9 | 9 |
10 using i::CodeEntry; | 10 using i::CodeEntry; |
(...skipping 19 matching lines...) Expand all Loading... |
30 return &te->token_removed_; | 30 return &te->token_removed_; |
31 } | 31 } |
32 }; | 32 }; |
33 | 33 |
34 } } // namespace v8::internal | 34 } } // namespace v8::internal |
35 | 35 |
36 TEST(TokenEnumerator) { | 36 TEST(TokenEnumerator) { |
37 TokenEnumerator te; | 37 TokenEnumerator te; |
38 CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL)); | 38 CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL)); |
39 v8::HandleScope hs; | 39 v8::HandleScope hs; |
40 v8::Local<v8::String> token1(v8::String::New("1")); | 40 v8::Local<v8::String> token1(v8::String::New("1x")); |
41 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 41 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
42 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 42 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
43 v8::Local<v8::String> token2(v8::String::New("2")); | 43 v8::Local<v8::String> token2(v8::String::New("2x")); |
44 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 44 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
45 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 45 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
46 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 46 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
47 { | 47 { |
48 v8::HandleScope hs; | 48 v8::HandleScope hs; |
49 v8::Local<v8::String> token3(v8::String::New("3")); | 49 v8::Local<v8::String> token3(v8::String::New("3x")); |
50 CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); | 50 CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); |
51 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 51 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
52 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 52 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
53 } | 53 } |
54 CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); | 54 CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
55 HEAP->CollectAllGarbage(false); | 55 HEAP->CollectAllGarbage(false); |
56 CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); | 56 CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
57 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 57 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
58 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 58 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
59 } | 59 } |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 i::Vector<char> title = i::Vector<char>::New(16); | 813 i::Vector<char> title = i::Vector<char>::New(16); |
814 i::OS::SNPrintF(title, "%d", i); | 814 i::OS::SNPrintF(title, "%d", i); |
815 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0. | 815 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0. |
816 titles[i] = title.start(); | 816 titles[i] = title.start(); |
817 } | 817 } |
818 CHECK(!collection.StartProfiling( | 818 CHECK(!collection.StartProfiling( |
819 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); | 819 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); |
820 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) | 820 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) |
821 i::DeleteArray(titles[i]); | 821 i::DeleteArray(titles[i]); |
822 } | 822 } |
OLD | NEW |