| 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 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 class FunctionTester : public InitializedHandleScope { | 25 class FunctionTester : public InitializedHandleScope { |
| 26 public: | 26 public: |
| 27 explicit FunctionTester(const char* source, uint32_t flags = 0) | 27 explicit FunctionTester(const char* source, uint32_t flags = 0) |
| 28 : isolate(main_isolate()), | 28 : isolate(main_isolate()), |
| 29 function((FLAG_allow_natives_syntax = true, NewFunction(source))), | 29 function((FLAG_allow_natives_syntax = true, NewFunction(source))), |
| 30 flags_(flags) { | 30 flags_(flags) { |
| 31 Compile(function); | 31 Compile(function); |
| 32 const uint32_t supported_flags = | 32 const uint32_t supported_flags = |
| 33 CompilationInfo::kFunctionContextSpecializing | | 33 CompilationInfo::kFunctionContextSpecializing | |
| 34 CompilationInfo::kInliningEnabled | CompilationInfo::kTypingEnabled; | 34 CompilationInfo::kInliningEnabled; |
| 35 CHECK_EQ(0u, flags_ & ~supported_flags); | 35 CHECK_EQ(0u, flags_ & ~supported_flags); |
| 36 } | 36 } |
| 37 | 37 |
| 38 FunctionTester(Graph* graph, int param_count) | 38 FunctionTester(Graph* graph, int param_count) |
| 39 : isolate(main_isolate()), | 39 : isolate(main_isolate()), |
| 40 function(NewFunction(BuildFunction(param_count).c_str())), | 40 function(NewFunction(BuildFunction(param_count).c_str())), |
| 41 flags_(0) { | 41 flags_(0) { |
| 42 CompileGraph(graph); | 42 CompileGraph(graph); |
| 43 } | 43 } |
| 44 | 44 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) { |
| 189 info.MarkAsInliningEnabled(); | 189 info.MarkAsInliningEnabled(); |
| 190 } | 190 } |
| 191 if (flags_ & CompilationInfo::kTypingEnabled) { | |
| 192 info.MarkAsTypingEnabled(); | |
| 193 } | |
| 194 CHECK(Compiler::Analyze(info.parse_info())); | 191 CHECK(Compiler::Analyze(info.parse_info())); |
| 195 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 192 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
| 196 | 193 |
| 197 Pipeline pipeline(&info); | 194 Pipeline pipeline(&info); |
| 198 Handle<Code> code = pipeline.GenerateCode(); | 195 Handle<Code> code = pipeline.GenerateCode(); |
| 199 CHECK(!code.is_null()); | 196 CHECK(!code.is_null()); |
| 200 info.dependencies()->Commit(code); | 197 info.dependencies()->Commit(code); |
| 201 info.context()->native_context()->AddOptimizedCode(*code); | 198 info.context()->native_context()->AddOptimizedCode(*code); |
| 202 function->ReplaceCode(*code); | 199 function->ReplaceCode(*code); |
| 203 return function; | 200 return function; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 CHECK(!code.is_null()); | 234 CHECK(!code.is_null()); |
| 238 function->ReplaceCode(*code); | 235 function->ReplaceCode(*code); |
| 239 return function; | 236 return function; |
| 240 } | 237 } |
| 241 }; | 238 }; |
| 242 } // namespace compiler | 239 } // namespace compiler |
| 243 } // namespace internal | 240 } // namespace internal |
| 244 } // namespace v8 | 241 } // namespace v8 |
| 245 | 242 |
| 246 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 243 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |