| 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/v8.h" | 8 #include "src/v8.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace internal { | 24 namespace internal { |
| 25 namespace compiler { | 25 namespace compiler { |
| 26 | 26 |
| 27 class FunctionTester : public InitializedHandleScope { | 27 class FunctionTester : public InitializedHandleScope { |
| 28 public: | 28 public: |
| 29 explicit FunctionTester(const char* source, uint32_t flags = 0) | 29 explicit FunctionTester(const char* source, uint32_t flags = 0) |
| 30 : isolate(main_isolate()), | 30 : isolate(main_isolate()), |
| 31 function((FLAG_allow_natives_syntax = true, NewFunction(source))), | 31 function((FLAG_allow_natives_syntax = true, NewFunction(source))), |
| 32 flags_(flags) { | 32 flags_(flags) { |
| 33 Compile(function); | 33 Compile(function); |
| 34 const uint32_t supported_flags = CompilationInfo::kContextSpecializing | | 34 const uint32_t supported_flags = |
| 35 CompilationInfo::kInliningEnabled | | 35 CompilationInfo::kFunctionContextSpecializing | |
| 36 CompilationInfo::kTypingEnabled; | 36 CompilationInfo::kInliningEnabled | CompilationInfo::kTypingEnabled; |
| 37 CHECK_EQ(0u, flags_ & ~supported_flags); | 37 CHECK_EQ(0u, flags_ & ~supported_flags); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // TODO(turbofan): generalize FunctionTester to work with N arguments. Now, it | 40 // TODO(turbofan): generalize FunctionTester to work with N arguments. Now, it |
| 41 // can handle up to four. | 41 // can handle up to four. |
| 42 explicit FunctionTester(Graph* graph) | 42 explicit FunctionTester(Graph* graph) |
| 43 : isolate(main_isolate()), | 43 : isolate(main_isolate()), |
| 44 function(NewFunction("(function(a,b,c,d){})")), | 44 function(NewFunction("(function(a,b,c,d){})")), |
| 45 flags_(0) { | 45 flags_(0) { |
| 46 CompileGraph(graph); | 46 CompileGraph(graph); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 Handle<JSFunction> Compile(Handle<JSFunction> function) { | 155 Handle<JSFunction> Compile(Handle<JSFunction> function) { |
| 156 // TODO(titzer): make this method private. | 156 // TODO(titzer): make this method private. |
| 157 Zone zone; | 157 Zone zone; |
| 158 ParseInfo parse_info(&zone, function); | 158 ParseInfo parse_info(&zone, function); |
| 159 CompilationInfo info(&parse_info); | 159 CompilationInfo info(&parse_info); |
| 160 info.MarkAsDeoptimizationEnabled(); | 160 info.MarkAsDeoptimizationEnabled(); |
| 161 | 161 |
| 162 CHECK(Parser::ParseStatic(info.parse_info())); | 162 CHECK(Parser::ParseStatic(info.parse_info())); |
| 163 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 163 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); |
| 164 if (flags_ & CompilationInfo::kContextSpecializing) { | 164 if (flags_ & CompilationInfo::kFunctionContextSpecializing) { |
| 165 info.MarkAsContextSpecializing(); | 165 info.MarkAsFunctionContextSpecializing(); |
| 166 } | 166 } |
| 167 if (flags_ & CompilationInfo::kInliningEnabled) { | 167 if (flags_ & CompilationInfo::kInliningEnabled) { |
| 168 info.MarkAsInliningEnabled(); | 168 info.MarkAsInliningEnabled(); |
| 169 } | 169 } |
| 170 if (flags_ & CompilationInfo::kTypingEnabled) { | 170 if (flags_ & CompilationInfo::kTypingEnabled) { |
| 171 info.MarkAsTypingEnabled(); | 171 info.MarkAsTypingEnabled(); |
| 172 } | 172 } |
| 173 CHECK(Compiler::Analyze(info.parse_info())); | 173 CHECK(Compiler::Analyze(info.parse_info())); |
| 174 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 174 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
| 175 | 175 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 CHECK(!code.is_null()); | 210 CHECK(!code.is_null()); |
| 211 function->ReplaceCode(*code); | 211 function->ReplaceCode(*code); |
| 212 return function; | 212 return function; |
| 213 } | 213 } |
| 214 }; | 214 }; |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 } // namespace v8::internal::compiler | 217 } // namespace v8::internal::compiler |
| 218 | 218 |
| 219 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 219 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |