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

Side by Side Diff: src/compiler.cc

Issue 2267693002: [interpreter] Allow mixed stacks if bytecode is preserved. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: One more comment. Created 4 years, 4 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 | « no previous file | test/cctest/test-compiler.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 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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 940
941 // TODO(4280): For now we do not switch generators or async functions to 941 // TODO(4280): For now we do not switch generators or async functions to
942 // baseline code because there might be suspended activations stored in 942 // baseline code because there might be suspended activations stored in
943 // generator objects on the heap. We could eventually go directly to 943 // generator objects on the heap. We could eventually go directly to
944 // TurboFan in this case. 944 // TurboFan in this case.
945 if (function->shared()->is_resumable()) { 945 if (function->shared()->is_resumable()) {
946 return MaybeHandle<Code>(); 946 return MaybeHandle<Code>();
947 } 947 }
948 948
949 // TODO(4280): For now we disable switching to baseline code in the presence 949 // TODO(4280): For now we disable switching to baseline code in the presence
950 // of interpreter activations of the given function. The reasons are: 950 // of interpreter activations of the given function. The reasons is that the
951 // 1) The debugger assumes each function is either full-code or bytecode. 951 // underlying bytecode is cleared below. Note that this only applies in case
952 // 2) The underlying bytecode is cleared below, breaking stack unwinding. 952 // the --ignition-preserve-bytecode flag is not passed.
953 InterpreterActivationsFinder activations_finder(function->shared()); 953 if (!FLAG_ignition_preserve_bytecode) {
954 if (HasInterpreterActivations(isolate, &activations_finder)) { 954 InterpreterActivationsFinder activations_finder(function->shared());
955 if (FLAG_trace_opt) { 955 if (HasInterpreterActivations(isolate, &activations_finder)) {
956 OFStream os(stdout);
957 os << "[unable to switch " << Brief(*function) << " due to activations]"
958 << std::endl;
959 }
960
961 if (activations_finder.MarkActivationsForBaselineOnReturn(isolate)) {
962 if (FLAG_trace_opt) { 956 if (FLAG_trace_opt) {
963 OFStream os(stdout); 957 OFStream os(stdout);
964 os << "[marking " << Brief(function->shared()) 958 os << "[unable to switch " << Brief(*function) << " due to activations]"
965 << " for baseline recompilation on return]" << std::endl; 959 << std::endl;
966 } 960 }
961
962 if (activations_finder.MarkActivationsForBaselineOnReturn(isolate)) {
963 if (FLAG_trace_opt) {
964 OFStream os(stdout);
965 os << "[marking " << Brief(function->shared())
966 << " for baseline recompilation on return]" << std::endl;
967 }
968 }
969
970 return MaybeHandle<Code>();
967 } 971 }
968
969 return MaybeHandle<Code>();
970 } 972 }
971 973
972 if (FLAG_trace_opt) { 974 if (FLAG_trace_opt) {
973 OFStream os(stdout); 975 OFStream os(stdout);
974 os << "[switching method " << Brief(*function) << " to baseline code]" 976 os << "[switching method " << Brief(*function) << " to baseline code]"
975 << std::endl; 977 << std::endl;
976 } 978 }
977 979
978 // Parse and update CompilationInfo with the results. 980 // Parse and update CompilationInfo with the results.
979 if (!Parser::ParseStatic(info.parse_info())) return MaybeHandle<Code>(); 981 if (!Parser::ParseStatic(info.parse_info())) return MaybeHandle<Code>();
980 Handle<SharedFunctionInfo> shared = info.shared_info(); 982 Handle<SharedFunctionInfo> shared = info.shared_info();
981 DCHECK_EQ(shared->language_mode(), info.literal()->language_mode()); 983 DCHECK_EQ(shared->language_mode(), info.literal()->language_mode());
982 984
983 // Compile baseline code using the full code generator. 985 // Compile baseline code using the full code generator.
984 if (!Compiler::Analyze(info.parse_info()) || 986 if (!Compiler::Analyze(info.parse_info()) ||
985 !FullCodeGenerator::MakeCode(&info)) { 987 !FullCodeGenerator::MakeCode(&info)) {
986 if (!isolate->has_pending_exception()) isolate->StackOverflow(); 988 if (!isolate->has_pending_exception()) isolate->StackOverflow();
987 return MaybeHandle<Code>(); 989 return MaybeHandle<Code>();
988 } 990 }
989 991
990 // TODO(4280): For now we play it safe and remove the bytecode array when we 992 // TODO(4280): For now we play it safe and remove the bytecode array when we
991 // switch to baseline code. We might consider keeping around the bytecode so 993 // switch to baseline code. We might consider keeping around the bytecode so
992 // that it can be used as the "source of truth" eventually. 994 // that it can be used as the "source of truth" eventually. Note that this
995 // only applies in case the --ignition-preserve-bytecode flag is not passed.
993 if (!FLAG_ignition_preserve_bytecode) shared->ClearBytecodeArray(); 996 if (!FLAG_ignition_preserve_bytecode) shared->ClearBytecodeArray();
994 997
995 // Update the shared function info with the scope info. 998 // Update the shared function info with the scope info.
996 InstallSharedScopeInfo(&info, shared); 999 InstallSharedScopeInfo(&info, shared);
997 1000
998 // Install compilation result on the shared function info 1001 // Install compilation result on the shared function info
999 InstallSharedCompilationResult(&info, shared); 1002 InstallSharedCompilationResult(&info, shared);
1000 1003
1001 // Record the function compilation event. 1004 // Record the function compilation event.
1002 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, &info); 1005 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, &info);
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 CompilationInfo unoptimized(info->parse_info(), info->closure()); 1410 CompilationInfo unoptimized(info->parse_info(), info->closure());
1408 unoptimized.EnableDeoptimizationSupport(); 1411 unoptimized.EnableDeoptimizationSupport();
1409 1412
1410 // TODO(4280): For now we do not switch generators or async functions to 1413 // TODO(4280): For now we do not switch generators or async functions to
1411 // baseline code because there might be suspended activations stored in 1414 // baseline code because there might be suspended activations stored in
1412 // generator objects on the heap. We could eventually go directly to 1415 // generator objects on the heap. We could eventually go directly to
1413 // TurboFan in this case. 1416 // TurboFan in this case.
1414 if (shared->is_resumable()) return false; 1417 if (shared->is_resumable()) return false;
1415 1418
1416 // TODO(4280): For now we disable switching to baseline code in the presence 1419 // TODO(4280): For now we disable switching to baseline code in the presence
1417 // of interpreter activations of the given function. The reasons are: 1420 // of interpreter activations of the given function. The reasons is that the
1418 // 1) The debugger assumes each function is either full-code or bytecode. 1421 // underlying bytecode is cleared below. The expensive check for activations
1419 // 2) The underlying bytecode is cleared below, breaking stack unwinding. 1422 // only needs to be done when the given function has bytecode, otherwise we
1420 // The expensive check for activations only needs to be done when the given 1423 // can be sure there are no activations. Note that this only applies in case
1421 // function has bytecode, otherwise we can be sure there are no activations. 1424 // the --ignition-preserve-bytecode flag is not passed.
1422 if (shared->HasBytecodeArray()) { 1425 if (!FLAG_ignition_preserve_bytecode && shared->HasBytecodeArray()) {
1423 InterpreterActivationsFinder activations_finder(*shared); 1426 InterpreterActivationsFinder activations_finder(*shared);
1424 if (HasInterpreterActivations(info->isolate(), &activations_finder)) { 1427 if (HasInterpreterActivations(info->isolate(), &activations_finder)) {
1425 return false; 1428 return false;
1426 } 1429 }
1427 } 1430 }
1428 1431
1429 // If the current code has reloc info for serialization, also include 1432 // If the current code has reloc info for serialization, also include
1430 // reloc info for serialization for the new code, so that deopt support 1433 // reloc info for serialization for the new code, so that deopt support
1431 // can be added without losing IC state. 1434 // can be added without losing IC state.
1432 if (shared->code()->kind() == Code::FUNCTION && 1435 if (shared->code()->kind() == Code::FUNCTION &&
1433 shared->code()->has_reloc_info_for_serialization()) { 1436 shared->code()->has_reloc_info_for_serialization()) {
1434 unoptimized.PrepareForSerializing(); 1437 unoptimized.PrepareForSerializing();
1435 } 1438 }
1436 EnsureFeedbackMetadata(&unoptimized); 1439 EnsureFeedbackMetadata(&unoptimized);
1437 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; 1440 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false;
1438 1441
1439 // TODO(4280): For now we play it safe and remove the bytecode array when we 1442 // TODO(4280): For now we play it safe and remove the bytecode array when we
1440 // switch to baseline code. We might consider keeping around the bytecode so 1443 // switch to baseline code. We might consider keeping around the bytecode so
1441 // that it can be used as the "source of truth" eventually. 1444 // that it can be used as the "source of truth" eventually. Note that this
1442 if (shared->HasBytecodeArray()) { 1445 // only applies in case the --ignition-preserve-bytecode flag is not passed.
1443 if (!FLAG_ignition_preserve_bytecode) shared->ClearBytecodeArray(); 1446 if (!FLAG_ignition_preserve_bytecode && shared->HasBytecodeArray()) {
1447 shared->ClearBytecodeArray();
1444 } 1448 }
1445 1449
1446 // The scope info might not have been set if a lazily compiled 1450 // The scope info might not have been set if a lazily compiled
1447 // function is inlined before being called for the first time. 1451 // function is inlined before being called for the first time.
1448 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) { 1452 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) {
1449 InstallSharedScopeInfo(info, shared); 1453 InstallSharedScopeInfo(info, shared);
1450 } 1454 }
1451 1455
1452 // Install compilation result on the shared function info 1456 // Install compilation result on the shared function info
1453 shared->EnableDeoptimizationSupport(*unoptimized.code()); 1457 shared->EnableDeoptimizationSupport(*unoptimized.code());
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 DCHECK(shared->is_compiled()); 1970 DCHECK(shared->is_compiled());
1967 function->set_literals(cached.literals); 1971 function->set_literals(cached.literals);
1968 } else if (shared->is_compiled()) { 1972 } else if (shared->is_compiled()) {
1969 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1973 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1970 JSFunction::EnsureLiterals(function); 1974 JSFunction::EnsureLiterals(function);
1971 } 1975 }
1972 } 1976 }
1973 1977
1974 } // namespace internal 1978 } // namespace internal
1975 } // namespace v8 1979 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698