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

Side by Side Diff: src/compiler.cc

Issue 2318653002: [Interpreter] Localize the CanonicalHandleScope to parsing and renumbering. (Closed)
Patch Set: Created 4 years, 3 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 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-js.h" 10 #include "src/asmjs/asm-js.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 InstallSharedCompilationResult(info, shared); 414 InstallSharedCompilationResult(info, shared);
415 415
416 // Record the function compilation event. 416 // Record the function compilation event.
417 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); 417 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info);
418 } 418 }
419 419
420 MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) { 420 MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) {
421 VMState<COMPILER> state(info->isolate()); 421 VMState<COMPILER> state(info->isolate());
422 PostponeInterruptsScope postpone(info->isolate()); 422 PostponeInterruptsScope postpone(info->isolate());
423 423
424 // Create a canonical handle scope before internalizing parsed values if
425 // compiling bytecode. This is required for off-thread bytecode generation.
426 std::unique_ptr<CanonicalHandleScope> canonical;
427 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(info->isolate()));
428
429 // Parse and update CompilationInfo with the results. 424 // Parse and update CompilationInfo with the results.
430 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); 425 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>();
431 DCHECK_EQ(info->shared_info()->language_mode(), 426 DCHECK_EQ(info->shared_info()->language_mode(),
432 info->literal()->language_mode()); 427 info->literal()->language_mode());
433 428
434 // Compile either unoptimized code or bytecode for the interpreter. 429 // Compile either unoptimized code or bytecode for the interpreter.
435 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); 430 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
436 431
437 InstallUnoptimizedCode(info); 432 InstallUnoptimizedCode(info);
438 433
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { 1015 Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
1021 Isolate* isolate = info->isolate(); 1016 Isolate* isolate = info->isolate();
1022 TimerEventScope<TimerEventCompileCode> timer(isolate); 1017 TimerEventScope<TimerEventCompileCode> timer(isolate);
1023 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode); 1018 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode);
1024 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); 1019 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode");
1025 PostponeInterruptsScope postpone(isolate); 1020 PostponeInterruptsScope postpone(isolate);
1026 DCHECK(!isolate->native_context().is_null()); 1021 DCHECK(!isolate->native_context().is_null());
1027 ParseInfo* parse_info = info->parse_info(); 1022 ParseInfo* parse_info = info->parse_info();
1028 Handle<Script> script = parse_info->script(); 1023 Handle<Script> script = parse_info->script();
1029 1024
1030 // Create a canonical handle scope before internalizing parsed values if
1031 // compiling bytecode. This is required for off-thread bytecode generation.
1032 std::unique_ptr<CanonicalHandleScope> canonical;
1033 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(isolate));
1034
1035 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? 1025 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile?
1036 FixedArray* array = isolate->native_context()->embedder_data(); 1026 FixedArray* array = isolate->native_context()->embedder_data();
1037 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); 1027 script->set_context_data(array->get(v8::Context::kDebugIdIndex));
1038 1028
1039 isolate->debug()->OnBeforeCompile(script); 1029 isolate->debug()->OnBeforeCompile(script);
1040 1030
1041 DCHECK(parse_info->is_eval() || parse_info->is_global() || 1031 DCHECK(parse_info->is_eval() || parse_info->is_global() ||
1042 parse_info->is_module()); 1032 parse_info->is_module());
1043 1033
1044 parse_info->set_toplevel(); 1034 parse_info->set_toplevel();
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 1757
1768 // Consider compiling eagerly when compiling bytecode for Ignition. 1758 // Consider compiling eagerly when compiling bytecode for Ignition.
1769 lazy &= 1759 lazy &=
1770 !(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled()); 1760 !(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled());
1771 1761
1772 // Generate code 1762 // Generate code
1773 TimerEventScope<TimerEventCompileCode> timer(isolate); 1763 TimerEventScope<TimerEventCompileCode> timer(isolate);
1774 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode); 1764 RuntimeCallTimerScope runtimeTimer(isolate, &RuntimeCallStats::CompileCode);
1775 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); 1765 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode");
1776 1766
1777 // Create a canonical handle scope if compiling ignition bytecode. This is
1778 // required by the constant array builder to de-duplicate common objects
1779 // without dereferencing handles.
1780 std::unique_ptr<CanonicalHandleScope> canonical;
1781 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(info.isolate()));
1782
1783 if (lazy) { 1767 if (lazy) {
1784 info.SetCode(isolate->builtins()->CompileLazy()); 1768 info.SetCode(isolate->builtins()->CompileLazy());
1785 } else if (Renumber(info.parse_info()) && GenerateUnoptimizedCode(&info)) { 1769 } else if (Renumber(info.parse_info()) && GenerateUnoptimizedCode(&info)) {
1786 // Code generation will ensure that the feedback vector is present and 1770 // Code generation will ensure that the feedback vector is present and
1787 // appropriately sized. 1771 // appropriately sized.
1788 DCHECK(!info.code().is_null()); 1772 DCHECK(!info.code().is_null());
1789 if (literal->should_eager_compile() && 1773 if (literal->should_eager_compile() &&
1790 literal->should_be_used_once_hint()) { 1774 literal->should_be_used_once_hint()) {
1791 info.code()->MarkToBeExecutedOnce(isolate); 1775 info.code()->MarkToBeExecutedOnce(isolate);
1792 } 1776 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 DCHECK(shared->is_compiled()); 1873 DCHECK(shared->is_compiled());
1890 function->set_literals(cached.literals); 1874 function->set_literals(cached.literals);
1891 } else if (shared->is_compiled()) { 1875 } else if (shared->is_compiled()) {
1892 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. 1876 // TODO(mvstanton): pass pretenure flag to EnsureLiterals.
1893 JSFunction::EnsureLiterals(function); 1877 JSFunction::EnsureLiterals(function);
1894 } 1878 }
1895 } 1879 }
1896 1880
1897 } // namespace internal 1881 } // namespace internal
1898 } // namespace v8 1882 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698