Chromium Code Reviews| Index: src/ia32/code-stubs-ia32.cc |
| diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc |
| index 90e3672a91d8315adb4074d3c2049c9dfa74a8fa..61a277cdc0216543b91dfb0c9801cd2f7e9acea9 100644 |
| --- a/src/ia32/code-stubs-ia32.cc |
| +++ b/src/ia32/code-stubs-ia32.cc |
| @@ -2265,6 +2265,157 @@ void CallIC_ArrayStub::Generate(MacroAssembler* masm) { |
| } |
| +void CallIC_RoundStub::Generate(MacroAssembler* masm) { |
| + Register function = edi; |
| + Register vector = ebx; |
| + Register slot = edx; |
| + |
| + Register temp = eax; |
| + XMMRegister xmm_temp1 = xmm0; |
| + XMMRegister xmm_temp2 = xmm1; |
| + Label tail, miss; |
| + |
| + // Ensure nobody has snuck in another function. |
| + __ BranchIfNotBuiltin(function, temp, kMathRound, &miss); |
| + |
| + if (arg_count() > 0) { |
| + ExternalReference minus_one_half = |
| + ExternalReference::address_of_minus_one_half(); |
| + |
| + __ mov(temp, Operand(esp, arg_count() * kPointerSize)); |
| + Handle<Map> map = isolate()->factory()->heap_number_map(); |
| + __ CheckMap(temp, map, &tail, DO_SMI_CHECK); |
| + |
| + // If the number is positive, it doesn't round to -0 |
| + __ movsd(xmm_temp1, FieldOperand(eax, HeapNumber::kValueOffset)); |
| + |
| + // If the number is >0, it doesn't round to -0 |
| + __ xorps(xmm_temp2, xmm_temp2); |
| + __ ucomisd(xmm_temp1, xmm_temp2); |
| + __ j(above, &tail, Label::kNear); |
| + |
| + // If the number is <-.5, it doesn't round to -0 |
| + __ movsd(xmm_temp2, Operand::StaticVariable(minus_one_half)); |
| + __ ucomisd(xmm_temp1, xmm_temp2); |
| + __ j(below, &tail, Label::kNear); |
| + |
| + // The only positive result remaining is 0, it doesn't round to -0.. |
| + __ movmskpd(temp, xmm_temp1); |
| + __ test(temp, Immediate(1)); |
| + __ j(zero, &tail, Label::kNear); |
| + |
| + __ mov(FieldOperand(vector, slot, times_half_pointer_size, |
| + FixedArray::kHeaderSize + kPointerSize), |
| + Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel))); |
| + } |
| + |
| + __ bind(&tail); |
| + CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
| + |
| + // Unreachable. |
| + __ int3(); |
| + |
| + __ bind(&miss); |
| + GenerateMiss(masm); |
| + __ jmp(&tail); |
| +} |
| + |
| + |
| +void CallIC_FloorStub::Generate(MacroAssembler* masm) { |
| + Register function = edi; |
| + Register vector = ebx; |
| + Register slot = edx; |
| + |
| + Register temp = eax; |
| + Label tail, miss; |
| + |
| + // Ensure nobody has snuck in another function. |
| + __ BranchIfNotBuiltin(function, temp, kMathFloor, &miss); |
| + |
| + if (arg_count() > 0) { |
| + __ mov(temp, Operand(esp, arg_count() * kPointerSize)); |
| + Handle<Map> map = isolate()->factory()->heap_number_map(); |
| + __ CheckMap(temp, map, &tail, DO_SMI_CHECK); |
| + |
| + // The only number that floors to -0 is -0. |
| + __ cmp(FieldOperand(temp, HeapNumber::kExponentOffset), |
| + Immediate(0x80000000)); |
| + __ j(not_equal, &tail); |
| + |
| + __ cmp(FieldOperand(temp, HeapNumber::kMantissaOffset), Immediate(0)); |
| + __ j(not_equal, &tail); |
| + |
| + __ mov(FieldOperand(vector, slot, times_half_pointer_size, |
| + FixedArray::kHeaderSize + kPointerSize), |
| + Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel))); |
| + } |
| + |
| + __ bind(&tail); |
| + CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
| + |
| + // Unreachable. |
| + __ int3(); |
| + |
| + __ bind(&miss); |
| + GenerateMiss(masm); |
| + __ jmp(&tail); |
| +} |
| + |
| + |
| +void CallIC_CeilStub::Generate(MacroAssembler* masm) { |
| + Register function = edi; |
| + Register vector = ebx; |
| + Register slot = edx; |
| + |
| + Register temp = eax; |
| + XMMRegister xmm_temp1 = xmm0; |
| + XMMRegister xmm_temp2 = xmm1; |
| + Label tail, miss; |
| + |
| + // Ensure nobody has snuck in another function. |
| + __ BranchIfNotBuiltin(function, temp, kMathCeil, &miss); |
| + |
| + if (arg_count() > 0) { |
| + ExternalReference minus_one = ExternalReference::address_of_minus_one(); |
| + |
| + __ mov(temp, Operand(esp, arg_count() * kPointerSize)); |
| + Handle<Map> map = isolate()->factory()->heap_number_map(); |
| + __ CheckMap(temp, map, &tail, DO_SMI_CHECK); |
| + |
| + __ movsd(xmm_temp1, FieldOperand(eax, HeapNumber::kValueOffset)); |
| + |
| + // If the number is >0, it doesn't round to -0 |
| + __ xorps(xmm_temp2, xmm_temp2); |
| + __ ucomisd(xmm_temp1, xmm_temp2); |
| + __ j(greater, &tail, Label::kNear); |
| + |
| + // If the number is <=-1, it doesn't round to -0 |
| + __ movsd(xmm_temp2, Operand::StaticVariable(minus_one)); |
| + __ ucomisd(xmm_temp1, xmm_temp2); |
| + __ j(less_equal, &tail, Label::kNear); |
| + |
| + // The only positive result remaining is 0, it doesn't round to -0.. |
| + __ movmskpd(temp, xmm_temp1); |
| + __ test(temp, Immediate(1)); |
| + __ j(zero, &tail, Label::kNear); |
| + |
| + __ mov(FieldOperand(vector, slot, times_half_pointer_size, |
| + FixedArray::kHeaderSize + kPointerSize), |
| + Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel))); |
| + } |
| + |
| + __ bind(&tail); |
| + CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
| + |
| + // Unreachable. |
| + __ int3(); |
| + |
| + __ bind(&miss); |
| + GenerateMiss(masm); |
| + __ jmp(&tail); |
| +} |
| + |
| + |
| void CallICStub::Generate(MacroAssembler* masm) { |
| // edi - function |
| // edx - slot id |
| @@ -2373,6 +2524,17 @@ void CallICStub::Generate(MacroAssembler* masm) { |
| __ cmp(edi, ecx); |
| __ j(equal, &miss); |
| + // Make sure that the function is not Math.floor, Math.round or Math.ceil |
| + // which have special CallICs to handle -0.0. |
| + __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| + __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); |
| + __ cmp(eax, Immediate(Smi::FromInt(kMathRound))); |
|
mvstanton
2015/05/04 09:41:22
Make this look like the other platforms, where you
danno
2015/05/04 14:31:56
Done.
|
| + __ j(equal, &miss); |
| + __ cmp(eax, Immediate(Smi::FromInt(kMathFloor))); |
| + __ j(equal, &miss); |
| + __ cmp(eax, Immediate(Smi::FromInt(kMathCeil))); |
| + __ j(equal, &miss); |
| + |
| // Update stats. |
| __ add(FieldOperand(ebx, with_types_offset), Immediate(Smi::FromInt(1))); |
| @@ -4648,6 +4810,27 @@ void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) { |
| } |
| +void CallIC_RoundTrampolineStub::Generate(MacroAssembler* masm) { |
| + EmitLoadTypeFeedbackVector(masm, ebx); |
| + CallIC_RoundStub stub(isolate(), state()); |
| + __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); |
| +} |
| + |
| + |
| +void CallIC_FloorTrampolineStub::Generate(MacroAssembler* masm) { |
| + EmitLoadTypeFeedbackVector(masm, ebx); |
| + CallIC_FloorStub stub(isolate(), state()); |
| + __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); |
| +} |
| + |
| + |
| +void CallIC_CeilTrampolineStub::Generate(MacroAssembler* masm) { |
| + EmitLoadTypeFeedbackVector(masm, ebx); |
| + CallIC_CeilStub stub(isolate(), state()); |
| + __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); |
| +} |
| + |
| + |
| void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { |
| if (masm->isolate()->function_entry_hook() != NULL) { |
| ProfileEntryHookStub stub(masm->isolate()); |