From d23330d49647d3b179c1213fe8fd95540f1b9fe4 Mon Sep 17 00:00:00 2001 From: "zhengxing.li" Date: Sun, 22 Nov 2015 19:16:48 -0800 Subject: [PATCH] X87: Fix object initialization when slack tracking for it's map is still enabled. port 2fc2cb99f52974d0743610189213a94585c30ac6 (r32144) original commit message: The old code was not ready for properly initialize objects with non standard headers and non zero in-object properties number. MacroAssembler::Allocate() implementations now return both start and end addresses of the new object (done by parameter renaming). BUG= Review URL: https://codereview.chromium.org/1467923002 Cr-Commit-Position: refs/heads/master@{#32161} --- src/x87/builtins-x87.cc | 14 ++++---------- src/x87/macro-assembler-x87.cc | 10 +++++----- src/x87/macro-assembler-x87.h | 11 +++++------ 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/x87/builtins-x87.cc b/src/x87/builtins-x87.cc index 651616aa6a..80141d3f46 100644 --- a/src/x87/builtins-x87.cc +++ b/src/x87/builtins-x87.cc @@ -241,18 +241,12 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, __ j(less, &no_inobject_slack_tracking); // Allocate object with a slack. - __ movzx_b( - esi, - FieldOperand( - eax, - Map::kInObjectPropertiesOrConstructorFunctionIndexOffset)); - __ movzx_b(eax, FieldOperand(eax, Map::kUnusedPropertyFieldsOffset)); - __ sub(esi, eax); - __ lea(esi, - Operand(ebx, esi, times_pointer_size, JSObject::kHeaderSize)); + __ movzx_b(esi, FieldOperand(eax, Map::kUnusedPropertyFieldsOffset)); + __ neg(esi); + __ lea(esi, Operand(edi, esi, times_pointer_size, 0)); // esi: offset of first field after pre-allocated fields if (FLAG_debug_code) { - __ cmp(esi, edi); + __ cmp(ecx, esi); __ Assert(less_equal, kUnexpectedNumberOfPreAllocatedPropertyFields); } diff --git a/src/x87/macro-assembler-x87.cc b/src/x87/macro-assembler-x87.cc index 0d2ff96dcb..a743380c60 100644 --- a/src/x87/macro-assembler-x87.cc +++ b/src/x87/macro-assembler-x87.cc @@ -1700,16 +1700,16 @@ void MacroAssembler::CopyBytes(Register source, } -void MacroAssembler::InitializeFieldsWithFiller(Register start_offset, - Register end_offset, +void MacroAssembler::InitializeFieldsWithFiller(Register current_address, + Register end_address, Register filler) { Label loop, entry; jmp(&entry); bind(&loop); - mov(Operand(start_offset, 0), filler); - add(start_offset, Immediate(kPointerSize)); + mov(Operand(current_address, 0), filler); + add(current_address, Immediate(kPointerSize)); bind(&entry); - cmp(start_offset, end_offset); + cmp(current_address, end_address); j(below, &loop); } diff --git a/src/x87/macro-assembler-x87.h b/src/x87/macro-assembler-x87.h index 06dfdaf79d..481581eba9 100644 --- a/src/x87/macro-assembler-x87.h +++ b/src/x87/macro-assembler-x87.h @@ -685,12 +685,11 @@ class MacroAssembler: public Assembler { Register length, Register scratch); - // Initialize fields with filler values. Fields starting at |start_offset| - // not including end_offset are overwritten with the value in |filler|. At - // the end the loop, |start_offset| takes the value of |end_offset|. - void InitializeFieldsWithFiller(Register start_offset, - Register end_offset, - Register filler); + // Initialize fields with filler values. Fields starting at |current_address| + // not including |end_address| are overwritten with the value in |filler|. At + // the end the loop, |current_address| takes the value of |end_address|. + void InitializeFieldsWithFiller(Register current_address, + Register end_address, Register filler); // --------------------------------------------------------------------------- // Support functions.