| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 Handle<Object> true_value() { return isolate->factory()->true_value(); } | 149 Handle<Object> true_value() { return isolate->factory()->true_value(); } |
| 150 | 150 |
| 151 Handle<Object> false_value() { return isolate->factory()->false_value(); } | 151 Handle<Object> false_value() { return isolate->factory()->false_value(); } |
| 152 | 152 |
| 153 Handle<JSFunction> Compile(Handle<JSFunction> function) { | 153 Handle<JSFunction> Compile(Handle<JSFunction> function) { |
| 154 // TODO(titzer): make this method private. | 154 // TODO(titzer): make this method private. |
| 155 #if V8_TURBOFAN_TARGET | 155 #if V8_TURBOFAN_TARGET |
| 156 CompilationInfoWithZone info(function); | 156 CompilationInfoWithZone info(function); |
| 157 | 157 |
| 158 CHECK(Parser::ParseStatic(&info)); | 158 CHECK(Parser::ParseStatic(info.parse_info())); |
| 159 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 159 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); |
| 160 if (flags_ & CompilationInfo::kContextSpecializing) { | 160 if (flags_ & CompilationInfo::kContextSpecializing) { |
| 161 info.MarkAsContextSpecializing(); | 161 info.MarkAsContextSpecializing(); |
| 162 } | 162 } |
| 163 if (flags_ & CompilationInfo::kInliningEnabled) { | 163 if (flags_ & CompilationInfo::kInliningEnabled) { |
| 164 info.MarkAsInliningEnabled(); | 164 info.MarkAsInliningEnabled(); |
| 165 } | 165 } |
| 166 if (flags_ & CompilationInfo::kTypingEnabled) { | 166 if (flags_ & CompilationInfo::kTypingEnabled) { |
| 167 info.MarkAsTypingEnabled(); | 167 info.MarkAsTypingEnabled(); |
| 168 } | 168 } |
| 169 CHECK(Compiler::Analyze(&info)); | 169 CHECK(Compiler::Analyze(info.parse_info())); |
| 170 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 170 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
| 171 | 171 |
| 172 Pipeline pipeline(&info); | 172 Pipeline pipeline(&info); |
| 173 Handle<Code> code = pipeline.GenerateCode(); | 173 Handle<Code> code = pipeline.GenerateCode(); |
| 174 if (FLAG_turbo_deoptimization) { | 174 if (FLAG_turbo_deoptimization) { |
| 175 info.context()->native_context()->AddOptimizedCode(*code); | 175 info.context()->native_context()->AddOptimizedCode(*code); |
| 176 } | 176 } |
| 177 | 177 |
| 178 CHECK(!code.is_null()); | 178 CHECK(!code.is_null()); |
| 179 function->ReplaceCode(*code); | 179 function->ReplaceCode(*code); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 204 | 204 |
| 205 private: | 205 private: |
| 206 uint32_t flags_; | 206 uint32_t flags_; |
| 207 | 207 |
| 208 // Compile the given machine graph instead of the source of the function | 208 // Compile the given machine graph instead of the source of the function |
| 209 // and replace the JSFunction's code with the result. | 209 // and replace the JSFunction's code with the result. |
| 210 Handle<JSFunction> CompileGraph(Graph* graph) { | 210 Handle<JSFunction> CompileGraph(Graph* graph) { |
| 211 CHECK(Pipeline::SupportedTarget()); | 211 CHECK(Pipeline::SupportedTarget()); |
| 212 CompilationInfoWithZone info(function); | 212 CompilationInfoWithZone info(function); |
| 213 | 213 |
| 214 CHECK(Parser::ParseStatic(&info)); | 214 CHECK(Parser::ParseStatic(info.parse_info())); |
| 215 info.SetOptimizing(BailoutId::None(), | 215 info.SetOptimizing(BailoutId::None(), |
| 216 Handle<Code>(function->shared()->code())); | 216 Handle<Code>(function->shared()->code())); |
| 217 CHECK(Compiler::Analyze(&info)); | 217 CHECK(Compiler::Analyze(info.parse_info())); |
| 218 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 218 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
| 219 | 219 |
| 220 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); | 220 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); |
| 221 CHECK(!code.is_null()); | 221 CHECK(!code.is_null()); |
| 222 function->ReplaceCode(*code); | 222 function->ReplaceCode(*code); |
| 223 return function; | 223 return function; |
| 224 } | 224 } |
| 225 }; | 225 }; |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 } // namespace v8::internal::compiler | 228 } // namespace v8::internal::compiler |
| 229 | 229 |
| 230 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 230 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |