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

Side by Side Diff: test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc

Issue 2632123006: Reland: [Parse] ParseInfo owns the parsing Zone. (Closed)
Patch Set: Rebase Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler-dispatcher/compiler-dispatcher.h" 5 #include "src/compiler-dispatcher/compiler-dispatcher.h"
6 6
7 #include "include/v8-platform.h" 7 #include "include/v8-platform.h"
8 #include "src/base/platform/semaphore.h" 8 #include "src/base/platform/semaphore.h"
9 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" 9 #include "src/compiler-dispatcher/compiler-dispatcher-job.h"
10 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" 10 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h"
11 #include "src/compiler.h" 11 #include "src/compiler.h"
12 #include "src/flags.h" 12 #include "src/flags.h"
13 #include "src/handles.h" 13 #include "src/handles.h"
14 #include "src/objects-inl.h" 14 #include "src/objects-inl.h"
15 #include "src/parsing/parse-info.h" 15 #include "src/parsing/parse-info.h"
16 #include "src/v8.h" 16 #include "src/v8.h"
17 #include "src/zone/zone.h"
18 #include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h" 17 #include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h"
19 #include "test/unittests/test-utils.h" 18 #include "test/unittests/test-utils.h"
20 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
21 20
22 namespace v8 { 21 namespace v8 {
23 namespace internal { 22 namespace internal {
24 23
25 class CompilerDispatcherTest : public TestWithContext { 24 class CompilerDispatcherTest : public TestWithContext {
26 public: 25 public:
27 CompilerDispatcherTest() = default; 26 CompilerDispatcherTest() = default;
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 TEST_F(CompilerDispatcherTest, EnqueueParsed) { 807 TEST_F(CompilerDispatcherTest, EnqueueParsed) {
809 MockPlatform platform; 808 MockPlatform platform;
810 CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); 809 CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
811 810
812 const char script[] = 811 const char script[] =
813 "function g() { var y = 1; function f17(x) { return x * y }; return f17; " 812 "function g() { var y = 1; function f17(x) { return x * y }; return f17; "
814 "} g();"; 813 "} g();";
815 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); 814 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
816 Handle<SharedFunctionInfo> shared(f->shared(), i_isolate()); 815 Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
817 816
818 Zone zone(i_isolate()->allocator(), ZONE_NAME); 817 ParseInfo parse_info(shared);
819 ParseInfo parse_info(&zone, shared);
820 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info)); 818 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info));
821 819
822 ASSERT_FALSE(dispatcher.IsEnqueued(shared)); 820 ASSERT_FALSE(dispatcher.IsEnqueued(shared));
823 ASSERT_TRUE(dispatcher.Enqueue(shared, parse_info.literal())); 821 ASSERT_TRUE(dispatcher.Enqueue(shared, parse_info.literal()));
824 ASSERT_TRUE(dispatcher.IsEnqueued(shared)); 822 ASSERT_TRUE(dispatcher.IsEnqueued(shared));
825 823
826 ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() == 824 ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
827 CompileJobStatus::kAnalyzed); 825 CompileJobStatus::kAnalyzed);
828 826
829 ASSERT_TRUE(platform.IdleTaskPending()); 827 ASSERT_TRUE(platform.IdleTaskPending());
830 platform.ClearIdleTask(); 828 platform.ClearIdleTask();
831 ASSERT_FALSE(platform.BackgroundTasksPending()); 829 ASSERT_FALSE(platform.BackgroundTasksPending());
832 } 830 }
833 831
834 TEST_F(CompilerDispatcherTest, EnqueueAndStepParsed) { 832 TEST_F(CompilerDispatcherTest, EnqueueAndStepParsed) {
835 MockPlatform platform; 833 MockPlatform platform;
836 CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size); 834 CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
837 835
838 const char script[] = 836 const char script[] =
839 "function g() { var y = 1; function f18(x) { return x * y }; return f18; " 837 "function g() { var y = 1; function f18(x) { return x * y }; return f18; "
840 "} g();"; 838 "} g();";
841 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); 839 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
842 Handle<SharedFunctionInfo> shared(f->shared(), i_isolate()); 840 Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
843 841
844 Zone zone(i_isolate()->allocator(), ZONE_NAME); 842 ParseInfo parse_info(shared);
845 ParseInfo parse_info(&zone, shared);
846 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info)); 843 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info));
847 844
848 ASSERT_FALSE(dispatcher.IsEnqueued(shared)); 845 ASSERT_FALSE(dispatcher.IsEnqueued(shared));
849 ASSERT_TRUE(dispatcher.EnqueueAndStep(shared, parse_info.literal())); 846 ASSERT_TRUE(dispatcher.EnqueueAndStep(shared, parse_info.literal()));
850 ASSERT_TRUE(dispatcher.IsEnqueued(shared)); 847 ASSERT_TRUE(dispatcher.IsEnqueued(shared));
851 848
852 ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() == 849 ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
853 CompileJobStatus::kReadyToCompile); 850 CompileJobStatus::kReadyToCompile);
854 851
855 ASSERT_TRUE(platform.IdleTaskPending()); 852 ASSERT_TRUE(platform.IdleTaskPending());
(...skipping 15 matching lines...) Expand all
871 const char script2[] = 868 const char script2[] =
872 "function g() { var y = 1; function f20(x) { return x * y }; return f20; " 869 "function g() { var y = 1; function f20(x) { return x * y }; return f20; "
873 "} g();"; 870 "} g();";
874 Handle<JSFunction> f2 = Handle<JSFunction>::cast(RunJS(isolate(), script2)); 871 Handle<JSFunction> f2 = Handle<JSFunction>::cast(RunJS(isolate(), script2));
875 Handle<SharedFunctionInfo> shared2(f2->shared(), i_isolate()); 872 Handle<SharedFunctionInfo> shared2(f2->shared(), i_isolate());
876 873
877 ASSERT_FALSE(shared1->is_compiled()); 874 ASSERT_FALSE(shared1->is_compiled());
878 ASSERT_FALSE(shared2->is_compiled()); 875 ASSERT_FALSE(shared2->is_compiled());
879 876
880 // Enqueue shared1 as already parsed. 877 // Enqueue shared1 as already parsed.
881 Zone zone(i_isolate()->allocator(), ZONE_NAME); 878 ParseInfo parse_info(shared1);
882 ParseInfo parse_info(&zone, shared1);
883 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info)); 879 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info));
884 ASSERT_TRUE(dispatcher.Enqueue(shared1, parse_info.literal())); 880 ASSERT_TRUE(dispatcher.Enqueue(shared1, parse_info.literal()));
885 881
886 // Enqueue shared2 for parsing and compiling 882 // Enqueue shared2 for parsing and compiling
887 ASSERT_TRUE(dispatcher.Enqueue(shared2)); 883 ASSERT_TRUE(dispatcher.Enqueue(shared2));
888 884
889 ASSERT_TRUE(dispatcher.FinishAllNow()); 885 ASSERT_TRUE(dispatcher.FinishAllNow());
890 886
891 // Finishing removes the SFI from the queue. 887 // Finishing removes the SFI from the queue.
892 ASSERT_FALSE(dispatcher.IsEnqueued(shared1)); 888 ASSERT_FALSE(dispatcher.IsEnqueued(shared1));
893 ASSERT_FALSE(dispatcher.IsEnqueued(shared2)); 889 ASSERT_FALSE(dispatcher.IsEnqueued(shared2));
894 ASSERT_TRUE(shared1->is_compiled()); 890 ASSERT_TRUE(shared1->is_compiled());
895 ASSERT_TRUE(shared2->is_compiled()); 891 ASSERT_TRUE(shared2->is_compiled());
896 ASSERT_TRUE(platform.IdleTaskPending()); 892 ASSERT_TRUE(platform.IdleTaskPending());
897 platform.ClearIdleTask(); 893 platform.ClearIdleTask();
898 } 894 }
899 895
900 } // namespace internal 896 } // namespace internal
901 } // namespace v8 897 } // namespace v8
OLDNEW
« no previous file with comments | « test/fuzzer/parser.cc ('k') | test/unittests/compiler-dispatcher/optimizing-compile-dispatcher-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698