* Re: [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch [not found] ` <20170118171311.A84EA220125@vcs.savannah.gnu.org> @ 2017-01-18 17:48 ` Stefan Monnier 2017-01-18 18:19 ` Vibhav Pant ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Stefan Monnier @ 2017-01-18 17:48 UTC (permalink / raw) To: emacs-devel; +Cc: Vibhav Pant > * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch > Fgethash type checks the provided table object, which is unnecessary > for compiled bytecode. While it's true that we can cause a core dump of Emacs if we feed it an invalid .elc file, that's a "feature" I'd rather shrink rather than generalize. Stefan ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch 2017-01-18 17:48 ` [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch Stefan Monnier @ 2017-01-18 18:19 ` Vibhav Pant 2017-01-19 12:16 ` Vibhav Pant 2017-01-20 9:10 ` Daniel Colascione 2 siblings, 0 replies; 7+ messages in thread From: Vibhav Pant @ 2017-01-18 18:19 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 472 bytes --] Will push a fix soon, thanks. On 18 Jan 2017 11:18 p.m., "Stefan Monnier" <monnier@iro.umontreal.ca> wrote: > > * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch > > Fgethash type checks the provided table object, which is unnecessary > > for compiled bytecode. > > While it's true that we can cause a core dump of Emacs if we feed it an > invalid .elc file, that's a "feature" I'd rather shrink rather > than generalize. > > > Stefan > [-- Attachment #2: Type: text/html, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch 2017-01-18 17:48 ` [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch Stefan Monnier 2017-01-18 18:19 ` Vibhav Pant @ 2017-01-19 12:16 ` Vibhav Pant 2017-01-19 16:34 ` Stefan Monnier 2017-01-20 9:10 ` Daniel Colascione 2 siblings, 1 reply; 7+ messages in thread From: Vibhav Pant @ 2017-01-19 12:16 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel@gnu.org On another thought, `byte-switch` is used while compiling certain `cond` forms. It replaces the traditional goto-if-nil bytecode by using a hash table mapping values to addresses/tags to be jumped to. Since `byte-switch` is essentially a "dynamic" goto (in the sense that the address/tag cannot be known at compile time), wouldn't doing a runtime type check in the bytecode VM for what is a hash table lookup + goto have a significant performance penalty? On Wed, Jan 18, 2017 at 11:18 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote: >> * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch >> Fgethash type checks the provided table object, which is unnecessary >> for compiled bytecode. > > While it's true that we can cause a core dump of Emacs if we feed it an > invalid .elc file, that's a "feature" I'd rather shrink rather > than generalize. > > > Stefan -- Vibhav Pant vibhavp@gmail.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch 2017-01-19 12:16 ` Vibhav Pant @ 2017-01-19 16:34 ` Stefan Monnier 2017-01-19 17:53 ` Vibhav Pant 0 siblings, 1 reply; 7+ messages in thread From: Stefan Monnier @ 2017-01-19 16:34 UTC (permalink / raw) To: Vibhav Pant; +Cc: emacs-devel@gnu.org > On another thought, `byte-switch` is used while compiling certain > `cond` forms. It > replaces the traditional goto-if-nil bytecode by using a hash table mapping > values to addresses/tags to be jumped to. Since `byte-switch` is essentially a > "dynamic" goto (in the sense that the address/tag cannot be known at > compile time), > wouldn't doing a runtime type check in the bytecode VM for what is a > hash table lookup + goto have a significant performance penalty? I don't know. Only measurement can tell. My guess is that hash_lookup already takes a significant amount of time, so a HASH_TABLE_P test would be negligible in comparison. Stefan > On Wed, Jan 18, 2017 at 11:18 PM, Stefan Monnier > <monnier@iro.umontreal.ca> wrote: >>> * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch >>> Fgethash type checks the provided table object, which is unnecessary >>> for compiled bytecode. >> >> While it's true that we can cause a core dump of Emacs if we feed it an >> invalid .elc file, that's a "feature" I'd rather shrink rather >> than generalize. >> >> >> Stefan > -- > Vibhav Pant > vibhavp@gmail.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch 2017-01-19 16:34 ` Stefan Monnier @ 2017-01-19 17:53 ` Vibhav Pant 0 siblings, 0 replies; 7+ messages in thread From: Vibhav Pant @ 2017-01-19 17:53 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel@gnu.org [-- Attachment #1: Type: text/plain, Size: 1516 bytes --] I see. For now, I've made the type check only work when BYTE_CODE_SAFE is defined at compile time. I'll make it a part of the regular code once the byte-switch is implemented and there are no performance issues with doing so. On Thu, 19 Jan 2017, 22:04 Stefan Monnier, <monnier@iro.umontreal.ca> wrote: > > On another thought, `byte-switch` is used while compiling certain > > `cond` forms. It > > replaces the traditional goto-if-nil bytecode by using a hash table > mapping > > values to addresses/tags to be jumped to. Since `byte-switch` is > essentially a > > "dynamic" goto (in the sense that the address/tag cannot be known at > > compile time), > > wouldn't doing a runtime type check in the bytecode VM for what is a > > hash table lookup + goto have a significant performance penalty? > > I don't know. Only measurement can tell. My guess is that hash_lookup > already takes a significant amount of time, so a HASH_TABLE_P test would be > negligible in comparison. > > > Stefan > > > > On Wed, Jan 18, 2017 at 11:18 PM, Stefan Monnier > > <monnier@iro.umontreal.ca> wrote: > >>> * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch > >>> Fgethash type checks the provided table object, which is unnecessary > >>> for compiled bytecode. > >> > >> While it's true that we can cause a core dump of Emacs if we feed it an > >> invalid .elc file, that's a "feature" I'd rather shrink rather > >> than generalize. > >> > >> > >> Stefan > > > > > -- > > Vibhav Pant > > vibhavp@gmail.com > [-- Attachment #2: Type: text/html, Size: 2819 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch 2017-01-18 17:48 ` [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch Stefan Monnier 2017-01-18 18:19 ` Vibhav Pant 2017-01-19 12:16 ` Vibhav Pant @ 2017-01-20 9:10 ` Daniel Colascione 2017-01-20 14:53 ` Stefan Monnier 2 siblings, 1 reply; 7+ messages in thread From: Daniel Colascione @ 2017-01-20 9:10 UTC (permalink / raw) To: Stefan Monnier; +Cc: Vibhav Pant, emacs-devel On Wed, Jan 18 2017, Stefan Monnier wrote: >> * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch >> Fgethash type checks the provided table object, which is unnecessary >> for compiled bytecode. > > While it's true that we can cause a core dump of Emacs if we feed it an > invalid .elc file, that's a "feature" I'd rather shrink rather > than generalize. Why? If anything, the opposite direction is the right one. elc files should be tightly coupled to the Emacs that built them so that they can be specialized for specific machines. You could imagine them containing, say, saved JIT traces. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch 2017-01-20 9:10 ` Daniel Colascione @ 2017-01-20 14:53 ` Stefan Monnier 0 siblings, 0 replies; 7+ messages in thread From: Stefan Monnier @ 2017-01-20 14:53 UTC (permalink / raw) To: Daniel Colascione; +Cc: Vibhav Pant, emacs-devel > Why? If anything, the opposite direction is the right one. elc files > should be tightly coupled to the Emacs that built them so that they can > be specialized for specific machines. You could imagine them > containing, say, saved JIT traces. But that basically means auto-generating and managing the compiled files, so it's very different from what happens with our .elc files. I would also like to move in the direction you suggest, tho (and get rid of the Elisp interpreter altogether, while we're at it), and we'd then indeed be more free to change the format of byte-code. Stefan ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-01-20 14:53 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20170118171311.10996.72260@vcs.savannah.gnu.org> [not found] ` <20170118171311.A84EA220125@vcs.savannah.gnu.org> 2017-01-18 17:48 ` [Emacs-diffs] feature/byte-switch 086c4ea: * src/bytecode.c: (exec_byte_code) Use hash_lookup for Bswitch Stefan Monnier 2017-01-18 18:19 ` Vibhav Pant 2017-01-19 12:16 ` Vibhav Pant 2017-01-19 16:34 ` Stefan Monnier 2017-01-19 17:53 ` Vibhav Pant 2017-01-20 9:10 ` Daniel Colascione 2017-01-20 14:53 ` Stefan Monnier
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.