| Index: runtime/vm/intermediate_language_x64.cc
|
| ===================================================================
|
| --- runtime/vm/intermediate_language_x64.cc (revision 13969)
|
| +++ runtime/vm/intermediate_language_x64.cc (working copy)
|
| @@ -199,26 +199,35 @@
|
| }
|
|
|
|
|
| +static void EmitAssertBoolean(Register reg,
|
| + intptr_t token_pos,
|
| + LocationSummary* locs,
|
| + FlowGraphCompiler* compiler) {
|
| + // Check that the type of the value is allowed in conditional context.
|
| + // Call the runtime if the object is not bool::true or bool::false.
|
| + ASSERT(locs->always_calls());
|
| + Label done;
|
| + __ CompareObject(reg, compiler->bool_true());
|
| + __ j(EQUAL, &done, Assembler::kNearJump);
|
| + __ CompareObject(reg, compiler->bool_false());
|
| + __ j(EQUAL, &done, Assembler::kNearJump);
|
| +
|
| + __ pushq(reg); // Push the source object.
|
| + compiler->GenerateCallRuntime(token_pos,
|
| + kConditionTypeErrorRuntimeEntry,
|
| + locs);
|
| + // We should never return here.
|
| + __ int3();
|
| + __ Bind(&done);
|
| +}
|
| +
|
| +
|
| void AssertBooleanInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
|
| Register obj = locs()->in(0).reg();
|
| Register result = locs()->out().reg();
|
|
|
| if (!is_eliminated()) {
|
| - // Check that the type of the value is allowed in conditional context.
|
| - // Call the runtime if the object is not bool::true or bool::false.
|
| - Label done;
|
| - __ CompareObject(obj, compiler->bool_true());
|
| - __ j(EQUAL, &done, Assembler::kNearJump);
|
| - __ CompareObject(obj, compiler->bool_false());
|
| - __ j(EQUAL, &done, Assembler::kNearJump);
|
| -
|
| - __ pushq(obj); // Push the source object.
|
| - compiler->GenerateCallRuntime(token_pos(),
|
| - kConditionTypeErrorRuntimeEntry,
|
| - locs());
|
| - // We should never return here.
|
| - __ int3();
|
| - __ Bind(&done);
|
| + EmitAssertBoolean(obj, token_pos(), locs(), compiler);
|
| }
|
| ASSERT(obj == result);
|
| }
|
| @@ -455,6 +464,9 @@
|
| __ jmp(&done);
|
| }
|
| } else {
|
| + if (branch->is_checked()) {
|
| + EmitAssertBoolean(RAX, token_pos, locs, compiler);
|
| + }
|
| __ CompareObject(RAX, compiler->bool_true());
|
| branch->EmitBranchOnCondition(compiler, cond);
|
| }
|
| @@ -732,6 +744,9 @@
|
| token_pos(),
|
| Token::kEQ, // kNE reverse occurs at branch.
|
| locs());
|
| + if (branch->is_checked()) {
|
| + EmitAssertBoolean(RAX, token_pos(), locs(), compiler);
|
| + }
|
| Condition branch_condition = (kind() == Token::kNE) ? NOT_EQUAL : EQUAL;
|
| __ CompareObject(RAX, compiler->bool_true());
|
| branch->EmitBranchOnCondition(compiler, branch_condition);
|
|
|