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

https://codereview.chromium.org/268353005/diff/1/src/arm64/macro-assembler-arm64.cc#newcode4871
src/arm64/macro-assembler-arm64.cc:4871: CPURegister
pcs[kPrintfMaxArgCount] = {NoReg, NoReg, NoReg, NoReg};
On 2014/05/08 09:32:13, rmcilroy wrote:
I'm guessing pcs stands for procedure call standard? Maybe it would be
clearer
as in_args and out_args? If not, please expand PCS in the comment
above.

I'll expand PCS in the comment.

https://codereview.chromium.org/268353005/diff/1/src/arm64/macro-assembler-arm64.cc#newcode4899
src/arm64/macro-assembler-arm64.cc:4899: // Copies of the arg lists that
we can iterate through.
On 2014/05/08 09:32:13, rmcilroy wrote:
Nit - "Copies of the printf  vararg registers that we can pop from."

Done.

https://codereview.chromium.org/268353005/diff/1/src/arm64/simulator-arm64.cc
File src/arm64/simulator-arm64.cc (right):

https://codereview.chromium.org/268353005/diff/1/src/arm64/simulator-arm64.cc#newcode3625
src/arm64/simulator-arm64.cc:3625: // format placeholder at a time.
On 2014/05/08 09:32:13, rmcilroy wrote:
It's sad you need to go to all this bother since you can't just
portably create
a varargs list in C :(.

Yes, it is! I tried a few approaches and this was the only one that was
even slightly portable. It's a pain, but hopefully worth it.

https://codereview.chromium.org/268353005/diff/1/src/arm64/simulator-arm64.cc#newcode3651
src/arm64/simulator-arm64.cc:3651: if (placeholder_count > 0)
*format_scratch++ = format_base[i];
On 2014/05/08 09:32:13, rmcilroy wrote:
Doesn't this mean you can overrun the size of the format buffer?  As
far as I
can tell you are compensating for the the extra '\0' by having format
be length
+ arg_count, but not for the escaping of %%'s.

Also should you be double escaping %'s anyway?  Surely if code calls
  __ PrintF("%%\n")
the expected output is just "%" just like it would be with normal
printf, right?
  Surely this double escaping would lead to the output of "%%"?

  - For the first chunk (which contains no format placeholders and is
printed with `printf("%s", format)`), "%%" is converted to "%".
  - For subsequent chunks (which each contain exactly one placeholder),
"%%" is converted to "%%" (and is not counted as a placeholder). These
chunks are printed with `printf(chunk, arg)`.

It's a bit ugly that the first chunk is printed differently, but this
avoids a GCC warning about code like `printf(string)`: it doesn't like
the non-literal format string without an arguments list.

There is no double-escaping: `Printf("%%")` prints "%". (Note the `i++`
on the previous line.)

If you like, I can add an assertion after the loop:
ASSERT(format_scratch <= (format + length + arg_count));

(That assertion doesn't fail in the assembler tests, where Printf is
tested.)

https://codereview.chromium.org/268353005/

--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to