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

Side by Side Diff: src/compiler.cc

Issue 737373003: When optimizing deserialized code, make sure IC state is preserved. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month 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 | src/flag-definitions.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 8
9 #include "src/ast-numbering.h" 9 #include "src/ast-numbering.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 return true; 931 return true;
932 } 932 }
933 933
934 934
935 // TODO(turbofan): In the future, unoptimized code with deopt support could 935 // TODO(turbofan): In the future, unoptimized code with deopt support could
936 // be generated lazily once deopt is triggered. 936 // be generated lazily once deopt is triggered.
937 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { 937 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
938 DCHECK(info->function() != NULL); 938 DCHECK(info->function() != NULL);
939 DCHECK(info->scope() != NULL); 939 DCHECK(info->scope() != NULL);
940 if (!info->shared_info()->has_deoptimization_support()) { 940 if (!info->shared_info()->has_deoptimization_support()) {
941 CompilationInfoWithZone unoptimized(info->shared_info()); 941 Handle<SharedFunctionInfo> shared = info->shared_info();
942 CompilationInfoWithZone unoptimized(shared);
942 // Note that we use the same AST that we will use for generating the 943 // Note that we use the same AST that we will use for generating the
943 // optimized code. 944 // optimized code.
944 unoptimized.SetFunction(info->function()); 945 unoptimized.SetFunction(info->function());
945 unoptimized.PrepareForCompilation(info->scope()); 946 unoptimized.PrepareForCompilation(info->scope());
946 unoptimized.SetContext(info->context()); 947 unoptimized.SetContext(info->context());
947 unoptimized.EnableDeoptimizationSupport(); 948 unoptimized.EnableDeoptimizationSupport();
949 // If the current code has reloc info for serialization, also include
950 // reloc info for serialization for the new code, so that deopt support
951 // can be added without losing IC state.
952 if (shared->code()->kind() == Code::FUNCTION &&
953 shared->code()->has_reloc_info_for_serialization()) {
954 unoptimized.PrepareForSerializing();
955 }
948 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false; 956 if (!FullCodeGenerator::MakeCode(&unoptimized)) return false;
949 957
950 Handle<SharedFunctionInfo> shared = info->shared_info();
951 shared->EnableDeoptimizationSupport(*unoptimized.code()); 958 shared->EnableDeoptimizationSupport(*unoptimized.code());
952 shared->set_feedback_vector(*unoptimized.feedback_vector()); 959 shared->set_feedback_vector(*unoptimized.feedback_vector());
953 960
954 // The scope info might not have been set if a lazily compiled 961 // The scope info might not have been set if a lazily compiled
955 // function is inlined before being called for the first time. 962 // function is inlined before being called for the first time.
956 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) { 963 if (shared->scope_info() == ScopeInfo::Empty(info->isolate())) {
957 Handle<ScopeInfo> target_scope_info = 964 Handle<ScopeInfo> target_scope_info =
958 ScopeInfo::Create(info->scope(), info->zone()); 965 ScopeInfo::Create(info->scope(), info->zone());
959 shared->set_scope_info(*target_scope_info); 966 shared->set_scope_info(*target_scope_info);
960 } 967 }
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 // if a function uses the special natives syntax, which is something the 1313 // if a function uses the special natives syntax, which is something the
1307 // parser records. 1314 // parser records.
1308 // If the debugger requests compilation for break points, we cannot be 1315 // If the debugger requests compilation for break points, we cannot be
1309 // aggressive about lazy compilation, because it might trigger compilation 1316 // aggressive about lazy compilation, because it might trigger compilation
1310 // of functions without an outer context when setting a breakpoint through 1317 // of functions without an outer context when setting a breakpoint through
1311 // Debug::FindSharedFunctionInfoInScript. 1318 // Debug::FindSharedFunctionInfoInScript.
1312 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext(); 1319 bool allow_lazy_without_ctx = literal->AllowsLazyCompilationWithoutContext();
1313 bool allow_lazy = literal->AllowsLazyCompilation() && 1320 bool allow_lazy = literal->AllowsLazyCompilation() &&
1314 !DebuggerWantsEagerCompilation(&info, allow_lazy_without_ctx); 1321 !DebuggerWantsEagerCompilation(&info, allow_lazy_without_ctx);
1315 1322
1316
1317 if (outer_info->is_toplevel() && outer_info->will_serialize()) { 1323 if (outer_info->is_toplevel() && outer_info->will_serialize()) {
1318 // Make sure that if the toplevel code (possibly to be serialized), 1324 // Make sure that if the toplevel code (possibly to be serialized),
1319 // the inner function must be allowed to be compiled lazily. 1325 // the inner function must be allowed to be compiled lazily.
1326 // This is necessary to serialize toplevel code without inner functions.
1320 DCHECK(allow_lazy); 1327 DCHECK(allow_lazy);
1321 } 1328 }
1322 1329
1323 // Generate code 1330 // Generate code
1324 Handle<ScopeInfo> scope_info; 1331 Handle<ScopeInfo> scope_info;
1325 if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) { 1332 if (FLAG_lazy && allow_lazy && !literal->is_parenthesized()) {
1326 Handle<Code> code = isolate->builtins()->CompileLazy(); 1333 Handle<Code> code = isolate->builtins()->CompileLazy();
1327 info.SetCode(code); 1334 info.SetCode(code);
1328 // There's no need in theory for a lazy-compiled function to have a type 1335 // There's no need in theory for a lazy-compiled function to have a type
1329 // feedback vector, but some parts of the system expect all 1336 // feedback vector, but some parts of the system expect all
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 AllowHandleDereference allow_deref; 1500 AllowHandleDereference allow_deref;
1494 bool tracing_on = info()->IsStub() 1501 bool tracing_on = info()->IsStub()
1495 ? FLAG_trace_hydrogen_stubs 1502 ? FLAG_trace_hydrogen_stubs
1496 : (FLAG_trace_hydrogen && 1503 : (FLAG_trace_hydrogen &&
1497 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); 1504 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter));
1498 return (tracing_on && 1505 return (tracing_on &&
1499 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); 1506 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL);
1500 } 1507 }
1501 1508
1502 } } // namespace v8::internal 1509 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698