OLD | NEW |
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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "include/v8.h" | 7 #include "include/v8.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 typedef TestWithContext CompilerDispatcherJobTest; | 23 typedef TestWithContext CompilerDispatcherJobTest; |
24 | 24 |
25 class IgnitionCompilerDispatcherJobTest : public TestWithContext { | 25 class IgnitionCompilerDispatcherJobTest : public TestWithContext { |
26 public: | 26 public: |
27 IgnitionCompilerDispatcherJobTest() {} | 27 IgnitionCompilerDispatcherJobTest() {} |
28 ~IgnitionCompilerDispatcherJobTest() override {} | 28 ~IgnitionCompilerDispatcherJobTest() override {} |
29 | 29 |
30 static void SetUpTestCase() { | 30 static void SetUpTestCase() { |
31 old_flag_ = i::FLAG_ignition; | 31 old_flag_ = i::FLAG_ignition; |
32 i::FLAG_ignition = true; | 32 i::FLAG_ignition = true; |
| 33 i::FLAG_never_compact = true; |
33 TestWithContext::SetUpTestCase(); | 34 TestWithContext::SetUpTestCase(); |
34 } | 35 } |
35 | 36 |
36 static void TearDownTestCase() { | 37 static void TearDownTestCase() { |
37 TestWithContext::TearDownTestCase(); | 38 TestWithContext::TearDownTestCase(); |
38 i::FLAG_ignition = old_flag_; | 39 i::FLAG_ignition = old_flag_; |
39 } | 40 } |
40 | 41 |
41 private: | 42 private: |
42 static bool old_flag_; | 43 static bool old_flag_; |
(...skipping 15 matching lines...) Expand all Loading... |
58 const char* data() const override { return data_; } | 59 const char* data() const override { return data_; } |
59 size_t length() const override { return length_; } | 60 size_t length() const override { return length_; } |
60 | 61 |
61 private: | 62 private: |
62 const char* data_; | 63 const char* data_; |
63 size_t length_; | 64 size_t length_; |
64 | 65 |
65 DISALLOW_COPY_AND_ASSIGN(ScriptResource); | 66 DISALLOW_COPY_AND_ASSIGN(ScriptResource); |
66 }; | 67 }; |
67 | 68 |
68 Handle<JSFunction> CreateFunction( | 69 Handle<SharedFunctionInfo> CreateSharedFunctionInfo( |
69 Isolate* isolate, ExternalOneByteString::Resource* maybe_resource) { | 70 Isolate* isolate, ExternalOneByteString::Resource* maybe_resource) { |
70 HandleScope scope(isolate); | 71 HandleScope scope(isolate); |
71 Handle<String> source; | 72 Handle<String> source; |
72 if (maybe_resource) { | 73 if (maybe_resource) { |
73 source = isolate->factory() | 74 source = isolate->factory() |
74 ->NewExternalStringFromOneByte(maybe_resource) | 75 ->NewExternalStringFromOneByte(maybe_resource) |
75 .ToHandleChecked(); | 76 .ToHandleChecked(); |
76 } else { | 77 } else { |
77 source = isolate->factory()->NewStringFromAsciiChecked(test_script); | 78 source = isolate->factory()->NewStringFromAsciiChecked(test_script); |
78 } | 79 } |
79 Handle<Script> script = isolate->factory()->NewScript(source); | 80 Handle<Script> script = isolate->factory()->NewScript(source); |
80 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( | 81 Handle<SharedFunctionInfo> shared = isolate->factory()->NewSharedFunctionInfo( |
81 isolate->factory()->NewStringFromAsciiChecked("f"), | 82 isolate->factory()->NewStringFromAsciiChecked("f"), |
82 isolate->builtins()->CompileLazy(), false); | 83 isolate->builtins()->CompileLazy(), false); |
83 SharedFunctionInfo::SetScript(shared, script); | 84 SharedFunctionInfo::SetScript(shared, script); |
84 shared->set_end_position(source->length()); | 85 shared->set_end_position(source->length()); |
85 Handle<JSFunction> function = | 86 shared->set_outer_scope_info(ScopeInfo::Empty(isolate)); |
86 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 87 return scope.CloseAndEscape(shared); |
87 shared, handle(isolate->context(), isolate)); | |
88 return scope.CloseAndEscape(function); | |
89 } | 88 } |
90 | 89 |
91 Handle<Object> RunJS(v8::Isolate* isolate, const char* script) { | 90 Handle<Object> RunJS(v8::Isolate* isolate, const char* script) { |
92 return Utils::OpenHandle( | 91 return Utils::OpenHandle( |
93 *v8::Script::Compile( | 92 *v8::Script::Compile( |
94 isolate->GetCurrentContext(), | 93 isolate->GetCurrentContext(), |
95 v8::String::NewFromUtf8(isolate, script, v8::NewStringType::kNormal) | 94 v8::String::NewFromUtf8(isolate, script, v8::NewStringType::kNormal) |
96 .ToLocalChecked()) | 95 .ToLocalChecked()) |
97 .ToLocalChecked() | 96 .ToLocalChecked() |
98 ->Run(isolate->GetCurrentContext()) | 97 ->Run(isolate->GetCurrentContext()) |
99 .ToLocalChecked()); | 98 .ToLocalChecked()); |
100 } | 99 } |
101 | 100 |
102 } // namespace | 101 } // namespace |
103 | 102 |
104 TEST_F(CompilerDispatcherJobTest, Construct) { | 103 TEST_F(CompilerDispatcherJobTest, Construct) { |
105 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 104 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
106 i_isolate(), CreateFunction(i_isolate(), nullptr), FLAG_stack_size)); | 105 i_isolate(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
| 106 FLAG_stack_size)); |
107 } | 107 } |
108 | 108 |
109 TEST_F(CompilerDispatcherJobTest, CanParseOnBackgroundThread) { | 109 TEST_F(CompilerDispatcherJobTest, CanParseOnBackgroundThread) { |
110 { | 110 { |
111 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 111 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
112 i_isolate(), CreateFunction(i_isolate(), nullptr), FLAG_stack_size)); | 112 i_isolate(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
| 113 FLAG_stack_size)); |
113 ASSERT_FALSE(job->can_parse_on_background_thread()); | 114 ASSERT_FALSE(job->can_parse_on_background_thread()); |
114 } | 115 } |
115 { | 116 { |
116 ScriptResource script(test_script, strlen(test_script)); | 117 ScriptResource script(test_script, strlen(test_script)); |
117 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 118 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
118 i_isolate(), CreateFunction(i_isolate(), &script), FLAG_stack_size)); | 119 i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), |
| 120 FLAG_stack_size)); |
119 ASSERT_TRUE(job->can_parse_on_background_thread()); | 121 ASSERT_TRUE(job->can_parse_on_background_thread()); |
120 } | 122 } |
121 } | 123 } |
122 | 124 |
123 TEST_F(CompilerDispatcherJobTest, StateTransitions) { | 125 TEST_F(CompilerDispatcherJobTest, StateTransitions) { |
124 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 126 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
125 i_isolate(), CreateFunction(i_isolate(), nullptr), FLAG_stack_size)); | 127 i_isolate(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
| 128 FLAG_stack_size)); |
126 | 129 |
127 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 130 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
128 job->PrepareToParseOnMainThread(); | 131 job->PrepareToParseOnMainThread(); |
129 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToParse); | 132 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToParse); |
130 job->Parse(); | 133 job->Parse(); |
131 ASSERT_TRUE(job->status() == CompileJobStatus::kParsed); | 134 ASSERT_TRUE(job->status() == CompileJobStatus::kParsed); |
132 ASSERT_TRUE(job->FinalizeParsingOnMainThread()); | 135 ASSERT_TRUE(job->FinalizeParsingOnMainThread()); |
133 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToAnalyse); | 136 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToAnalyse); |
134 ASSERT_TRUE(job->PrepareToCompileOnMainThread()); | 137 ASSERT_TRUE(job->PrepareToCompileOnMainThread()); |
135 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); | 138 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); |
136 job->Compile(); | 139 job->Compile(); |
137 ASSERT_TRUE(job->status() == CompileJobStatus::kCompiled); | 140 ASSERT_TRUE(job->status() == CompileJobStatus::kCompiled); |
138 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); | 141 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); |
139 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); | 142 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); |
140 job->ResetOnMainThread(); | 143 job->ResetOnMainThread(); |
141 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 144 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
142 } | 145 } |
143 | 146 |
144 TEST_F(CompilerDispatcherJobTest, SyntaxError) { | 147 TEST_F(CompilerDispatcherJobTest, SyntaxError) { |
145 ScriptResource script("^^^", strlen("^^^")); | 148 ScriptResource script("^^^", strlen("^^^")); |
146 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 149 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
147 i_isolate(), CreateFunction(i_isolate(), &script), FLAG_stack_size)); | 150 i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), |
| 151 FLAG_stack_size)); |
148 | 152 |
149 job->PrepareToParseOnMainThread(); | 153 job->PrepareToParseOnMainThread(); |
150 job->Parse(); | 154 job->Parse(); |
151 ASSERT_FALSE(job->FinalizeParsingOnMainThread()); | 155 ASSERT_FALSE(job->FinalizeParsingOnMainThread()); |
152 ASSERT_TRUE(job->status() == CompileJobStatus::kFailed); | 156 ASSERT_TRUE(job->status() == CompileJobStatus::kFailed); |
153 ASSERT_TRUE(i_isolate()->has_pending_exception()); | 157 ASSERT_TRUE(i_isolate()->has_pending_exception()); |
154 | 158 |
155 i_isolate()->clear_pending_exception(); | 159 i_isolate()->clear_pending_exception(); |
156 | 160 |
157 job->ResetOnMainThread(); | 161 job->ResetOnMainThread(); |
158 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 162 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
159 } | 163 } |
160 | 164 |
161 TEST_F(CompilerDispatcherJobTest, ScopeChain) { | 165 TEST_F(CompilerDispatcherJobTest, ScopeChain) { |
162 const char script[] = | 166 const char script[] = |
163 "function g() { var g = 1; function f(x) { return x * g }; return f; } " | 167 "function g() { var y = 1; function f(x) { return x * y }; return f; } " |
164 "g();"; | 168 "g();"; |
165 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); | 169 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); |
166 | 170 |
167 std::unique_ptr<CompilerDispatcherJob> job( | 171 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
168 new CompilerDispatcherJob(i_isolate(), f, FLAG_stack_size)); | 172 i_isolate(), handle(f->shared()), FLAG_stack_size)); |
169 | 173 |
170 job->PrepareToParseOnMainThread(); | 174 job->PrepareToParseOnMainThread(); |
171 job->Parse(); | 175 job->Parse(); |
172 ASSERT_TRUE(job->FinalizeParsingOnMainThread()); | 176 ASSERT_TRUE(job->FinalizeParsingOnMainThread()); |
173 ASSERT_TRUE(job->PrepareToCompileOnMainThread()); | 177 ASSERT_TRUE(job->PrepareToCompileOnMainThread()); |
174 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); | 178 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); |
175 | 179 |
176 const AstRawString* var_x = | 180 const AstRawString* var_x = |
177 job->parse_info_->ast_value_factory()->GetOneByteString("x"); | 181 job->parse_info_->ast_value_factory()->GetOneByteString("x"); |
178 Variable* var = job->parse_info_->literal()->scope()->Lookup(var_x); | 182 Variable* var = job->parse_info_->literal()->scope()->Lookup(var_x); |
179 ASSERT_TRUE(var); | 183 ASSERT_TRUE(var); |
180 ASSERT_TRUE(var->IsParameter()); | 184 ASSERT_TRUE(var->IsParameter()); |
181 | 185 |
182 const AstRawString* var_g = | 186 const AstRawString* var_y = |
183 job->parse_info_->ast_value_factory()->GetOneByteString("g"); | 187 job->parse_info_->ast_value_factory()->GetOneByteString("y"); |
184 var = job->parse_info_->literal()->scope()->Lookup(var_g); | 188 var = job->parse_info_->literal()->scope()->Lookup(var_y); |
185 ASSERT_TRUE(var); | 189 ASSERT_TRUE(var); |
186 ASSERT_TRUE(var->IsContextSlot()); | 190 ASSERT_TRUE(var->IsContextSlot()); |
187 | 191 |
188 job->ResetOnMainThread(); | 192 job->ResetOnMainThread(); |
189 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 193 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
190 } | 194 } |
191 | 195 |
192 TEST_F(CompilerDispatcherJobTest, CompileAndRun) { | 196 TEST_F(CompilerDispatcherJobTest, CompileAndRun) { |
193 const char script[] = | 197 const char script[] = |
194 "function g() {\n" | 198 "function g() {\n" |
195 " f = function(a) {\n" | 199 " f = function(a) {\n" |
196 " for (var i = 0; i < 3; i++) { a += 20; }\n" | 200 " for (var i = 0; i < 3; i++) { a += 20; }\n" |
197 " return a;\n" | 201 " return a;\n" |
198 " }\n" | 202 " }\n" |
199 " return f;\n" | 203 " return f;\n" |
200 "}\n" | 204 "}\n" |
201 "g();"; | 205 "g();"; |
202 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); | 206 Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); |
203 std::unique_ptr<CompilerDispatcherJob> job( | 207 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
204 new CompilerDispatcherJob(i_isolate(), f, FLAG_stack_size)); | 208 i_isolate(), handle(f->shared()), FLAG_stack_size)); |
205 | 209 |
206 job->PrepareToParseOnMainThread(); | 210 job->PrepareToParseOnMainThread(); |
207 job->Parse(); | 211 job->Parse(); |
208 job->FinalizeParsingOnMainThread(); | 212 job->FinalizeParsingOnMainThread(); |
209 job->PrepareToCompileOnMainThread(); | 213 job->PrepareToCompileOnMainThread(); |
210 job->Compile(); | 214 job->Compile(); |
211 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); | 215 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); |
212 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); | 216 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); |
213 | 217 |
214 Smi* value = Smi::cast(*RunJS(isolate(), "f(100);")); | 218 Smi* value = Smi::cast(*RunJS(isolate(), "f(100);")); |
215 ASSERT_TRUE(value == Smi::FromInt(160)); | 219 ASSERT_TRUE(value == Smi::FromInt(160)); |
216 | 220 |
217 job->ResetOnMainThread(); | 221 job->ResetOnMainThread(); |
218 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 222 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
219 } | 223 } |
220 | 224 |
221 TEST_F(CompilerDispatcherJobTest, CompileFailureToPrepare) { | 225 TEST_F(CompilerDispatcherJobTest, CompileFailureToPrepare) { |
222 std::string raw_script("() { var a = "); | 226 std::string raw_script("() { var a = "); |
223 for (int i = 0; i < 100000; i++) { | 227 for (int i = 0; i < 100000; i++) { |
224 raw_script += "'x' + "; | 228 raw_script += "'x' + "; |
225 } | 229 } |
226 raw_script += " 'x'; }"; | 230 raw_script += " 'x'; }"; |
227 ScriptResource script(raw_script.c_str(), strlen(raw_script.c_str())); | 231 ScriptResource script(raw_script.c_str(), strlen(raw_script.c_str())); |
228 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 232 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
229 i_isolate(), CreateFunction(i_isolate(), &script), 100)); | 233 i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), 100)); |
230 | 234 |
231 job->PrepareToParseOnMainThread(); | 235 job->PrepareToParseOnMainThread(); |
232 job->Parse(); | 236 job->Parse(); |
233 job->FinalizeParsingOnMainThread(); | 237 job->FinalizeParsingOnMainThread(); |
234 ASSERT_FALSE(job->PrepareToCompileOnMainThread()); | 238 ASSERT_FALSE(job->PrepareToCompileOnMainThread()); |
235 ASSERT_TRUE(job->status() == CompileJobStatus::kFailed); | 239 ASSERT_TRUE(job->status() == CompileJobStatus::kFailed); |
236 ASSERT_TRUE(i_isolate()->has_pending_exception()); | 240 ASSERT_TRUE(i_isolate()->has_pending_exception()); |
237 | 241 |
238 i_isolate()->clear_pending_exception(); | 242 i_isolate()->clear_pending_exception(); |
239 job->ResetOnMainThread(); | 243 job->ResetOnMainThread(); |
240 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 244 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
241 } | 245 } |
242 | 246 |
243 TEST_F(CompilerDispatcherJobTest, CompileFailureToFinalize) { | 247 TEST_F(CompilerDispatcherJobTest, CompileFailureToFinalize) { |
244 std::string raw_script("() { var a = "); | 248 std::string raw_script("() { var a = "); |
245 for (int i = 0; i < 1000; i++) { | 249 for (int i = 0; i < 1000; i++) { |
246 raw_script += "'x' + "; | 250 raw_script += "'x' + "; |
247 } | 251 } |
248 raw_script += " 'x'; }"; | 252 raw_script += " 'x'; }"; |
249 ScriptResource script(raw_script.c_str(), strlen(raw_script.c_str())); | 253 ScriptResource script(raw_script.c_str(), strlen(raw_script.c_str())); |
250 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 254 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
251 i_isolate(), CreateFunction(i_isolate(), &script), 50)); | 255 i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), 50)); |
252 | 256 |
253 job->PrepareToParseOnMainThread(); | 257 job->PrepareToParseOnMainThread(); |
254 job->Parse(); | 258 job->Parse(); |
255 job->FinalizeParsingOnMainThread(); | 259 job->FinalizeParsingOnMainThread(); |
256 job->PrepareToCompileOnMainThread(); | 260 job->PrepareToCompileOnMainThread(); |
257 job->Compile(); | 261 job->Compile(); |
258 ASSERT_FALSE(job->FinalizeCompilingOnMainThread()); | 262 ASSERT_FALSE(job->FinalizeCompilingOnMainThread()); |
259 ASSERT_TRUE(job->status() == CompileJobStatus::kFailed); | 263 ASSERT_TRUE(job->status() == CompileJobStatus::kFailed); |
260 ASSERT_TRUE(i_isolate()->has_pending_exception()); | 264 ASSERT_TRUE(i_isolate()->has_pending_exception()); |
261 | 265 |
(...skipping 22 matching lines...) Expand all Loading... |
284 TEST_F(IgnitionCompilerDispatcherJobTest, CompileOnBackgroundThread) { | 288 TEST_F(IgnitionCompilerDispatcherJobTest, CompileOnBackgroundThread) { |
285 const char* raw_script = | 289 const char* raw_script = |
286 "(a, b) {\n" | 290 "(a, b) {\n" |
287 " var c = a + b;\n" | 291 " var c = a + b;\n" |
288 " function bar() { return b }\n" | 292 " function bar() { return b }\n" |
289 " var d = { foo: 100, bar : bar() }\n" | 293 " var d = { foo: 100, bar : bar() }\n" |
290 " return bar;" | 294 " return bar;" |
291 "}"; | 295 "}"; |
292 ScriptResource script(raw_script, strlen(raw_script)); | 296 ScriptResource script(raw_script, strlen(raw_script)); |
293 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 297 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
294 i_isolate(), CreateFunction(i_isolate(), &script), 100)); | 298 i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), 100)); |
295 | 299 |
296 job->PrepareToParseOnMainThread(); | 300 job->PrepareToParseOnMainThread(); |
297 job->Parse(); | 301 job->Parse(); |
298 job->FinalizeParsingOnMainThread(); | 302 job->FinalizeParsingOnMainThread(); |
299 job->PrepareToCompileOnMainThread(); | 303 job->PrepareToCompileOnMainThread(); |
300 ASSERT_TRUE(job->can_compile_on_background_thread()); | 304 ASSERT_TRUE(job->can_compile_on_background_thread()); |
301 | 305 |
302 base::Semaphore semaphore(0); | 306 base::Semaphore semaphore(0); |
303 CompileTask* background_task = new CompileTask(job.get(), &semaphore); | 307 CompileTask* background_task = new CompileTask(job.get(), &semaphore); |
304 V8::GetCurrentPlatform()->CallOnBackgroundThread(background_task, | 308 V8::GetCurrentPlatform()->CallOnBackgroundThread(background_task, |
305 Platform::kShortRunningTask); | 309 Platform::kShortRunningTask); |
306 semaphore.Wait(); | 310 semaphore.Wait(); |
307 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); | 311 ASSERT_TRUE(job->FinalizeCompilingOnMainThread()); |
308 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); | 312 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); |
309 | 313 |
310 job->ResetOnMainThread(); | 314 job->ResetOnMainThread(); |
311 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 315 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
312 } | 316 } |
313 | 317 |
314 } // namespace internal | 318 } // namespace internal |
315 } // namespace v8 | 319 } // namespace v8 |
OLD | NEW |