https://codereview.chromium.org/164793003/diff/1/src/a64/macro-assembler-a64.cc
File src/a64/macro-assembler-a64.cc (right):

https://codereview.chromium.org/164793003/diff/1/src/a64/macro-assembler-a64.cc#newcode5172
src/a64/macro-assembler-a64.cc:5172: void
UseScratchRegisterScope::Include(const CPURegList& regs) {

They're useful in tests (such as Dump), but there aren't many cases
where we
need to explicitly exclude registers. Most of the time, if we need to
use a
specific register, it's because we're calling a function. We _could_
go
over-the-top and Exclude the arguments registers (x0, ...) in those
cases, to be
safe, but such an invasive change is almost certainly not worthwhile.

Regarding incorrect use: It is true that modifications to TmpList()
will be
reverted when a scope exits, even if a caller started the scope, but
we thought
that was the correct behaviour. What accidental use-case did you think
of?

The accidental use-case I'm thinking of is something along the lines of
code which adds a random register to a scratch register scope, does some
work, then accidentally uses that same register thinking it's free
(either within the same scope, or a further scope of a called
MacroAssembler method).  E.g.:

MacroAssembler::bar(... Register scratch) {
  // load scratch1
  Mov(x1, MemOperand...) // clobbers scratch1
  // use scratch1
}

MacroAssembler::foo() {
  UseScratchRegisterScope tmps(this);
  tmps.Include(scratch1);
  // ...
  bar(..., scratch1);  // mistakenly think scratch1 is free
}

I realise the use of scratch1 after including it in the
UseScratchRegisterScope in foo is incorrect, but I could see something
like this easily being accidentally introduced via copy/pasted code or
in extra long scopes where it's not obvious which temps are available.

Also, even if I remove Include and Exclude, the same behaviour could
be achieved
by directly manipulating TmpList(), but I don't want to encourage
that.

Sure anything's possible by manipulating TmpList, but as you say we
don't want to encourage this, and Include/Exclude encourage this
manipulation of the available scratch registers :).

https://codereview.chromium.org/164793003/

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to