OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 static i::List<bool>* token_removed(TokenEnumerator* te) { | 54 static i::List<bool>* token_removed(TokenEnumerator* te) { |
55 return &te->token_removed_; | 55 return &te->token_removed_; |
56 } | 56 } |
57 }; | 57 }; |
58 | 58 |
59 } } // namespace v8::internal | 59 } } // namespace v8::internal |
60 | 60 |
61 TEST(TokenEnumerator) { | 61 TEST(TokenEnumerator) { |
62 TokenEnumerator te; | 62 TokenEnumerator te; |
63 CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL)); | 63 CHECK_EQ(TokenEnumerator::kNoSecurityToken, te.GetTokenId(NULL)); |
64 v8::HandleScope hs; | 64 v8::HandleScope hs(v8::Isolate::GetCurrent()); |
65 v8::Local<v8::String> token1(v8::String::New("1x")); | 65 v8::Local<v8::String> token1(v8::String::New("1x")); |
66 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 66 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
67 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 67 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
68 v8::Local<v8::String> token2(v8::String::New("2x")); | 68 v8::Local<v8::String> token2(v8::String::New("2x")); |
69 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 69 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
70 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 70 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
71 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 71 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
72 { | 72 { |
73 v8::HandleScope hs; | 73 v8::HandleScope hs(v8::Isolate::GetCurrent()); |
74 v8::Local<v8::String> token3(v8::String::New("3x")); | 74 v8::Local<v8::String> token3(v8::String::New("3x")); |
75 CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); | 75 CHECK_EQ(2, te.GetTokenId(*v8::Utils::OpenHandle(*token3))); |
76 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 76 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
77 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 77 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
78 } | 78 } |
79 CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); | 79 CHECK(!i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
80 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 80 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); |
81 CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); | 81 CHECK(i::TokenEnumeratorTester::token_removed(&te)->at(2)); |
82 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); | 82 CHECK_EQ(1, te.GetTokenId(*v8::Utils::OpenHandle(*token2))); |
83 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); | 83 CHECK_EQ(0, te.GetTokenId(*v8::Utils::OpenHandle(*token1))); |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 return NULL; | 777 return NULL; |
778 } | 778 } |
779 | 779 |
780 | 780 |
781 TEST(RecordStackTraceAtStartProfiling) { | 781 TEST(RecordStackTraceAtStartProfiling) { |
782 // This test does not pass with inlining enabled since inlined functions | 782 // This test does not pass with inlining enabled since inlined functions |
783 // don't appear in the stack trace. | 783 // don't appear in the stack trace. |
784 i::FLAG_use_inlining = false; | 784 i::FLAG_use_inlining = false; |
785 | 785 |
786 if (env.IsEmpty()) { | 786 if (env.IsEmpty()) { |
787 v8::HandleScope scope; | 787 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
788 const char* extensions[] = { "v8/profiler" }; | 788 const char* extensions[] = { "v8/profiler" }; |
789 v8::ExtensionConfiguration config(1, extensions); | 789 v8::ExtensionConfiguration config(1, extensions); |
790 env = v8::Context::New(&config); | 790 env = v8::Context::New(&config); |
791 } | 791 } |
792 v8::HandleScope scope; | 792 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
793 env->Enter(); | 793 env->Enter(); |
794 | 794 |
795 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); | 795 CHECK_EQ(0, CpuProfiler::GetProfilesCount()); |
796 CompileRun( | 796 CompileRun( |
797 "function c() { startProfiling(); }\n" | 797 "function c() { startProfiling(); }\n" |
798 "function b() { c(); }\n" | 798 "function b() { c(); }\n" |
799 "function a() { b(); }\n" | 799 "function a() { b(); }\n" |
800 "a();\n" | 800 "a();\n" |
801 "stopProfiling();"); | 801 "stopProfiling();"); |
802 CHECK_EQ(1, CpuProfiler::GetProfilesCount()); | 802 CHECK_EQ(1, CpuProfiler::GetProfilesCount()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 i::Vector<char> title = i::Vector<char>::New(16); | 839 i::Vector<char> title = i::Vector<char>::New(16); |
840 i::OS::SNPrintF(title, "%d", i); | 840 i::OS::SNPrintF(title, "%d", i); |
841 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0. | 841 CHECK(collection.StartProfiling(title.start(), i + 1)); // UID must be > 0. |
842 titles[i] = title.start(); | 842 titles[i] = title.start(); |
843 } | 843 } |
844 CHECK(!collection.StartProfiling( | 844 CHECK(!collection.StartProfiling( |
845 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); | 845 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1)); |
846 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) | 846 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) |
847 i::DeleteArray(titles[i]); | 847 i::DeleteArray(titles[i]); |
848 } | 848 } |
OLD | NEW |