| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 int param_count) { | 148 int param_count) { |
| 149 JSFunction* p = NULL; | 149 JSFunction* p = NULL; |
| 150 { // because of the implicit handle scope of FunctionTester. | 150 { // because of the implicit handle scope of FunctionTester. |
| 151 FunctionTester f(graph, param_count); | 151 FunctionTester f(graph, param_count); |
| 152 p = *f.function; | 152 p = *f.function; |
| 153 } | 153 } |
| 154 return Handle<JSFunction>(p); // allocated in outer handle scope. | 154 return Handle<JSFunction>(p); // allocated in outer handle scope. |
| 155 } | 155 } |
| 156 | 156 |
| 157 Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { | 157 Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { |
| 158 ParseInfo parse_info(handle(function->shared())); | 158 Zone zone(function->GetIsolate()->allocator(), ZONE_NAME); |
| 159 ParseInfo parse_info(&zone, handle(function->shared())); |
| 159 CompilationInfo info(&parse_info, function); | 160 CompilationInfo info(&parse_info, function); |
| 160 | 161 |
| 161 info.SetOptimizing(); | 162 info.SetOptimizing(); |
| 162 info.MarkAsDeoptimizationEnabled(); | 163 info.MarkAsDeoptimizationEnabled(); |
| 163 if (flags_ & CompilationInfo::kInliningEnabled) { | 164 if (flags_ & CompilationInfo::kInliningEnabled) { |
| 164 info.MarkAsInliningEnabled(); | 165 info.MarkAsInliningEnabled(); |
| 165 } | 166 } |
| 166 | 167 |
| 167 CHECK(Compiler::Compile(function, Compiler::CLEAR_EXCEPTION)); | 168 CHECK(Compiler::Compile(function, Compiler::CLEAR_EXCEPTION)); |
| 168 if (info.shared_info()->HasBytecodeArray()) { | 169 if (info.shared_info()->HasBytecodeArray()) { |
| 169 info.MarkAsOptimizeFromBytecode(); | 170 info.MarkAsOptimizeFromBytecode(); |
| 170 } else { | 171 } else { |
| 171 CHECK(Compiler::ParseAndAnalyze(info.parse_info())); | 172 CHECK(Compiler::ParseAndAnalyze(info.parse_info())); |
| 172 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); | 173 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); |
| 173 } | 174 } |
| 174 JSFunction::EnsureLiterals(function); | 175 JSFunction::EnsureLiterals(function); |
| 175 | 176 |
| 176 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info); | 177 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info); |
| 177 CHECK(!code.is_null()); | 178 CHECK(!code.is_null()); |
| 178 info.dependencies()->Commit(code); | 179 info.dependencies()->Commit(code); |
| 179 info.context()->native_context()->AddOptimizedCode(*code); | 180 info.context()->native_context()->AddOptimizedCode(*code); |
| 180 function->ReplaceCode(*code); | 181 function->ReplaceCode(*code); |
| 181 return function; | 182 return function; |
| 182 } | 183 } |
| 183 | 184 |
| 184 // Compile the given machine graph instead of the source of the function | 185 // Compile the given machine graph instead of the source of the function |
| 185 // and replace the JSFunction's code with the result. | 186 // and replace the JSFunction's code with the result. |
| 186 Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { | 187 Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { |
| 187 ParseInfo parse_info(handle(function->shared())); | 188 Zone zone(function->GetIsolate()->allocator(), ZONE_NAME); |
| 189 ParseInfo parse_info(&zone, handle(function->shared())); |
| 188 CompilationInfo info(&parse_info, function); | 190 CompilationInfo info(&parse_info, function); |
| 189 | 191 |
| 190 CHECK(parsing::ParseFunction(info.parse_info())); | 192 CHECK(parsing::ParseFunction(info.parse_info())); |
| 191 info.SetOptimizing(); | 193 info.SetOptimizing(); |
| 192 | 194 |
| 193 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); | 195 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); |
| 194 CHECK(!code.is_null()); | 196 CHECK(!code.is_null()); |
| 195 function->ReplaceCode(*code); | 197 function->ReplaceCode(*code); |
| 196 return function; | 198 return function; |
| 197 } | 199 } |
| 198 | 200 |
| 199 } // namespace compiler | 201 } // namespace compiler |
| 200 } // namespace internal | 202 } // namespace internal |
| 201 } // namespace v8 | 203 } // namespace v8 |
| OLD | NEW |