Commit f8b274ee authored by antonm@chromium.org's avatar antonm@chromium.org

Rename some x64 macros to be more precise about their semantics.

Review URL: http://codereview.chromium.org/3574002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5566 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4e961fdd
...@@ -715,7 +715,7 @@ static void ArrayNativeCode(MacroAssembler* masm, ...@@ -715,7 +715,7 @@ static void ArrayNativeCode(MacroAssembler* masm,
__ cmpq(rax, Immediate(1)); __ cmpq(rax, Immediate(1));
__ j(not_equal, &argc_two_or_more); __ j(not_equal, &argc_two_or_more);
__ movq(rdx, Operand(rsp, kPointerSize)); // Get the argument from the stack. __ movq(rdx, Operand(rsp, kPointerSize)); // Get the argument from the stack.
__ JumpIfNotPositiveSmi(rdx, call_generic_code); __ JumpUnlessNonNegativeSmi(rdx, call_generic_code);
// Handle construction of an empty array of a certain size. Bail out if size // Handle construction of an empty array of a certain size. Bail out if size
// is to large to actually allocate an elements array. // is to large to actually allocate an elements array.
......
...@@ -3801,7 +3801,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { ...@@ -3801,7 +3801,7 @@ void SubStringStub::Generate(MacroAssembler* masm) {
Label result_longer_than_two; Label result_longer_than_two;
__ movq(rcx, Operand(rsp, kToOffset)); __ movq(rcx, Operand(rsp, kToOffset));
__ movq(rdx, Operand(rsp, kFromOffset)); __ movq(rdx, Operand(rsp, kFromOffset));
__ JumpIfNotBothPositiveSmi(rcx, rdx, &runtime); __ JumpUnlessBothNonNegativeSmi(rcx, rdx, &runtime);
__ SmiSub(rcx, rcx, rdx); // Overflow doesn't happen. __ SmiSub(rcx, rcx, rdx); // Overflow doesn't happen.
__ cmpq(FieldOperand(rax, String::kLengthOffset), rcx); __ cmpq(FieldOperand(rax, String::kLengthOffset), rcx);
......
...@@ -1884,8 +1884,7 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, ...@@ -1884,8 +1884,7 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr,
operand->reg(), operand->reg(),
smi_value, smi_value,
overwrite_mode); overwrite_mode);
// Check for negative or non-Smi left hand side. __ JumpUnlessNonNegativeSmi(operand->reg(), deferred->entry_label());
__ JumpIfNotPositiveSmi(operand->reg(), deferred->entry_label());
if (int_value < 0) int_value = -int_value; if (int_value < 0) int_value = -int_value;
if (int_value == 1) { if (int_value == 1) {
__ Move(operand->reg(), Smi::FromInt(0)); __ Move(operand->reg(), Smi::FromInt(0));
...@@ -5684,9 +5683,9 @@ void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList<Expression*>* args) { ...@@ -5684,9 +5683,9 @@ void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList<Expression*>* args) {
Result value = frame_->Pop(); Result value = frame_->Pop();
value.ToRegister(); value.ToRegister();
ASSERT(value.is_valid()); ASSERT(value.is_valid());
Condition positive_smi = masm_->CheckPositiveSmi(value.reg()); Condition non_negative_smi = masm_->CheckNonNegativeSmi(value.reg());
value.Unuse(); value.Unuse();
destination()->Split(positive_smi); destination()->Split(non_negative_smi);
} }
...@@ -6911,7 +6910,7 @@ void CodeGenerator::GenerateSwapElements(ZoneList<Expression*>* args) { ...@@ -6911,7 +6910,7 @@ void CodeGenerator::GenerateSwapElements(ZoneList<Expression*>* args) {
deferred->Branch(not_equal); deferred->Branch(not_equal);
// Check that both indices are smis. // Check that both indices are smis.
Condition both_smi = __ CheckBothSmi(index1.reg(), index2.reg()); Condition both_smi = masm()->CheckBothSmi(index1.reg(), index2.reg());
deferred->Branch(NegateCondition(both_smi)); deferred->Branch(NegateCondition(both_smi));
// Bring addresses into index1 and index2. // Bring addresses into index1 and index2.
...@@ -8377,7 +8376,7 @@ Result CodeGenerator::EmitNamedStore(Handle<String> name, bool is_contextual) { ...@@ -8377,7 +8376,7 @@ Result CodeGenerator::EmitNamedStore(Handle<String> name, bool is_contextual) {
} }
// Check that the receiver is a heap object. // Check that the receiver is a heap object.
Condition is_smi = __ CheckSmi(receiver.reg()); Condition is_smi = masm()->CheckSmi(receiver.reg());
slow.Branch(is_smi, &value, &receiver); slow.Branch(is_smi, &value, &receiver);
// This is the map check instruction that will be patched. // This is the map check instruction that will be patched.
...@@ -8506,8 +8505,7 @@ Result CodeGenerator::EmitKeyedLoad() { ...@@ -8506,8 +8505,7 @@ Result CodeGenerator::EmitKeyedLoad() {
kScratchRegister); kScratchRegister);
deferred->Branch(not_equal); deferred->Branch(not_equal);
// Check that the key is a non-negative smi. __ JumpUnlessNonNegativeSmi(key.reg(), deferred->entry_label());
__ JumpIfNotPositiveSmi(key.reg(), deferred->entry_label());
// Get the elements array from the receiver. // Get the elements array from the receiver.
__ movq(elements.reg(), __ movq(elements.reg(),
......
...@@ -767,7 +767,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { ...@@ -767,7 +767,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
// Get the current entry of the array into register rbx. // Get the current entry of the array into register rbx.
__ movq(rbx, Operand(rsp, 2 * kPointerSize)); __ movq(rbx, Operand(rsp, 2 * kPointerSize));
SmiIndex index = __ SmiToIndex(rax, rax, kPointerSizeLog2); SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2);
__ movq(rbx, FieldOperand(rbx, __ movq(rbx, FieldOperand(rbx,
index.reg, index.reg,
index.scale, index.scale,
...@@ -1407,7 +1407,7 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr, ...@@ -1407,7 +1407,7 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr,
Label done, stub_call, smi_case; Label done, stub_call, smi_case;
__ pop(rdx); __ pop(rdx);
__ movq(rcx, rax); __ movq(rcx, rax);
Condition smi = __ CheckBothSmi(rdx, rax); Condition smi = masm()->CheckBothSmi(rdx, rax);
__ j(smi, &smi_case); __ j(smi, &smi_case);
__ bind(&stub_call); __ bind(&stub_call);
...@@ -1965,8 +1965,8 @@ void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList<Expression*>* args) { ...@@ -1965,8 +1965,8 @@ void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList<Expression*>* args) {
context()->PrepareTest(&materialize_true, &materialize_false, context()->PrepareTest(&materialize_true, &materialize_false,
&if_true, &if_false, &fall_through); &if_true, &if_false, &fall_through);
Condition positive_smi = __ CheckPositiveSmi(rax); Condition non_negative_smi = masm()->CheckNonNegativeSmi(rax);
Split(positive_smi, if_true, if_false, fall_through); Split(non_negative_smi, if_true, if_false, fall_through);
context()->Plug(if_true, if_false); context()->Plug(if_true, if_false);
} }
......
...@@ -895,7 +895,7 @@ void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { ...@@ -895,7 +895,7 @@ void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) {
// Check that the key is an array index, that is Uint32. // Check that the key is an array index, that is Uint32.
STATIC_ASSERT(kSmiValueSize <= 32); STATIC_ASSERT(kSmiValueSize <= 32);
__ JumpIfNotPositiveSmi(rax, &slow); __ JumpUnlessNonNegativeSmi(rax, &slow);
// Get the map of the receiver. // Get the map of the receiver.
__ movq(rcx, FieldOperand(rdx, HeapObject::kMapOffset)); __ movq(rcx, FieldOperand(rdx, HeapObject::kMapOffset));
......
...@@ -825,7 +825,7 @@ Condition MacroAssembler::CheckSmi(Register src) { ...@@ -825,7 +825,7 @@ Condition MacroAssembler::CheckSmi(Register src) {
} }
Condition MacroAssembler::CheckPositiveSmi(Register src) { Condition MacroAssembler::CheckNonNegativeSmi(Register src) {
ASSERT_EQ(0, kSmiTag); ASSERT_EQ(0, kSmiTag);
// Make mask 0x8000000000000001 and test that both bits are zero. // Make mask 0x8000000000000001 and test that both bits are zero.
movq(kScratchRegister, src); movq(kScratchRegister, src);
...@@ -846,15 +846,15 @@ Condition MacroAssembler::CheckBothSmi(Register first, Register second) { ...@@ -846,15 +846,15 @@ Condition MacroAssembler::CheckBothSmi(Register first, Register second) {
} }
Condition MacroAssembler::CheckBothPositiveSmi(Register first, Condition MacroAssembler::CheckBothNonNegativeSmi(Register first,
Register second) { Register second) {
if (first.is(second)) { if (first.is(second)) {
return CheckPositiveSmi(first); return CheckNonNegativeSmi(first);
} }
movq(kScratchRegister, first); movq(kScratchRegister, first);
or_(kScratchRegister, second); or_(kScratchRegister, second);
rol(kScratchRegister, Immediate(1)); rol(kScratchRegister, Immediate(1));
testl(kScratchRegister, Immediate(0x03)); testl(kScratchRegister, Immediate(3));
return zero; return zero;
} }
......
...@@ -265,14 +265,14 @@ class MacroAssembler: public Assembler { ...@@ -265,14 +265,14 @@ class MacroAssembler: public Assembler {
// Is the value a tagged smi. // Is the value a tagged smi.
Condition CheckSmi(Register src); Condition CheckSmi(Register src);
// Is the value a positive tagged smi. // Is the value a non-negative tagged smi.
Condition CheckPositiveSmi(Register src); Condition CheckNonNegativeSmi(Register src);
// Are both values tagged smis. // Are both values tagged smis.
Condition CheckBothSmi(Register first, Register second); Condition CheckBothSmi(Register first, Register second);
// Are both values tagged smis. // Are both values non-negative tagged smis.
Condition CheckBothPositiveSmi(Register first, Register second); Condition CheckBothNonNegativeSmi(Register first, Register second);
// Are either value a tagged smi. // Are either value a tagged smi.
Condition CheckEitherSmi(Register first, Condition CheckEitherSmi(Register first,
...@@ -311,9 +311,9 @@ class MacroAssembler: public Assembler { ...@@ -311,9 +311,9 @@ class MacroAssembler: public Assembler {
template <typename LabelType> template <typename LabelType>
void JumpIfNotSmi(Register src, LabelType* on_not_smi); void JumpIfNotSmi(Register src, LabelType* on_not_smi);
// Jump to label if the value is not a positive tagged smi. // Jump to label if the value is not a non-negative tagged smi.
template <typename LabelType> template <typename LabelType>
void JumpIfNotPositiveSmi(Register src, LabelType* on_not_smi); void JumpUnlessNonNegativeSmi(Register src, LabelType* on_not_smi);
// Jump to label if the value, which must be a tagged smi, has value equal // Jump to label if the value, which must be a tagged smi, has value equal
// to the constant. // to the constant.
...@@ -328,10 +328,10 @@ class MacroAssembler: public Assembler { ...@@ -328,10 +328,10 @@ class MacroAssembler: public Assembler {
Register src2, Register src2,
LabelType* on_not_both_smi); LabelType* on_not_both_smi);
// Jump if either or both register are not positive smi values. // Jump if either or both register are not non-negative smi values.
template <typename LabelType> template <typename LabelType>
void JumpIfNotBothPositiveSmi(Register src1, Register src2, void JumpUnlessBothNonNegativeSmi(Register src1, Register src2,
LabelType* on_not_both_smi); LabelType* on_not_both_smi);
// Operations on tagged smi values. // Operations on tagged smi values.
...@@ -1463,10 +1463,10 @@ void MacroAssembler::JumpIfNotSmi(Register src, LabelType* on_not_smi) { ...@@ -1463,10 +1463,10 @@ void MacroAssembler::JumpIfNotSmi(Register src, LabelType* on_not_smi) {
template <typename LabelType> template <typename LabelType>
void MacroAssembler::JumpIfNotPositiveSmi(Register src, void MacroAssembler::JumpUnlessNonNegativeSmi(
LabelType* on_not_positive_smi) { Register src, LabelType* on_not_smi_or_negative) {
Condition positive_smi = CheckPositiveSmi(src); Condition non_negative_smi = CheckNonNegativeSmi(src);
j(NegateCondition(positive_smi), on_not_positive_smi); j(NegateCondition(non_negative_smi), on_not_smi_or_negative);
} }
...@@ -1505,10 +1505,10 @@ void MacroAssembler::JumpIfNotBothSmi(Register src1, ...@@ -1505,10 +1505,10 @@ void MacroAssembler::JumpIfNotBothSmi(Register src1,
template <typename LabelType> template <typename LabelType>
void MacroAssembler::JumpIfNotBothPositiveSmi(Register src1, void MacroAssembler::JumpUnlessBothNonNegativeSmi(Register src1,
Register src2, Register src2,
LabelType* on_not_both_smi) { LabelType* on_not_both_smi) {
Condition both_smi = CheckBothPositiveSmi(src1, src2); Condition both_smi = CheckBothNonNegativeSmi(src1, src2);
j(NegateCondition(both_smi), on_not_both_smi); j(NegateCondition(both_smi), on_not_both_smi);
} }
......
...@@ -519,40 +519,40 @@ TEST(SmiCheck) { ...@@ -519,40 +519,40 @@ TEST(SmiCheck) {
__ incq(rax); __ incq(rax);
__ movl(rcx, Immediate(0)); __ movl(rcx, Immediate(0));
__ Integer32ToSmi(rcx, rcx); __ Integer32ToSmi(rcx, rcx);
cond = masm->CheckPositiveSmi(rcx); // Zero counts as positive. cond = masm->CheckNonNegativeSmi(rcx);
__ j(NegateCondition(cond), &exit); __ j(NegateCondition(cond), &exit);
__ incq(rax); __ incq(rax);
__ xor_(rcx, Immediate(kSmiTagMask)); __ xor_(rcx, Immediate(kSmiTagMask));
cond = masm->CheckPositiveSmi(rcx); // "zero" non-smi. cond = masm->CheckNonNegativeSmi(rcx); // "zero" non-smi.
__ j(cond, &exit); __ j(cond, &exit);
__ incq(rax); __ incq(rax);
__ movq(rcx, Immediate(-1)); __ movq(rcx, Immediate(-1));
__ Integer32ToSmi(rcx, rcx); __ Integer32ToSmi(rcx, rcx);
cond = masm->CheckPositiveSmi(rcx); // Negative smis are not positive. cond = masm->CheckNonNegativeSmi(rcx); // Negative smis are not positive.
__ j(cond, &exit); __ j(cond, &exit);
__ incq(rax); __ incq(rax);
__ movq(rcx, Immediate(Smi::kMinValue)); __ movq(rcx, Immediate(Smi::kMinValue));
__ Integer32ToSmi(rcx, rcx); __ Integer32ToSmi(rcx, rcx);
cond = masm->CheckPositiveSmi(rcx); // Most negative smi is not positive. cond = masm->CheckNonNegativeSmi(rcx); // Most negative smi is not positive.
__ j(cond, &exit); __ j(cond, &exit);
__ incq(rax); __ incq(rax);
__ xor_(rcx, Immediate(kSmiTagMask)); __ xor_(rcx, Immediate(kSmiTagMask));
cond = masm->CheckPositiveSmi(rcx); // "Negative" non-smi. cond = masm->CheckNonNegativeSmi(rcx); // "Negative" non-smi.
__ j(cond, &exit); __ j(cond, &exit);
__ incq(rax); __ incq(rax);
__ movq(rcx, Immediate(Smi::kMaxValue)); __ movq(rcx, Immediate(Smi::kMaxValue));
__ Integer32ToSmi(rcx, rcx); __ Integer32ToSmi(rcx, rcx);
cond = masm->CheckPositiveSmi(rcx); // Most positive smi is positive. cond = masm->CheckNonNegativeSmi(rcx); // Most positive smi is positive.
__ j(NegateCondition(cond), &exit); __ j(NegateCondition(cond), &exit);
__ incq(rax); __ incq(rax);
__ xor_(rcx, Immediate(kSmiTagMask)); __ xor_(rcx, Immediate(kSmiTagMask));
cond = masm->CheckPositiveSmi(rcx); // "Positive" non-smi. cond = masm->CheckNonNegativeSmi(rcx); // "Positive" non-smi.
__ j(cond, &exit); __ j(cond, &exit);
// CheckIsMinSmi // CheckIsMinSmi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment