Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(899)

Side by Side Diff: test/cctest/test-profile-generator.cc

Issue 1371363006: Continuing removing deprecated function from cctest (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed a bug in test-serialize.cc. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-platform-win32.cc ('k') | test/cctest/test-random-number-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 // 27 //
28 // Tests of profiles generator and utilities. 28 // Tests of profiles generator and utilities.
29 29
30 // TODO(mythria): Remove this define after this flag is turned on globally
31 #define V8_IMMINENT_DEPRECATION_WARNINGS
32
30 #include "src/v8.h" 33 #include "src/v8.h"
31 34
32 #include "include/v8-profiler.h" 35 #include "include/v8-profiler.h"
33 #include "src/profiler/cpu-profiler.h" 36 #include "src/profiler/cpu-profiler.h"
34 #include "src/profiler/profile-generator-inl.h" 37 #include "src/profiler/profile-generator-inl.h"
35 #include "test/cctest/cctest.h" 38 #include "test/cctest/cctest.h"
36 #include "test/cctest/profiler-extension.h" 39 #include "test/cctest/profiler-extension.h"
37 40
38 using i::CodeEntry; 41 using i::CodeEntry;
39 using i::CodeMap; 42 using i::CodeMap;
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 // don't appear in the stack trace. 573 // don't appear in the stack trace.
571 i::FLAG_use_inlining = false; 574 i::FLAG_use_inlining = false;
572 575
573 v8::HandleScope scope(CcTest::isolate()); 576 v8::HandleScope scope(CcTest::isolate());
574 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); 577 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
575 v8::Context::Scope context_scope(env); 578 v8::Context::Scope context_scope(env);
576 579
577 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); 580 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
578 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); 581 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
579 CHECK_EQ(0, iprofiler->GetProfilesCount()); 582 CHECK_EQ(0, iprofiler->GetProfilesCount());
580 v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::NewFromUtf8( 583 v8::Local<v8::Script> script_a =
581 env->GetIsolate(), "function a() { startProfiling(); }\n")); 584 v8_compile(v8_str("function a() { startProfiling(); }\n"));
582 script_a->Run(); 585 script_a->Run(v8::Isolate::GetCurrent()->GetCurrentContext())
583 v8::Handle<v8::Script> script_b = 586 .ToLocalChecked();
584 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 587 v8::Local<v8::Script> script_b =
585 "function b() { a(); }\n" 588 v8_compile(v8_str("function b() { a(); }\n"
586 "b();\n" 589 "b();\n"
587 "stopProfiling();\n")); 590 "stopProfiling();\n"));
588 script_b->Run(); 591 script_b->Run(v8::Isolate::GetCurrent()->GetCurrentContext())
592 .ToLocalChecked();
589 CHECK_EQ(1, iprofiler->GetProfilesCount()); 593 CHECK_EQ(1, iprofiler->GetProfilesCount());
590 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; 594 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile;
591 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); 595 const v8::CpuProfileNode* current = profile->GetTopDownRoot();
592 reinterpret_cast<ProfileNode*>( 596 reinterpret_cast<ProfileNode*>(
593 const_cast<v8::CpuProfileNode*>(current))->Print(0); 597 const_cast<v8::CpuProfileNode*>(current))->Print(0);
594 // The tree should look like this: 598 // The tree should look like this:
595 // (root) 599 // (root)
596 // "" 600 // ""
597 // b 601 // b
598 // a 602 // a
(...skipping 26 matching lines...) Expand all
625 "// Empty first line\n" 629 "// Empty first line\n"
626 "function bar_at_the_second_line() {\n" 630 "function bar_at_the_second_line() {\n"
627 " foo_at_the_first_line();\n" 631 " foo_at_the_first_line();\n"
628 "}\n" 632 "}\n"
629 "bar_at_the_second_line();\n" 633 "bar_at_the_second_line();\n"
630 "function lazy_func_at_6th_line() {}"; 634 "function lazy_func_at_6th_line() {}";
631 635
632 int GetFunctionLineNumber(LocalContext* env, const char* name) { 636 int GetFunctionLineNumber(LocalContext* env, const char* name) {
633 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler(); 637 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler();
634 CodeMap* code_map = profiler->generator()->code_map(); 638 CodeMap* code_map = profiler->generator()->code_map();
635 i::Handle<i::JSFunction> func = v8::Utils::OpenHandle( 639 i::Handle<i::JSFunction> func =
636 *v8::Local<v8::Function>::Cast( 640 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
637 (*(*env))->Global()->Get(v8_str(name)))); 641 (*(*env))
642 ->Global()
643 ->Get(v8::Isolate::GetCurrent()->GetCurrentContext(),
644 v8_str(name))
645 .ToLocalChecked()));
638 CodeEntry* func_entry = code_map->FindEntry(func->code()->address()); 646 CodeEntry* func_entry = code_map->FindEntry(func->code()->address());
639 if (!func_entry) 647 if (!func_entry)
640 FATAL(name); 648 FATAL(name);
641 return func_entry->line_number(); 649 return func_entry->line_number();
642 } 650 }
643 651
644 652
645 TEST(LineNumber) { 653 TEST(LineNumber) {
646 i::FLAG_use_inlining = false; 654 i::FLAG_use_inlining = false;
647 655
(...skipping 24 matching lines...) Expand all
672 680
673 681
674 TEST(BailoutReason) { 682 TEST(BailoutReason) {
675 v8::HandleScope scope(CcTest::isolate()); 683 v8::HandleScope scope(CcTest::isolate());
676 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION); 684 v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
677 v8::Context::Scope context_scope(env); 685 v8::Context::Scope context_scope(env);
678 686
679 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); 687 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
680 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); 688 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
681 CHECK_EQ(0, iprofiler->GetProfilesCount()); 689 CHECK_EQ(0, iprofiler->GetProfilesCount());
682 v8::Handle<v8::Script> script = 690 v8::Local<v8::Script> script =
683 v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), 691 v8_compile(v8_str("function Debugger() {\n"
684 "function Debugger() {\n" 692 " debugger;\n"
685 " debugger;\n" 693 " startProfiling();\n"
686 " startProfiling();\n" 694 "}\n"
687 "}\n" 695 "function TryFinally() {\n"
688 "function TryFinally() {\n" 696 " try {\n"
689 " try {\n" 697 " Debugger();\n"
690 " Debugger();\n" 698 " } finally { };\n"
691 " } finally { };\n" 699 "}\n"
692 "}\n" 700 "TryFinally();\n"
693 "TryFinally();\n" 701 "stopProfiling();"));
694 "stopProfiling();")); 702 script->Run(v8::Isolate::GetCurrent()->GetCurrentContext()).ToLocalChecked();
695 script->Run();
696 CHECK_EQ(1, iprofiler->GetProfilesCount()); 703 CHECK_EQ(1, iprofiler->GetProfilesCount());
697 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; 704 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile;
698 CHECK(profile); 705 CHECK(profile);
699 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); 706 const v8::CpuProfileNode* current = profile->GetTopDownRoot();
700 reinterpret_cast<ProfileNode*>( 707 reinterpret_cast<ProfileNode*>(
701 const_cast<v8::CpuProfileNode*>(current))->Print(0); 708 const_cast<v8::CpuProfileNode*>(current))->Print(0);
702 // The tree should look like this: 709 // The tree should look like this:
703 // (root) 710 // (root)
704 // "" 711 // ""
705 // kTryFinallyStatement 712 // kTryFinallyStatement
706 // kDebuggerStatement 713 // kDebuggerStatement
707 current = PickChild(current, ""); 714 current = PickChild(current, "");
708 CHECK(const_cast<v8::CpuProfileNode*>(current)); 715 CHECK(const_cast<v8::CpuProfileNode*>(current));
709 716
710 current = PickChild(current, "TryFinally"); 717 current = PickChild(current, "TryFinally");
711 CHECK(const_cast<v8::CpuProfileNode*>(current)); 718 CHECK(const_cast<v8::CpuProfileNode*>(current));
712 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); 719 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason()));
713 720
714 current = PickChild(current, "Debugger"); 721 current = PickChild(current, "Debugger");
715 CHECK(const_cast<v8::CpuProfileNode*>(current)); 722 CHECK(const_cast<v8::CpuProfileNode*>(current));
716 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); 723 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason()));
717 } 724 }
OLDNEW
« no previous file with comments | « test/cctest/test-platform-win32.cc ('k') | test/cctest/test-random-number-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698