From 1494beed429c5e562d1ab26ce46f5d87df6c83cb Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Tue, 25 Jan 2011 14:03:20 +0000 Subject: [PATCH] X64 Crankshaft: Added some functions needed for delta-blue. Review URL: http://codereview.chromium.org/6262013 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6468 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/lithium-codegen-x64.cc | 57 ++++++++++++++++++++++++++++++++++++++---- src/x64/lithium-x64.cc | 30 +++++++++++++--------- 2 files changed, 70 insertions(+), 17 deletions(-) diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 0a04f03..a0fa73b 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -1389,7 +1389,19 @@ void LCodeGen::DoReturn(LReturn* instr) { void LCodeGen::DoLoadGlobal(LLoadGlobal* instr) { - Abort("Unimplemented: %s", "DoLoadGlobal"); + Register result = ToRegister(instr->result()); + if (result.is(rax)) { + __ load_rax(instr->hydrogen()->cell().location(), + RelocInfo::GLOBAL_PROPERTY_CELL); + } else { + __ movq(result, instr->hydrogen()->cell().location(), + RelocInfo::GLOBAL_PROPERTY_CELL); + __ movq(result, Operand(result, 0)); + } + if (instr->hydrogen()->check_hole_value()) { + __ CompareRoot(result, Heap::kTheHoleValueRootIndex); + DeoptimizeIf(equal, instr->environment()); + } } @@ -1454,7 +1466,26 @@ void LCodeGen::DoApplyArguments(LApplyArguments* instr) { void LCodeGen::DoPushArgument(LPushArgument* instr) { - Abort("Unimplemented: %s", "DoPushArgument"); + LOperand* argument = instr->InputAt(0); + if (argument->IsConstantOperand()) { + LConstantOperand* const_op = LConstantOperand::cast(argument); + Handle literal = chunk_->LookupLiteral(const_op); + Representation r = chunk_->LookupLiteralRepresentation(const_op); + if (r.IsInteger32()) { + ASSERT(literal->IsNumber()); + __ push(Immediate(static_cast(literal->Number()))); + } else if (r.IsDouble()) { + Abort("unsupported double immediate"); + } else { + ASSERT(r.IsTagged()); + __ Push(literal); + } + } else if (argument->IsRegister()) { + __ push(ToRegister(argument)); + } else { + ASSERT(!argument->IsDoubleRegister()); + __ push(ToOperand(argument)); + } } @@ -1562,7 +1593,12 @@ void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { void LCodeGen::DoCallNew(LCallNew* instr) { - Abort("Unimplemented: %s", "DoCallNew"); + ASSERT(ToRegister(instr->InputAt(0)).is(rdi)); + ASSERT(ToRegister(instr->result()).is(rax)); + + Handle builtin(Builtins::builtin(Builtins::JSConstructCall)); + __ Set(rax, instr->arity()); + CallCode(builtin, RelocInfo::CONSTRUCT_CALL, instr); } @@ -1722,7 +1758,13 @@ void LCodeGen::DoDoubleToI(LDoubleToI* instr) { void LCodeGen::DoCheckSmi(LCheckSmi* instr) { - Abort("Unimplemented: %s", "DoCheckSmi"); + LOperand* input = instr->InputAt(0); + ASSERT(input->IsRegister()); + Condition cc = masm()->CheckSmi(ToRegister(input)); + if (instr->condition() != equal) { + cc = NegateCondition(cc); + } + DeoptimizeIf(cc, instr->environment()); } @@ -1737,7 +1779,12 @@ void LCodeGen::DoCheckFunction(LCheckFunction* instr) { void LCodeGen::DoCheckMap(LCheckMap* instr) { - Abort("Unimplemented: %s", "DoCheckMap"); + LOperand* input = instr->InputAt(0); + ASSERT(input->IsRegister()); + Register reg = ToRegister(input); + __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), + instr->hydrogen()->map()); + DeoptimizeIf(not_equal, instr->environment()); } diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 5b7169b..f0610d4 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -1027,8 +1027,9 @@ LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { - Abort("Unimplemented: %s", "DoPushArgument"); - return NULL; + ++argument_count_; + LOperand* argument = UseOrConstant(instr->argument()); + return new LPushArgument(argument); } @@ -1081,8 +1082,10 @@ LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) { LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { - Abort("Unimplemented: %s", "DoCallNew"); - return NULL; + LOperand* constructor = UseFixed(instr->constructor(), rdi); + argument_count_ -= instr->argument_count(); + LCallNew* result = new LCallNew(constructor); + return MarkAsCall(DefineFixed(result, rax), instr); } @@ -1378,8 +1381,8 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) { LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) { - Abort("Unimplemented: %s", "DoCheckNonSmi"); - return NULL; + LOperand* value = UseRegisterAtStart(instr->value()); + return AssignEnvironment(new LCheckSmi(value, zero)); } @@ -1396,8 +1399,8 @@ LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { - Abort("Unimplemented: %s", "DoCheckSmi"); - return NULL; + LOperand* value = UseRegisterAtStart(instr->value()); + return AssignEnvironment(new LCheckSmi(value, not_zero)); } @@ -1408,8 +1411,9 @@ LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) { LInstruction* LChunkBuilder::DoCheckMap(HCheckMap* instr) { - Abort("Unimplemented: %s", "DoCheckMap"); - return NULL; + LOperand* value = UseRegisterAtStart(instr->value()); + LCheckMap* result = new LCheckMap(value); + return AssignEnvironment(result); } @@ -1437,8 +1441,10 @@ LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { LInstruction* LChunkBuilder::DoLoadGlobal(HLoadGlobal* instr) { - Abort("Unimplemented: %s", "DoLoadGlobal"); - return NULL; + LLoadGlobal* result = new LLoadGlobal; + return instr->check_hole_value() + ? AssignEnvironment(DefineAsRegister(result)) + : DefineAsRegister(result); } -- 2.7.4