x64: Implemented object, array and function literals in lithium codegen.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6628 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
ager@chromium.org 2011-02-04 06:54:45 +00:00
parent c894b1f317
commit 3a214b8f50
2 changed files with 63 additions and 12 deletions

View File

@ -364,7 +364,13 @@ void LCodeGen::CallCode(Handle<Code> code,
void LCodeGen::CallRuntime(Runtime::Function* function, void LCodeGen::CallRuntime(Runtime::Function* function,
int num_arguments, int num_arguments,
LInstruction* instr) { LInstruction* instr) {
Abort("Unimplemented: %s", "CallRuntime"); ASSERT(instr != NULL);
ASSERT(instr->HasPointerMap());
LPointerMap* pointers = instr->pointer_map();
RecordPosition(pointers->position());
__ CallRuntime(function, num_arguments);
RegisterLazyDeoptimization(instr);
} }
@ -1929,12 +1935,47 @@ void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) {
void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
Abort("Unimplemented: %s", "DoArrayLiteral"); // Setup the parameters to the stub/runtime call.
__ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
__ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
__ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
__ Push(instr->hydrogen()->constant_elements());
// Pick the right runtime function or stub to call.
int length = instr->hydrogen()->length();
if (instr->hydrogen()->IsCopyOnWrite()) {
ASSERT(instr->hydrogen()->depth() == 1);
FastCloneShallowArrayStub::Mode mode =
FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS;
FastCloneShallowArrayStub stub(mode, length);
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
} else if (instr->hydrogen()->depth() > 1) {
CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
} else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
} else {
FastCloneShallowArrayStub::Mode mode =
FastCloneShallowArrayStub::CLONE_ELEMENTS;
FastCloneShallowArrayStub stub(mode, length);
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
}
} }
void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
Abort("Unimplemented: %s", "DoObjectLiteral"); // Setup the parameters to the stub/runtime call.
__ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
__ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
__ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
__ Push(instr->hydrogen()->constant_properties());
__ Push(Smi::FromInt(instr->hydrogen()->fast_elements() ? 1 : 0));
// Pick the right runtime function to call.
if (instr->hydrogen()->depth() > 1) {
CallRuntime(Runtime::kCreateObjectLiteral, 4, instr);
} else {
CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr);
}
} }
@ -1944,7 +1985,20 @@ void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) { void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
Abort("Unimplemented: %s", "DoFunctionLiteral"); // Use the fast case closure allocation code that allocates in new
// space for nested functions that don't need literals cloning.
Handle<SharedFunctionInfo> shared_info = instr->shared_info();
bool pretenure = instr->hydrogen()->pretenure();
if (shared_info->num_literals() == 0 && !pretenure) {
FastNewClosureStub stub;
__ Push(shared_info);
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
} else {
__ push(rsi);
__ Push(shared_info);
__ Push(pretenure ? Factory::true_value() : Factory::false_value());
CallRuntime(Runtime::kNewClosure, 3, instr);
}
} }

View File

@ -1125,8 +1125,8 @@ LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) { LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
Abort("Unimplemented: %s", "DoCallRuntime"); argument_count_ -= instr->argument_count();
return NULL; return MarkAsCall(DefineFixed(new LCallRuntime, rax), instr);
} }
@ -1597,14 +1597,12 @@ LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) {
LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) {
Abort("Unimplemented: %s", "DoArrayLiteral"); return MarkAsCall(DefineFixed(new LArrayLiteral, rax), instr);
return NULL;
} }
LInstruction* LChunkBuilder::DoObjectLiteral(HObjectLiteral* instr) { LInstruction* LChunkBuilder::DoObjectLiteral(HObjectLiteral* instr) {
Abort("Unimplemented: %s", "DoObjectLiteral"); return MarkAsCall(DefineFixed(new LObjectLiteral, rax), instr);
return NULL;
} }
@ -1615,8 +1613,7 @@ LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) { LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
Abort("Unimplemented: %s", "DoFunctionLiteral"); return MarkAsCall(DefineFixed(new LFunctionLiteral, rax), instr);
return NULL;
} }