Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Issue 10696151: Skeleton of a linear scan register allocator. (Closed)

Created:
8 years, 5 months ago by Vyacheslav Egorov (Google)
Modified:
8 years, 5 months ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Skeleton of a linear scan register allocator. BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=9563

Patch Set 1 #

Total comments: 91

Patch Set 2 : address comments #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+1664 lines, -150 lines) Patch
M runtime/vm/compiler.cc View 3 chunks +9 lines, -9 lines 0 comments Download
M runtime/vm/flow_graph_allocator.h View 1 4 chunks +237 lines, -6 lines 2 comments Download
M runtime/vm/flow_graph_allocator.cc View 1 4 chunks +774 lines, -16 lines 1 comment Download
M runtime/vm/flow_graph_builder.cc View 3 chunks +6 lines, -0 lines 1 comment Download
M runtime/vm/flow_graph_compiler.h View 1 2 chunks +74 lines, -2 lines 0 comments Download
M runtime/vm/flow_graph_compiler.cc View 1 14 chunks +147 lines, -16 lines 0 comments Download
M runtime/vm/flow_graph_compiler_ia32.h View 1 3 chunks +9 lines, -31 lines 0 comments Download
M runtime/vm/flow_graph_compiler_ia32.cc View 1 2 chunks +70 lines, -3 lines 1 comment Download
M runtime/vm/flow_graph_compiler_x64.h View 1 3 chunks +9 lines, -31 lines 0 comments Download
M runtime/vm/flow_graph_compiler_x64.cc View 1 2 chunks +70 lines, -3 lines 0 comments Download
M runtime/vm/flow_graph_optimizer.cc View 4 chunks +10 lines, -0 lines 1 comment Download
M runtime/vm/growable_array.h View 2 chunks +9 lines, -1 line 0 comments Download
M runtime/vm/il_printer.h View 1 chunk +7 lines, -3 lines 0 comments Download
M runtime/vm/il_printer.cc View 1 3 chunks +14 lines, -1 line 0 comments Download
M runtime/vm/intermediate_language.h View 1 7 chunks +73 lines, -5 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 2 chunks +2 lines, -7 lines 0 comments Download
M runtime/vm/intermediate_language_x64.cc View 1 4 chunks +4 lines, -8 lines 0 comments Download
M runtime/vm/locations.h View 1 10 chunks +79 lines, -8 lines 0 comments Download
M runtime/vm/locations.cc View 2 chunks +61 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Vyacheslav Egorov (Google)
Please take a look. This is just a skeleton. But it can allocate registers correctly ...
8 years, 5 months ago (2012-07-10 17:56:36 UTC) #1
Vyacheslav Egorov (Google)
Couple of comments about code that is commented out in this CL. http://codereview.chromium.org/10696151/diff/1/runtime/vm/flow_graph_builder.cc File runtime/vm/flow_graph_builder.cc ...
8 years, 5 months ago (2012-07-10 18:02:05 UTC) #2
srdjan
LGTM with comments/questions. I think you should have split the CL into smaller ones, especially ...
8 years, 5 months ago (2012-07-10 23:27:54 UTC) #3
Vyacheslav Egorov (Google)
please take another look http://codereview.chromium.org/10696151/diff/1/runtime/vm/flow_graph_allocator.cc File runtime/vm/flow_graph_allocator.cc (right): http://codereview.chromium.org/10696151/diff/1/runtime/vm/flow_graph_allocator.cc#newcode30 runtime/vm/flow_graph_allocator.cc:30: live_out_(builder->postorder_block_entries().length()), On 2012/07/10 23:27:54, srdjan ...
8 years, 5 months ago (2012-07-11 13:27:58 UTC) #4
srdjan
8 years, 5 months ago (2012-07-11 17:22:31 UTC) #5
LGTM

http://codereview.chromium.org/10696151/diff/1/runtime/vm/flow_graph_allocato...
File runtime/vm/flow_graph_allocator.cc (right):

http://codereview.chromium.org/10696151/diff/1/runtime/vm/flow_graph_allocato...
runtime/vm/flow_graph_allocator.cc:508: pos -= 2;
On 2012/07/11 13:27:58, Vyacheslav Egorov (Google) wrote:
> On 2012/07/10 23:27:54, srdjan wrote:
> > Why -2?
> 
> Each instruction occupies two positions. See comment for NumberInstructions()
in
> the header.
> 
> I added a comment, but I am a bit hesitant to make a constant (e.g.
> kPositionsPerInstruction), because then I would have to express constant 1 in
> some cases as kPositionsPerInstruction / 2 which makes very little sense.
> 
> In V8 I solved the problem by ecapsulating this into LifetimePosition class
that
> had methods like
> 
> LifetimePosition NextInstruction() const;
> LifetimePosition PrevInstruction() const;
> LifetimePosition InstructionStart() const;
> LifetimePosition InstructionEnd() const;
> intptr_t Value();
> 
> so pos - 1 could be expressed as
> 
> pos.PrevInstruction().InstructionEnd() which is more readable if one is not
> familiar with how positions are calculated but a bit wordy.
> 
> Also operator overloading is forbiden so we had to compare positions like
> 
> pos.Value() == other.Value() 
> 
> 
> 
>  

Using -2, -1 is more readable in this case.

http://codereview.chromium.org/10696151/diff/1/runtime/vm/flow_graph_allocator.h
File runtime/vm/flow_graph_allocator.h (right):

http://codereview.chromium.org/10696151/diff/1/runtime/vm/flow_graph_allocato...
runtime/vm/flow_graph_allocator.h:138: : pos_(pos << kPositionShift),
On 2012/07/11 13:27:58, Vyacheslav Egorov (Google) wrote:
> On 2012/07/10 23:27:54, srdjan wrote:
> > This shift is wasted if instr != NULL. Maybe set it to -1, and do the shift
if
> > instr == NULL
> 
> instr != NULL is considered an unlikely occasion that is why I decided to do
> shift ahead of time.

Add comment, otherwise 'somebody' may clean it up accidentally ;-).

http://codereview.chromium.org/10696151/diff/1/runtime/vm/intermediate_langua...
File runtime/vm/intermediate_language.h (right):

http://codereview.chromium.org/10696151/diff/1/runtime/vm/intermediate_langua...
runtime/vm/intermediate_language.h:2360: return dest;
On 2012/07/11 13:27:58, Vyacheslav Egorov (Google) wrote:
> On 2012/07/10 23:27:54, srdjan wrote:
> > Wouldn't it be much simpler to use a field bool is_pending_?  Should it be
> > called MarkInProgress instead? I would read Pending as something that has to
> > happen yet, maybe has not started yet or is in progress.
> 
> I suspect it will be simpler, but bool will waste a word in every parallel
move.
> 
> 
> (implementation of parallel move resolution is copied from V8 keeping names
sans
> differences between Dart VM Location and V8's LOperands).

OK

http://codereview.chromium.org/10696151/diff/1/runtime/vm/intermediate_langua...
runtime/vm/intermediate_language.h:2414: GrowableArray<MoveOperands> moves_;
On 2012/07/11 13:27:58, Vyacheslav Egorov (Google) wrote:
> On 2012/07/10 23:27:54, srdjan wrote:
> > Why is this not MoveOperands* ?
> 
> I am not sure what additional indirection buys us here.

It is more fragile, since it can get suddenly really slow if somebody adds
fields to MoveOperands. How about adding a comment/warning to MoveOperands?

http://codereview.chromium.org/10696151/diff/1/runtime/vm/intermediate_langua...
runtime/vm/intermediate_language.h:2438: const GrowableArray<Location>*
locations() const {
On 2012/07/11 13:27:58, Vyacheslav Egorov (Google) wrote:
> On 2012/07/10 23:27:54, srdjan wrote:
> > Is it really necessary to have const overloaded getters?
> 
> Deoptimization stub references const Environment* so I need a const version of
> this getter. I can't remove non-const getter because register allocator want
to
> get hold of non-const slots inside the array.

How about renaming it to const_locations() then ?

http://codereview.chromium.org/10696151/diff/1/runtime/vm/locations.cc
File runtime/vm/locations.cc (right):

http://codereview.chromium.org/10696151/diff/1/runtime/vm/locations.cc#newcode38
runtime/vm/locations.cc:38: #endif
On 2012/07/11 13:27:58, Vyacheslav Egorov (Google) wrote:
> On 2012/07/10 23:27:54, srdjan wrote:
> > Move cpu_reg_names to constants_<arch>.h
> 
> Do we really want to have arrays declarations in the header file?

We do not want to have if def targets in shared code.

You could define a functions in constants_arch.h that converts register to
string. (similar to assembler-x64.h in v8)

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_alloc...
File runtime/vm/flow_graph_allocator.cc (right):

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_alloc...
runtime/vm/flow_graph_allocator.cc:39: for (intptr_t i = 0; i < vreg_count_;
i++) live_ranges_.Add(NULL);
Initialize cpu_regs_ elements to NULL

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_alloc...
File runtime/vm/flow_graph_allocator.h (right):

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_alloc...
runtime/vm/flow_graph_allocator.h:73: intptr_t use,
Please describe what are def and use. intptr_t sometime represents a virtual
register sometimes a position. Maybe we should use value types for those in
order to eliminate confusion (later CL)?

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_alloc...
runtime/vm/flow_graph_allocator.h:91: // TODO(vegorov): this field is used only
to call Bailout. remove when
s/remove/Remove/

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_build...
File runtime/vm/flow_graph_builder.cc (right):

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_build...
runtime/vm/flow_graph_builder.cc:1075: #if 0
Enable stack overflow check before submitting

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_compi...
File runtime/vm/flow_graph_compiler_ia32.cc (right):

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_compi...
runtime/vm/flow_graph_compiler_ia32.cc:32: if (deoptimization_env_ == NULL) {
ASSERT in ia32 that deoptimization_env_ == NULL (since else not implemented)

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_optim...
File runtime/vm/flow_graph_optimizer.cc (right):

http://codereview.chromium.org/10696151/diff/9001/runtime/vm/flow_graph_optim...
runtime/vm/flow_graph_optimizer.cc:588: #if 0
Enable once synced with branch fusion fix

Powered by Google App Engine
This is Rietveld 408576698