| 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" |
| 11 #include "src/code-factory.h" | 11 #include "src/code-factory.h" |
| 12 #include "src/codegen.h" | 12 #include "src/codegen.h" |
| 13 #include "src/compiler.h" | 13 #include "src/compiler.h" |
| 14 #include "src/debug/debug.h" | 14 #include "src/debug/debug.h" |
| 15 #include "src/debug/liveedit.h" | 15 #include "src/debug/liveedit.h" |
| 16 #include "src/frames-inl.h" | 16 #include "src/frames-inl.h" |
| 17 #include "src/globals.h" | 17 #include "src/globals.h" |
| 18 #include "src/isolate-inl.h" | 18 #include "src/isolate-inl.h" |
| 19 #include "src/macro-assembler.h" | 19 #include "src/macro-assembler.h" |
| 20 #include "src/snapshot/snapshot.h" | 20 #include "src/snapshot/snapshot.h" |
| 21 #include "src/tracing/trace-event.h" | 21 #include "src/tracing/trace-event.h" |
| 22 | 22 |
| 23 namespace v8 { | 23 namespace v8 { |
| 24 namespace internal { | 24 namespace internal { |
| 25 | 25 |
| 26 #define __ ACCESS_MASM(masm()) | 26 #define __ ACCESS_MASM(masm()) |
| 27 | 27 |
| 28 bool FullCodeGenerator::MakeCode(CompilationInfo* info) { | 28 class FullCodegenCompilationJob final : public CompilationJob { |
| 29 public: |
| 30 explicit FullCodegenCompilationJob(CompilationInfo* info) |
| 31 : CompilationJob(info->isolate(), info, "Full-Codegen") {} |
| 32 |
| 33 bool can_execute_on_background_thread() const override { return false; } |
| 34 |
| 35 CompilationJob::Status PrepareJobImpl() final { return SUCCEEDED; } |
| 36 |
| 37 CompilationJob::Status ExecuteJobImpl() final { |
| 38 DCHECK(ThreadId::Current().Equals(isolate()->thread_id())); |
| 39 return FullCodeGenerator::MakeCode(info(), stack_limit()) ? SUCCEEDED |
| 40 : FAILED; |
| 41 } |
| 42 |
| 43 CompilationJob::Status FinalizeJobImpl() final { return SUCCEEDED; } |
| 44 }; |
| 45 |
| 46 // static |
| 47 CompilationJob* FullCodeGenerator::NewCompilationJob(CompilationInfo* info) { |
| 48 return new FullCodegenCompilationJob(info); |
| 49 } |
| 50 |
| 51 // static |
| 52 bool FullCodeGenerator::MakeCode(CompilationInfo* info, uintptr_t stack_limit) { |
| 29 Isolate* isolate = info->isolate(); | 53 Isolate* isolate = info->isolate(); |
| 30 | 54 |
| 31 DCHECK(!FLAG_minimal); | 55 DCHECK(!FLAG_minimal); |
| 32 RuntimeCallTimerScope runtimeTimer(isolate, | 56 RuntimeCallTimerScope runtimeTimer(isolate, |
| 33 &RuntimeCallStats::CompileFullCode); | 57 &RuntimeCallStats::CompileFullCode); |
| 34 TimerEventScope<TimerEventCompileFullCode> timer(info->isolate()); | 58 TimerEventScope<TimerEventCompileFullCode> timer(info->isolate()); |
| 35 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | 59 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 36 isolate, &tracing::TraceEventStatsTable::CompileFullCode); | 60 isolate, &tracing::TraceEventStatsTable::CompileFullCode); |
| 37 | 61 |
| 38 Handle<Script> script = info->script(); | 62 Handle<Script> script = info->script(); |
| 39 if (!script->IsUndefined(isolate) && | 63 if (!script->IsUndefined(isolate) && |
| 40 !script->source()->IsUndefined(isolate)) { | 64 !script->source()->IsUndefined(isolate)) { |
| 41 int len = String::cast(script->source())->length(); | 65 int len = String::cast(script->source())->length(); |
| 42 isolate->counters()->total_full_codegen_source_size()->Increment(len); | 66 isolate->counters()->total_full_codegen_source_size()->Increment(len); |
| 43 } | 67 } |
| 44 CodeGenerator::MakeCodePrologue(info, "full"); | 68 CodeGenerator::MakeCodePrologue(info, "full"); |
| 45 const int kInitialBufferSize = 4 * KB; | 69 const int kInitialBufferSize = 4 * KB; |
| 46 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize, | 70 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize, |
| 47 CodeObjectRequired::kYes); | 71 CodeObjectRequired::kYes); |
| 48 if (info->will_serialize()) masm.enable_serializer(); | 72 if (info->will_serialize()) masm.enable_serializer(); |
| 49 | 73 |
| 50 FullCodeGenerator cgen(&masm, info); | 74 FullCodeGenerator cgen(&masm, info, stack_limit); |
| 51 cgen.Generate(); | 75 cgen.Generate(); |
| 52 if (cgen.HasStackOverflow()) { | 76 if (cgen.HasStackOverflow()) { |
| 53 DCHECK(!isolate->has_pending_exception()); | 77 DCHECK(!isolate->has_pending_exception()); |
| 54 return false; | 78 return false; |
| 55 } | 79 } |
| 56 unsigned table_offset = cgen.EmitBackEdgeTable(); | 80 unsigned table_offset = cgen.EmitBackEdgeTable(); |
| 57 | 81 |
| 58 Handle<Code> code = | 82 Handle<Code> code = |
| 59 CodeGenerator::MakeCodeEpilogue(&masm, nullptr, info, masm.CodeObject()); | 83 CodeGenerator::MakeCodeEpilogue(&masm, nullptr, info, masm.CodeObject()); |
| 60 cgen.PopulateDeoptimizationData(code); | 84 cgen.PopulateDeoptimizationData(code); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 !FastCloneShallowObjectStub::IsSupported(expr); | 174 !FastCloneShallowObjectStub::IsSupported(expr); |
| 151 } | 175 } |
| 152 | 176 |
| 153 | 177 |
| 154 bool FullCodeGenerator::MustCreateArrayLiteralWithRuntime( | 178 bool FullCodeGenerator::MustCreateArrayLiteralWithRuntime( |
| 155 ArrayLiteral* expr) const { | 179 ArrayLiteral* expr) const { |
| 156 return expr->depth() > 1 || | 180 return expr->depth() > 1 || |
| 157 expr->values()->length() > JSArray::kInitialMaxFastElementArray; | 181 expr->values()->length() > JSArray::kInitialMaxFastElementArray; |
| 158 } | 182 } |
| 159 | 183 |
| 160 | 184 void FullCodeGenerator::Initialize(uintptr_t stack_limit) { |
| 161 void FullCodeGenerator::Initialize() { | 185 InitializeAstVisitor(stack_limit); |
| 162 InitializeAstVisitor(info_->isolate()); | |
| 163 masm_->set_emit_debug_code(FLAG_debug_code); | 186 masm_->set_emit_debug_code(FLAG_debug_code); |
| 164 masm_->set_predictable_code_size(true); | 187 masm_->set_predictable_code_size(true); |
| 165 } | 188 } |
| 166 | 189 |
| 167 void FullCodeGenerator::PrepareForBailout(Expression* node, | 190 void FullCodeGenerator::PrepareForBailout(Expression* node, |
| 168 BailoutState state) { | 191 BailoutState state) { |
| 169 PrepareForBailoutForId(node->id(), state); | 192 PrepareForBailoutForId(node->id(), state); |
| 170 } | 193 } |
| 171 | 194 |
| 172 void FullCodeGenerator::CallLoadIC(TypeFeedbackId id) { | 195 void FullCodeGenerator::CallLoadIC(TypeFeedbackId id) { |
| (...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1938 return var->scope()->is_nonlinear() || | 1961 return var->scope()->is_nonlinear() || |
| 1939 var->initializer_position() >= proxy->position(); | 1962 var->initializer_position() >= proxy->position(); |
| 1940 } | 1963 } |
| 1941 | 1964 |
| 1942 | 1965 |
| 1943 #undef __ | 1966 #undef __ |
| 1944 | 1967 |
| 1945 | 1968 |
| 1946 } // namespace internal | 1969 } // namespace internal |
| 1947 } // namespace v8 | 1970 } // namespace v8 |
| OLD | NEW |