From 04bf6c5c61b4700c5b6f39dc3c737b483d0f0c0b Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Mon, 3 Jan 2011 11:39:22 +0000 Subject: [PATCH] Use the macro assembler Set instead of explicit xor for clearing registers. Review URL: http://codereview.chromium.org/6015011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6135 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ia32/builtins-ia32.cc | 8 ++++---- src/ia32/code-stubs-ia32.cc | 10 +++++----- src/ia32/debug-ia32.cc | 2 +- src/ia32/ic-ia32.cc | 2 +- src/ia32/regexp-macro-assembler-ia32.cc | 2 +- src/x64/assembler-x64.cc | 2 +- src/x64/builtins-x64.cc | 10 +++++----- src/x64/code-stubs-x64.cc | 8 ++++---- src/x64/debug-x64.cc | 2 +- src/x64/full-codegen-x64.cc | 2 +- src/x64/macro-assembler-x64.cc | 4 ++-- src/x64/macro-assembler-x64.h | 2 +- src/x64/regexp-macro-assembler-x64.cc | 2 +- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc index 918f346d89..0a3e093056 100644 --- a/src/ia32/builtins-ia32.cc +++ b/src/ia32/builtins-ia32.cc @@ -399,7 +399,7 @@ void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, bool is_construct) { // Clear the context before we push it when entering the JS frame. - __ xor_(esi, Operand(esi)); // clear esi + __ Set(esi, Immediate(0)); // Enter an internal frame. __ EnterInternalFrame(); @@ -421,7 +421,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, // Copy arguments to the stack in a loop. Label loop, entry; - __ xor_(ecx, Operand(ecx)); // clear ecx + __ Set(ecx, Immediate(0)); __ jmp(&entry); __ bind(&loop); __ mov(edx, Operand(ebx, ecx, times_4, 0)); // push parameter from argv @@ -644,7 +644,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ bind(&non_function); __ mov(Operand(esp, eax, times_4, 0), edi); // Clear edi to indicate a non-function being called. - __ xor_(edi, Operand(edi)); + __ Set(edi, Immediate(0)); // 4. Shift arguments and return address one slot down on the stack // (overwriting the original receiver). Adjust argument count to make @@ -665,7 +665,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { { Label function; __ test(edi, Operand(edi)); __ j(not_zero, &function, taken); - __ xor_(ebx, Operand(ebx)); + __ Set(ebx, Immediate(0)); __ GetBuiltinEntry(edx, Builtins::CALL_NON_FUNCTION); __ jmp(Handle(builtin(ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index a371c96393..bd95c8d0ba 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -104,7 +104,7 @@ void FastNewContextStub::Generate(MacroAssembler* masm) { Immediate(Smi::FromInt(length))); // Setup the fixed slots. - __ xor_(ebx, Operand(ebx)); // Set to NULL. + __ Set(ebx, Immediate(0)); // Set to NULL. __ mov(Operand(eax, Context::SlotOffset(Context::CLOSURE_INDEX)), ecx); __ mov(Operand(eax, Context::SlotOffset(Context::FCONTEXT_INDEX)), eax); __ mov(Operand(eax, Context::SlotOffset(Context::PREVIOUS_INDEX)), ebx); @@ -4303,7 +4303,7 @@ void CompareStub::Generate(MacroAssembler* masm) { // that contains the exponent and high bit of the mantissa. STATIC_ASSERT(((kQuietNaNHighBitsMask << 1) & 0x80000000u) != 0); __ mov(edx, FieldOperand(edx, HeapNumber::kExponentOffset)); - __ xor_(eax, Operand(eax)); + __ Set(eax, Immediate(0)); // Shift value and mask so kQuietNaNHighBitsMask applies to topmost // bits. __ add(edx, Operand(edx)); @@ -4433,7 +4433,7 @@ void CompareStub::Generate(MacroAssembler* masm) { __ j(below, &below_label, not_taken); __ j(above, &above_label, not_taken); - __ xor_(eax, Operand(eax)); + __ Set(eax, Immediate(0)); __ ret(0); __ bind(&below_label); @@ -4646,7 +4646,7 @@ void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { // Before returning we restore the context from the frame pointer if // not NULL. The frame pointer is NULL in the exception handler of // a JS entry frame. - __ xor_(esi, Operand(esi)); // Tentatively set context pointer to NULL. + __ Set(esi, Immediate(0)); // Tentatively set context pointer to NULL. NearLabel skip; __ cmp(ebp, 0); __ j(equal, &skip, not_taken); @@ -4799,7 +4799,7 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, } // Clear the context pointer. - __ xor_(esi, Operand(esi)); + __ Set(esi, Immediate(0)); // Restore fp from handler and discard handler state. STATIC_ASSERT(StackHandlerConstants::kFPOffset == 1 * kPointerSize); diff --git a/src/ia32/debug-ia32.cc b/src/ia32/debug-ia32.cc index ee9456564c..678cc93115 100644 --- a/src/ia32/debug-ia32.cc +++ b/src/ia32/debug-ia32.cc @@ -125,7 +125,7 @@ static void Generate_DebugBreakCallHelper(MacroAssembler* masm, #ifdef DEBUG __ RecordComment("// Calling from debug break to runtime - come in - over"); #endif - __ Set(eax, Immediate(0)); // no arguments + __ Set(eax, Immediate(0)); // No arguments. __ mov(ebx, Immediate(ExternalReference::debug_break())); CEntryStub ceb(1); diff --git a/src/ia32/ic-ia32.cc b/src/ia32/ic-ia32.cc index 9c9304d5a4..f46b97b47f 100644 --- a/src/ia32/ic-ia32.cc +++ b/src/ia32/ic-ia32.cc @@ -1199,7 +1199,7 @@ void KeyedStoreIC::GenerateExternalArray(MacroAssembler* masm, break; case kExternalShortArray: case kExternalUnsignedShortArray: - __ xor_(ecx, Operand(ecx)); + __ Set(ecx, Immediate(0)); __ mov_w(Operand(edi, ebx, times_2, 0), ecx); break; case kExternalIntArray: diff --git a/src/ia32/regexp-macro-assembler-ia32.cc b/src/ia32/regexp-macro-assembler-ia32.cc index cc2f30dc12..1213448841 100644 --- a/src/ia32/regexp-macro-assembler-ia32.cc +++ b/src/ia32/regexp-macro-assembler-ia32.cc @@ -652,7 +652,7 @@ bool RegExpMacroAssemblerIA32::CheckSpecialCharacterClass(uc16 type, void RegExpMacroAssemblerIA32::Fail() { ASSERT(FAILURE == 0); // Return value for failure is zero. - __ xor_(eax, Operand(eax)); // zero eax. + __ Set(eax, Immediate(0)); __ jmp(&exit_label_); } diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index 8f15f23ba7..36299677df 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -74,7 +74,7 @@ void CpuFeatures::Probe(bool portable) { __ xor_(rax, rdx); // Different if CPUID is supported. __ j(not_zero, &cpuid); - // CPUID not supported. Clear the supported features in edx:eax. + // CPUID not supported. Clear the supported features in rax. __ xor_(rax, rax); __ jmp(&done); diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc index 456d0765b9..d738261a1b 100644 --- a/src/x64/builtins-x64.cc +++ b/src/x64/builtins-x64.cc @@ -422,7 +422,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, // [rsp+0x20] : argv // Clear the context before we push it when entering the JS frame. - __ xor_(rsi, rsi); + __ Set(rsi, 0); __ EnterInternalFrame(); // Load the function context into rsi. @@ -451,7 +451,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, // rdi : function // Clear the context before we push it when entering the JS frame. - __ xor_(rsi, rsi); + __ Set(rsi, 0); // Enter an internal frame. __ EnterInternalFrame(); @@ -479,7 +479,7 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, // Register rbx points to array of pointers to handle locations. // Push the values of these handles. Label loop, entry; - __ xor_(rcx, rcx); // Set loop variable to 0. + __ Set(rcx, 0); // Set loop variable to 0. __ jmp(&entry); __ bind(&loop); __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); @@ -668,7 +668,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // become the receiver. __ bind(&non_function); __ movq(Operand(rsp, rax, times_pointer_size, 0), rdi); - __ xor_(rdi, rdi); + __ Set(rdi, 0); // 4. Shift arguments and return address one slot down on the stack // (overwriting the original receiver). Adjust argument count to make @@ -689,7 +689,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { { Label function; __ testq(rdi, rdi); __ j(not_zero, &function); - __ xor_(rbx, rbx); + __ Set(rbx, 0); __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); __ Jump(Handle(builtin(ArgumentsAdaptorTrampoline)), RelocInfo::CODE_TARGET); diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index c3eb5bf440..60ec35d06e 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -104,7 +104,7 @@ void FastNewContextStub::Generate(MacroAssembler* masm) { __ Move(FieldOperand(rax, FixedArray::kLengthOffset), Smi::FromInt(length)); // Setup the fixed slots. - __ xor_(rbx, rbx); // Set to NULL. + __ Set(rbx, 0); // Set to NULL. __ movq(Operand(rax, Context::SlotOffset(Context::CLOSURE_INDEX)), rcx); __ movq(Operand(rax, Context::SlotOffset(Context::FCONTEXT_INDEX)), rax); __ movq(Operand(rax, Context::SlotOffset(Context::PREVIOUS_INDEX)), rbx); @@ -250,7 +250,7 @@ void ToBooleanStub::Generate(MacroAssembler* masm) { __ movq(rax, Immediate(1)); __ ret(1 * kPointerSize); __ bind(&false_result); - __ xor_(rax, rax); + __ Set(rax, 0); __ ret(1 * kPointerSize); } @@ -2572,7 +2572,7 @@ void CEntryStub::GenerateThrowTOS(MacroAssembler* masm) { // Before returning we restore the context from the frame pointer if not NULL. // The frame pointer is NULL in the exception handler of a JS entry frame. - __ xor_(rsi, rsi); // tentatively set context pointer to NULL + __ Set(rsi, 0); // Tentatively set context pointer to NULL NearLabel skip; __ cmpq(rbp, Immediate(0)); __ j(equal, &skip); @@ -2756,7 +2756,7 @@ void CEntryStub::GenerateThrowUncatchable(MacroAssembler* masm, } // Clear the context pointer. - __ xor_(rsi, rsi); + __ Set(rsi, 0); // Restore registers from handler. STATIC_ASSERT(StackHandlerConstants::kNextOffset + kPointerSize == diff --git a/src/x64/debug-x64.cc b/src/x64/debug-x64.cc index 2c1056f579..94a29f2249 100644 --- a/src/x64/debug-x64.cc +++ b/src/x64/debug-x64.cc @@ -80,7 +80,7 @@ static void Generate_DebugBreakCallHelper(MacroAssembler* masm, #ifdef DEBUG __ RecordComment("// Calling from debug break to runtime - come in - over"); #endif - __ xor_(rax, rax); // No arguments (argc == 0). + __ Set(rax, 0); // No arguments (argc == 0). __ movq(rbx, ExternalReference::debug_break()); CEntryStub ceb(1); diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index dd28d4d8c1..66bc4ede96 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -199,7 +199,7 @@ void FullCodeGenerator::Generate(CompilationInfo* info) { void FullCodeGenerator::ClearAccumulator() { - __ xor_(rax, rax); + __ Set(rax, 0); } diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 1df9b4750c..70a3dab6d2 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -1110,7 +1110,7 @@ void MacroAssembler::SmiAnd(Register dst, Register src1, Register src2) { void MacroAssembler::SmiAndConstant(Register dst, Register src, Smi* constant) { if (constant->value() == 0) { - xor_(dst, dst); + Set(dst, 0); } else if (dst.is(src)) { ASSERT(!dst.is(kScratchRegister)); Register constant_reg = GetSmiConstant(constant); @@ -1605,7 +1605,7 @@ void MacroAssembler::DecrementCounter(StatsCounter* counter, int value) { #ifdef ENABLE_DEBUGGER_SUPPORT void MacroAssembler::DebugBreak() { ASSERT(allow_stub_calls()); - xor_(rax, rax); // no arguments + Set(rax, 0); // No arguments. movq(rbx, ExternalReference(Runtime::kDebugBreak)); CEntryStub ces(1); Call(ces.GetCode(), RelocInfo::DEBUG_BREAK); diff --git a/src/x64/macro-assembler-x64.h b/src/x64/macro-assembler-x64.h index d8f2fba42a..30b9ba5152 100644 --- a/src/x64/macro-assembler-x64.h +++ b/src/x64/macro-assembler-x64.h @@ -1176,7 +1176,7 @@ void MacroAssembler::SmiMul(Register dst, jmp(on_not_smi_result); bind(&zero_correct_result); - xor_(dst, dst); + Set(dst, 0); bind(&correct_result); } else { diff --git a/src/x64/regexp-macro-assembler-x64.cc b/src/x64/regexp-macro-assembler-x64.cc index 0838ddd461..27f3482a9a 100644 --- a/src/x64/regexp-macro-assembler-x64.cc +++ b/src/x64/regexp-macro-assembler-x64.cc @@ -688,7 +688,7 @@ bool RegExpMacroAssemblerX64::CheckSpecialCharacterClass(uc16 type, void RegExpMacroAssemblerX64::Fail() { ASSERT(FAILURE == 0); // Return value for failure is zero. - __ xor_(rax, rax); // zero rax. + __ Set(rax, 0); __ jmp(&exit_label_); }