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