Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: test/cctest/compiler/function-tester.h

Issue 1282763002: [turbofan] Drop V8_TURBOFAN_BACKEND and V8_TURBOFAN_TARGET defines. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/compiler/codegen-tester.cc ('k') | test/cctest/compiler/graph-builder-tester.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "src/ast-numbering.h" 11 #include "src/ast-numbering.h"
12 #include "src/compiler.h" 12 #include "src/compiler.h"
13 #include "src/compiler/linkage.h" 13 #include "src/compiler/linkage.h"
14 #include "src/compiler/pipeline.h" 14 #include "src/compiler/pipeline.h"
15 #include "src/execution.h" 15 #include "src/execution.h"
16 #include "src/full-codegen/full-codegen.h" 16 #include "src/full-codegen/full-codegen.h"
17 #include "src/handles.h" 17 #include "src/handles.h"
18 #include "src/objects-inl.h" 18 #include "src/objects-inl.h"
19 #include "src/parser.h" 19 #include "src/parser.h"
20 #include "src/rewriter.h" 20 #include "src/rewriter.h"
21 #include "src/scopes.h" 21 #include "src/scopes.h"
22 22
23 #define USE_CRANKSHAFT 0
24
25 namespace v8 { 23 namespace v8 {
26 namespace internal { 24 namespace internal {
27 namespace compiler { 25 namespace compiler {
28 26
29 class FunctionTester : public InitializedHandleScope { 27 class FunctionTester : public InitializedHandleScope {
30 public: 28 public:
31 explicit FunctionTester(const char* source, uint32_t flags = 0) 29 explicit FunctionTester(const char* source, uint32_t flags = 0)
32 : isolate(main_isolate()), 30 : isolate(main_isolate()),
33 function((FLAG_allow_natives_syntax = true, NewFunction(source))), 31 function((FLAG_allow_natives_syntax = true, NewFunction(source))),
34 flags_(flags) { 32 flags_(flags) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 Handle<Object> undefined() { return isolate->factory()->undefined_value(); } 147 Handle<Object> undefined() { return isolate->factory()->undefined_value(); }
150 148
151 Handle<Object> null() { return isolate->factory()->null_value(); } 149 Handle<Object> null() { return isolate->factory()->null_value(); }
152 150
153 Handle<Object> true_value() { return isolate->factory()->true_value(); } 151 Handle<Object> true_value() { return isolate->factory()->true_value(); }
154 152
155 Handle<Object> false_value() { return isolate->factory()->false_value(); } 153 Handle<Object> false_value() { return isolate->factory()->false_value(); }
156 154
157 Handle<JSFunction> Compile(Handle<JSFunction> function) { 155 Handle<JSFunction> Compile(Handle<JSFunction> function) {
158 // TODO(titzer): make this method private. 156 // TODO(titzer): make this method private.
159 #if V8_TURBOFAN_TARGET
160 Zone zone; 157 Zone zone;
161 ParseInfo parse_info(&zone, function); 158 ParseInfo parse_info(&zone, function);
162 CompilationInfo info(&parse_info); 159 CompilationInfo info(&parse_info);
163 info.MarkAsDeoptimizationEnabled(); 160 info.MarkAsDeoptimizationEnabled();
164 161
165 CHECK(Parser::ParseStatic(info.parse_info())); 162 CHECK(Parser::ParseStatic(info.parse_info()));
166 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); 163 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
167 if (flags_ & CompilationInfo::kContextSpecializing) { 164 if (flags_ & CompilationInfo::kContextSpecializing) {
168 info.MarkAsContextSpecializing(); 165 info.MarkAsContextSpecializing();
169 } 166 }
170 if (flags_ & CompilationInfo::kInliningEnabled) { 167 if (flags_ & CompilationInfo::kInliningEnabled) {
171 info.MarkAsInliningEnabled(); 168 info.MarkAsInliningEnabled();
172 } 169 }
173 if (flags_ & CompilationInfo::kTypingEnabled) { 170 if (flags_ & CompilationInfo::kTypingEnabled) {
174 info.MarkAsTypingEnabled(); 171 info.MarkAsTypingEnabled();
175 } 172 }
176 CHECK(Compiler::Analyze(info.parse_info())); 173 CHECK(Compiler::Analyze(info.parse_info()));
177 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); 174 CHECK(Compiler::EnsureDeoptimizationSupport(&info));
178 175
179 Pipeline pipeline(&info); 176 Pipeline pipeline(&info);
180 Handle<Code> code = pipeline.GenerateCode(); 177 Handle<Code> code = pipeline.GenerateCode();
181 CHECK(!code.is_null()); 178 CHECK(!code.is_null());
182 info.context()->native_context()->AddOptimizedCode(*code); 179 info.context()->native_context()->AddOptimizedCode(*code);
183 function->ReplaceCode(*code); 180 function->ReplaceCode(*code);
184 #elif USE_CRANKSHAFT
185 Handle<Code> unoptimized = Handle<Code>(function->code());
186 Handle<Code> code = Compiler::GetOptimizedCode(function, unoptimized,
187 Compiler::NOT_CONCURRENT);
188 CHECK(!code.is_null());
189 #if ENABLE_DISASSEMBLER
190 if (FLAG_print_opt_code) {
191 CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
192 code->Disassemble("test code", tracing_scope.file());
193 }
194 #endif
195 function->ReplaceCode(*code);
196 #endif
197 return function; 181 return function;
198 } 182 }
199 183
200 static Handle<JSFunction> ForMachineGraph(Graph* graph) { 184 static Handle<JSFunction> ForMachineGraph(Graph* graph) {
201 JSFunction* p = NULL; 185 JSFunction* p = NULL;
202 { // because of the implicit handle scope of FunctionTester. 186 { // because of the implicit handle scope of FunctionTester.
203 FunctionTester f(graph); 187 FunctionTester f(graph);
204 p = *f.function; 188 p = *f.function;
205 } 189 }
206 return Handle<JSFunction>(p); // allocated in outer handle scope. 190 return Handle<JSFunction>(p); // allocated in outer handle scope.
207 } 191 }
208 192
209 private: 193 private:
210 uint32_t flags_; 194 uint32_t flags_;
211 195
212 // Compile the given machine graph instead of the source of the function 196 // Compile the given machine graph instead of the source of the function
213 // and replace the JSFunction's code with the result. 197 // and replace the JSFunction's code with the result.
214 Handle<JSFunction> CompileGraph(Graph* graph) { 198 Handle<JSFunction> CompileGraph(Graph* graph) {
215 CHECK(Pipeline::SupportedTarget());
216 Zone zone; 199 Zone zone;
217 ParseInfo parse_info(&zone, function); 200 ParseInfo parse_info(&zone, function);
218 CompilationInfo info(&parse_info); 201 CompilationInfo info(&parse_info);
219 202
220 CHECK(Parser::ParseStatic(info.parse_info())); 203 CHECK(Parser::ParseStatic(info.parse_info()));
221 info.SetOptimizing(BailoutId::None(), 204 info.SetOptimizing(BailoutId::None(),
222 Handle<Code>(function->shared()->code())); 205 Handle<Code>(function->shared()->code()));
223 CHECK(Compiler::Analyze(info.parse_info())); 206 CHECK(Compiler::Analyze(info.parse_info()));
224 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); 207 CHECK(Compiler::EnsureDeoptimizationSupport(&info));
225 208
226 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); 209 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph);
227 CHECK(!code.is_null()); 210 CHECK(!code.is_null());
228 function->ReplaceCode(*code); 211 function->ReplaceCode(*code);
229 return function; 212 return function;
230 } 213 }
231 }; 214 };
232 } 215 }
233 } 216 }
234 } // namespace v8::internal::compiler 217 } // namespace v8::internal::compiler
235 218
236 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ 219 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
OLDNEW
« no previous file with comments | « test/cctest/compiler/codegen-tester.cc ('k') | test/cctest/compiler/graph-builder-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698