From 707a5831167fed41d1127f8d5e278a1c8c70549f Mon Sep 17 00:00:00 2001 From: "haitao.feng@intel.com" Date: Thu, 10 Apr 2014 02:11:43 +0000 Subject: [PATCH] Introduce LoadSharedFunctionInfoSpecialField for x64 port. R=verwaest@chromium.org Review URL: https://codereview.chromium.org/231013002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20636 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/x64/builtins-x64.cc | 5 ++--- src/x64/full-codegen-x64.cc | 5 ++--- src/x64/macro-assembler-x64.cc | 38 +++++++++++++++++++++++++++++++------- src/x64/macro-assembler-x64.h | 9 +++++++-- 4 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc index 66ac556..d14a935 100644 --- a/src/x64/builtins-x64.cc +++ b/src/x64/builtins-x64.cc @@ -963,9 +963,8 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // expected arguments matches what we're providing. If so, jump // (tail-call) to the code in register edx without checking arguments. __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); - __ movsxlq(rbx, - FieldOperand(rdx, - SharedFunctionInfo::kFormalParameterCountOffset)); + __ LoadSharedFunctionInfoSpecialField(rbx, rdx, + SharedFunctionInfo::kFormalParameterCountOffset); __ movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); __ cmpp(rax, rbx); __ j(not_equal, diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index e4fa4d9..8962267 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -2169,9 +2169,8 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator, // Push holes for arguments to generator function. __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); - __ movsxlq(rdx, - FieldOperand(rdx, - SharedFunctionInfo::kFormalParameterCountOffset)); + __ LoadSharedFunctionInfoSpecialField(rdx, rdx, + SharedFunctionInfo::kFormalParameterCountOffset); __ LoadRoot(rcx, Heap::kTheHoleValueRootIndex); Label push_argument_holes, push_frame; __ bind(&push_argument_holes); diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index f943177..693a5c6 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -2696,10 +2696,34 @@ void MacroAssembler::Pop(const Operand& dst) { } -void MacroAssembler::TestBit(const Operand& src, int bits) { +void MacroAssembler::LoadSharedFunctionInfoSpecialField(Register dst, + Register base, + int offset) { + ASSERT(offset > SharedFunctionInfo::kLengthOffset && + offset <= SharedFunctionInfo::kSize && + (((offset - SharedFunctionInfo::kLengthOffset) / kIntSize) % 2 == 1)); + if (kPointerSize == kInt64Size) { + movsxlq(dst, FieldOperand(base, offset)); + } else { + movp(dst, FieldOperand(base, offset)); + SmiToInteger32(dst, dst); + } +} + + +void MacroAssembler::TestBitSharedFunctionInfoSpecialField(Register base, + int offset, + int bits) { + ASSERT(offset > SharedFunctionInfo::kLengthOffset && + offset <= SharedFunctionInfo::kSize && + (((offset - SharedFunctionInfo::kLengthOffset) / kIntSize) % 2 == 1)); + if (kPointerSize == kInt32Size) { + // On x32, this field is represented by SMI. + bits += kSmiShift; + } int byte_offset = bits / kBitsPerByte; int bit_in_byte = bits & (kBitsPerByte - 1); - testb(Operand(src, byte_offset), Immediate(1 << bit_in_byte)); + testb(FieldOperand(base, offset + byte_offset), Immediate(1 << bit_in_byte)); } @@ -3538,9 +3562,9 @@ void MacroAssembler::TryGetFunctionPrototype(Register function, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); // It's not smi-tagged (stored in the top half of a smi-tagged 8-byte // field). - TestBit(FieldOperand(kScratchRegister, - SharedFunctionInfo::kCompilerHintsOffset), - SharedFunctionInfo::kBoundFunction); + TestBitSharedFunctionInfoSpecialField(kScratchRegister, + SharedFunctionInfo::kCompilerHintsOffset, + SharedFunctionInfo::kBoundFunction); j(not_zero, miss); } @@ -3667,8 +3691,8 @@ void MacroAssembler::InvokeFunction(Register function, ASSERT(function.is(rdi)); movp(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); movp(rsi, FieldOperand(function, JSFunction::kContextOffset)); - movsxlq(rbx, - FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); + LoadSharedFunctionInfoSpecialField(rbx, rdx, + SharedFunctionInfo::kFormalParameterCountOffset); // Advances rdx to the end of the Code object header, to the start of // the executable code. movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index 7448c19..ee4fb85 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -813,8 +813,13 @@ class MacroAssembler: public Assembler { // Move if the registers are not identical. void Move(Register target, Register source); - // Bit-field support. - void TestBit(const Operand& dst, int bit_index); + // TestBit and Load SharedFunctionInfo special field. + void TestBitSharedFunctionInfoSpecialField(Register base, + int offset, + int bit_index); + void LoadSharedFunctionInfoSpecialField(Register dst, + Register base, + int offset); // Handle support void Move(Register dst, Handle source); -- 2.7.4