OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
7 | 7 |
8 #include "src/ast/ast-numbering.h" | 8 #include "src/ast/ast-numbering.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 FunctionTester f(graph, param_count); | 168 FunctionTester f(graph, param_count); |
169 p = *f.function; | 169 p = *f.function; |
170 } | 170 } |
171 return Handle<JSFunction>(p); // allocated in outer handle scope. | 171 return Handle<JSFunction>(p); // allocated in outer handle scope. |
172 } | 172 } |
173 | 173 |
174 private: | 174 private: |
175 uint32_t flags_; | 175 uint32_t flags_; |
176 | 176 |
177 Handle<JSFunction> Compile(Handle<JSFunction> function) { | 177 Handle<JSFunction> Compile(Handle<JSFunction> function) { |
178 Zone zone; | 178 Zone zone(function->GetIsolate()->allocator()); |
179 ParseInfo parse_info(&zone, function); | 179 ParseInfo parse_info(&zone, function); |
180 CompilationInfo info(&parse_info); | 180 CompilationInfo info(&parse_info); |
181 info.MarkAsDeoptimizationEnabled(); | 181 info.MarkAsDeoptimizationEnabled(); |
182 | 182 |
183 CHECK(Parser::ParseStatic(info.parse_info())); | 183 CHECK(Parser::ParseStatic(info.parse_info())); |
184 info.SetOptimizing(); | 184 info.SetOptimizing(); |
185 if (flags_ & CompilationInfo::kFunctionContextSpecializing) { | 185 if (flags_ & CompilationInfo::kFunctionContextSpecializing) { |
186 info.MarkAsFunctionContextSpecializing(); | 186 info.MarkAsFunctionContextSpecializing(); |
187 } | 187 } |
188 if (flags_ & CompilationInfo::kInliningEnabled) { | 188 if (flags_ & CompilationInfo::kInliningEnabled) { |
(...skipping 28 matching lines...) Expand all Loading... |
217 } | 217 } |
218 | 218 |
219 std::string BuildFunctionFromDescriptor( | 219 std::string BuildFunctionFromDescriptor( |
220 const CallInterfaceDescriptor& descriptor) { | 220 const CallInterfaceDescriptor& descriptor) { |
221 return BuildFunction(descriptor.GetParameterCount()); | 221 return BuildFunction(descriptor.GetParameterCount()); |
222 } | 222 } |
223 | 223 |
224 // Compile the given machine graph instead of the source of the function | 224 // Compile the given machine graph instead of the source of the function |
225 // and replace the JSFunction's code with the result. | 225 // and replace the JSFunction's code with the result. |
226 Handle<JSFunction> CompileGraph(Graph* graph) { | 226 Handle<JSFunction> CompileGraph(Graph* graph) { |
227 Zone zone; | 227 Zone zone(function->GetIsolate()->allocator()); |
228 ParseInfo parse_info(&zone, function); | 228 ParseInfo parse_info(&zone, function); |
229 CompilationInfo info(&parse_info); | 229 CompilationInfo info(&parse_info); |
230 | 230 |
231 CHECK(Parser::ParseStatic(info.parse_info())); | 231 CHECK(Parser::ParseStatic(info.parse_info())); |
232 info.SetOptimizing(); | 232 info.SetOptimizing(); |
233 CHECK(Compiler::Analyze(info.parse_info())); | 233 CHECK(Compiler::Analyze(info.parse_info())); |
234 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 234 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
235 | 235 |
236 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); | 236 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); |
237 CHECK(!code.is_null()); | 237 CHECK(!code.is_null()); |
238 function->ReplaceCode(*code); | 238 function->ReplaceCode(*code); |
239 return function; | 239 return function; |
240 } | 240 } |
241 }; | 241 }; |
242 } // namespace compiler | 242 } // namespace compiler |
243 } // namespace internal | 243 } // namespace internal |
244 } // namespace v8 | 244 } // namespace v8 |
245 | 245 |
246 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 246 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
OLD | NEW |