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

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

Issue 2632123006: Reland: [Parse] ParseInfo owns the parsing Zone. (Closed)
Patch Set: Rebase Created 3 years, 10 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/asmjs/test-asm-typer.cc ('k') | test/cctest/compiler/test-linkage.cc » ('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 #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
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 Zone zone(function->GetIsolate()->allocator(), ZONE_NAME); 158 ParseInfo parse_info(handle(function->shared()));
159 ParseInfo parse_info(&zone, handle(function->shared()));
160 CompilationInfo info(&parse_info, function); 159 CompilationInfo info(&parse_info, function);
161 160
162 info.SetOptimizing(); 161 info.SetOptimizing();
163 info.MarkAsDeoptimizationEnabled(); 162 info.MarkAsDeoptimizationEnabled();
164 if (flags_ & CompilationInfo::kInliningEnabled) { 163 if (flags_ & CompilationInfo::kInliningEnabled) {
165 info.MarkAsInliningEnabled(); 164 info.MarkAsInliningEnabled();
166 } 165 }
167 166
168 CHECK(Compiler::Compile(function, Compiler::CLEAR_EXCEPTION)); 167 CHECK(Compiler::Compile(function, Compiler::CLEAR_EXCEPTION));
169 if (info.shared_info()->HasBytecodeArray()) { 168 if (info.shared_info()->HasBytecodeArray()) {
170 info.MarkAsOptimizeFromBytecode(); 169 info.MarkAsOptimizeFromBytecode();
171 } else { 170 } else {
172 CHECK(Compiler::ParseAndAnalyze(info.parse_info())); 171 CHECK(Compiler::ParseAndAnalyze(info.parse_info()));
173 CHECK(Compiler::EnsureDeoptimizationSupport(&info)); 172 CHECK(Compiler::EnsureDeoptimizationSupport(&info));
174 } 173 }
175 JSFunction::EnsureLiterals(function); 174 JSFunction::EnsureLiterals(function);
176 175
177 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info); 176 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info);
178 CHECK(!code.is_null()); 177 CHECK(!code.is_null());
179 info.dependencies()->Commit(code); 178 info.dependencies()->Commit(code);
180 info.context()->native_context()->AddOptimizedCode(*code); 179 info.context()->native_context()->AddOptimizedCode(*code);
181 function->ReplaceCode(*code); 180 function->ReplaceCode(*code);
182 return function; 181 return function;
183 } 182 }
184 183
185 // Compile the given machine graph instead of the source of the function 184 // Compile the given machine graph instead of the source of the function
186 // and replace the JSFunction's code with the result. 185 // and replace the JSFunction's code with the result.
187 Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { 186 Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) {
188 Zone zone(function->GetIsolate()->allocator(), ZONE_NAME); 187 ParseInfo parse_info(handle(function->shared()));
189 ParseInfo parse_info(&zone, handle(function->shared()));
190 CompilationInfo info(&parse_info, function); 188 CompilationInfo info(&parse_info, function);
191 189
192 CHECK(parsing::ParseFunction(info.parse_info())); 190 CHECK(parsing::ParseFunction(info.parse_info()));
193 info.SetOptimizing(); 191 info.SetOptimizing();
194 192
195 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph); 193 Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph);
196 CHECK(!code.is_null()); 194 CHECK(!code.is_null());
197 function->ReplaceCode(*code); 195 function->ReplaceCode(*code);
198 return function; 196 return function;
199 } 197 }
200 198
201 } // namespace compiler 199 } // namespace compiler
202 } // namespace internal 200 } // namespace internal
203 } // namespace v8 201 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/asmjs/test-asm-typer.cc ('k') | test/cctest/compiler/test-linkage.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698