RESOLVED FIXED 121732
VirtualRegister should be a class
https://bugs.webkit.org/show_bug.cgi?id=121732
Summary VirtualRegister should be a class
Michael Saboff
Reported 2013-09-20 20:48:35 PDT
VirtualRegister is currently an enum, but this offer little type safety and breaks when a VirtualRegister variable is used for an array index. Instead it should be a POD class with a single int member.
Attachments
First pass - compiles and runs - need to convert more "int" variables to VirtualRegister (40.11 KB, patch)
2013-09-20 20:52 PDT, Michael Saboff
no flags
Patch - Pretty close to done. Runs js tests (100.43 KB, patch)
2013-09-24 08:25 PDT, Michael Saboff
no flags
Patch for Review (187.14 KB, patch)
2013-09-24 16:41 PDT, Michael Saboff
no flags
Patch with updates from initial review (236.84 KB, patch)
2013-09-25 22:30 PDT, Michael Saboff
ggaren: review+
Patch for Landing (218.83 KB, patch)
2013-09-26 10:48 PDT, Michael Saboff
no flags
Michael Saboff
Comment 1 2013-09-20 20:52:09 PDT
Created attachment 212252 [details] First pass - compiles and runs - need to convert more "int" variables to VirtualRegister
Michael Saboff
Comment 2 2013-09-24 08:25:43 PDT
Created attachment 212469 [details] Patch - Pretty close to done. Runs js tests
Michael Saboff
Comment 3 2013-09-24 16:41:38 PDT
Created attachment 212520 [details] Patch for Review The style failure already existed.
Geoffrey Garen
Comment 4 2013-09-24 17:36:34 PDT
Comment on attachment 212520 [details] Patch for Review View in context: https://bugs.webkit.org/attachment.cgi?id=212520&action=review > Source/JavaScriptCore/ChangeLog:18 > + * bytecode/CodeBlock.cpp: > + (JSC::CodeBlock::registerName): I'm not a fan of this long, unannotated list. > Source/JavaScriptCore/bytecode/VirtualRegister.h:38 > +// enum VirtualRegister { InvalidVirtualRegister = 0x3fffffff }; Please remove this commented-out code. > Source/JavaScriptCore/bytecode/VirtualRegister.h:50 > + VirtualRegister(int virtualRegister) This should be explicit, so we don't automatically convert unknown data into this typed format. Otherwise, we don't get any type safety. > Source/JavaScriptCore/bytecode/VirtualRegister.h:65 > + VirtualRegister operator+(int offset) { return VirtualRegister(m_virtualRegister + offset); } This is another way to accidentally convert an int to a VirtualRegister without explicitly specifying your intent, so let's get rid of it. > Source/JavaScriptCore/bytecode/VirtualRegister.h:89 > + operator int() { return m_virtualRegister; } This is a hole in our type safety, since it allows someone to accidentally cast a VirtualRegister into an index into an array of locals or arguments. Let's remove it.
Michael Saboff
Comment 5 2013-09-25 22:30:15 PDT
Created attachment 212668 [details] Patch with updates from initial review
Geoffrey Garen
Comment 6 2013-09-25 23:34:37 PDT
Comment on attachment 212668 [details] Patch with updates from initial review View in context: https://bugs.webkit.org/attachment.cgi?id=212668&action=review > Source/JavaScriptCore/dfg/DFGAssemblyHelpers.h:27 > +#ifndef DFGAssemblyHelpers_h > +#define DFGAssemblyHelpers_h What's up with this file move?
Michael Saboff
Comment 7 2013-09-26 07:04:07 PDT
(In reply to comment #6) > (From update of attachment 212668 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=212668&action=review > > > Source/JavaScriptCore/dfg/DFGAssemblyHelpers.h:27 > > +#ifndef DFGAssemblyHelpers_h > > +#define DFGAssemblyHelpers_h > > What's up with this file move? I think it got moved while I was working on this patch. I'll rebase my patch so that I don't move it back.
Michael Saboff
Comment 8 2013-09-26 10:48:23 PDT
Created attachment 212724 [details] Patch for Landing
Michael Saboff
Comment 9 2013-09-26 10:49:37 PDT
WebKit Commit Bot
Comment 10 2013-09-26 11:13:28 PDT
Re-opened since this is blocked by bug 121966
Michael Saboff
Comment 11 2013-09-26 15:52:48 PDT
Note You need to log in before you can comment on or make changes to this bug.