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..7681c211b12e58b5418b446fd364737ea63c1c61 100644 |
--- a/src/ia32/code-stubs-ia32.cc |
+++ b/src/ia32/code-stubs-ia32.cc |
@@ -2265,6 +2265,163 @@ void CallIC_ArrayStub::Generate(MacroAssembler* masm) { |
} |
+void CallIC_RoundStub::Generate(MacroAssembler* masm) { |
+ // edi - function |
+ // edx - slot id |
+ // ebx - vector |
+ |
+ Label slow, miss; |
+ |
+ // Ensure nobody has snuck in another function. |
+ __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
+ __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); |
+ __ cmp(eax, Immediate(Smi::FromInt(kMathRound))); |
+ __ j(not_equal, &miss); |
+ |
+ if (arg_count() > 0) { |
+ Register output_reg = eax; |
+ XMMRegister input_reg = xmm1; |
+ XMMRegister xmm_scratch = xmm0; |
+ ExternalReference minus_one_half = |
+ ExternalReference::address_of_minus_one_half(); |
+ |
+ __ mov(eax, Operand(esp, arg_count() * kPointerSize)); |
+ Handle<Map> map = isolate()->factory()->heap_number_map(); |
+ __ CheckMap(eax, map, &slow, DO_SMI_CHECK); |
+ |
+ // If the number is positive, it doesn't round to -0 |
+ __ movsd(input_reg, FieldOperand(eax, HeapNumber::kValueOffset)); |
+ |
+ __ xorps(xmm_scratch, xmm_scratch); |
+ __ ucomisd(input_reg, xmm_scratch); |
+ __ j(above, &slow, Label::kNear); |
+ |
+ __ movsd(xmm_scratch, Operand::StaticVariable(minus_one_half)); |
+ __ ucomisd(input_reg, xmm_scratch); |
+ __ j(below, &slow, Label::kNear); |
+ |
+ // The only positive result remaining is 0, don't set the sentinel. |
+ __ movmskpd(output_reg, input_reg); |
+ __ test(output_reg, Immediate(1)); |
+ __ j(zero, &slow, Label::kNear); |
+ |
+ __ mov(FieldOperand(ebx, edx, times_half_pointer_size, |
+ FixedArray::kHeaderSize + kPointerSize), |
+ Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel))); |
+ } |
+ |
+ __ bind(&slow); |
+ CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
+ |
+ __ bind(&miss); |
+ GenerateMiss(masm); |
+ // The slow case, we need this no matter what to complete a call after a miss. |
+ CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
+ |
+ // Unreachable. |
+ __ int3(); |
+} |
+ |
+ |
+void CallIC_FloorStub::Generate(MacroAssembler* masm) { |
+ // edi - function |
+ // edx - slot id |
+ // ebx - vector |
+ |
+ Label slow, miss; |
+ |
+ // Ensure nobody has snuck in another function. |
+ __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
+ __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); |
+ __ cmp(eax, Immediate(Smi::FromInt(kMathFloor))); |
+ __ j(not_equal, &miss); |
+ |
+ if (arg_count() > 0) { |
+ __ mov(eax, Operand(esp, arg_count() * kPointerSize)); |
+ Handle<Map> map = isolate()->factory()->heap_number_map(); |
+ __ CheckMap(eax, map, &slow, DO_SMI_CHECK); |
+ |
+ __ cmp(FieldOperand(eax, HeapNumber::kExponentOffset), |
+ Immediate(0x80000000)); |
+ __ j(not_equal, &slow); |
+ |
+ __ cmp(FieldOperand(eax, HeapNumber::kMantissaOffset), Immediate(0)); |
+ __ j(not_equal, &slow); |
+ |
+ __ mov(FieldOperand(ebx, edx, times_half_pointer_size, |
+ FixedArray::kHeaderSize + kPointerSize), |
+ Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel))); |
+ } |
+ |
+ __ bind(&slow); |
+ CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
+ |
+ __ bind(&miss); |
+ GenerateMiss(masm); |
+ // The slow case, we need this no matter what to complete a call after a miss. |
+ CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
+ |
+ // Unreachable. |
+ __ int3(); |
+} |
+ |
+ |
+void CallIC_CeilStub::Generate(MacroAssembler* masm) { |
+ // edi - function |
+ // edx - slot id |
+ // ebx - vector |
+ |
+ Label slow, miss; |
+ |
+ // Ensure nobody has snuck in another function. |
+ __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
mvstanton
2015/04/28 14:21:20
Since this sequence happens three times, maybe it'
danno
2015/04/30 13:34:32
Done.
|
+ __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); |
+ __ cmp(eax, Immediate(Smi::FromInt(kMathCeil))); |
+ __ j(not_equal, &miss); |
+ |
+ if (arg_count() > 0) { |
+ Register output_reg = eax; |
+ XMMRegister input_reg = xmm1; |
+ XMMRegister xmm_scratch = xmm0; |
+ ExternalReference minus_one = ExternalReference::address_of_minus_one(); |
+ |
+ __ mov(eax, Operand(esp, arg_count() * kPointerSize)); |
+ Handle<Map> map = isolate()->factory()->heap_number_map(); |
+ __ CheckMap(eax, map, &slow, DO_SMI_CHECK); |
+ |
+ __ movsd(input_reg, FieldOperand(eax, HeapNumber::kValueOffset)); |
+ |
+ __ xorps(xmm_scratch, xmm_scratch); |
+ __ ucomisd(input_reg, xmm_scratch); |
+ __ j(greater, &slow, Label::kNear); |
+ |
+ __ movsd(xmm_scratch, Operand::StaticVariable(minus_one)); |
+ __ ucomisd(input_reg, xmm_scratch); |
+ __ j(less_equal, &slow, Label::kNear); |
+ |
+ // If the number is positive, it doesn't round to -0 |
+ __ movmskpd(output_reg, input_reg); |
+ __ test(output_reg, Immediate(1)); |
+ __ j(zero, &slow, Label::kNear); |
+ |
+ __ mov(FieldOperand(ebx, edx, times_half_pointer_size, |
+ FixedArray::kHeaderSize + kPointerSize), |
+ Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel))); |
+ } |
+ |
+ __ bind(&slow); |
+ CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
+ |
+ __ bind(&miss); |
+ GenerateMiss(masm); |
+ // The slow case, we need this no matter what to complete a call after a miss. |
+ CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod()); |
+ |
+ // Unreachable. |
+ __ int3(); |
+} |
+ |
+ |
void CallICStub::Generate(MacroAssembler* masm) { |
// edi - function |
// edx - slot id |
@@ -2373,6 +2530,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/04/28 14:21:20
Maybe it's okay to go to the miss handler if it's
danno
2015/04/30 13:34:32
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 +4816,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()); |