From: mvstanton@chromium.org Date: Thu, 9 Jan 2014 09:00:19 +0000 (+0000) Subject: FunctionLiteral has work to do in the typing phase. X-Git-Tag: upstream/4.7.83~11224 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7baadbfac160fdf146e8782a84767689b83b0e03;p=platform%2Fupstream%2Fv8.git FunctionLiteral has work to do in the typing phase. In crankshaft, we searched un-optimized code for a SharedFunctionInfo that matches the FunctionLiteral we are processing. Ideally, this work should be done in the typing phase. R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/104883006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18508 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/ast.cc b/src/ast.cc index ecf83ea..21ea50b 100644 --- a/src/ast.cc +++ b/src/ast.cc @@ -186,6 +186,23 @@ LanguageMode FunctionLiteral::language_mode() const { } +void FunctionLiteral::InitializeSharedInfo( + Handle unoptimized_code) { + for (RelocIterator it(*unoptimized_code); !it.done(); it.next()) { + RelocInfo* rinfo = it.rinfo(); + if (rinfo->rmode() != RelocInfo::EMBEDDED_OBJECT) continue; + Object* obj = rinfo->target_object(); + if (obj->IsSharedFunctionInfo()) { + SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); + if (shared->start_position() == start_position()) { + shared_info_ = Handle(shared); + break; + } + } + } +} + + ObjectLiteralProperty::ObjectLiteralProperty(Literal* key, Expression* value, Isolate* isolate) { diff --git a/src/ast.h b/src/ast.h index 3fabfdd..64a56e9 100644 --- a/src/ast.h +++ b/src/ast.h @@ -2296,6 +2296,8 @@ class FunctionLiteral V8_FINAL : public Expression { bool AllowsLazyCompilation(); bool AllowsLazyCompilationWithoutContext(); + void InitializeSharedInfo(Handle code); + Handle debug_name() const { if (name_->length() > 0) return name_; return inferred_name(); @@ -2306,6 +2308,9 @@ class FunctionLiteral V8_FINAL : public Expression { inferred_name_ = inferred_name; } + // shared_info may be null if it's not cached in full code. + Handle shared_info() { return shared_info_; } + bool pretenure() { return Pretenure::decode(bitfield_); } void set_pretenure() { bitfield_ |= Pretenure::encode(true); } @@ -2381,6 +2386,7 @@ class FunctionLiteral V8_FINAL : public Expression { private: Handle name_; + Handle shared_info_; Scope* scope_; ZoneList* body_; Handle inferred_name_; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 529ebd2..3c4ff15 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -4572,31 +4572,11 @@ void HOptimizedGraphBuilder::VisitCaseClause(CaseClause* clause) { } -static Handle SearchSharedFunctionInfo( - Code* unoptimized_code, FunctionLiteral* expr) { - int start_position = expr->start_position(); - for (RelocIterator it(unoptimized_code); !it.done(); it.next()) { - RelocInfo* rinfo = it.rinfo(); - if (rinfo->rmode() != RelocInfo::EMBEDDED_OBJECT) continue; - Object* obj = rinfo->target_object(); - if (obj->IsSharedFunctionInfo()) { - SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); - if (shared->start_position() == start_position) { - return Handle(shared); - } - } - } - - return Handle(); -} - - void HOptimizedGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) { ASSERT(!HasStackOverflow()); ASSERT(current_block() != NULL); ASSERT(current_block()->HasPredecessor()); - Handle shared_info = - SearchSharedFunctionInfo(current_info()->shared_info()->code(), expr); + Handle shared_info = expr->shared_info(); if (shared_info.is_null()) { shared_info = Compiler::BuildFunctionInfo(expr, current_info()->script()); } diff --git a/src/typing.cc b/src/typing.cc index c692f48..152f3c7 100644 --- a/src/typing.cc +++ b/src/typing.cc @@ -368,6 +368,7 @@ void AstTyper::VisitDebuggerStatement(DebuggerStatement* stmt) { void AstTyper::VisitFunctionLiteral(FunctionLiteral* expr) { + expr->InitializeSharedInfo(Handle(info_->closure()->shared()->code())); }