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" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 JSFunction* p = NULL; | 152 JSFunction* p = NULL; |
153 { // because of the implicit handle scope of FunctionTester. | 153 { // because of the implicit handle scope of FunctionTester. |
154 FunctionTester f(graph, param_count); | 154 FunctionTester f(graph, param_count); |
155 p = *f.function; | 155 p = *f.function; |
156 } | 156 } |
157 return Handle<JSFunction>(p); // allocated in outer handle scope. | 157 return Handle<JSFunction>(p); // allocated in outer handle scope. |
158 } | 158 } |
159 | 159 |
160 Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { | 160 Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { |
161 Zone zone(function->GetIsolate()->allocator()); | 161 Zone zone(function->GetIsolate()->allocator()); |
162 ParseInfo parse_info(&zone, handle(function->shared())); | 162 ParseInfo parse_info(&zone, function); |
163 CompilationInfo info(&parse_info, function); | 163 CompilationInfo info(&parse_info, function); |
164 | 164 |
165 info.SetOptimizing(); | 165 info.SetOptimizing(); |
166 info.MarkAsDeoptimizationEnabled(); | 166 info.MarkAsDeoptimizationEnabled(); |
167 if (flags_ & CompilationInfo::kNativeContextSpecializing) { | 167 if (flags_ & CompilationInfo::kNativeContextSpecializing) { |
168 info.MarkAsNativeContextSpecializing(); | 168 info.MarkAsNativeContextSpecializing(); |
169 } | 169 } |
170 if (flags_ & CompilationInfo::kInliningEnabled) { | 170 if (flags_ & CompilationInfo::kInliningEnabled) { |
171 info.MarkAsInliningEnabled(); | 171 info.MarkAsInliningEnabled(); |
172 } | 172 } |
(...skipping 10 matching lines...) Expand all Loading... |
183 info.dependencies()->Commit(code); | 183 info.dependencies()->Commit(code); |
184 info.context()->native_context()->AddOptimizedCode(*code); | 184 info.context()->native_context()->AddOptimizedCode(*code); |
185 function->ReplaceCode(*code); | 185 function->ReplaceCode(*code); |
186 return function; | 186 return function; |
187 } | 187 } |
188 | 188 |
189 // Compile the given machine graph instead of the source of the function | 189 // Compile the given machine graph instead of the source of the function |
190 // and replace the JSFunction's code with the result. | 190 // and replace the JSFunction's code with the result. |
191 Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { | 191 Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { |
192 Zone zone(function->GetIsolate()->allocator()); | 192 Zone zone(function->GetIsolate()->allocator()); |
193 ParseInfo parse_info(&zone, handle(function->shared())); | 193 ParseInfo parse_info(&zone, function); |
194 CompilationInfo info(&parse_info, function); | 194 CompilationInfo info(&parse_info, function); |
195 | 195 |
196 CHECK(Parser::ParseStatic(info.parse_info())); | 196 CHECK(Parser::ParseStatic(info.parse_info())); |
197 info.SetOptimizing(); | 197 info.SetOptimizing(); |
198 | 198 |
199 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); | 199 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); |
200 CHECK(!code.is_null()); | 200 CHECK(!code.is_null()); |
201 function->ReplaceCode(*code); | 201 function->ReplaceCode(*code); |
202 return function; | 202 return function; |
203 } | 203 } |
204 | 204 |
205 } // namespace compiler | 205 } // namespace compiler |
206 } // namespace internal | 206 } // namespace internal |
207 } // namespace v8 | 207 } // namespace v8 |
OLD | NEW |