OLD | NEW |
---|---|
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 Loading... | |
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); | |
marja
2017/01/10 10:10:43
You probably didn't mean to delete the DISALLOW_..
rmcilroy
2017/01/11 10:20:11
Done, thanks.
| |
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 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1276 Comment cmnt(masm_, "[ Literal"); | 1266 Comment cmnt(masm_, "[ Literal"); |
1277 context()->Plug(expr->value()); | 1267 context()->Plug(expr->value()); |
1278 } | 1268 } |
1279 | 1269 |
1280 | 1270 |
1281 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { | 1271 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { |
1282 Comment cmnt(masm_, "[ FunctionLiteral"); | 1272 Comment cmnt(masm_, "[ FunctionLiteral"); |
1283 | 1273 |
1284 // Build the function boilerplate and instantiate it. | 1274 // Build the function boilerplate and instantiate it. |
1285 Handle<SharedFunctionInfo> function_info = | 1275 Handle<SharedFunctionInfo> function_info = |
1286 Compiler::GetSharedFunctionInfo(expr, script(), info_, compilation_mode_); | 1276 Compiler::GetSharedFunctionInfo(expr, script(), info_); |
1287 if (function_info.is_null()) { | 1277 if (function_info.is_null()) { |
1288 SetStackOverflow(); | 1278 SetStackOverflow(); |
1289 return; | 1279 return; |
1290 } | 1280 } |
1291 EmitNewClosure(function_info, expr->pretenure()); | 1281 EmitNewClosure(function_info, expr->pretenure()); |
1292 } | 1282 } |
1293 | 1283 |
1294 | 1284 |
1295 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { | 1285 void FullCodeGenerator::VisitClassLiteral(ClassLiteral* lit) { |
1296 // Unsupported | 1286 // Unsupported |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1600 return info_->has_simple_parameters(); | 1590 return info_->has_simple_parameters(); |
1601 } | 1591 } |
1602 | 1592 |
1603 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } | 1593 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } |
1604 | 1594 |
1605 #undef __ | 1595 #undef __ |
1606 | 1596 |
1607 | 1597 |
1608 } // namespace internal | 1598 } // namespace internal |
1609 } // namespace v8 | 1599 } // namespace v8 |
OLD | NEW |