Change the interface of CodeGenerator::InstantiateBoilerplate.

Begin changing the interface of the virtual-frame-based code generator
to avoid pushing short-lived temporaries on the frame.

Review URL: http://codereview.chromium.org/600097

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3840 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
kmillikin@chromium.org 2010-02-12 10:28:40 +00:00
parent 4a2c81d3b0
commit 85c24cee57
2 changed files with 12 additions and 12 deletions

View File

@ -3912,28 +3912,26 @@ void CodeGenerator::VisitDebuggerStatement(DebuggerStatement* node) {
} }
void CodeGenerator::InstantiateBoilerplate(Handle<JSFunction> boilerplate) { Result CodeGenerator::InstantiateBoilerplate(Handle<JSFunction> boilerplate) {
ASSERT(boilerplate->IsBoilerplate()); ASSERT(boilerplate->IsBoilerplate());
// The inevitable call will sync frame elements to memory anyway, so // The inevitable call will sync frame elements to memory anyway, so
// we do it eagerly to allow us to push the arguments directly into // we do it eagerly to allow us to push the arguments directly into
// place. // place.
frame_->SyncRange(0, frame_->element_count() - 1); frame()->SyncRange(0, frame()->element_count() - 1);
// Use the fast case closure allocation code that allocates in new // Use the fast case closure allocation code that allocates in new
// space for nested functions that don't need literals cloning. // space for nested functions that don't need literals cloning.
if (scope()->is_function_scope() && boilerplate->NumberOfLiterals() == 0) { if (scope()->is_function_scope() && boilerplate->NumberOfLiterals() == 0) {
FastNewClosureStub stub; FastNewClosureStub stub;
frame_->EmitPush(Immediate(boilerplate)); frame()->EmitPush(Immediate(boilerplate));
Result answer = frame_->CallStub(&stub, 1); return frame()->CallStub(&stub, 1);
frame_->Push(&answer);
} else { } else {
// Call the runtime to instantiate the function boilerplate // Call the runtime to instantiate the function boilerplate
// object. // object.
frame_->EmitPush(esi); frame()->EmitPush(esi);
frame_->EmitPush(Immediate(boilerplate)); frame()->EmitPush(Immediate(boilerplate));
Result result = frame_->CallRuntime(Runtime::kNewClosure, 2); return frame()->CallRuntime(Runtime::kNewClosure, 2);
frame_->Push(&result);
} }
} }
@ -3946,14 +3944,16 @@ void CodeGenerator::VisitFunctionLiteral(FunctionLiteral* node) {
Compiler::BuildBoilerplate(node, script(), this); Compiler::BuildBoilerplate(node, script(), this);
// Check for stack-overflow exception. // Check for stack-overflow exception.
if (HasStackOverflow()) return; if (HasStackOverflow()) return;
InstantiateBoilerplate(boilerplate); Result result = InstantiateBoilerplate(boilerplate);
frame()->Push(&result);
} }
void CodeGenerator::VisitFunctionBoilerplateLiteral( void CodeGenerator::VisitFunctionBoilerplateLiteral(
FunctionBoilerplateLiteral* node) { FunctionBoilerplateLiteral* node) {
Comment cmnt(masm_, "[ FunctionBoilerplateLiteral"); Comment cmnt(masm_, "[ FunctionBoilerplateLiteral");
InstantiateBoilerplate(node->boilerplate()); Result result = InstantiateBoilerplate(node->boilerplate());
frame()->Push(&result);
} }

View File

@ -533,7 +533,7 @@ class CodeGenerator: public AstVisitor {
void DeclareGlobals(Handle<FixedArray> pairs); void DeclareGlobals(Handle<FixedArray> pairs);
// Instantiate the function boilerplate. // Instantiate the function boilerplate.
void InstantiateBoilerplate(Handle<JSFunction> boilerplate); Result InstantiateBoilerplate(Handle<JSFunction> boilerplate);
// Support for type checks. // Support for type checks.
void GenerateIsSmi(ZoneList<Expression*>* args); void GenerateIsSmi(ZoneList<Expression*>* args);