Commit 81425a20 authored by olivf@chromium.org's avatar olivf@chromium.org

Intel: Branch reordering and port arm EmitNumberUntagD() Improvement

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/23872026

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16714 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a8443629
......@@ -5308,7 +5308,7 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
bool deoptimize_on_minus_zero,
LEnvironment* env,
NumberUntagDMode mode) {
Label load_smi, done;
Label convert, load_smi, done;
if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) {
// Smi check.
......@@ -5317,26 +5317,15 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
// Heap number map check.
__ cmp(FieldOperand(input_reg, HeapObject::kMapOffset),
factory()->heap_number_map());
if (!can_convert_undefined_to_nan) {
DeoptimizeIf(not_equal, env);
if (can_convert_undefined_to_nan) {
__ j(not_equal, &convert, Label::kNear);
} else {
Label heap_number, convert;
__ j(equal, &heap_number, Label::kNear);
// Convert undefined (and hole) to NaN.
__ cmp(input_reg, factory()->undefined_value());
DeoptimizeIf(not_equal, env);
__ bind(&convert);
ExternalReference nan =
ExternalReference::address_of_canonical_non_hole_nan();
__ movdbl(result_reg, Operand::StaticVariable(nan));
__ jmp(&done, Label::kNear);
__ bind(&heap_number);
}
// Heap number to XMM conversion.
__ movdbl(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset));
if (deoptimize_on_minus_zero) {
XMMRegister xmm_scratch = xmm0;
__ xorps(xmm_scratch, xmm_scratch);
......@@ -5347,6 +5336,19 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
DeoptimizeIf(not_zero, env);
}
__ jmp(&done, Label::kNear);
if (can_convert_undefined_to_nan) {
__ bind(&convert);
// Convert undefined (and hole) to NaN.
__ cmp(input_reg, factory()->undefined_value());
DeoptimizeIf(not_equal, env);
ExternalReference nan =
ExternalReference::address_of_canonical_non_hole_nan();
__ movdbl(result_reg, Operand::StaticVariable(nan));
__ jmp(&done, Label::kNear);
}
} else {
ASSERT(mode == NUMBER_CANDIDATE_IS_SMI);
}
......
......@@ -4623,7 +4623,7 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
bool deoptimize_on_minus_zero,
LEnvironment* env,
NumberUntagDMode mode) {
Label load_smi, done;
Label convert, load_smi, done;
if (mode == NUMBER_CANDIDATE_IS_ANY_TAGGED) {
// Smi check.
......@@ -4632,25 +4632,17 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
// Heap number map check.
__ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
Heap::kHeapNumberMapRootIndex);
if (!can_convert_undefined_to_nan) {
DeoptimizeIf(not_equal, env);
} else {
Label heap_number, convert;
__ j(equal, &heap_number, Label::kNear);
// Convert undefined (and hole) to NaN. Compute NaN as 0/0.
__ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
DeoptimizeIf(not_equal, env);
__ bind(&convert);
__ xorps(result_reg, result_reg);
__ divsd(result_reg, result_reg);
__ jmp(&done, Label::kNear);
// On x64 it is safe to load at heap number offset before evaluating the map
// check, since all heap objects are at least two words long.
__ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset));
__ bind(&heap_number);
if (can_convert_undefined_to_nan) {
__ j(not_equal, &convert);
} else {
DeoptimizeIf(not_equal, env);
}
// Heap number to XMM conversion.
__ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset));
if (deoptimize_on_minus_zero) {
XMMRegister xmm_scratch = xmm0;
__ xorps(xmm_scratch, xmm_scratch);
......@@ -4661,6 +4653,18 @@ void LCodeGen::EmitNumberUntagD(Register input_reg,
DeoptimizeIf(not_zero, env);
}
__ jmp(&done, Label::kNear);
if (can_convert_undefined_to_nan) {
__ bind(&convert);
// Convert undefined (and hole) to NaN. Compute NaN as 0/0.
__ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
DeoptimizeIf(not_equal, env);
__ xorps(result_reg, result_reg);
__ divsd(result_reg, result_reg);
__ jmp(&done, Label::kNear);
}
} else {
ASSERT(mode == NUMBER_CANDIDATE_IS_SMI);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment