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 #include "test/cctest/compiler/function-tester.h" | 5 #include "test/cctest/compiler/function-tester.h" |
6 | 6 |
7 #include "src/ast/ast-numbering.h" | 7 #include "src/ast/ast-numbering.h" |
8 #include "src/compilation-info.h" | 8 #include "src/compilation-info.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
11 #include "src/compiler/pipeline.h" | 11 #include "src/compiler/pipeline.h" |
12 #include "src/execution.h" | 12 #include "src/execution.h" |
13 #include "src/full-codegen/full-codegen.h" | 13 #include "src/full-codegen/full-codegen.h" |
14 #include "src/handles.h" | 14 #include "src/handles.h" |
15 #include "src/objects-inl.h" | 15 #include "src/objects-inl.h" |
16 #include "src/parsing/parse-info.h" | 16 #include "src/parsing/parse-info.h" |
17 #include "src/parsing/parser.h" | 17 #include "src/parsing/parser.h" |
18 #include "test/cctest/cctest.h" | 18 #include "test/cctest/cctest.h" |
19 | 19 |
20 namespace v8 { | 20 namespace v8 { |
21 namespace internal { | 21 namespace internal { |
22 namespace compiler { | 22 namespace compiler { |
23 | 23 |
24 FunctionTester::FunctionTester(const char* source, uint32_t flags) | 24 FunctionTester::FunctionTester(const char* source, uint32_t flags) |
25 : isolate(main_isolate()), | 25 : isolate(main_isolate()), |
26 function((FLAG_allow_natives_syntax = true, NewFunction(source))), | 26 function((FLAG_allow_natives_syntax = true, NewFunction(source))), |
27 flags_(flags) { | 27 flags_(flags) { |
28 Compile(function); | 28 Compile(function); |
29 const uint32_t supported_flags = CompilationInfo::kNativeContextSpecializing | | 29 const uint32_t supported_flags = CompilationInfo::kInliningEnabled; |
30 CompilationInfo::kInliningEnabled; | |
31 CHECK_EQ(0u, flags_ & ~supported_flags); | 30 CHECK_EQ(0u, flags_ & ~supported_flags); |
32 } | 31 } |
33 | 32 |
34 FunctionTester::FunctionTester(Graph* graph, int param_count) | 33 FunctionTester::FunctionTester(Graph* graph, int param_count) |
35 : isolate(main_isolate()), | 34 : isolate(main_isolate()), |
36 function(NewFunction(BuildFunction(param_count).c_str())), | 35 function(NewFunction(BuildFunction(param_count).c_str())), |
37 flags_(0) { | 36 flags_(0) { |
38 CompileGraph(graph); | 37 CompileGraph(graph); |
39 } | 38 } |
40 | 39 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return Handle<JSFunction>(p); // allocated in outer handle scope. | 156 return Handle<JSFunction>(p); // allocated in outer handle scope. |
158 } | 157 } |
159 | 158 |
160 Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { | 159 Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { |
161 Zone zone(function->GetIsolate()->allocator()); | 160 Zone zone(function->GetIsolate()->allocator()); |
162 ParseInfo parse_info(&zone, function); | 161 ParseInfo parse_info(&zone, function); |
163 CompilationInfo info(&parse_info, function); | 162 CompilationInfo info(&parse_info, function); |
164 | 163 |
165 info.SetOptimizing(); | 164 info.SetOptimizing(); |
166 info.MarkAsDeoptimizationEnabled(); | 165 info.MarkAsDeoptimizationEnabled(); |
167 if (flags_ & CompilationInfo::kNativeContextSpecializing) { | |
168 info.MarkAsNativeContextSpecializing(); | |
169 } | |
170 if (flags_ & CompilationInfo::kInliningEnabled) { | 166 if (flags_ & CompilationInfo::kInliningEnabled) { |
171 info.MarkAsInliningEnabled(); | 167 info.MarkAsInliningEnabled(); |
172 } | 168 } |
173 if (Compiler::EnsureBytecode(&info)) { | 169 if (Compiler::EnsureBytecode(&info)) { |
174 info.MarkAsOptimizeFromBytecode(); | 170 info.MarkAsOptimizeFromBytecode(); |
175 } else { | 171 } else { |
176 CHECK(Compiler::ParseAndAnalyze(info.parse_info())); | 172 CHECK(Compiler::ParseAndAnalyze(info.parse_info())); |
177 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 173 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
178 } | 174 } |
179 JSFunction::EnsureLiterals(function); | 175 JSFunction::EnsureLiterals(function); |
(...skipping 18 matching lines...) Expand all Loading... |
198 | 194 |
199 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); | 195 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); |
200 CHECK(!code.is_null()); | 196 CHECK(!code.is_null()); |
201 function->ReplaceCode(*code); | 197 function->ReplaceCode(*code); |
202 return function; | 198 return function; |
203 } | 199 } |
204 | 200 |
205 } // namespace compiler | 201 } // namespace compiler |
206 } // namespace internal | 202 } // namespace internal |
207 } // namespace v8 | 203 } // namespace v8 |
OLD | NEW |