| Index: runtime/vm/intermediate_language_x64.cc
|
| ===================================================================
|
| --- runtime/vm/intermediate_language_x64.cc (revision 30039)
|
| +++ runtime/vm/intermediate_language_x64.cc (working copy)
|
| @@ -123,21 +123,6 @@
|
| }
|
|
|
|
|
| -static bool BindsToSmiConstant(Value* val, intptr_t* smi_value) {
|
| - if (!val->BindsToConstant()) {
|
| - return false;
|
| - }
|
| -
|
| - const Object& bound_constant = val->BoundConstant();
|
| - if (!bound_constant.IsSmi()) {
|
| - return false;
|
| - }
|
| -
|
| - *smi_value = Smi::Cast(bound_constant).Value();
|
| - return true;
|
| -}
|
| -
|
| -
|
| // Detect pattern when one value is zero and another is a power of 2.
|
| static bool IsPowerOfTwoKind(intptr_t v1, intptr_t v2) {
|
| return (Utils::IsPowerOfTwo(v1) && (v2 == 0)) ||
|
| @@ -145,27 +130,6 @@
|
| }
|
|
|
|
|
| -bool IfThenElseInstr::Supports(ComparisonInstr* comparison,
|
| - Value* v1,
|
| - Value* v2) {
|
| - if (!(comparison->IsStrictCompare() &&
|
| - !comparison->AsStrictCompare()->needs_number_check()) &&
|
| - !(comparison->IsEqualityCompare() &&
|
| - (comparison->AsEqualityCompare()->operation_cid() == kSmiCid))) {
|
| - return false;
|
| - }
|
| -
|
| - intptr_t v1_value, v2_value;
|
| -
|
| - if (!BindsToSmiConstant(v1, &v1_value) ||
|
| - !BindsToSmiConstant(v2, &v2_value)) {
|
| - return false;
|
| - }
|
| -
|
| - return false;
|
| -}
|
| -
|
| -
|
| LocationSummary* IfThenElseInstr::MakeLocationSummary() const {
|
| const intptr_t kNumInputs = 2;
|
| const intptr_t kNumTemps = 0;
|
| @@ -445,6 +409,38 @@
|
| }
|
|
|
|
|
| +static void EmitBranchOnValue(FlowGraphCompiler* compiler,
|
| + TargetEntryInstr* true_successor,
|
| + TargetEntryInstr* false_successor,
|
| + bool value) {
|
| + if (value && !compiler->CanFallThroughTo(true_successor)) {
|
| + __ jmp(compiler->GetJumpLabel(true_successor));
|
| + } else if (!value && !compiler->CanFallThroughTo(false_successor)) {
|
| + __ jmp(compiler->GetJumpLabel(false_successor));
|
| + }
|
| +}
|
| +
|
| +
|
| +static void EmitBranchOnCondition(FlowGraphCompiler* compiler,
|
| + TargetEntryInstr* true_successor,
|
| + TargetEntryInstr* false_successor,
|
| + Condition true_condition) {
|
| + if (compiler->CanFallThroughTo(false_successor)) {
|
| + // If the next block is the false successor, fall through to it.
|
| + __ j(true_condition, compiler->GetJumpLabel(true_successor));
|
| + } else {
|
| + // If the next block is not the false successor, branch to it.
|
| + Condition false_condition = NegateCondition(true_condition);
|
| + __ j(false_condition, compiler->GetJumpLabel(false_successor));
|
| +
|
| + // Fall through or jump to the true successor.
|
| + if (!compiler->CanFallThroughTo(true_successor)) {
|
| + __ jmp(compiler->GetJumpLabel(true_successor));
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| static void EmitSmiComparisonOp(FlowGraphCompiler* compiler,
|
| const LocationSummary& locs,
|
| Token::Kind kind,
|
| @@ -467,7 +463,10 @@
|
| }
|
|
|
| if (branch != NULL) {
|
| - branch->EmitBranchOnCondition(compiler, true_condition);
|
| + EmitBranchOnCondition(compiler,
|
| + branch->true_successor(),
|
| + branch->false_successor(),
|
| + true_condition);
|
| } else {
|
| Register result = locs.out().reg();
|
| Label done, is_true;
|
| @@ -496,6 +495,43 @@
|
| }
|
|
|
|
|
| +static void EmitDoubleCompareBranch(FlowGraphCompiler* compiler,
|
| + Condition true_condition,
|
| + FpuRegister left,
|
| + FpuRegister right,
|
| + BranchInstr* branch) {
|
| + ASSERT(branch != NULL);
|
| + __ comisd(left, right);
|
| + BlockEntryInstr* nan_result = (true_condition == NOT_EQUAL) ?
|
| + branch->true_successor() : branch->false_successor();
|
| + __ j(PARITY_EVEN, compiler->GetJumpLabel(nan_result));
|
| + EmitBranchOnCondition(compiler,
|
| + branch->true_successor(),
|
| + branch->false_successor(),
|
| + true_condition);
|
| +}
|
| +
|
| +
|
| +static void EmitDoubleCompareBool(FlowGraphCompiler* compiler,
|
| + Condition true_condition,
|
| + FpuRegister left,
|
| + FpuRegister right,
|
| + Register result) {
|
| + __ comisd(left, right);
|
| + Label is_false, is_true, done;
|
| + // x == NaN -> false, x != NaN -> true.
|
| + Label* nan_label = (true_condition == NOT_EQUAL) ? &is_true : &is_false;
|
| + __ j(PARITY_EVEN, nan_label, Assembler::kNearJump);
|
| + __ j(true_condition, &is_true, Assembler::kNearJump);
|
| + __ Bind(&is_false);
|
| + __ LoadObject(result, Bool::False(), PP);
|
| + __ jmp(&done);
|
| + __ Bind(&is_true);
|
| + __ LoadObject(result, Bool::True(), PP);
|
| + __ Bind(&done);
|
| +}
|
| +
|
| +
|
| static void EmitDoubleComparisonOp(FlowGraphCompiler* compiler,
|
| const LocationSummary& locs,
|
| Token::Kind kind,
|
| @@ -505,11 +541,10 @@
|
|
|
| Condition true_condition = TokenKindToDoubleCondition(kind);
|
| if (branch != NULL) {
|
| - compiler->EmitDoubleCompareBranch(
|
| - true_condition, left, right, branch);
|
| + EmitDoubleCompareBranch(compiler, true_condition, left, right, branch);
|
| } else {
|
| - compiler->EmitDoubleCompareBool(
|
| - true_condition, left, right, locs.out().reg());
|
| + EmitDoubleCompareBool(compiler, true_condition,
|
| + left, right, locs.out().reg());
|
| }
|
| }
|
|
|
| @@ -580,7 +615,10 @@
|
| } else {
|
| __ testq(left_reg, right.reg());
|
| }
|
| - branch->EmitBranchOnCondition(compiler, branch_condition);
|
| + EmitBranchOnCondition(compiler,
|
| + branch->true_successor(),
|
| + branch->false_successor(),
|
| + branch_condition);
|
| }
|
|
|
|
|
| @@ -4317,34 +4355,6 @@
|
| }
|
|
|
|
|
| -void ControlInstruction::EmitBranchOnValue(FlowGraphCompiler* compiler,
|
| - bool value) {
|
| - if (value && !compiler->CanFallThroughTo(true_successor())) {
|
| - __ jmp(compiler->GetJumpLabel(true_successor()));
|
| - } else if (!value && !compiler->CanFallThroughTo(false_successor())) {
|
| - __ jmp(compiler->GetJumpLabel(false_successor()));
|
| - }
|
| -}
|
| -
|
| -
|
| -void ControlInstruction::EmitBranchOnCondition(FlowGraphCompiler* compiler,
|
| - Condition true_condition) {
|
| - if (compiler->CanFallThroughTo(false_successor())) {
|
| - // If the next block is the false successor, fall through to it.
|
| - __ j(true_condition, compiler->GetJumpLabel(true_successor()));
|
| - } else {
|
| - // If the next block is not the false successor, branch to it.
|
| - Condition false_condition = NegateCondition(true_condition);
|
| - __ j(false_condition, compiler->GetJumpLabel(false_successor()));
|
| -
|
| - // Fall through or jump to the true successor.
|
| - if (!compiler->CanFallThroughTo(true_successor())) {
|
| - __ jmp(compiler->GetJumpLabel(true_successor()));
|
| - }
|
| - }
|
| -}
|
| -
|
| -
|
| LocationSummary* CurrentContextInstr::MakeLocationSummary() const {
|
| return LocationSummary::Make(0,
|
| Location::RequiresRegister(),
|
| @@ -4421,7 +4431,10 @@
|
| const bool result = (kind() == Token::kEQ_STRICT) ?
|
| left.constant().raw() == right.constant().raw() :
|
| left.constant().raw() != right.constant().raw();
|
| - branch->EmitBranchOnValue(compiler, result);
|
| + EmitBranchOnValue(compiler,
|
| + branch->true_successor(),
|
| + branch->false_successor(),
|
| + result);
|
| return;
|
| }
|
| if (left.IsConstant()) {
|
| @@ -4442,7 +4455,10 @@
|
| }
|
|
|
| Condition true_condition = (kind() == Token::kEQ_STRICT) ? EQUAL : NOT_EQUAL;
|
| - branch->EmitBranchOnCondition(compiler, true_condition);
|
| + EmitBranchOnCondition(compiler,
|
| + branch->true_successor(),
|
| + branch->false_successor(),
|
| + true_condition);
|
| }
|
|
|
|
|
|
|