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

Side by Side Diff: src/compiler.cc

Issue 1730853005: [interpreter] Make setting of function data more resilient. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_interpreter-test-enable-strong
Patch Set: Addressed comments. Created 4 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
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 8
9 #include "src/ast/ast-numbering.h" 9 #include "src/ast/ast-numbering.h"
10 #include "src/ast/prettyprinter.h" 10 #include "src/ast/prettyprinter.h"
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 // Update the shared function info with the scope info. Allocating the 831 // Update the shared function info with the scope info. Allocating the
832 // ScopeInfo object may cause a GC. 832 // ScopeInfo object may cause a GC.
833 Handle<ScopeInfo> scope_info = 833 Handle<ScopeInfo> scope_info =
834 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()); 834 ScopeInfo::Create(info->isolate(), info->zone(), info->scope());
835 shared->set_scope_info(*scope_info); 835 shared->set_scope_info(*scope_info);
836 836
837 // Update the code and feedback vector for the shared function info. 837 // Update the code and feedback vector for the shared function info.
838 shared->ReplaceCode(*info->code()); 838 shared->ReplaceCode(*info->code());
839 shared->set_feedback_vector(*info->feedback_vector()); 839 shared->set_feedback_vector(*info->feedback_vector());
840 if (info->has_bytecode_array()) { 840 if (info->has_bytecode_array()) {
841 DCHECK(shared->function_data()->IsUndefined()); 841 DCHECK(!shared->HasBytecodeArray()); // Only compiled once.
842 shared->set_function_data(*info->bytecode_array()); 842 shared->set_bytecode_array(*info->bytecode_array());
843 } 843 }
844 844
845 return info->code(); 845 return info->code();
846 } 846 }
847 847
848 848
849 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap( 849 MUST_USE_RESULT static MaybeHandle<Code> GetCodeFromOptimizedCodeMap(
850 Handle<JSFunction> function, BailoutId osr_ast_id) { 850 Handle<JSFunction> function, BailoutId osr_ast_id) {
851 Handle<SharedFunctionInfo> shared(function->shared()); 851 Handle<SharedFunctionInfo> shared(function->shared());
852 DisallowHeapAllocation no_gc; 852 DisallowHeapAllocation no_gc;
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 } 1301 }
1302 1302
1303 // Allocate function. 1303 // Allocate function.
1304 DCHECK(!info->code().is_null()); 1304 DCHECK(!info->code().is_null());
1305 result = isolate->factory()->NewSharedFunctionInfo( 1305 result = isolate->factory()->NewSharedFunctionInfo(
1306 lit->name(), lit->materialized_literal_count(), lit->kind(), 1306 lit->name(), lit->materialized_literal_count(), lit->kind(),
1307 info->code(), 1307 info->code(),
1308 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()), 1308 ScopeInfo::Create(info->isolate(), info->zone(), info->scope()),
1309 info->feedback_vector()); 1309 info->feedback_vector());
1310 if (info->has_bytecode_array()) { 1310 if (info->has_bytecode_array()) {
1311 DCHECK(result->function_data()->IsUndefined()); 1311 DCHECK(!result->HasBytecodeArray()); // Only compiled once.
1312 result->set_function_data(*info->bytecode_array()); 1312 result->set_bytecode_array(*info->bytecode_array());
1313 } 1313 }
1314 1314
1315 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); 1315 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position());
1316 SharedFunctionInfo::InitFromFunctionLiteral(result, lit); 1316 SharedFunctionInfo::InitFromFunctionLiteral(result, lit);
1317 SharedFunctionInfo::SetScript(result, script); 1317 SharedFunctionInfo::SetScript(result, script);
1318 result->set_is_toplevel(true); 1318 result->set_is_toplevel(true);
1319 if (info->is_eval()) { 1319 if (info->is_eval()) {
1320 // Eval scripts cannot be (re-)compiled without context. 1320 // Eval scripts cannot be (re-)compiled without context.
1321 result->set_allows_lazy_compilation_without_context(false); 1321 result->set_allows_lazy_compilation_without_context(false);
1322 } 1322 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 return Handle<SharedFunctionInfo>::null(); 1662 return Handle<SharedFunctionInfo>::null();
1663 } 1663 }
1664 1664
1665 if (maybe_existing.is_null()) { 1665 if (maybe_existing.is_null()) {
1666 // Create a shared function info object. 1666 // Create a shared function info object.
1667 Handle<SharedFunctionInfo> result = 1667 Handle<SharedFunctionInfo> result =
1668 isolate->factory()->NewSharedFunctionInfo( 1668 isolate->factory()->NewSharedFunctionInfo(
1669 literal->name(), literal->materialized_literal_count(), 1669 literal->name(), literal->materialized_literal_count(),
1670 literal->kind(), info.code(), scope_info, info.feedback_vector()); 1670 literal->kind(), info.code(), scope_info, info.feedback_vector());
1671 if (info.has_bytecode_array()) { 1671 if (info.has_bytecode_array()) {
1672 DCHECK(result->function_data()->IsUndefined()); 1672 DCHECK(!result->HasBytecodeArray()); // Only compiled once.
1673 result->set_function_data(*info.bytecode_array()); 1673 result->set_bytecode_array(*info.bytecode_array());
1674 } 1674 }
1675 1675
1676 SharedFunctionInfo::InitFromFunctionLiteral(result, literal); 1676 SharedFunctionInfo::InitFromFunctionLiteral(result, literal);
1677 SharedFunctionInfo::SetScript(result, script); 1677 SharedFunctionInfo::SetScript(result, script);
1678 result->set_is_toplevel(false); 1678 result->set_is_toplevel(false);
1679 // If the outer function has been compiled before, we cannot be sure that 1679 // If the outer function has been compiled before, we cannot be sure that
1680 // shared function info for this function literal has been created for the 1680 // shared function info for this function literal has been created for the
1681 // first time. It may have already been compiled previously. 1681 // first time. It may have already been compiled previously.
1682 result->set_never_compiled(outer_info->is_first_compile() && lazy); 1682 result->set_never_compiled(outer_info->is_first_compile() && lazy);
1683 1683
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 } 1888 }
1889 1889
1890 #if DEBUG 1890 #if DEBUG
1891 void CompilationInfo::PrintAstForTesting() { 1891 void CompilationInfo::PrintAstForTesting() {
1892 PrintF("--- Source from AST ---\n%s\n", 1892 PrintF("--- Source from AST ---\n%s\n",
1893 PrettyPrinter(isolate()).PrintProgram(literal())); 1893 PrettyPrinter(isolate()).PrintProgram(literal()));
1894 } 1894 }
1895 #endif 1895 #endif
1896 } // namespace internal 1896 } // namespace internal
1897 } // namespace v8 1897 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/objects.h » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698