In X64 code, never assume anything about the representation of smis outside of
the Smi-macros in macro-assembler-x64.cc. Always use the Smi-macros for
operations on smis that are anything except moving them around uninterpreted
(movq is ok for that).
If there is no Smi-macro that does what you need, just implement one and
document its behavior (anything that isn't documented in the comments in
macro-assembler-x64.h is allowed to change without notice).

It's likely that we will try other tagging strategies in the  future, so we
don't want any implicit dependencies on the current representation.


http://codereview.chromium.org/1706013/diff/35003/48011
File src/x64/codegen-x64.cc (right):

http://codereview.chromium.org/1706013/diff/35003/48011#newcode3924
src/x64/codegen-x64.cc:3924: __ cmpq(index.reg(),
FieldOperand(object.reg(), String::kLengthOffset));
Use SmiCompare(Operand,Register) instead.
Don't make any operation that assumes anything about Smi representation
directly in X64 code, use the SmiXXX macros instead.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode5614
src/x64/codegen-x64.cc:5614: __ SmiSubConstant(temp2.reg(), temp2.reg(),
Smi::FromInt(1));
It's undocumented that SmiSubConstant sets flags like sub does. If you
rely on it, please add it to the documentation for SmiSubConstant in
macro-assembler-x64.h, so any rewrite of the function will preserve
that.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode7449
src/x64/codegen-x64.cc:7449: __ cmpq(rax, rbx);
Use SmiCompare

http://codereview.chromium.org/1706013/diff/35003/48011#newcode9685
src/x64/codegen-x64.cc:9685: __ testq(rcx, rcx);
Use SmiTest(rcx).
This one is important (don't assume that the tag or filler bits are
zero! This is likely to change).

http://codereview.chromium.org/1706013/diff/35003/48011#newcode9692
src/x64/codegen-x64.cc:9692: __ testq(rbx, rbx);
SmiTest again.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode9721
src/x64/codegen-x64.cc:9721: __ addq(rbx, rcx);
Use SmiAdd when adding smis.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode10303
src/x64/codegen-x64.cc:10303: __ subq(scratch4, FieldOperand(right,
String::kLengthOffset));
Use SmiSub for subtracting smis.

There is no SmiSub(Register, Operand), so either use movq to load from
memory and SmiSub(Register,Register), or add a SmiSub(Register,Operand)
macro.,

http://codereview.chromium.org/1706013/diff/35003/48011#newcode10311
src/x64/codegen-x64.cc:10311: __ subq(scratch1, length_difference);
Use SmiSub.

http://codereview.chromium.org/1706013/diff/35003/48011#newcode10319
src/x64/codegen-x64.cc:10319: __ testq(min_length, min_length);
Use SmiTest

http://codereview.chromium.org/1706013/diff/35003/48011#newcode10354
src/x64/codegen-x64.cc:10354: ASSERT(kSmiTag == 0);
Don't ASSERT or assume anything about the smi tag value. Use Smi-macros
instead (SmiTest here).

http://codereview.chromium.org/1706013/show

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to