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

Side by Side Diff: src/compiler.cc

Issue 2683733002: Revert of Reland: [Parse] ParseInfo owns the parsing Zone. (Closed)
Patch Set: 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 | « src/background-parsing-task.cc ('k') | src/compiler-dispatcher/compiler-dispatcher-job.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "src/compiler.h" 5 #include "src/compiler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-js.h" 10 #include "src/asmjs/asm-js.h"
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // Try to enqueue the eager function on the compiler dispatcher. 530 // Try to enqueue the eager function on the compiler dispatcher.
531 CompilerDispatcher* dispatcher = isolate->compiler_dispatcher(); 531 CompilerDispatcher* dispatcher = isolate->compiler_dispatcher();
532 if (UseCompilerDispatcher(dispatcher, literal->scope(), shared, is_debug, 532 if (UseCompilerDispatcher(dispatcher, literal->scope(), shared, is_debug,
533 will_serialize) && 533 will_serialize) &&
534 dispatcher->EnqueueAndStep(shared, literal)) { 534 dispatcher->EnqueueAndStep(shared, literal)) {
535 // If we have successfully queued up the function for compilation on the 535 // If we have successfully queued up the function for compilation on the
536 // compiler dispatcher then we are done. 536 // compiler dispatcher then we are done.
537 continue; 537 continue;
538 } else { 538 } else {
539 // Otherwise generate unoptimized code now. 539 // Otherwise generate unoptimized code now.
540 ParseInfo parse_info(script); 540 Zone zone(isolate->allocator(), ZONE_NAME);
541 ParseInfo parse_info(&zone, script);
541 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); 542 CompilationInfo info(&parse_info, Handle<JSFunction>::null());
542 543
543 parse_info.set_literal(literal); 544 parse_info.set_literal(literal);
544 parse_info.set_shared_info(shared); 545 parse_info.set_shared_info(shared);
545 parse_info.set_function_literal_id(shared->function_literal_id()); 546 parse_info.set_function_literal_id(shared->function_literal_id());
546 parse_info.set_language_mode(literal->scope()->language_mode()); 547 parse_info.set_language_mode(literal->scope()->language_mode());
547 parse_info.set_ast_value_factory( 548 parse_info.set_ast_value_factory(
548 outer_info->parse_info()->ast_value_factory()); 549 outer_info->parse_info()->ast_value_factory());
549 parse_info.set_ast_value_factory_owned(false); 550 parse_info.set_ast_value_factory_owned(false);
550 551
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason())); 918 PrintF(" because: %s]\n", GetBailoutReason(info->bailout_reason()));
918 } 919 }
919 info->closure()->ReplaceCode(shared->code()); 920 info->closure()->ReplaceCode(shared->code());
920 return CompilationJob::FAILED; 921 return CompilationJob::FAILED;
921 } 922 }
922 923
923 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { 924 MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
924 Isolate* isolate = function->GetIsolate(); 925 Isolate* isolate = function->GetIsolate();
925 VMState<COMPILER> state(isolate); 926 VMState<COMPILER> state(isolate);
926 PostponeInterruptsScope postpone(isolate); 927 PostponeInterruptsScope postpone(isolate);
927 ParseInfo parse_info(handle(function->shared())); 928 Zone zone(isolate->allocator(), ZONE_NAME);
929 ParseInfo parse_info(&zone, handle(function->shared()));
928 CompilationInfo info(&parse_info, function); 930 CompilationInfo info(&parse_info, function);
929 931
930 DCHECK(function->shared()->is_compiled()); 932 DCHECK(function->shared()->is_compiled());
931 933
932 // Function no longer needs to be tiered up 934 // Function no longer needs to be tiered up
933 function->shared()->set_marked_for_tier_up(false); 935 function->shared()->set_marked_for_tier_up(false);
934 936
935 // Reset profiler ticks, function is no longer considered hot. 937 // Reset profiler ticks, function is no longer considered hot.
936 if (function->shared()->HasBytecodeArray()) { 938 if (function->shared()->HasBytecodeArray()) {
937 function->shared()->set_profiler_ticks(0); 939 function->shared()->set_profiler_ticks(0);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 if (function->shared()->is_compiled()) { 1052 if (function->shared()->is_compiled()) {
1051 return Handle<Code>(function->shared()->code()); 1053 return Handle<Code>(function->shared()->code());
1052 } 1054 }
1053 1055
1054 if (function->shared()->HasBytecodeArray()) { 1056 if (function->shared()->HasBytecodeArray()) {
1055 Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline(); 1057 Handle<Code> entry = isolate->builtins()->InterpreterEntryTrampoline();
1056 function->shared()->ReplaceCode(*entry); 1058 function->shared()->ReplaceCode(*entry);
1057 return entry; 1059 return entry;
1058 } 1060 }
1059 1061
1060 ParseInfo parse_info(handle(function->shared())); 1062 Zone zone(isolate->allocator(), ZONE_NAME);
1063 ParseInfo parse_info(&zone, handle(function->shared()));
1061 CompilationInfo info(&parse_info, function); 1064 CompilationInfo info(&parse_info, function);
1062 Handle<Code> result; 1065 Handle<Code> result;
1063 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code); 1066 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, GetUnoptimizedCode(&info), Code);
1064 1067
1065 if (FLAG_always_opt && !info.shared_info()->HasAsmWasmData()) { 1068 if (FLAG_always_opt && !info.shared_info()->HasAsmWasmData()) {
1066 Handle<Code> opt_code; 1069 Handle<Code> opt_code;
1067 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT) 1070 if (GetOptimizedCode(function, Compiler::NOT_CONCURRENT)
1068 .ToHandle(&opt_code)) { 1071 .ToHandle(&opt_code)) {
1069 result = opt_code; 1072 result = opt_code;
1070 } 1073 }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 Handle<Code> code; 1234 Handle<Code> code;
1232 if (!GetOptimizedCode(function, mode).ToHandle(&code)) { 1235 if (!GetOptimizedCode(function, mode).ToHandle(&code)) {
1233 // Optimization failed, get unoptimized code. 1236 // Optimization failed, get unoptimized code.
1234 DCHECK(!isolate->has_pending_exception()); 1237 DCHECK(!isolate->has_pending_exception());
1235 if (function->shared()->is_compiled()) { 1238 if (function->shared()->is_compiled()) {
1236 code = handle(function->shared()->code(), isolate); 1239 code = handle(function->shared()->code(), isolate);
1237 } else if (function->shared()->HasBytecodeArray()) { 1240 } else if (function->shared()->HasBytecodeArray()) {
1238 code = isolate->builtins()->InterpreterEntryTrampoline(); 1241 code = isolate->builtins()->InterpreterEntryTrampoline();
1239 function->shared()->ReplaceCode(*code); 1242 function->shared()->ReplaceCode(*code);
1240 } else { 1243 } else {
1241 ParseInfo parse_info(handle(function->shared())); 1244 Zone zone(isolate->allocator(), ZONE_NAME);
1245 ParseInfo parse_info(&zone, handle(function->shared()));
1242 CompilationInfo info(&parse_info, function); 1246 CompilationInfo info(&parse_info, function);
1243 if (!GetUnoptimizedCode(&info).ToHandle(&code)) { 1247 if (!GetUnoptimizedCode(&info).ToHandle(&code)) {
1244 return false; 1248 return false;
1245 } 1249 }
1246 } 1250 }
1247 } 1251 }
1248 1252
1249 // Install code on closure. 1253 // Install code on closure.
1250 function->ReplaceCode(*code); 1254 function->ReplaceCode(*code);
1251 JSFunction::EnsureLiterals(function); 1255 JSFunction::EnsureLiterals(function);
1252 1256
1253 // Check postconditions on success. 1257 // Check postconditions on success.
1254 DCHECK(!isolate->has_pending_exception()); 1258 DCHECK(!isolate->has_pending_exception());
1255 DCHECK(function->shared()->is_compiled()); 1259 DCHECK(function->shared()->is_compiled());
1256 DCHECK(function->is_compiled()); 1260 DCHECK(function->is_compiled());
1257 return true; 1261 return true;
1258 } 1262 }
1259 1263
1260 bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) { 1264 bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) {
1261 Isolate* isolate = shared->GetIsolate(); 1265 Isolate* isolate = shared->GetIsolate();
1262 DCHECK(AllowCompilation::IsAllowed(isolate)); 1266 DCHECK(AllowCompilation::IsAllowed(isolate));
1263 1267
1264 // Start a compilation. 1268 // Start a compilation.
1265 ParseInfo parse_info(shared); 1269 Zone zone(isolate->allocator(), ZONE_NAME);
1270 ParseInfo parse_info(&zone, shared);
1266 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); 1271 CompilationInfo info(&parse_info, Handle<JSFunction>::null());
1267 info.MarkAsDebug(); 1272 info.MarkAsDebug();
1268 if (GetUnoptimizedCode(&info).is_null()) { 1273 if (GetUnoptimizedCode(&info).is_null()) {
1269 isolate->clear_pending_exception(); 1274 isolate->clear_pending_exception();
1270 return false; 1275 return false;
1271 } 1276 }
1272 1277
1273 // Check postconditions on success. 1278 // Check postconditions on success.
1274 DCHECK(!isolate->has_pending_exception()); 1279 DCHECK(!isolate->has_pending_exception());
1275 DCHECK(shared->is_compiled()); 1280 DCHECK(shared->is_compiled());
1276 DCHECK(shared->HasDebugCode()); 1281 DCHECK(shared->HasDebugCode());
1277 return true; 1282 return true;
1278 } 1283 }
1279 1284
1280 MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) { 1285 MaybeHandle<JSArray> Compiler::CompileForLiveEdit(Handle<Script> script) {
1281 Isolate* isolate = script->GetIsolate(); 1286 Isolate* isolate = script->GetIsolate();
1282 DCHECK(AllowCompilation::IsAllowed(isolate)); 1287 DCHECK(AllowCompilation::IsAllowed(isolate));
1283 1288
1284 // In order to ensure that live edit function info collection finds the newly 1289 // In order to ensure that live edit function info collection finds the newly
1285 // generated shared function infos, clear the script's list temporarily 1290 // generated shared function infos, clear the script's list temporarily
1286 // and restore it at the end of this method. 1291 // and restore it at the end of this method.
1287 Handle<FixedArray> old_function_infos(script->shared_function_infos(), 1292 Handle<FixedArray> old_function_infos(script->shared_function_infos(),
1288 isolate); 1293 isolate);
1289 script->set_shared_function_infos(isolate->heap()->empty_fixed_array()); 1294 script->set_shared_function_infos(isolate->heap()->empty_fixed_array());
1290 1295
1291 // Start a compilation. 1296 // Start a compilation.
1292 ParseInfo parse_info(script); 1297 Zone zone(isolate->allocator(), ZONE_NAME);
1298 ParseInfo parse_info(&zone, script);
1293 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); 1299 CompilationInfo info(&parse_info, Handle<JSFunction>::null());
1294 info.MarkAsDebug(); 1300 info.MarkAsDebug();
1295 1301
1296 // TODO(635): support extensions. 1302 // TODO(635): support extensions.
1297 const bool compilation_succeeded = !CompileToplevel(&info).is_null(); 1303 const bool compilation_succeeded = !CompileToplevel(&info).is_null();
1298 Handle<JSArray> infos; 1304 Handle<JSArray> infos;
1299 if (compilation_succeeded) { 1305 if (compilation_succeeded) {
1300 // Check postconditions on success. 1306 // Check postconditions on success.
1301 DCHECK(!isolate->has_pending_exception()); 1307 DCHECK(!isolate->has_pending_exception());
1302 infos = LiveEditFunctionTracker::Collect(parse_info.literal(), script, 1308 infos = LiveEditFunctionTracker::Collect(parse_info.literal(), script,
1303 parse_info.zone(), isolate); 1309 &zone, isolate);
1304 } 1310 }
1305 1311
1306 // Restore the original function info list in order to remain side-effect 1312 // Restore the original function info list in order to remain side-effect
1307 // free as much as possible, since some code expects the old shared function 1313 // free as much as possible, since some code expects the old shared function
1308 // infos to stick around. 1314 // infos to stick around.
1309 script->set_shared_function_infos(*old_function_infos); 1315 script->set_shared_function_infos(*old_function_infos);
1310 1316
1311 return infos; 1317 return infos;
1312 } 1318 }
1313 1319
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 } 1429 }
1424 if (!script_name.is_null()) { 1430 if (!script_name.is_null()) {
1425 script->set_name(*script_name); 1431 script->set_name(*script_name);
1426 script->set_line_offset(line_offset); 1432 script->set_line_offset(line_offset);
1427 script->set_column_offset(column_offset); 1433 script->set_column_offset(column_offset);
1428 } 1434 }
1429 script->set_origin_options(options); 1435 script->set_origin_options(options);
1430 script->set_compilation_type(Script::COMPILATION_TYPE_EVAL); 1436 script->set_compilation_type(Script::COMPILATION_TYPE_EVAL);
1431 Script::SetEvalOrigin(script, outer_info, eval_position); 1437 Script::SetEvalOrigin(script, outer_info, eval_position);
1432 1438
1433 ParseInfo parse_info(script); 1439 Zone zone(isolate->allocator(), ZONE_NAME);
1440 ParseInfo parse_info(&zone, script);
1434 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); 1441 CompilationInfo info(&parse_info, Handle<JSFunction>::null());
1435 parse_info.set_eval(); 1442 parse_info.set_eval();
1436 parse_info.set_language_mode(language_mode); 1443 parse_info.set_language_mode(language_mode);
1437 parse_info.set_parse_restriction(restriction); 1444 parse_info.set_parse_restriction(restriction);
1438 if (!context->IsNativeContext()) { 1445 if (!context->IsNativeContext()) {
1439 parse_info.set_outer_scope_info(handle(context->scope_info())); 1446 parse_info.set_outer_scope_info(handle(context->scope_info()));
1440 } 1447 }
1441 1448
1442 shared_info = CompileToplevel(&info); 1449 shared_info = CompileToplevel(&info);
1443 if (shared_info.is_null()) { 1450 if (shared_info.is_null()) {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 script->set_name(*script_name); 1639 script->set_name(*script_name);
1633 script->set_line_offset(line_offset); 1640 script->set_line_offset(line_offset);
1634 script->set_column_offset(column_offset); 1641 script->set_column_offset(column_offset);
1635 } 1642 }
1636 script->set_origin_options(resource_options); 1643 script->set_origin_options(resource_options);
1637 if (!source_map_url.is_null()) { 1644 if (!source_map_url.is_null()) {
1638 script->set_source_mapping_url(*source_map_url); 1645 script->set_source_mapping_url(*source_map_url);
1639 } 1646 }
1640 1647
1641 // Compile the function and add it to the cache. 1648 // Compile the function and add it to the cache.
1642 ParseInfo parse_info(script); 1649 Zone zone(isolate->allocator(), ZONE_NAME);
1650 ParseInfo parse_info(&zone, script);
1643 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); 1651 CompilationInfo info(&parse_info, Handle<JSFunction>::null());
1644 if (resource_options.IsModule()) parse_info.set_module(); 1652 if (resource_options.IsModule()) parse_info.set_module();
1645 if (compile_options != ScriptCompiler::kNoCompileOptions) { 1653 if (compile_options != ScriptCompiler::kNoCompileOptions) {
1646 parse_info.set_cached_data(cached_data); 1654 parse_info.set_cached_data(cached_data);
1647 } 1655 }
1648 parse_info.set_compile_options(compile_options); 1656 parse_info.set_compile_options(compile_options);
1649 parse_info.set_extension(extension); 1657 parse_info.set_extension(extension);
1650 if (!context->IsNativeContext()) { 1658 if (!context->IsNativeContext()) {
1651 parse_info.set_outer_scope_info(handle(context->scope_info())); 1659 parse_info.set_outer_scope_info(handle(context->scope_info()));
1652 } 1660 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 } 1837 }
1830 1838
1831 if (shared->is_compiled()) { 1839 if (shared->is_compiled()) {
1832 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1840 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1833 JSFunction::EnsureLiterals(function); 1841 JSFunction::EnsureLiterals(function);
1834 } 1842 }
1835 } 1843 }
1836 1844
1837 } // namespace internal 1845 } // namespace internal
1838 } // namespace v8 1846 } // namespace v8
OLDNEW
« no previous file with comments | « src/background-parsing-task.cc ('k') | src/compiler-dispatcher/compiler-dispatcher-job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698