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

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

Issue 23534067: bulk replace Isolate::Current in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/cctest/test-random.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
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 // don't appear in the stack trace. 605 // don't appear in the stack trace.
606 i::FLAG_use_inlining = false; 606 i::FLAG_use_inlining = false;
607 607
608 v8::Isolate* isolate = CcTest::isolate(); 608 v8::Isolate* isolate = CcTest::isolate();
609 v8::HandleScope scope(isolate); 609 v8::HandleScope scope(isolate);
610 const char* extensions[] = { "v8/profiler" }; 610 const char* extensions[] = { "v8/profiler" };
611 v8::ExtensionConfiguration config(1, extensions); 611 v8::ExtensionConfiguration config(1, extensions);
612 v8::Local<v8::Context> context = v8::Context::New(isolate, &config); 612 v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
613 context->Enter(); 613 context->Enter();
614 614
615 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); 615 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler();
616 CHECK_EQ(0, profiler->GetProfilesCount()); 616 CHECK_EQ(0, profiler->GetProfilesCount());
617 CompileRun( 617 CompileRun(
618 "function c() { startProfiling(); }\n" 618 "function c() { startProfiling(); }\n"
619 "function b() { c(); }\n" 619 "function b() { c(); }\n"
620 "function a() { b(); }\n" 620 "function a() { b(); }\n"
621 "a();\n" 621 "a();\n"
622 "stopProfiling();"); 622 "stopProfiling();");
623 CHECK_EQ(1, profiler->GetProfilesCount()); 623 CHECK_EQ(1, profiler->GetProfilesCount());
624 CpuProfile* profile = profiler->GetProfile(0); 624 CpuProfile* profile = profiler->GetProfile(0);
625 const ProfileTree* topDown = profile->top_down(); 625 const ProfileTree* topDown = profile->top_down();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 737
738 static const char* line_number_test_source_profile_time_functions = 738 static const char* line_number_test_source_profile_time_functions =
739 "// Empty first line\n" 739 "// Empty first line\n"
740 "function bar_at_the_second_line() {\n" 740 "function bar_at_the_second_line() {\n"
741 " foo_at_the_first_line();\n" 741 " foo_at_the_first_line();\n"
742 "}\n" 742 "}\n"
743 "bar_at_the_second_line();\n" 743 "bar_at_the_second_line();\n"
744 "function lazy_func_at_6th_line() {}"; 744 "function lazy_func_at_6th_line() {}";
745 745
746 int GetFunctionLineNumber(LocalContext* env, const char* name) { 746 int GetFunctionLineNumber(LocalContext* env, const char* name) {
747 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); 747 CpuProfiler* profiler = CcTest::i_isolate()->cpu_profiler();
748 CodeMap* code_map = profiler->generator()->code_map(); 748 CodeMap* code_map = profiler->generator()->code_map();
749 i::Handle<i::JSFunction> func = v8::Utils::OpenHandle( 749 i::Handle<i::JSFunction> func = v8::Utils::OpenHandle(
750 *v8::Local<v8::Function>::Cast( 750 *v8::Local<v8::Function>::Cast(
751 (*(*env))->Global()->Get(v8_str(name)))); 751 (*(*env))->Global()->Get(v8_str(name))));
752 CodeEntry* func_entry = code_map->FindEntry(func->code()->address()); 752 CodeEntry* func_entry = code_map->FindEntry(func->code()->address());
753 if (!func_entry) 753 if (!func_entry)
754 FATAL(name); 754 FATAL(name);
755 return func_entry->line_number(); 755 return func_entry->line_number();
756 } 756 }
757 757
758 758
759 TEST(LineNumber) { 759 TEST(LineNumber) {
760 i::FLAG_use_inlining = false; 760 i::FLAG_use_inlining = false;
761 761
762 CcTest::InitializeVM(); 762 CcTest::InitializeVM();
763 LocalContext env; 763 LocalContext env;
764 i::Isolate* isolate = i::Isolate::Current(); 764 i::Isolate* isolate = CcTest::i_isolate();
765 TestSetup test_setup; 765 TestSetup test_setup;
766 766
767 i::HandleScope scope(isolate); 767 i::HandleScope scope(isolate);
768 768
769 CompileRun(line_number_test_source_existing_functions); 769 CompileRun(line_number_test_source_existing_functions);
770 770
771 CpuProfiler* profiler = isolate->cpu_profiler(); 771 CpuProfiler* profiler = isolate->cpu_profiler();
772 profiler->StartProfiling("LineNumber"); 772 profiler->StartProfiling("LineNumber");
773 773
774 CompileRun(line_number_test_source_profile_time_functions); 774 CompileRun(line_number_test_source_profile_time_functions);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); 821 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
822 822
823 current = PickChild(current, "TryFinally"); 823 current = PickChild(current, "TryFinally");
824 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); 824 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
825 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); 825 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason()));
826 826
827 current = PickChild(current, "TryCatch"); 827 current = PickChild(current, "TryCatch");
828 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); 828 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current));
829 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); 829 CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason()));
830 } 830 }
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/cctest/test-random.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698