Fixing style issues in codegen-ia32.*
See Kevin's comments for http://codereview.chromium.org/554062. Review URL: http://codereview.chromium.org/543193 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3695 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
e138669a1f
commit
921540510c
@ -741,14 +741,14 @@ void CodeGenerator::ToBoolean(ControlDestination* dest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
enum ArgLocation {
|
|
||||||
ARGS_ON_STACK,
|
|
||||||
ARGS_IN_REGISTERS
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class FloatingPointHelper : public AllStatic {
|
class FloatingPointHelper : public AllStatic {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum ArgLocation {
|
||||||
|
ARGS_ON_STACK,
|
||||||
|
ARGS_IN_REGISTERS
|
||||||
|
};
|
||||||
|
|
||||||
// Code pattern for loading a floating point value. Input value must
|
// Code pattern for loading a floating point value. Input value must
|
||||||
// be either a smi or a heap number object (fp value). Requirements:
|
// be either a smi or a heap number object (fp value). Requirements:
|
||||||
// operand in register number. Returns operand as floating point number
|
// operand in register number. Returns operand as floating point number
|
||||||
@ -7077,7 +7077,7 @@ void GenericBinaryOpStub::GenerateCall(
|
|||||||
|
|
||||||
|
|
||||||
void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) {
|
void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) {
|
||||||
if (HasArgumentsInRegisters()) {
|
if (HasArgsInRegisters()) {
|
||||||
__ mov(ebx, eax);
|
__ mov(ebx, eax);
|
||||||
__ mov(eax, edx);
|
__ mov(eax, edx);
|
||||||
} else {
|
} else {
|
||||||
@ -7249,16 +7249,18 @@ void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) {
|
|||||||
case Token::DIV: {
|
case Token::DIV: {
|
||||||
Label after_alloc_failure;
|
Label after_alloc_failure;
|
||||||
|
|
||||||
ArgLocation arg_location =
|
FloatingPointHelper::ArgLocation arg_location =
|
||||||
(op_ == Token::ADD || op_ == Token::SUB) ?
|
(op_ == Token::ADD || op_ == Token::SUB) ?
|
||||||
ARGS_IN_REGISTERS :
|
FloatingPointHelper::ARGS_IN_REGISTERS :
|
||||||
ARGS_ON_STACK;
|
FloatingPointHelper::ARGS_ON_STACK;
|
||||||
|
|
||||||
__ AllocateHeapNumber(
|
__ AllocateHeapNumber(
|
||||||
edx,
|
edx,
|
||||||
ecx,
|
ecx,
|
||||||
no_reg,
|
no_reg,
|
||||||
arg_location == ARGS_IN_REGISTERS ? &after_alloc_failure : slow);
|
arg_location == FloatingPointHelper::ARGS_IN_REGISTERS ?
|
||||||
|
&after_alloc_failure :
|
||||||
|
slow);
|
||||||
|
|
||||||
if (CpuFeatures::IsSupported(SSE2)) {
|
if (CpuFeatures::IsSupported(SSE2)) {
|
||||||
CpuFeatures::Scope use_sse2(SSE2);
|
CpuFeatures::Scope use_sse2(SSE2);
|
||||||
@ -7285,13 +7287,15 @@ void GenericBinaryOpStub::GenerateSmiCode(MacroAssembler* masm, Label* slow) {
|
|||||||
__ mov(eax, edx);
|
__ mov(eax, edx);
|
||||||
GenerateReturn(masm);
|
GenerateReturn(masm);
|
||||||
|
|
||||||
if (arg_location == ARGS_IN_REGISTERS) {
|
if (arg_location == FloatingPointHelper::ARGS_IN_REGISTERS) {
|
||||||
__ bind(&after_alloc_failure);
|
__ bind(&after_alloc_failure);
|
||||||
__ mov(edx, eax);
|
__ mov(edx, eax);
|
||||||
__ mov(eax, ebx);
|
__ mov(eax, ebx);
|
||||||
__ jmp(slow);
|
__ jmp(slow);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Token::BIT_OR:
|
case Token::BIT_OR:
|
||||||
case Token::BIT_AND:
|
case Token::BIT_AND:
|
||||||
case Token::BIT_XOR:
|
case Token::BIT_XOR:
|
||||||
@ -7375,7 +7379,10 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) {
|
|||||||
GenerateReturn(masm);
|
GenerateReturn(masm);
|
||||||
} else { // SSE2 not available, use FPU.
|
} else { // SSE2 not available, use FPU.
|
||||||
FloatingPointHelper::CheckFloatOperands(masm, &call_runtime, ebx);
|
FloatingPointHelper::CheckFloatOperands(masm, &call_runtime, ebx);
|
||||||
FloatingPointHelper::LoadFloatOperands(masm, ecx, ARGS_IN_REGISTERS);
|
FloatingPointHelper::LoadFloatOperands(
|
||||||
|
masm,
|
||||||
|
ecx,
|
||||||
|
FloatingPointHelper::ARGS_IN_REGISTERS);
|
||||||
switch (op_) {
|
switch (op_) {
|
||||||
case Token::ADD: __ faddp(1); break;
|
case Token::ADD: __ faddp(1); break;
|
||||||
case Token::SUB: __ fsubp(1); break;
|
case Token::SUB: __ fsubp(1); break;
|
||||||
@ -7469,9 +7476,9 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) {
|
|||||||
// result. If arguments was passed in registers now place them on the
|
// result. If arguments was passed in registers now place them on the
|
||||||
// stack in the correct order below the return address.
|
// stack in the correct order below the return address.
|
||||||
__ bind(&call_runtime);
|
__ bind(&call_runtime);
|
||||||
if (HasArgumentsInRegisters()) {
|
if (HasArgsInRegisters()) {
|
||||||
__ pop(ecx);
|
__ pop(ecx);
|
||||||
if (HasArgumentsReversed()) {
|
if (HasArgsReversed()) {
|
||||||
__ push(eax);
|
__ push(eax);
|
||||||
__ push(edx);
|
__ push(edx);
|
||||||
} else {
|
} else {
|
||||||
@ -7503,10 +7510,10 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) {
|
|||||||
// Only first argument is a string.
|
// Only first argument is a string.
|
||||||
__ bind(&string1);
|
__ bind(&string1);
|
||||||
__ InvokeBuiltin(
|
__ InvokeBuiltin(
|
||||||
HasArgumentsReversed() ?
|
HasArgsReversed() ?
|
||||||
Builtins::STRING_ADD_RIGHT :
|
Builtins::STRING_ADD_RIGHT :
|
||||||
Builtins::STRING_ADD_LEFT,
|
Builtins::STRING_ADD_LEFT,
|
||||||
JUMP_FUNCTION);
|
JUMP_FUNCTION);
|
||||||
|
|
||||||
// First argument was not a string, test second.
|
// First argument was not a string, test second.
|
||||||
__ bind(¬_string1);
|
__ bind(¬_string1);
|
||||||
@ -7517,10 +7524,10 @@ void GenericBinaryOpStub::Generate(MacroAssembler* masm) {
|
|||||||
|
|
||||||
// Only second argument is a string.
|
// Only second argument is a string.
|
||||||
__ InvokeBuiltin(
|
__ InvokeBuiltin(
|
||||||
HasArgumentsReversed() ?
|
HasArgsReversed() ?
|
||||||
Builtins::STRING_ADD_LEFT :
|
Builtins::STRING_ADD_LEFT :
|
||||||
Builtins::STRING_ADD_RIGHT,
|
Builtins::STRING_ADD_RIGHT,
|
||||||
JUMP_FUNCTION);
|
JUMP_FUNCTION);
|
||||||
|
|
||||||
__ bind(¬_strings);
|
__ bind(¬_strings);
|
||||||
// Neither argument is a string.
|
// Neither argument is a string.
|
||||||
@ -7567,7 +7574,7 @@ void GenericBinaryOpStub::GenerateHeapResultAllocation(MacroAssembler* masm,
|
|||||||
Label* alloc_failure) {
|
Label* alloc_failure) {
|
||||||
Label skip_allocation;
|
Label skip_allocation;
|
||||||
OverwriteMode mode = mode_;
|
OverwriteMode mode = mode_;
|
||||||
if (HasArgumentsReversed()) {
|
if (HasArgsReversed()) {
|
||||||
if (mode == OVERWRITE_RIGHT) {
|
if (mode == OVERWRITE_RIGHT) {
|
||||||
mode = OVERWRITE_LEFT;
|
mode = OVERWRITE_LEFT;
|
||||||
} else if (mode == OVERWRITE_LEFT) {
|
} else if (mode == OVERWRITE_LEFT) {
|
||||||
@ -7613,7 +7620,7 @@ void GenericBinaryOpStub::GenerateHeapResultAllocation(MacroAssembler* masm,
|
|||||||
|
|
||||||
void GenericBinaryOpStub::GenerateLoadArguments(MacroAssembler* masm) {
|
void GenericBinaryOpStub::GenerateLoadArguments(MacroAssembler* masm) {
|
||||||
// If arguments are not passed in registers read them from the stack.
|
// If arguments are not passed in registers read them from the stack.
|
||||||
if (!HasArgumentsInRegisters()) {
|
if (!HasArgsInRegisters()) {
|
||||||
__ mov(eax, Operand(esp, 1 * kPointerSize));
|
__ mov(eax, Operand(esp, 1 * kPointerSize));
|
||||||
__ mov(edx, Operand(esp, 2 * kPointerSize));
|
__ mov(edx, Operand(esp, 2 * kPointerSize));
|
||||||
}
|
}
|
||||||
@ -7623,7 +7630,7 @@ void GenericBinaryOpStub::GenerateLoadArguments(MacroAssembler* masm) {
|
|||||||
void GenericBinaryOpStub::GenerateReturn(MacroAssembler* masm) {
|
void GenericBinaryOpStub::GenerateReturn(MacroAssembler* masm) {
|
||||||
// If arguments are not passed in registers remove them from the stack before
|
// If arguments are not passed in registers remove them from the stack before
|
||||||
// returning.
|
// returning.
|
||||||
if (!HasArgumentsInRegisters()) {
|
if (!HasArgsInRegisters()) {
|
||||||
__ ret(2 * kPointerSize); // Remove both operands
|
__ ret(2 * kPointerSize); // Remove both operands
|
||||||
} else {
|
} else {
|
||||||
__ ret(0);
|
__ ret(0);
|
||||||
|
@ -704,9 +704,11 @@ class GenericBinaryOpStub: public CodeStub {
|
|||||||
// are also OK. Though MUL and DIV on SMIs modify the original registers so
|
// are also OK. Though MUL and DIV on SMIs modify the original registers so
|
||||||
// we need to push args on stack anyway.
|
// we need to push args on stack anyway.
|
||||||
bool ArgsInRegistersSupported() {
|
bool ArgsInRegistersSupported() {
|
||||||
return ((op_ == Token::ADD) || (op_ == Token::SUB)) ||
|
if (op_ == Token::ADD || op_ == Token::SUB) return true;
|
||||||
(((op_ == Token::MUL) || (op_ == Token::DIV))
|
if (op_ == Token::MUL || op_ == Token::DIV) {
|
||||||
&& (flags_ == NO_SMI_CODE_IN_STUB));
|
return flags_ == NO_SMI_CODE_IN_STUB;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
bool IsOperationCommutative() {
|
bool IsOperationCommutative() {
|
||||||
return (op_ == Token::ADD) || (op_ == Token::MUL);
|
return (op_ == Token::ADD) || (op_ == Token::MUL);
|
||||||
@ -715,8 +717,8 @@ class GenericBinaryOpStub: public CodeStub {
|
|||||||
void SetArgsInRegisters() { args_in_registers_ = true; }
|
void SetArgsInRegisters() { args_in_registers_ = true; }
|
||||||
void SetArgsReversed() { args_reversed_ = true; }
|
void SetArgsReversed() { args_reversed_ = true; }
|
||||||
bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; }
|
bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; }
|
||||||
bool HasArgumentsInRegisters() { return args_in_registers_; }
|
bool HasArgsInRegisters() { return args_in_registers_; }
|
||||||
bool HasArgumentsReversed() { return args_reversed_; }
|
bool HasArgsReversed() { return args_reversed_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user