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

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

Issue 2618553004: [compiler] Collect eager inner functions for compilation during renumbering. (Closed)
Patch Set: Remove unused variable Created 3 years, 11 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/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 FullCodegenCompilationJob(CompilationInfo* info, LazyCompilationMode mode) 31 explicit FullCodegenCompilationJob(CompilationInfo* info)
32 : CompilationJob(info->isolate(), info, "Full-Codegen"), mode_(mode) {} 32 : CompilationJob(info->isolate(), info, "Full-Codegen") {}
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(), mode_) ? SUCCEEDED 40 return FullCodeGenerator::MakeCode(info(), stack_limit()) ? 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);
50 }; 45 };
51 46
52 FullCodeGenerator::FullCodeGenerator(MacroAssembler* masm, 47 FullCodeGenerator::FullCodeGenerator(MacroAssembler* masm,
53 CompilationInfo* info, 48 CompilationInfo* info,
54 uintptr_t stack_limit, 49 uintptr_t stack_limit)
55 LazyCompilationMode mode)
56 : masm_(masm), 50 : masm_(masm),
57 info_(info), 51 info_(info),
58 isolate_(info->isolate()), 52 isolate_(info->isolate()),
59 compilation_mode_(mode),
60 zone_(info->zone()), 53 zone_(info->zone()),
61 scope_(info->scope()), 54 scope_(info->scope()),
62 nesting_stack_(NULL), 55 nesting_stack_(NULL),
63 loop_depth_(0), 56 loop_depth_(0),
64 operand_stack_depth_(0), 57 operand_stack_depth_(0),
65 globals_(NULL), 58 globals_(NULL),
66 context_(NULL), 59 context_(NULL),
67 bailout_entries_(info->HasDeoptimizationSupport() 60 bailout_entries_(info->HasDeoptimizationSupport()
68 ? info->literal()->ast_node_count() 61 ? info->literal()->ast_node_count()
69 : 0, 62 : 0,
70 info->zone()), 63 info->zone()),
71 back_edges_(2, info->zone()), 64 back_edges_(2, info->zone()),
72 source_position_table_builder_(info->zone(), 65 source_position_table_builder_(info->zone(),
73 info->SourcePositionRecordingMode()), 66 info->SourcePositionRecordingMode()),
74 ic_total_count_(0) { 67 ic_total_count_(0) {
75 DCHECK(!info->IsStub()); 68 DCHECK(!info->IsStub());
76 Initialize(stack_limit); 69 Initialize(stack_limit);
77 } 70 }
78 71
79 // static 72 // static
80 CompilationJob* FullCodeGenerator::NewCompilationJob(CompilationInfo* info, 73 CompilationJob* FullCodeGenerator::NewCompilationJob(CompilationInfo* info) {
81 LazyCompilationMode mode) { 74 return new FullCodegenCompilationJob(info);
82 return new FullCodegenCompilationJob(info, mode);
83 } 75 }
84 76
85 // static 77 // static
86 bool FullCodeGenerator::MakeCode(CompilationInfo* info) { 78 bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
87 return MakeCode(info, info->isolate()->stack_guard()->real_climit(), 79 return MakeCode(info, info->isolate()->stack_guard()->real_climit());
88 LazyCompilationMode::kIfRequested);
89 } 80 }
90 81
91 // static 82 // static
92 bool FullCodeGenerator::MakeCode(CompilationInfo* info, uintptr_t stack_limit, 83 bool FullCodeGenerator::MakeCode(CompilationInfo* info, uintptr_t stack_limit) {
93 LazyCompilationMode mode) {
94 Isolate* isolate = info->isolate(); 84 Isolate* isolate = info->isolate();
95 85
96 DCHECK(!info->shared_info()->must_use_ignition_turbo()); 86 DCHECK(!info->shared_info()->must_use_ignition_turbo());
97 DCHECK(!FLAG_minimal); 87 DCHECK(!FLAG_minimal);
98 RuntimeCallTimerScope runtimeTimer(isolate, 88 RuntimeCallTimerScope runtimeTimer(isolate,
99 &RuntimeCallStats::CompileFullCode); 89 &RuntimeCallStats::CompileFullCode);
100 TimerEventScope<TimerEventCompileFullCode> timer(info->isolate()); 90 TimerEventScope<TimerEventCompileFullCode> timer(info->isolate());
101 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileFullCode"); 91 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileFullCode");
102 92
103 Handle<Script> script = info->script(); 93 Handle<Script> script = info->script();
104 if (!script->IsUndefined(isolate) && 94 if (!script->IsUndefined(isolate) &&
105 !script->source()->IsUndefined(isolate)) { 95 !script->source()->IsUndefined(isolate)) {
106 int len = String::cast(script->source())->length(); 96 int len = String::cast(script->source())->length();
107 isolate->counters()->total_full_codegen_source_size()->Increment(len); 97 isolate->counters()->total_full_codegen_source_size()->Increment(len);
108 } 98 }
109 CodeGenerator::MakeCodePrologue(info, "full"); 99 CodeGenerator::MakeCodePrologue(info, "full");
110 const int kInitialBufferSize = 4 * KB; 100 const int kInitialBufferSize = 4 * KB;
111 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize, 101 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize,
112 CodeObjectRequired::kYes); 102 CodeObjectRequired::kYes);
113 if (info->will_serialize()) masm.enable_serializer(); 103 if (info->will_serialize()) masm.enable_serializer();
114 104
115 FullCodeGenerator cgen(&masm, info, stack_limit, mode); 105 FullCodeGenerator cgen(&masm, info, stack_limit);
116 cgen.Generate(); 106 cgen.Generate();
117 if (cgen.HasStackOverflow()) { 107 if (cgen.HasStackOverflow()) {
118 DCHECK(!isolate->has_pending_exception()); 108 DCHECK(!isolate->has_pending_exception());
119 return false; 109 return false;
120 } 110 }
121 unsigned table_offset = cgen.EmitBackEdgeTable(); 111 unsigned table_offset = cgen.EmitBackEdgeTable();
122 112
123 Handle<Code> code = 113 Handle<Code> code =
124 CodeGenerator::MakeCodeEpilogue(&masm, nullptr, info, masm.CodeObject()); 114 CodeGenerator::MakeCodeEpilogue(&masm, nullptr, info, masm.CodeObject());
125 cgen.PopulateDeoptimizationData(code); 115 cgen.PopulateDeoptimizationData(code);
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 Comment cmnt(masm_, "[ Literal"); 1274 Comment cmnt(masm_, "[ Literal");
1285 context()->Plug(expr->value()); 1275 context()->Plug(expr->value());
1286 } 1276 }
1287 1277
1288 1278
1289 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { 1279 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
1290 Comment cmnt(masm_, "[ FunctionLiteral"); 1280 Comment cmnt(masm_, "[ FunctionLiteral");
1291 1281
1292 // Build the function boilerplate and instantiate it. 1282 // Build the function boilerplate and instantiate it.
1293 Handle<SharedFunctionInfo> function_info = 1283 Handle<SharedFunctionInfo> function_info =
1294 Compiler::GetSharedFunctionInfo(expr, script(), info_, compilation_mode_); 1284 Compiler::GetSharedFunctionInfo(expr, script(), info_);
1295 if (function_info.is_null()) { 1285 if (function_info.is_null()) {
1296 SetStackOverflow(); 1286 SetStackOverflow();
1297 return; 1287 return;
1298 } 1288 }
1299 EmitNewClosure(function_info, expr->pretenure()); 1289 EmitNewClosure(function_info, expr->pretenure());
1300 } 1290 }
1301 1291
1302 1292
1303 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { 1293 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) {
1304 // Unsupported 1294 // Unsupported
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 return info_->has_simple_parameters(); 1598 return info_->has_simple_parameters();
1609 } 1599 }
1610 1600
1611 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } 1601 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); }
1612 1602
1613 #undef __ 1603 #undef __
1614 1604
1615 1605
1616 } // namespace internal 1606 } // namespace internal
1617 } // namespace v8 1607 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698