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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 Handle<Object> nan() { return isolate->factory()->nan_value(); } | 155 Handle<Object> nan() { return isolate->factory()->nan_value(); } |
156 | 156 |
157 Handle<Object> undefined() { return isolate->factory()->undefined_value(); } | 157 Handle<Object> undefined() { return isolate->factory()->undefined_value(); } |
158 | 158 |
159 Handle<Object> null() { return isolate->factory()->null_value(); } | 159 Handle<Object> null() { return isolate->factory()->null_value(); } |
160 | 160 |
161 Handle<Object> true_value() { return isolate->factory()->true_value(); } | 161 Handle<Object> true_value() { return isolate->factory()->true_value(); } |
162 | 162 |
163 Handle<Object> false_value() { return isolate->factory()->false_value(); } | 163 Handle<Object> false_value() { return isolate->factory()->false_value(); } |
164 | 164 |
| 165 static Handle<JSFunction> ForMachineGraph(Graph* graph, int param_count) { |
| 166 JSFunction* p = NULL; |
| 167 { // because of the implicit handle scope of FunctionTester. |
| 168 FunctionTester f(graph, param_count); |
| 169 p = *f.function; |
| 170 } |
| 171 return Handle<JSFunction>(p); // allocated in outer handle scope. |
| 172 } |
| 173 |
| 174 private: |
| 175 uint32_t flags_; |
| 176 |
165 Handle<JSFunction> Compile(Handle<JSFunction> function) { | 177 Handle<JSFunction> Compile(Handle<JSFunction> function) { |
166 // TODO(titzer): make this method private. | |
167 Zone zone; | 178 Zone zone; |
168 ParseInfo parse_info(&zone, function); | 179 ParseInfo parse_info(&zone, function); |
169 CompilationInfo info(&parse_info); | 180 CompilationInfo info(&parse_info); |
170 info.MarkAsDeoptimizationEnabled(); | 181 info.MarkAsDeoptimizationEnabled(); |
171 | 182 |
172 CHECK(Parser::ParseStatic(info.parse_info())); | 183 CHECK(Parser::ParseStatic(info.parse_info())); |
173 info.SetOptimizing(); | 184 info.SetOptimizing(); |
174 if (flags_ & CompilationInfo::kFunctionContextSpecializing) { | 185 if (flags_ & CompilationInfo::kFunctionContextSpecializing) { |
175 info.MarkAsFunctionContextSpecializing(); | 186 info.MarkAsFunctionContextSpecializing(); |
176 } | 187 } |
177 if (flags_ & CompilationInfo::kInliningEnabled) { | 188 if (flags_ & CompilationInfo::kInliningEnabled) { |
178 info.MarkAsInliningEnabled(); | 189 info.MarkAsInliningEnabled(); |
179 } | 190 } |
180 if (flags_ & CompilationInfo::kTypingEnabled) { | 191 if (flags_ & CompilationInfo::kTypingEnabled) { |
181 info.MarkAsTypingEnabled(); | 192 info.MarkAsTypingEnabled(); |
182 } | 193 } |
183 CHECK(Compiler::Analyze(info.parse_info())); | 194 CHECK(Compiler::Analyze(info.parse_info())); |
184 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 195 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
185 | 196 |
186 Pipeline pipeline(&info); | 197 Pipeline pipeline(&info); |
187 Handle<Code> code = pipeline.GenerateCode(); | 198 Handle<Code> code = pipeline.GenerateCode(); |
188 CHECK(!code.is_null()); | 199 CHECK(!code.is_null()); |
189 info.dependencies()->Commit(code); | 200 info.dependencies()->Commit(code); |
190 info.context()->native_context()->AddOptimizedCode(*code); | 201 info.context()->native_context()->AddOptimizedCode(*code); |
191 function->ReplaceCode(*code); | 202 function->ReplaceCode(*code); |
192 return function; | 203 return function; |
193 } | 204 } |
194 | 205 |
195 static Handle<JSFunction> ForMachineGraph(Graph* graph, int param_count) { | |
196 JSFunction* p = NULL; | |
197 { // because of the implicit handle scope of FunctionTester. | |
198 FunctionTester f(graph, param_count); | |
199 p = *f.function; | |
200 } | |
201 return Handle<JSFunction>(p); // allocated in outer handle scope. | |
202 } | |
203 | |
204 private: | |
205 uint32_t flags_; | |
206 | |
207 std::string BuildFunction(int param_count) { | 206 std::string BuildFunction(int param_count) { |
208 std::string function_string = "(function("; | 207 std::string function_string = "(function("; |
209 if (param_count > 0) { | 208 if (param_count > 0) { |
210 char next = 'a'; | 209 char next = 'a'; |
211 function_string += next; | 210 function_string += next; |
212 while (param_count-- > 0) { | 211 while (param_count-- > 0) { |
213 function_string += ','; | 212 function_string += ','; |
214 function_string += ++next; | 213 function_string += ++next; |
215 } | 214 } |
216 } | 215 } |
(...skipping 22 matching lines...) Expand all Loading... |
239 CHECK(!code.is_null()); | 238 CHECK(!code.is_null()); |
240 function->ReplaceCode(*code); | 239 function->ReplaceCode(*code); |
241 return function; | 240 return function; |
242 } | 241 } |
243 }; | 242 }; |
244 } // namespace compiler | 243 } // namespace compiler |
245 } // namespace internal | 244 } // namespace internal |
246 } // namespace v8 | 245 } // namespace v8 |
247 | 246 |
248 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 247 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
OLD | NEW |