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

Side by Side Diff: src/full-codegen/full-codegen.cc

Issue 2579973002: Don't compile inner functions when compiling via the dispatcher (Closed)
Patch Set: added comment Created 4 years 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/full-codegen/full-codegen.h" 5 #include "src/full-codegen/full-codegen.h"
6 6
7 #include "src/ast/ast-numbering.h" 7 #include "src/ast/ast-numbering.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 10 matching lines...) Expand all
21 #include "src/snapshot/snapshot.h" 21 #include "src/snapshot/snapshot.h"
22 #include "src/tracing/trace-event.h" 22 #include "src/tracing/trace-event.h"
23 23
24 namespace v8 { 24 namespace v8 {
25 namespace internal { 25 namespace internal {
26 26
27 #define __ ACCESS_MASM(masm()) 27 #define __ ACCESS_MASM(masm())
28 28
29 class FullCodegenCompilationJob final : public CompilationJob { 29 class FullCodegenCompilationJob final : public CompilationJob {
30 public: 30 public:
31 explicit FullCodegenCompilationJob(CompilationInfo* info) 31 FullCodegenCompilationJob(CompilationInfo* info, LazyCompilationMode mode)
32 : CompilationJob(info->isolate(), info, "Full-Codegen") {} 32 : CompilationJob(info->isolate(), info, "Full-Codegen"), mode_(mode) {}
33 33
34 bool can_execute_on_background_thread() const override { return false; } 34 bool can_execute_on_background_thread() const override { return false; }
35 35
36 CompilationJob::Status PrepareJobImpl() final { return SUCCEEDED; } 36 CompilationJob::Status PrepareJobImpl() final { return SUCCEEDED; }
37 37
38 CompilationJob::Status ExecuteJobImpl() final { 38 CompilationJob::Status ExecuteJobImpl() final {
39 DCHECK(ThreadId::Current().Equals(isolate()->thread_id())); 39 DCHECK(ThreadId::Current().Equals(isolate()->thread_id()));
40 return FullCodeGenerator::MakeCode(info(), stack_limit()) ? SUCCEEDED 40 return FullCodeGenerator::MakeCode(info(), stack_limit(), mode_) ? SUCCEEDED
41 : FAILED; 41 : FAILED;
42 } 42 }
43 43
44 CompilationJob::Status FinalizeJobImpl() final { return SUCCEEDED; } 44 CompilationJob::Status FinalizeJobImpl() final { return SUCCEEDED; }
45
46 private:
47 LazyCompilationMode mode_;
48
49 DISALLOW_COPY_AND_ASSIGN(FullCodegenCompilationJob);
45 }; 50 };
46 51
47 FullCodeGenerator::FullCodeGenerator(MacroAssembler* masm, 52 FullCodeGenerator::FullCodeGenerator(MacroAssembler* masm,
48 CompilationInfo* info, 53 CompilationInfo* info,
49 uintptr_t stack_limit) 54 uintptr_t stack_limit,
55 LazyCompilationMode mode)
50 : masm_(masm), 56 : masm_(masm),
51 info_(info), 57 info_(info),
52 isolate_(info->isolate()), 58 isolate_(info->isolate()),
59 compilation_mode_(mode),
53 zone_(info->zone()), 60 zone_(info->zone()),
54 scope_(info->scope()), 61 scope_(info->scope()),
55 nesting_stack_(NULL), 62 nesting_stack_(NULL),
56 loop_depth_(0), 63 loop_depth_(0),
57 operand_stack_depth_(0), 64 operand_stack_depth_(0),
58 globals_(NULL), 65 globals_(NULL),
59 context_(NULL), 66 context_(NULL),
60 bailout_entries_(info->HasDeoptimizationSupport() 67 bailout_entries_(info->HasDeoptimizationSupport()
61 ? info->literal()->ast_node_count() 68 ? info->literal()->ast_node_count()
62 : 0, 69 : 0,
63 info->zone()), 70 info->zone()),
64 back_edges_(2, info->zone()), 71 back_edges_(2, info->zone()),
65 source_position_table_builder_(info->zone(), 72 source_position_table_builder_(info->zone(),
66 info->SourcePositionRecordingMode()), 73 info->SourcePositionRecordingMode()),
67 ic_total_count_(0) { 74 ic_total_count_(0) {
68 DCHECK(!info->IsStub()); 75 DCHECK(!info->IsStub());
69 Initialize(stack_limit); 76 Initialize(stack_limit);
70 } 77 }
71 78
72 // static 79 // static
73 CompilationJob* FullCodeGenerator::NewCompilationJob(CompilationInfo* info) { 80 CompilationJob* FullCodeGenerator::NewCompilationJob(CompilationInfo* info,
74 return new FullCodegenCompilationJob(info); 81 LazyCompilationMode mode) {
82 return new FullCodegenCompilationJob(info, mode);
75 } 83 }
76 84
77 // static 85 // static
78 bool FullCodeGenerator::MakeCode(CompilationInfo* info) { 86 bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
79 return MakeCode(info, info->isolate()->stack_guard()->real_climit()); 87 return MakeCode(info, info->isolate()->stack_guard()->real_climit(),
88 LazyCompilationMode::kIfRequested);
80 } 89 }
81 90
82 // static 91 // static
83 bool FullCodeGenerator::MakeCode(CompilationInfo* info, uintptr_t stack_limit) { 92 bool FullCodeGenerator::MakeCode(CompilationInfo* info, uintptr_t stack_limit,
93 LazyCompilationMode mode) {
84 Isolate* isolate = info->isolate(); 94 Isolate* isolate = info->isolate();
85 95
86 DCHECK(!info->shared_info()->must_use_ignition_turbo()); 96 DCHECK(!info->shared_info()->must_use_ignition_turbo());
87 DCHECK(!FLAG_minimal); 97 DCHECK(!FLAG_minimal);
88 RuntimeCallTimerScope runtimeTimer(isolate, 98 RuntimeCallTimerScope runtimeTimer(isolate,
89 &RuntimeCallStats::CompileFullCode); 99 &RuntimeCallStats::CompileFullCode);
90 TimerEventScope<TimerEventCompileFullCode> timer(info->isolate()); 100 TimerEventScope<TimerEventCompileFullCode> timer(info->isolate());
91 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileFullCode"); 101 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileFullCode");
92 102
93 Handle<Script> script = info->script(); 103 Handle<Script> script = info->script();
94 if (!script->IsUndefined(isolate) && 104 if (!script->IsUndefined(isolate) &&
95 !script->source()->IsUndefined(isolate)) { 105 !script->source()->IsUndefined(isolate)) {
96 int len = String::cast(script->source())->length(); 106 int len = String::cast(script->source())->length();
97 isolate->counters()->total_full_codegen_source_size()->Increment(len); 107 isolate->counters()->total_full_codegen_source_size()->Increment(len);
98 } 108 }
99 CodeGenerator::MakeCodePrologue(info, "full"); 109 CodeGenerator::MakeCodePrologue(info, "full");
100 const int kInitialBufferSize = 4 * KB; 110 const int kInitialBufferSize = 4 * KB;
101 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize, 111 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize,
102 CodeObjectRequired::kYes); 112 CodeObjectRequired::kYes);
103 if (info->will_serialize()) masm.enable_serializer(); 113 if (info->will_serialize()) masm.enable_serializer();
104 114
105 FullCodeGenerator cgen(&masm, info, stack_limit); 115 FullCodeGenerator cgen(&masm, info, stack_limit, mode);
106 cgen.Generate(); 116 cgen.Generate();
107 if (cgen.HasStackOverflow()) { 117 if (cgen.HasStackOverflow()) {
108 DCHECK(!isolate->has_pending_exception()); 118 DCHECK(!isolate->has_pending_exception());
109 return false; 119 return false;
110 } 120 }
111 unsigned table_offset = cgen.EmitBackEdgeTable(); 121 unsigned table_offset = cgen.EmitBackEdgeTable();
112 122
113 Handle<Code> code = 123 Handle<Code> code =
114 CodeGenerator::MakeCodeEpilogue(&masm, nullptr, info, masm.CodeObject()); 124 CodeGenerator::MakeCodeEpilogue(&masm, nullptr, info, masm.CodeObject());
115 cgen.PopulateDeoptimizationData(code); 125 cgen.PopulateDeoptimizationData(code);
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 Comment cmnt(masm_, "[ Literal"); 1288 Comment cmnt(masm_, "[ Literal");
1279 context()->Plug(expr->value()); 1289 context()->Plug(expr->value());
1280 } 1290 }
1281 1291
1282 1292
1283 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { 1293 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
1284 Comment cmnt(masm_, "[ FunctionLiteral"); 1294 Comment cmnt(masm_, "[ FunctionLiteral");
1285 1295
1286 // Build the function boilerplate and instantiate it. 1296 // Build the function boilerplate and instantiate it.
1287 Handle<SharedFunctionInfo> function_info = 1297 Handle<SharedFunctionInfo> function_info =
1288 Compiler::GetSharedFunctionInfo(expr, script(), info_); 1298 Compiler::GetSharedFunctionInfo(expr, script(), info_, compilation_mode_);
1289 if (function_info.is_null()) { 1299 if (function_info.is_null()) {
1290 SetStackOverflow(); 1300 SetStackOverflow();
1291 return; 1301 return;
1292 } 1302 }
1293 EmitNewClosure(function_info, expr->pretenure()); 1303 EmitNewClosure(function_info, expr->pretenure());
1294 } 1304 }
1295 1305
1296 1306
1297 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { 1307 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) {
1298 // Unsupported 1308 // Unsupported
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 return info_->has_simple_parameters(); 1612 return info_->has_simple_parameters();
1603 } 1613 }
1604 1614
1605 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } 1615 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); }
1606 1616
1607 #undef __ 1617 #undef __
1608 1618
1609 1619
1610 } // namespace internal 1620 } // namespace internal
1611 } // namespace v8 1621 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698