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

Issue 10559035: Implement a simple register allocator that tries to keep instruction results in registers. (Closed)

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

Description

Implement a simple register allocator that tries to keep instruction results in registers. Add --optimization-filter flag that allows to disbable optimizations for all function which do not match prefix. This allows to quickly localize problems with code generation. BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=8811

Patch Set 1 #

Patch Set 2 : #

Total comments: 19
Unified diffs Side-by-side diffs Delta from patch set Stats (+595 lines, -265 lines) Patch
M runtime/vm/assembler_ia32.h View 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/assembler_ia32.cc View 1 chunk +10 lines, -0 lines 0 comments Download
M runtime/vm/assembler_x64.h View 1 chunk +2 lines, -0 lines 0 comments Download
M runtime/vm/assembler_x64.cc View 1 chunk +10 lines, -0 lines 0 comments Download
M runtime/vm/code_generator.cc View 2 chunks +8 lines, -0 lines 2 comments Download
M runtime/vm/flow_graph_compiler.h View 1 1 chunk +91 lines, -0 lines 9 comments Download
M runtime/vm/flow_graph_compiler.cc View 1 9 chunks +189 lines, -1 line 0 comments Download
M runtime/vm/flow_graph_compiler_ia32.h View 1 7 chunks +38 lines, -36 lines 0 comments Download
M runtime/vm/flow_graph_compiler_ia32.cc View 1 3 chunks +17 lines, -16 lines 0 comments Download
M runtime/vm/flow_graph_compiler_x64.h View 1 8 chunks +22 lines, -22 lines 0 comments Download
M runtime/vm/flow_graph_compiler_x64.cc View 1 3 chunks +8 lines, -7 lines 0 comments Download
M runtime/vm/growable_array.h View 1 chunk +8 lines, -0 lines 0 comments Download
M runtime/vm/intermediate_language.h View 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/intermediate_language.cc View 1 5 chunks +22 lines, -5 lines 0 comments Download
M runtime/vm/intermediate_language_ia32.cc View 1 21 chunks +61 lines, -39 lines 4 comments Download
M runtime/vm/intermediate_language_x64.cc View 20 chunks +63 lines, -40 lines 2 comments Download
M runtime/vm/locations.h View 3 chunks +34 lines, -7 lines 2 comments Download
M runtime/vm/locations.cc View 1 chunk +9 lines, -91 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
Vyacheslav Egorov (Google)
This is ready for review. It handles simple cases somewhat well, but gets easily confused ...
8 years, 6 months ago (2012-06-18 14:08:50 UTC) #1
srdjan
LGTM https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/code_generator.cc File runtime/vm/code_generator.cc (right): https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/code_generator.cc#newcode1349 runtime/vm/code_generator.cc:1349: function.set_usage_counter(kLowInvocationCount); Why not doing this in the compiler ...
8 years, 6 months ago (2012-06-18 16:33:20 UTC) #2
Florian Schneider
lgtm https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/flow_graph_compiler.h File runtime/vm/flow_graph_compiler.h (right): https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/flow_graph_compiler.h#newcode90 runtime/vm/flow_graph_compiler.h:90: Instruction* registers_[kNumberOfCpuRegisters]; Can it even be BindInstr*? https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/intermediate_language_ia32.cc ...
8 years, 6 months ago (2012-06-18 16:50:55 UTC) #3
Vyacheslav Egorov (Google)
8 years, 6 months ago (2012-06-18 17:51:16 UTC) #4
thanks for the review.

landing!

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/code_gen...
File runtime/vm/code_generator.cc (right):

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/code_gen...
runtime/vm/code_generator.cc:1349:
function.set_usage_counter(kLowInvocationCount);
On 2012/06/18 16:33:20, srdjan wrote:
> Why not doing this in the compiler and "Bailout" from optimizing this
function?

I don't see any profit in bailing out so late in the pipeline compared to
bailing out later. This is a purely debug flag.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/flow_gra...
File runtime/vm/flow_graph_compiler.h (right):

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/flow_gra...
runtime/vm/flow_graph_compiler.h:35: bool keep_values_in_registers)
On 2012/06/18 16:33:20, srdjan wrote:
> remove explicit

Done.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/flow_gra...
runtime/vm/flow_graph_compiler.h:90: Instruction*
registers_[kNumberOfCpuRegisters];
On 2012/06/18 16:50:55, Florian Schneider wrote:
> Can it even be BindInstr*?

Done.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/flow_gra...
runtime/vm/flow_graph_compiler.h:90: Instruction*
registers_[kNumberOfCpuRegisters];
On 2012/06/18 16:33:20, srdjan wrote:
> Consider renaming registers_to_instructions_, or just instructions_

I am not sure instructions_ reflects the purpose: it tracks registers' state,
not instrucitons' state.

I'll leave it registers for now. We can rename it later.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/flow_gra...
runtime/vm/flow_graph_compiler.h:92: bool keep_values_in_registers_;
On 2012/06/18 16:33:20, srdjan wrote:
> const?

Done.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/flow_gra...
runtime/vm/flow_graph_compiler.h:92: bool keep_values_in_registers_;
On 2012/06/18 16:33:20, srdjan wrote:
> const?

Done.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/intermed...
File runtime/vm/intermediate_language_ia32.cc (right):

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/intermed...
runtime/vm/intermediate_language_ia32.cc:1339: // TODO(vegorov): for many binary
operations this pattern can be rearrange
On 2012/06/18 16:33:20, srdjan wrote:
> rearranged

Done.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/intermed...
runtime/vm/intermediate_language_ia32.cc:1675: // TODO(vegorov): allocate box in
the driver loop to avoid pushing and poping.
On 2012/06/18 16:50:55, Florian Schneider wrote:
> s/poping/popping/

Done.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/intermed...
File runtime/vm/intermediate_language_x64.cc (right):

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/intermed...
runtime/vm/intermediate_language_x64.cc:1276: // TODO(vegorov): spilling is
required only on infrequently executed path.
On 2012/06/18 16:33:20, srdjan wrote:
> A quick fix could be to use the deoptimization stub for the this kind of
"stack
> checks"

Yes, I agree. 

In V8 we have a generic "deferred code facility for this kind of stuff (calls to
runtime from deferred code are surrounded by register spilling). Call to the
stack overflow runtime routine is done from this deferred code.

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/locations.h
File runtime/vm/locations.h (right):

https://chromiumcodereview.appspot.com/10559035/diff/2001/runtime/vm/location...
runtime/vm/locations.h:115: ContainsCall call = kNoCall,
On 2012/06/18 16:33:20, srdjan wrote:
> I am not sure having default value for 'call' is good. I think it will make
the
> caller more readable if we clearly state kNoCall where appropriate, so that
the
> differentiation is visible. 'branch' will go away, so I have no beef with it
> having a default value.

Having default value is definitely less safe than not having one. We can
eliminate it. I am adding todo.

Powered by Google App Engine
This is Rietveld 408576698