Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(740)

Unified Diff: runtime/vm/intermediate_language_x64.cc

Issue 11232063: Enable merging of comparisons into branches in checked mode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« runtime/vm/intermediate_language_ia32.cc ('K') | « runtime/vm/intermediate_language_ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698