From f8b274eea8f8a0009b7075ffa1aa6b0027ef6b86 Mon Sep 17 00:00:00 2001 From: "antonm@chromium.org" Date: Thu, 30 Sep 2010 11:48:03 +0000 Subject: [PATCH] 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 --- src/x64/builtins-x64.cc | 2 +- src/x64/code-stubs-x64.cc | 2 +- src/x64/codegen-x64.cc | 14 ++++++-------- src/x64/full-codegen-x64.cc | 8 ++++---- src/x64/ic-x64.cc | 2 +- src/x64/macro-assembler-x64.cc | 10 +++++----- src/x64/macro-assembler-x64.h | 34 ++++++++++++++++----------------- test/cctest/test-macro-assembler-x64.cc | 14 +++++++------- 8 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc index 08c19ba..0dead6b 100644 --- a/src/x64/builtins-x64.cc +++ b/src/x64/builtins-x64.cc @@ -715,7 +715,7 @@ static void ArrayNativeCode(MacroAssembler* masm, __ cmpq(rax, Immediate(1)); __ j(not_equal, &argc_two_or_more); __ 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 // is to large to actually allocate an elements array. diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 9d82e0e..b050ec8 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -3801,7 +3801,7 @@ void SubStringStub::Generate(MacroAssembler* masm) { Label result_longer_than_two; __ movq(rcx, Operand(rsp, kToOffset)); __ movq(rdx, Operand(rsp, kFromOffset)); - __ JumpIfNotBothPositiveSmi(rcx, rdx, &runtime); + __ JumpUnlessBothNonNegativeSmi(rcx, rdx, &runtime); __ SmiSub(rcx, rcx, rdx); // Overflow doesn't happen. __ cmpq(FieldOperand(rax, String::kLengthOffset), rcx); diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index 0d8b827..ea5a881 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -1884,8 +1884,7 @@ Result CodeGenerator::ConstantSmiBinaryOperation(BinaryOperation* expr, operand->reg(), smi_value, overwrite_mode); - // Check for negative or non-Smi left hand side. - __ JumpIfNotPositiveSmi(operand->reg(), deferred->entry_label()); + __ JumpUnlessNonNegativeSmi(operand->reg(), deferred->entry_label()); if (int_value < 0) int_value = -int_value; if (int_value == 1) { __ Move(operand->reg(), Smi::FromInt(0)); @@ -5684,9 +5683,9 @@ void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList* args) { Result value = frame_->Pop(); value.ToRegister(); ASSERT(value.is_valid()); - Condition positive_smi = masm_->CheckPositiveSmi(value.reg()); + Condition non_negative_smi = masm_->CheckNonNegativeSmi(value.reg()); value.Unuse(); - destination()->Split(positive_smi); + destination()->Split(non_negative_smi); } @@ -6911,7 +6910,7 @@ void CodeGenerator::GenerateSwapElements(ZoneList* args) { deferred->Branch(not_equal); // 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)); // Bring addresses into index1 and index2. @@ -8377,7 +8376,7 @@ Result CodeGenerator::EmitNamedStore(Handle name, bool is_contextual) { } // 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); // This is the map check instruction that will be patched. @@ -8506,8 +8505,7 @@ Result CodeGenerator::EmitKeyedLoad() { kScratchRegister); deferred->Branch(not_equal); - // Check that the key is a non-negative smi. - __ JumpIfNotPositiveSmi(key.reg(), deferred->entry_label()); + __ JumpUnlessNonNegativeSmi(key.reg(), deferred->entry_label()); // Get the elements array from the receiver. __ movq(elements.reg(), diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index c15860c..2256100 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -767,7 +767,7 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { // Get the current entry of the array into register rbx. __ movq(rbx, Operand(rsp, 2 * kPointerSize)); - SmiIndex index = __ SmiToIndex(rax, rax, kPointerSizeLog2); + SmiIndex index = masm()->SmiToIndex(rax, rax, kPointerSizeLog2); __ movq(rbx, FieldOperand(rbx, index.reg, index.scale, @@ -1407,7 +1407,7 @@ void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr, Label done, stub_call, smi_case; __ pop(rdx); __ movq(rcx, rax); - Condition smi = __ CheckBothSmi(rdx, rax); + Condition smi = masm()->CheckBothSmi(rdx, rax); __ j(smi, &smi_case); __ bind(&stub_call); @@ -1965,8 +1965,8 @@ void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList* args) { context()->PrepareTest(&materialize_true, &materialize_false, &if_true, &if_false, &fall_through); - Condition positive_smi = __ CheckPositiveSmi(rax); - Split(positive_smi, if_true, if_false, fall_through); + Condition non_negative_smi = masm()->CheckNonNegativeSmi(rax); + Split(non_negative_smi, if_true, if_false, fall_through); context()->Plug(if_true, if_false); } diff --git a/src/x64/ic-x64.cc b/src/x64/ic-x64.cc index 814da76..a76ba46 100644 --- a/src/x64/ic-x64.cc +++ b/src/x64/ic-x64.cc @@ -895,7 +895,7 @@ void KeyedLoadIC::GenerateIndexedInterceptor(MacroAssembler* masm) { // Check that the key is an array index, that is Uint32. STATIC_ASSERT(kSmiValueSize <= 32); - __ JumpIfNotPositiveSmi(rax, &slow); + __ JumpUnlessNonNegativeSmi(rax, &slow); // Get the map of the receiver. __ movq(rcx, FieldOperand(rdx, HeapObject::kMapOffset)); diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 869986e..2c946f5 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -825,7 +825,7 @@ Condition MacroAssembler::CheckSmi(Register src) { } -Condition MacroAssembler::CheckPositiveSmi(Register src) { +Condition MacroAssembler::CheckNonNegativeSmi(Register src) { ASSERT_EQ(0, kSmiTag); // Make mask 0x8000000000000001 and test that both bits are zero. movq(kScratchRegister, src); @@ -846,15 +846,15 @@ Condition MacroAssembler::CheckBothSmi(Register first, Register second) { } -Condition MacroAssembler::CheckBothPositiveSmi(Register first, - Register second) { +Condition MacroAssembler::CheckBothNonNegativeSmi(Register first, + Register second) { if (first.is(second)) { - return CheckPositiveSmi(first); + return CheckNonNegativeSmi(first); } movq(kScratchRegister, first); or_(kScratchRegister, second); rol(kScratchRegister, Immediate(1)); - testl(kScratchRegister, Immediate(0x03)); + testl(kScratchRegister, Immediate(3)); return zero; } diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index a8ffca9..1bd3443 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -265,14 +265,14 @@ class MacroAssembler: public Assembler { // Is the value a tagged smi. Condition CheckSmi(Register src); - // Is the value a positive tagged smi. - Condition CheckPositiveSmi(Register src); + // Is the value a non-negative tagged smi. + Condition CheckNonNegativeSmi(Register src); // Are both values tagged smis. Condition CheckBothSmi(Register first, Register second); - // Are both values tagged smis. - Condition CheckBothPositiveSmi(Register first, Register second); + // Are both values non-negative tagged smis. + Condition CheckBothNonNegativeSmi(Register first, Register second); // Are either value a tagged smi. Condition CheckEitherSmi(Register first, @@ -311,9 +311,9 @@ class MacroAssembler: public Assembler { template 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 - 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 // to the constant. @@ -328,10 +328,10 @@ class MacroAssembler: public Assembler { Register src2, 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 - void JumpIfNotBothPositiveSmi(Register src1, Register src2, - LabelType* on_not_both_smi); + void JumpUnlessBothNonNegativeSmi(Register src1, Register src2, + LabelType* on_not_both_smi); // Operations on tagged smi values. @@ -1463,10 +1463,10 @@ void MacroAssembler::JumpIfNotSmi(Register src, LabelType* on_not_smi) { template -void MacroAssembler::JumpIfNotPositiveSmi(Register src, - LabelType* on_not_positive_smi) { - Condition positive_smi = CheckPositiveSmi(src); - j(NegateCondition(positive_smi), on_not_positive_smi); +void MacroAssembler::JumpUnlessNonNegativeSmi( + Register src, LabelType* on_not_smi_or_negative) { + Condition non_negative_smi = CheckNonNegativeSmi(src); + j(NegateCondition(non_negative_smi), on_not_smi_or_negative); } @@ -1505,10 +1505,10 @@ void MacroAssembler::JumpIfNotBothSmi(Register src1, template -void MacroAssembler::JumpIfNotBothPositiveSmi(Register src1, - Register src2, - LabelType* on_not_both_smi) { - Condition both_smi = CheckBothPositiveSmi(src1, src2); +void MacroAssembler::JumpUnlessBothNonNegativeSmi(Register src1, + Register src2, + LabelType* on_not_both_smi) { + Condition both_smi = CheckBothNonNegativeSmi(src1, src2); j(NegateCondition(both_smi), on_not_both_smi); } diff --git a/test/cctest/test-macro-assembler-x64.cc b/test/cctest/test-macro-assembler-x64.cc index 3d2b91b..9b1fc46 100755 --- a/test/cctest/test-macro-assembler-x64.cc +++ b/test/cctest/test-macro-assembler-x64.cc @@ -519,40 +519,40 @@ TEST(SmiCheck) { __ incq(rax); __ movl(rcx, Immediate(0)); __ Integer32ToSmi(rcx, rcx); - cond = masm->CheckPositiveSmi(rcx); // Zero counts as positive. + cond = masm->CheckNonNegativeSmi(rcx); __ j(NegateCondition(cond), &exit); __ incq(rax); __ xor_(rcx, Immediate(kSmiTagMask)); - cond = masm->CheckPositiveSmi(rcx); // "zero" non-smi. + cond = masm->CheckNonNegativeSmi(rcx); // "zero" non-smi. __ j(cond, &exit); __ incq(rax); __ movq(rcx, Immediate(-1)); __ Integer32ToSmi(rcx, rcx); - cond = masm->CheckPositiveSmi(rcx); // Negative smis are not positive. + cond = masm->CheckNonNegativeSmi(rcx); // Negative smis are not positive. __ j(cond, &exit); __ incq(rax); __ movq(rcx, Immediate(Smi::kMinValue)); __ 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); __ incq(rax); __ xor_(rcx, Immediate(kSmiTagMask)); - cond = masm->CheckPositiveSmi(rcx); // "Negative" non-smi. + cond = masm->CheckNonNegativeSmi(rcx); // "Negative" non-smi. __ j(cond, &exit); __ incq(rax); __ movq(rcx, Immediate(Smi::kMaxValue)); __ 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); __ incq(rax); __ xor_(rcx, Immediate(kSmiTagMask)); - cond = masm->CheckPositiveSmi(rcx); // "Positive" non-smi. + cond = masm->CheckNonNegativeSmi(rcx); // "Positive" non-smi. __ j(cond, &exit); // CheckIsMinSmi -- 2.7.4