Commit 3a5056a2 authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC/s390: [crankshaft] Support all oddballs for truncating TaggedToI changes.

Port 7d383be9

Original commit message:

    For inputs to truncating binary operations like <<, | or >>>, support
    all Oddballs not just undefined, true and false. This unifies treatment
    of these truncations in Crankshaft and TurboFan, and is very easy
    nowadays, since the memory layout of Oddball and HeapNumber is
    compatible.

R=bmeurer@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com

BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2455993002
Cr-Commit-Position: refs/heads/master@{#40625}
parent 375afe2a
......@@ -4793,35 +4793,13 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) {
__ cmp(scratch1, ip);
if (instr->truncating()) {
// Performs a truncating conversion of a floating point number as used by
// the JS bitwise operations.
Label no_heap_number, check_bools, check_false;
__ bne(&no_heap_number);
Label truncate;
__ beq(&truncate);
__ CompareInstanceType(scratch1, scratch1, ODDBALL_TYPE);
DeoptimizeIf(ne, instr, DeoptimizeReason::kNotANumberOrOddball);
__ bind(&truncate);
__ mr(scratch2, input_reg);
__ TruncateHeapNumberToI(input_reg, scratch2);
__ b(&done);
// Check for Oddballs. Undefined/False is converted to zero and True to one
// for truncating conversions.
__ bind(&no_heap_number);
__ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
__ cmp(input_reg, ip);
__ bne(&check_bools);
__ li(input_reg, Operand::Zero());
__ b(&done);
__ bind(&check_bools);
__ LoadRoot(ip, Heap::kTrueValueRootIndex);
__ cmp(input_reg, ip);
__ bne(&check_false);
__ li(input_reg, Operand(1));
__ b(&done);
__ bind(&check_false);
__ LoadRoot(ip, Heap::kFalseValueRootIndex);
__ cmp(input_reg, ip);
DeoptimizeIf(ne, instr, DeoptimizeReason::kNotAHeapNumberUndefinedBoolean);
__ li(input_reg, Operand::Zero());
} else {
DeoptimizeIf(ne, instr, DeoptimizeReason::kNotAHeapNumber);
......
......@@ -4720,32 +4720,13 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) {
__ CompareRoot(scratch1, Heap::kHeapNumberMapRootIndex);
if (instr->truncating()) {
// Performs a truncating conversion of a floating point number as used by
// the JS bitwise operations.
Label no_heap_number, check_bools, check_false;
__ bne(&no_heap_number, Label::kNear);
Label truncate;
__ beq(&truncate);
__ CompareInstanceType(scratch1, scratch1, ODDBALL_TYPE);
DeoptimizeIf(ne, instr, DeoptimizeReason::kNotANumberOrOddball);
__ bind(&truncate);
__ LoadRR(scratch2, input_reg);
__ TruncateHeapNumberToI(input_reg, scratch2);
__ b(&done, Label::kNear);
// Check for Oddballs. Undefined/False is converted to zero and True to one
// for truncating conversions.
__ bind(&no_heap_number);
__ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
__ bne(&check_bools);
__ LoadImmP(input_reg, Operand::Zero());
__ b(&done, Label::kNear);
__ bind(&check_bools);
__ CompareRoot(input_reg, Heap::kTrueValueRootIndex);
__ bne(&check_false, Label::kNear);
__ LoadImmP(input_reg, Operand(1));
__ b(&done, Label::kNear);
__ bind(&check_false);
__ CompareRoot(input_reg, Heap::kFalseValueRootIndex);
DeoptimizeIf(ne, instr, DeoptimizeReason::kNotAHeapNumberUndefinedBoolean);
__ LoadImmP(input_reg, Operand::Zero());
} else {
// Deoptimize if we don't have a heap number.
DeoptimizeIf(ne, instr, DeoptimizeReason::kNotAHeapNumber);
......
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