From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6C8C24765E0 for ; Fri, 25 Dec 2020 14:24:02 +0300 (MSK) Date: Fri, 25 Dec 2020 14:23:16 +0300 From: Sergey Kaplun Message-ID: <20201225112316.GS9101@root> References: <333d99a8e4406e8c03cba132f9b50435f6d643bd.1608142899.git.skaplun@tarantool.org> <99BCEE4E-7AAC-4140-9BC9-88A19DA3139B@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <99BCEE4E-7AAC-4140-9BC9-88A19DA3139B@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH luajit v1 05/11] vm: introduce LFUNC and FFUNC vmstates List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Ostanevich Cc: tarantool-patches@dev.tarantool.org Hi, Sergos! Thanks for the review! On 25.12.20, Sergey Ostanevich wrote: > Hi! > > Thanks for the patch! > Some comments below. > > <...> > > diff --git a/src/vm_x64.dasc b/src/vm_x64.dasc > > index 80753e0..d4d3a1d 100644 > > --- a/src/vm_x64.dasc > > +++ b/src/vm_x64.dasc > > @@ -140,7 +140,7 @@ > > |//----------------------------------------------------------------------- > > |.else // x64/POSIX stack layout > > | > > -|.define CFRAME_SPACE, aword*5 // Delta for rsp (see <--). > > +|.define CFRAME_SPACE, qword*7 // Delta for rsp (see <--). > > |.macro saveregs_ > > | push rbx; push r15; push r14 > > |.if NO_UNWIND > > @@ -161,26 +161,29 @@ > > | > > |//----- 16 byte aligned, > > |.if NO_UNWIND > > -|.define SAVE_RET, aword [rsp+aword*11] //<-- rsp entering interpreter. > > -|.define SAVE_R4, aword [rsp+aword*10] > > -|.define SAVE_R3, aword [rsp+aword*9] > > -|.define SAVE_R2, aword [rsp+aword*8] > > -|.define SAVE_R1, aword [rsp+aword*7] > > -|.define SAVE_RU2, aword [rsp+aword*6] > > -|.define SAVE_RU1, aword [rsp+aword*5] //<-- rsp after register saves. > > Why did you change all ‘aword’ - which represents address, AFAIU into a qword? According unofficial dynasm documentation [1] `aword` equals 4 or 8 bytes on x86 and x64 correspondingly. Each of this `aword` usage is already inside defined x86 or x64 arch. So aword usage is misleading here -- there is always one case, how it can be represented. I've already changed this code chunk so I thought that is nothing bad to rewrite it in a more clear way. I can drop these changes if you and Igor insist on it. > > > +|.define SAVE_RET, qword [rsp+qword*13] //<-- rsp entering interpreter. > > +|.define SAVE_R4, qword [rsp+qword*12] > > +|.define SAVE_R3, qword [rsp+qword*11] > > +|.define SAVE_R2, qword [rsp+qword*10] > > +|.define SAVE_R1, qword [rsp+qword*9] > > +|.define SAVE_RU2, qword [rsp+qword*8] > > +|.define SAVE_RU1, qword [rsp+qword*7] //<-- rsp after register saves. > > |.else > > -|.define SAVE_RET, aword [rsp+aword*9] //<-- rsp entering interpreter. > > -|.define SAVE_R4, aword [rsp+aword*8] > > -|.define SAVE_R3, aword [rsp+aword*7] > > -|.define SAVE_R2, aword [rsp+aword*6] > > -|.define SAVE_R1, aword [rsp+aword*5] //<-- rsp after register saves. > > +|.define SAVE_RET, qword [rsp+qword*11] //<-- rsp entering interpreter. > > +|.define SAVE_R4, qword [rsp+qword*10] > > +|.define SAVE_R3, qword [rsp+qword*9] > > +|.define SAVE_R2, qword [rsp+qword*8] > > +|.define SAVE_R1, qword [rsp+qword*7] //<-- rsp after register saves. > > |.endif > > -|.define SAVE_CFRAME, aword [rsp+aword*4] > > -|.define SAVE_PC, aword [rsp+aword*3] > > -|.define SAVE_L, aword [rsp+aword*2] > > +|.define SAVE_CFRAME, qword [rsp+qword*6] > > +|.define SAVE_UNUSED2, qword [rsp+qword*5] > > The naming is quite boggling: to save something unused? Why? Will rewrite it as UNUSED only, thanks. > > > +|.define SAVE_UNUSED1, dword [rsp+dword*8] > > +|.define SAVE_VMSTATE, dword [rsp+dword*8] > > +|.define SAVE_PC, qword [rsp+qword*3] > > +|.define SAVE_L, qword [rsp+qword*2] > > |.define SAVE_ERRF, dword [rsp+dword*3] > > |.define SAVE_NRES, dword [rsp+dword*2] > > -|.define TMP1, aword [rsp] //<-- rsp while in interpreter. > > +|.define TMP1, qword [rsp] //<-- rsp while in interpreter. > > |//----- 16 byte aligned > > | > > |.define TMP1d, dword [rsp] > > @@ -342,6 +345,20 @@ > > | mov dword [DISPATCH+DISPATCH_GL(vmstate)], ~LJ_VMST_..st > > |.endmacro > > | > > Can you set an empty versions of the macros for WIN, so that > later at uses do not do not wrap with .if—--.endif? Good idea. Thank you! > > > +|.if not WIN > > +|// Save vmstate through register. > > +|.macro save_vmstate_through, reg > > +| mov reg, dword [DISPATCH+DISPATCH_GL(vmstate)] > > +| mov SAVE_VMSTATE, reg > > +|.endmacro > > +| > > +|// Restore vmstate through register. > > +|.macro restore_vmstate_through, reg > > +| mov reg, SAVE_VMSTATE > > +| mov dword [DISPATCH+DISPATCH_GL(vmstate)], reg > > +|.endmacro > > +|.endif // WIN > > +| > > |.macro fpop1; fstp st1; .endmacro > [1]: https://corsix.github.io/dynasm-doc/instructions.html#memory -- Best regards, Sergey Kaplun