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/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" | 10 #include "src/compiler-dispatcher/compiler-dispatcher-job.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 TEST_F(CompilerDispatcherJobTest, StateTransitions) { | 86 TEST_F(CompilerDispatcherJobTest, StateTransitions) { |
87 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 87 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
88 i_isolate(), CreateFunction(i_isolate(), nullptr), FLAG_stack_size)); | 88 i_isolate(), CreateFunction(i_isolate(), nullptr), FLAG_stack_size)); |
89 | 89 |
90 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 90 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
91 job->PrepareToParseOnMainThread(); | 91 job->PrepareToParseOnMainThread(); |
92 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToParse); | 92 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToParse); |
93 job->Parse(); | 93 job->Parse(); |
94 ASSERT_TRUE(job->status() == CompileJobStatus::kParsed); | 94 ASSERT_TRUE(job->status() == CompileJobStatus::kParsed); |
95 job->FinalizeParsingOnMainThread(); | 95 job->FinalizeParsingOnMainThread(); |
| 96 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToAnalyse); |
| 97 job->PrepareToCompileOnMainThread(); |
96 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); | 98 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); |
| 99 job->Compile(); |
| 100 ASSERT_TRUE(job->status() == CompileJobStatus::kCompiled); |
| 101 job->FinalizeCompilingOnMainThread(); |
| 102 ASSERT_TRUE(job->status() == CompileJobStatus::kDone); |
97 job->ResetOnMainThread(); | 103 job->ResetOnMainThread(); |
98 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 104 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
99 } | 105 } |
100 | 106 |
101 TEST_F(CompilerDispatcherJobTest, SyntaxError) { | 107 TEST_F(CompilerDispatcherJobTest, SyntaxError) { |
102 ScriptResource script("^^^", strlen("^^^")); | 108 ScriptResource script("^^^", strlen("^^^")); |
103 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( | 109 std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
104 i_isolate(), CreateFunction(i_isolate(), &script), FLAG_stack_size)); | 110 i_isolate(), CreateFunction(i_isolate(), &script), FLAG_stack_size)); |
105 | 111 |
106 job->PrepareToParseOnMainThread(); | 112 job->PrepareToParseOnMainThread(); |
(...skipping 20 matching lines...) Expand all Loading... |
127 .ToLocalChecked() | 133 .ToLocalChecked() |
128 ->Run(isolate()->GetCurrentContext()) | 134 ->Run(isolate()->GetCurrentContext()) |
129 .ToLocalChecked())); | 135 .ToLocalChecked())); |
130 | 136 |
131 std::unique_ptr<CompilerDispatcherJob> job( | 137 std::unique_ptr<CompilerDispatcherJob> job( |
132 new CompilerDispatcherJob(i_isolate(), f, FLAG_stack_size)); | 138 new CompilerDispatcherJob(i_isolate(), f, FLAG_stack_size)); |
133 | 139 |
134 job->PrepareToParseOnMainThread(); | 140 job->PrepareToParseOnMainThread(); |
135 job->Parse(); | 141 job->Parse(); |
136 job->FinalizeParsingOnMainThread(); | 142 job->FinalizeParsingOnMainThread(); |
137 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile); | 143 ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToAnalyse); |
138 | 144 |
139 const AstRawString* var_x = | 145 const AstRawString* var_x = |
140 job->parse_info_->ast_value_factory()->GetOneByteString("x"); | 146 job->parse_info_->ast_value_factory()->GetOneByteString("x"); |
141 Variable* var = job->parse_info_->literal()->scope()->Lookup(var_x); | 147 Variable* var = job->parse_info_->literal()->scope()->Lookup(var_x); |
142 ASSERT_TRUE(var); | 148 ASSERT_TRUE(var); |
143 ASSERT_TRUE(var->IsUnallocated()); | 149 ASSERT_TRUE(var->IsUnallocated()); |
144 | 150 |
145 const AstRawString* var_g = | 151 const AstRawString* var_g = |
146 job->parse_info_->ast_value_factory()->GetOneByteString("g"); | 152 job->parse_info_->ast_value_factory()->GetOneByteString("g"); |
147 var = job->parse_info_->literal()->scope()->Lookup(var_g); | 153 var = job->parse_info_->literal()->scope()->Lookup(var_g); |
148 ASSERT_TRUE(var); | 154 ASSERT_TRUE(var); |
149 ASSERT_TRUE(var->IsContextSlot()); | 155 ASSERT_TRUE(var->IsContextSlot()); |
150 | 156 |
151 job->ResetOnMainThread(); | 157 job->ResetOnMainThread(); |
152 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); | 158 ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
153 } | 159 } |
154 | 160 |
155 } // namespace internal | 161 } // namespace internal |
156 } // namespace v8 | 162 } // namespace v8 |
OLD | NEW |