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
parent e606d03c
......@@ -186,6 +186,23 @@ LanguageMode FunctionLiteral::language_mode() const {
}
void FunctionLiteral::InitializeSharedInfo(
Handle<Code> 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<SharedFunctionInfo>(shared);
break;
}
}
}
}
ObjectLiteralProperty::ObjectLiteralProperty(Literal* key,
Expression* value,
Isolate* isolate) {
......
......@@ -2296,6 +2296,8 @@ class FunctionLiteral V8_FINAL : public Expression {
bool AllowsLazyCompilation();
bool AllowsLazyCompilationWithoutContext();
void InitializeSharedInfo(Handle<Code> code);
Handle<String> 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<SharedFunctionInfo> 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<String> name_;
Handle<SharedFunctionInfo> shared_info_;
Scope* scope_;
ZoneList<Statement*>* body_;
Handle<String> inferred_name_;
......
......@@ -4572,31 +4572,11 @@ void HOptimizedGraphBuilder::VisitCaseClause(CaseClause* clause) {
}
static Handle<SharedFunctionInfo> 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<SharedFunctionInfo>(shared);
}
}
}
return Handle<SharedFunctionInfo>();
}
void HOptimizedGraphBuilder::VisitFunctionLiteral(FunctionLiteral* expr) {
ASSERT(!HasStackOverflow());
ASSERT(current_block() != NULL);
ASSERT(current_block()->HasPredecessor());
Handle<SharedFunctionInfo> shared_info =
SearchSharedFunctionInfo(current_info()->shared_info()->code(), expr);
Handle<SharedFunctionInfo> shared_info = expr->shared_info();
if (shared_info.is_null()) {
shared_info = Compiler::BuildFunctionInfo(expr, current_info()->script());
}
......
......@@ -368,6 +368,7 @@ void AstTyper::VisitDebuggerStatement(DebuggerStatement* stmt) {
void AstTyper::VisitFunctionLiteral(FunctionLiteral* expr) {
expr->InitializeSharedInfo(Handle<Code>(info_->closure()->shared()->code()));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment