| Index: src/compiler.cc
|
| diff --git a/src/compiler.cc b/src/compiler.cc
|
| index 402011ebb9ef418664caf657cab2c90c8bd68639..fa8201bf54158f58eb3d9f154e0988a213826ca3 100644
|
| --- a/src/compiler.cc
|
| +++ b/src/compiler.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "src/compiler.h"
|
|
|
| +#include "src/ast-numbering.h"
|
| #include "src/bootstrapper.h"
|
| #include "src/codegen.h"
|
| #include "src/compilation-cache.h"
|
| @@ -291,12 +292,13 @@ void CompilationInfo::PrepareForCompilation(Scope* scope) {
|
| DCHECK(scope_ == NULL);
|
| scope_ = scope;
|
|
|
| - int length = function()->slot_count();
|
| if (feedback_vector_.is_null()) {
|
| // Allocate the feedback vector too.
|
| - feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector(length);
|
| + feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector(
|
| + function()->slot_count(), function()->ic_slot_count());
|
| }
|
| - DCHECK(feedback_vector_->length() == length);
|
| + DCHECK(feedback_vector_->Slots() == function()->slot_count() &&
|
| + feedback_vector_->ICSlots() == function()->ic_slot_count());
|
| }
|
|
|
|
|
| @@ -412,9 +414,6 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
|
| compiler::Pipeline pipeline(info());
|
| pipeline.GenerateCode();
|
| if (!info()->code().is_null()) {
|
| - if (FLAG_turbo_deoptimization) {
|
| - info()->context()->native_context()->AddOptimizedCode(*info()->code());
|
| - }
|
| return SetLastStatus(SUCCEEDED);
|
| }
|
| }
|
| @@ -483,6 +482,9 @@ OptimizedCompileJob::Status OptimizedCompileJob::GenerateCode() {
|
| DCHECK(last_status() == SUCCEEDED);
|
| // TODO(turbofan): Currently everything is done in the first phase.
|
| if (!info()->code().is_null()) {
|
| + if (FLAG_turbo_deoptimization) {
|
| + info()->context()->native_context()->AddOptimizedCode(*info()->code());
|
| + }
|
| RecordOptimizationStats();
|
| return last_status();
|
| }
|
| @@ -645,11 +647,7 @@ static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
|
|
|
| static bool CompileUnoptimizedCode(CompilationInfo* info) {
|
| DCHECK(AllowCompilation::IsAllowed(info->isolate()));
|
| - DCHECK(info->function() != NULL);
|
| - if (!Rewriter::Rewrite(info)) return false;
|
| - if (!Scope::Analyze(info)) return false;
|
| - DCHECK(info->scope() != NULL);
|
| -
|
| + if (!Compiler::Analyze(info)) return false;
|
| if (!FullCodeGenerator::MakeCode(info)) {
|
| Isolate* isolate = info->isolate();
|
| if (!isolate->has_pending_exception()) isolate->StackOverflow();
|
| @@ -671,7 +669,6 @@ MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
|
| shared->set_strict_mode(lit->strict_mode());
|
| SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
|
| shared->set_bailout_reason(lit->dont_optimize_reason());
|
| - shared->set_ast_node_count(lit->ast_node_count());
|
|
|
| // Compile unoptimized code.
|
| if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
|
| @@ -741,17 +738,33 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
|
| }
|
|
|
|
|
| -static bool CompileOptimizedPrologue(CompilationInfo* info) {
|
| - if (!Parser::Parse(info)) return false;
|
| +static bool Renumber(CompilationInfo* info) {
|
| + if (!AstNumbering::Renumber(info->function(), info->zone())) return false;
|
| + if (!info->shared_info().is_null()) {
|
| + info->shared_info()->set_ast_node_count(info->function()->ast_node_count());
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +
|
| +bool Compiler::Analyze(CompilationInfo* info) {
|
| + DCHECK(info->function() != NULL);
|
| if (!Rewriter::Rewrite(info)) return false;
|
| if (!Scope::Analyze(info)) return false;
|
| + if (!Renumber(info)) return false;
|
| DCHECK(info->scope() != NULL);
|
| return true;
|
| }
|
|
|
|
|
| +bool Compiler::ParseAndAnalyze(CompilationInfo* info) {
|
| + if (!Parser::Parse(info)) return false;
|
| + return Compiler::Analyze(info);
|
| +}
|
| +
|
| +
|
| static bool GetOptimizedCodeNow(CompilationInfo* info) {
|
| - if (!CompileOptimizedPrologue(info)) return false;
|
| + if (!Compiler::ParseAndAnalyze(info)) return false;
|
|
|
| TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate());
|
|
|
| @@ -793,7 +806,7 @@ static bool GetOptimizedCodeLater(CompilationInfo* info) {
|
| }
|
|
|
| CompilationHandleScope handle_scope(info);
|
| - if (!CompileOptimizedPrologue(info)) return false;
|
| + if (!Compiler::ParseAndAnalyze(info)) return false;
|
| info->SaveHandles(); // Copy handles to the compilation handle scope.
|
|
|
| TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate());
|
| @@ -907,6 +920,8 @@ bool Compiler::EnsureCompiled(Handle<JSFunction> function,
|
| // TODO(turbofan): In the future, unoptimized code with deopt support could
|
| // be generated lazily once deopt is triggered.
|
| bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
|
| + DCHECK(info->function() != NULL);
|
| + DCHECK(info->scope() != NULL);
|
| if (!info->shared_info()->has_deoptimization_support()) {
|
| CompilationInfoWithZone unoptimized(info->shared_info());
|
| // Note that we use the same AST that we will use for generating the
|
| @@ -1235,8 +1250,8 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
|
| isolate->counters()->compile_serialize());
|
| *cached_data = CodeSerializer::Serialize(isolate, result, source);
|
| if (FLAG_profile_deserialization) {
|
| - PrintF("[Compiling and serializing %d bytes took %0.3f ms]\n",
|
| - (*cached_data)->length(), timer.Elapsed().InMillisecondsF());
|
| + PrintF("[Compiling and serializing took %0.3f ms]\n",
|
| + timer.Elapsed().InMillisecondsF());
|
| }
|
| }
|
| }
|
| @@ -1301,7 +1316,7 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(
|
| Handle<Code> code = isolate->builtins()->CompileLazy();
|
| info.SetCode(code);
|
| scope_info = Handle<ScopeInfo>(ScopeInfo::Empty(isolate));
|
| - } else if (FullCodeGenerator::MakeCode(&info)) {
|
| + } else if (Renumber(&info) && FullCodeGenerator::MakeCode(&info)) {
|
| DCHECK(!info.code().is_null());
|
| scope_info = ScopeInfo::Create(info.scope(), info.zone());
|
| } else {
|
|
|