When the stub return a heap number we do a state transition to
a version HEAP_NUMBER that can handle -0.
There is room for further improvement in the typefeedback for the
case of -0. This change however does not address this and only fixes
the acute issue.
Review URL: http://codereview.chromium.org/
7037025
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7944
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
void TypeRecordingUnaryOpStub::GenerateHeapNumberStubSub(MacroAssembler* masm) {
- Label non_smi, slow;
- GenerateSmiCodeSub(masm, &non_smi, &slow);
+ Label non_smi, slow, call_builtin;
+ GenerateSmiCodeSub(masm, &non_smi, &call_builtin);
__ bind(&non_smi);
GenerateHeapNumberCodeSub(masm, &slow);
__ bind(&slow);
GenerateTypeTransition(masm);
+ __ bind(&call_builtin);
+ GenerateGenericCodeFallback(masm);
}
}
-void TypeRecordingUnaryOpStub::GenerateSmiCodeSub(
- MacroAssembler* masm, Label* non_smi, Label* undo, Label* slow,
- Label::Distance non_smi_near, Label::Distance undo_near,
- Label::Distance slow_near) {
+void TypeRecordingUnaryOpStub::GenerateSmiCodeSub(MacroAssembler* masm,
+ Label* non_smi,
+ Label* undo,
+ Label* slow,
+ Label::Distance non_smi_near,
+ Label::Distance undo_near,
+ Label::Distance slow_near) {
// Check whether the value is a smi.
__ test(eax, Immediate(kSmiTagMask));
__ j(not_zero, non_smi, non_smi_near);
void TypeRecordingUnaryOpStub::GenerateHeapNumberStubSub(MacroAssembler* masm) {
- Label non_smi, undo, slow;
- GenerateSmiCodeSub(masm, &non_smi, &undo, &slow, Label::kNear);
+ Label non_smi, undo, slow, call_builtin;
+ GenerateSmiCodeSub(masm, &non_smi, &undo, &call_builtin, Label::kNear);
__ bind(&non_smi);
GenerateHeapNumberCodeSub(masm, &slow);
__ bind(&undo);
GenerateSmiCodeUndo(masm);
__ bind(&slow);
GenerateTypeTransition(masm);
+ __ bind(&call_builtin);
+ GenerateGenericCodeFallback(masm);
}
}
-TRUnaryOpIC::TypeInfo TRUnaryOpIC::JoinTypes(TRUnaryOpIC::TypeInfo x,
- TRUnaryOpIC::TypeInfo y) {
- return x >= y ? x : y;
+TRUnaryOpIC::TypeInfo TRUnaryOpIC::ComputeNewType(
+ TRUnaryOpIC::TypeInfo type,
+ TRUnaryOpIC::TypeInfo previous) {
+ switch (previous) {
+ case TRUnaryOpIC::UNINITIALIZED:
+ return type;
+ case TRUnaryOpIC::SMI:
+ return (type == TRUnaryOpIC::GENERIC)
+ ? TRUnaryOpIC::GENERIC
+ : TRUnaryOpIC::HEAP_NUMBER;
+ case TRUnaryOpIC::HEAP_NUMBER:
+ return TRUnaryOpIC::GENERIC;
+ case TRUnaryOpIC::GENERIC:
+ // We should never do patching if we are in GENERIC state.
+ UNREACHABLE();
+ return TRUnaryOpIC::GENERIC;
+ }
}
static_cast<TRUnaryOpIC::TypeInfo>(Smi::cast(args[3])->value());
TRUnaryOpIC::TypeInfo type = TRUnaryOpIC::GetTypeInfo(operand);
- type = TRUnaryOpIC::JoinTypes(type, previous_type);
+ type = TRUnaryOpIC::ComputeNewType(type, previous_type);
Handle<Code> code = GetTypeRecordingUnaryOpStub(key, type);
if (!code.is_null()) {
static TypeInfo GetTypeInfo(Handle<Object> operand);
- static TypeInfo JoinTypes(TypeInfo x, TypeInfo y);
+ static TypeInfo ComputeNewType(TypeInfo type, TypeInfo previous);
};
void TypeRecordingUnaryOpStub::GenerateHeapNumberStubSub(MacroAssembler* masm) {
- Label non_smi, slow;
- GenerateSmiCodeSub(masm, &non_smi, &slow, Label::kNear);
+ Label non_smi, slow, call_builtin;
+ GenerateSmiCodeSub(masm, &non_smi, &call_builtin, Label::kNear);
__ bind(&non_smi);
GenerateHeapNumberCodeSub(masm, &slow);
__ bind(&slow);
GenerateTypeTransition(masm);
+ __ bind(&call_builtin);
+ GenerateGenericCodeFallback(masm);
}