From c416ddf166bb2f45cbd92c2e91f5bf93f9b2ca90 Mon Sep 17 00:00:00 2001 From: "ricow@chromium.org" Date: Thu, 24 Feb 2011 19:25:22 +0000 Subject: [PATCH] X64: Implement DoHasInstanceType Review URL: http://codereview.chromium.org/6581036 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6940 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/lithium-codegen-x64.cc | 15 ++++++++++++++- src/x64/lithium-x64.cc | 6 ++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 2332e5228e..08488ca9fe 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -1579,7 +1579,20 @@ static Condition BranchCondition(HHasInstanceType* instr) { void LCodeGen::DoHasInstanceType(LHasInstanceType* instr) { - Abort("Unimplemented: %s", "DoHasInstanceType"); + Register input = ToRegister(instr->InputAt(0)); + Register result = ToRegister(instr->result()); + + ASSERT(instr->hydrogen()->value()->representation().IsTagged()); + __ testl(input, Immediate(kSmiTagMask)); + NearLabel done, is_false; + __ j(zero, &is_false); + __ CmpObjectType(input, TestType(instr->hydrogen()), result); + __ j(NegateCondition(BranchCondition(instr->hydrogen())), &is_false); + __ LoadRoot(result, Heap::kTrueValueRootIndex); + __ jmp(&done); + __ bind(&is_false); + __ LoadRoot(result, Heap::kFalseValueRootIndex); + __ bind(&done); } diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 2ed109d137..8db1ba9065 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -1502,8 +1502,10 @@ LInstruction* LChunkBuilder::DoIsSmi(HIsSmi* instr) { LInstruction* LChunkBuilder::DoHasInstanceType(HHasInstanceType* instr) { - Abort("Unimplemented: %s", "DoHasInstanceType"); - return NULL; + ASSERT(instr->value()->representation().IsTagged()); + LOperand* value = UseRegisterAtStart(instr->value()); + + return DefineAsRegister(new LHasInstanceType(value)); }