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

Side by Side Diff: test/unittests/compiler-dispatcher/optimizing-compile-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 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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/optimizing-compile-dispatcher.h" 5 #include "src/compiler-dispatcher/optimizing-compile-dispatcher.h"
6 6
7 #include "src/base/atomic-utils.h" 7 #include "src/base/atomic-utils.h"
8 #include "src/base/platform/semaphore.h" 8 #include "src/base/platform/semaphore.h"
9 #include "src/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
11 #include "src/handles.h" 11 #include "src/handles.h"
12 #include "src/isolate.h" 12 #include "src/isolate.h"
13 #include "src/objects-inl.h" 13 #include "src/objects-inl.h"
14 #include "src/parsing/parse-info.h" 14 #include "src/parsing/parse-info.h"
15 #include "src/zone/zone.h"
16 #include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h" 15 #include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h"
17 #include "test/unittests/test-utils.h" 16 #include "test/unittests/test-utils.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
19 18
20 namespace v8 { 19 namespace v8 {
21 namespace internal { 20 namespace internal {
22 21
23 typedef TestWithContext OptimizingCompileDispatcherTest; 22 typedef TestWithContext OptimizingCompileDispatcherTest;
24 23
25 namespace { 24 namespace {
26 25
27 class BlockingCompilationJob : public CompilationJob { 26 class BlockingCompilationJob : public CompilationJob {
28 public: 27 public:
29 BlockingCompilationJob(Isolate* isolate, Handle<JSFunction> function) 28 BlockingCompilationJob(Isolate* isolate, Handle<JSFunction> function)
30 : CompilationJob(isolate, &info_, "BlockingCompilationJob", 29 : CompilationJob(isolate, &info_, "BlockingCompilationJob",
31 State::kReadyToExecute), 30 State::kReadyToExecute),
32 zone_(isolate->allocator(), ZONE_NAME), 31 parse_info_(handle(function->shared())),
33 parse_info_(&zone_, handle(function->shared())),
34 info_(&parse_info_, function), 32 info_(&parse_info_, function),
35 blocking_(false), 33 blocking_(false),
36 semaphore_(0) {} 34 semaphore_(0) {}
37 ~BlockingCompilationJob() override = default; 35 ~BlockingCompilationJob() override = default;
38 36
39 bool IsBlocking() const { return blocking_.Value(); } 37 bool IsBlocking() const { return blocking_.Value(); }
40 void Signal() { semaphore_.Signal(); } 38 void Signal() { semaphore_.Signal(); }
41 39
42 // CompilationJob implementation. 40 // CompilationJob implementation.
43 Status PrepareJobImpl() override { 41 Status PrepareJobImpl() override {
44 UNREACHABLE(); 42 UNREACHABLE();
45 return FAILED; 43 return FAILED;
46 } 44 }
47 45
48 Status ExecuteJobImpl() override { 46 Status ExecuteJobImpl() override {
49 blocking_.SetValue(true); 47 blocking_.SetValue(true);
50 semaphore_.Wait(); 48 semaphore_.Wait();
51 blocking_.SetValue(false); 49 blocking_.SetValue(false);
52 return SUCCEEDED; 50 return SUCCEEDED;
53 } 51 }
54 52
55 Status FinalizeJobImpl() override { return SUCCEEDED; } 53 Status FinalizeJobImpl() override { return SUCCEEDED; }
56 54
57 private: 55 private:
58 Zone zone_;
59 ParseInfo parse_info_; 56 ParseInfo parse_info_;
60 CompilationInfo info_; 57 CompilationInfo info_;
61 base::AtomicValue<bool> blocking_; 58 base::AtomicValue<bool> blocking_;
62 base::Semaphore semaphore_; 59 base::Semaphore semaphore_;
63 60
64 DISALLOW_COPY_AND_ASSIGN(BlockingCompilationJob); 61 DISALLOW_COPY_AND_ASSIGN(BlockingCompilationJob);
65 }; 62 };
66 63
67 } // namespace 64 } // namespace
68 65
(...skipping 20 matching lines...) Expand all
89 // Should not block. 86 // Should not block.
90 dispatcher.Flush(OptimizingCompileDispatcher::BlockingBehavior::kDontBlock); 87 dispatcher.Flush(OptimizingCompileDispatcher::BlockingBehavior::kDontBlock);
91 88
92 // Unblock the job & finish. 89 // Unblock the job & finish.
93 job->Signal(); 90 job->Signal();
94 dispatcher.Stop(); 91 dispatcher.Stop();
95 } 92 }
96 93
97 } // namespace internal 94 } // namespace internal
98 } // namespace v8 95 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc ('k') | tools/parser-shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698