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

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

Issue 2611313002: [complier] Enable parallel eager inner function compilation with compiler dispatcher. (Closed)
Patch Set: Move flag Created 3 years, 11 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/flags.h" 12 #include "src/flags.h"
12 #include "src/handles.h" 13 #include "src/handles.h"
13 #include "src/objects-inl.h" 14 #include "src/objects-inl.h"
15 #include "src/parsing/parse-info.h"
14 #include "src/v8.h" 16 #include "src/v8.h"
17 #include "src/zone/zone.h"
15 #include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h" 18 #include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h"
16 #include "test/unittests/test-utils.h" 19 #include "test/unittests/test-utils.h"
17 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
18 21
19 namespace v8 { 22 namespace v8 {
20 namespace internal { 23 namespace internal {
21 24
22 class CompilerDispatcherTest : public TestWithContext { 25 class CompilerDispatcherTest : public TestWithContext {
23 public: 26 public:
24 CompilerDispatcherTest() = default; 27 CompilerDispatcherTest() = default;
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 ASSERT_TRUE(dispatcher.IsEnqueued(shared)); 815 ASSERT_TRUE(dispatcher.IsEnqueued(shared));
813 816
814 ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() == 817 ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
815 CompileJobStatus::kReadyToParse); 818 CompileJobStatus::kReadyToParse);
816 819
817 ASSERT_TRUE(platform.IdleTaskPending()); 820 ASSERT_TRUE(platform.IdleTaskPending());
818 platform.ClearIdleTask(); 821 platform.ClearIdleTask();
819 ASSERT_FALSE(platform.BackgroundTasksPending()); 822 ASSERT_FALSE(platform.BackgroundTasksPending());
820 } 823 }
821 824
825 TEST_F(CompilerDispatcherTest, EnqueueParsed) {
826 MockPlatform platform;
827 CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
828
829 const char script[] =
830 "function g() { var y = 1; function f17(x) { return x * y }; return f17; "
831 "} g();";
832 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
833 Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
834
835 Zone zone(i_isolate()->allocator(), ZONE_NAME);
836 ParseInfo parse_info(&zone, shared);
837 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info));
838
839 ASSERT_FALSE(dispatcher.IsEnqueued(shared));
840 ASSERT_TRUE(dispatcher.Enqueue(shared, parse_info.literal(),
841 parse_info.ast_value_factory()));
842 ASSERT_TRUE(dispatcher.IsEnqueued(shared));
843
844 ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
845 CompileJobStatus::kAnalyzed);
846
847 ASSERT_TRUE(platform.IdleTaskPending());
848 platform.ClearIdleTask();
849 ASSERT_FALSE(platform.BackgroundTasksPending());
850 }
851
852 TEST_F(CompilerDispatcherTest, EnqueueAndStepParsed) {
853 MockPlatform platform;
854 CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
855
856 const char script[] =
857 "function g() { var y = 1; function f18(x) { return x * y }; return f18; "
858 "} g();";
859 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
860 Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
861
862 Zone zone(i_isolate()->allocator(), ZONE_NAME);
863 ParseInfo parse_info(&zone, shared);
864 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info));
865
866 ASSERT_FALSE(dispatcher.IsEnqueued(shared));
867 ASSERT_TRUE(dispatcher.EnqueueAndStep(shared, parse_info.literal(),
868 parse_info.ast_value_factory()));
869 ASSERT_TRUE(dispatcher.IsEnqueued(shared));
870
871 ASSERT_TRUE(dispatcher.jobs_.begin()->second->status() ==
872 CompileJobStatus::kReadyToCompile);
873
874 ASSERT_TRUE(platform.IdleTaskPending());
875 ASSERT_EQ(
876 dispatcher.jobs_.begin()->second->can_compile_on_background_thread(),
877 platform.BackgroundTasksPending());
878 platform.ClearIdleTask();
879 platform.ClearBackgroundTasks();
880 }
881
882 TEST_F(CompilerDispatcherTest, FinishAllNow) {
883 MockPlatform platform;
884 CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
885
886 const char script1[] =
887 "function g() { var y = 1; function f19(x) { return x + y }; return f19; "
888 "} g();";
889 Handle<JSFunction> f1 = Handle<JSFunction>::cast(RunJS(isolate(), script1));
890 Handle<SharedFunctionInfo> shared1(f1->shared(), i_isolate());
891
892 const char script2[] =
893 "function g() { var y = 1; function f20(x) { return x * y }; return f20; "
894 "} g();";
895 Handle<JSFunction> f2 = Handle<JSFunction>::cast(RunJS(isolate(), script2));
896 Handle<SharedFunctionInfo> shared2(f2->shared(), i_isolate());
897
898 ASSERT_FALSE(shared1->is_compiled());
899 ASSERT_FALSE(shared2->is_compiled());
900
901 // Enqueue shared1 as already parsed.
902 Zone zone(i_isolate()->allocator(), ZONE_NAME);
903 ParseInfo parse_info(&zone, shared1);
904 ASSERT_TRUE(Compiler::ParseAndAnalyze(&parse_info));
905 ASSERT_TRUE(dispatcher.Enqueue(shared1, parse_info.literal(),
906 parse_info.ast_value_factory()));
907
908 // Enqueue shared2 for parsing and compiling
909 ASSERT_TRUE(dispatcher.Enqueue(shared2));
910
911 ASSERT_TRUE(dispatcher.FinishAllNow());
912
913 // Finishing removes the SFI from the queue.
914 ASSERT_FALSE(dispatcher.IsEnqueued(shared1));
915 ASSERT_FALSE(dispatcher.IsEnqueued(shared2));
916 ASSERT_TRUE(shared1->is_compiled());
917 ASSERT_TRUE(shared2->is_compiled());
918 ASSERT_TRUE(platform.IdleTaskPending());
919 platform.ClearIdleTask();
920 }
921
822 } // namespace internal 922 } // namespace internal
823 } // namespace v8 923 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698