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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart

Issue 36073002: Separate HTypeConversion checked type from output type. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
index dd086c9b31cfbb15e22438ccb91fcdeb1978b146..1876647a7d078c9af19dd00643cc7b19228b93db 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/codegen.dart
@@ -2469,39 +2469,38 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
}
}
- js.Expression generateTest(HCheck node) {
- HInstruction input = node.checkedInput;
+ js.Expression generateTest(HInstruction input, HType checkedType) {
TypeMask receiver = input.instructionType.computeMask(compiler);
- TypeMask mask = node.instructionType.computeMask(compiler);
+ TypeMask mask = checkedType.computeMask(compiler);
// Figure out if it is beneficial to turn this into a null check.
// V8 generally prefers 'typeof' checks, but for integers and
// indexable primitives we cannot compile this test into a single
// typeof check so the null check is cheaper.
- bool turnIntoNumCheck = input.isIntegerOrNull() && node.isInteger();
+ bool turnIntoNumCheck = input.isIntegerOrNull() && checkedType.isInteger();
bool turnIntoNullCheck = !turnIntoNumCheck
&& (mask.nullable() == receiver)
- && (node.isInteger() || node.isIndexablePrimitive(compiler));
+ && (checkedType.isInteger() || checkedType.isIndexablePrimitive(compiler));
ngeoffray 2013/10/24 06:50:55 Line too long.
sra1 2013/10/25 03:48:53 Done.
js.Expression test;
if (turnIntoNullCheck) {
use(input);
test = new js.Binary("==", pop(), new js.LiteralNull());
- } else if (node.isInteger() && !turnIntoNumCheck) {
+ } else if (checkedType.isInteger() && !turnIntoNumCheck) {
// input is !int
checkInt(input, '!==');
test = pop();
- } else if (node.isNumber() || turnIntoNumCheck) {
+ } else if (checkedType.isNumber() || turnIntoNumCheck) {
// input is !num
checkNum(input, '!==');
test = pop();
- } else if (node.isBoolean()) {
+ } else if (checkedType.isBoolean()) {
// input is !bool
checkBool(input, '!==');
test = pop();
- } else if (node.isString(compiler)) {
+ } else if (checkedType.isString(compiler)) {
// input is !string
checkString(input, '!==');
test = pop();
- } else if (node.isExtendableArray(compiler)) {
+ } else if (checkedType.isExtendableArray(compiler)) {
// input is !Object || input is !Array || input.isFixed
checkObject(input, '!==');
js.Expression objectTest = pop();
@@ -2510,7 +2509,7 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
checkFixedArray(input);
test = new js.Binary('||', objectTest, arrayTest);
test = new js.Binary('||', test, pop());
- } else if (node.isMutableArray(compiler)) {
+ } else if (checkedType.isMutableArray(compiler)) {
// input is !Object
// || ((input is !Array || input.isImmutable)
// && input is !JsIndexingBehavior)
@@ -2525,7 +2524,7 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
? new js.Binary('&&', notArrayOrImmutable, pop())
: notArrayOrImmutable;
test = new js.Binary('||', objectTest, notIndexing);
- } else if (node.isReadableArray(compiler)) {
+ } else if (checkedType.isReadableArray(compiler)) {
// input is !Object
// || (input is !Array && input is !JsIndexingBehavior)
checkObject(input, '!==');
@@ -2537,7 +2536,7 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
? new js.Binary('&&', arrayTest, pop())
: arrayTest;
test = new js.Binary('||', objectTest, notIndexing);
- } else if (node.isIndexablePrimitive(compiler)) {
+ } else if (checkedType.isIndexablePrimitive(compiler)) {
// input is !String
// && (input is !Object
// || (input is !Array && input is !JsIndexingBehavior))
@@ -2564,8 +2563,9 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
if (node.isArgumentTypeCheck || node.isReceiverTypeCheck) {
// An int check if the input is not int or null, is not
// sufficient for doing a argument or receiver check.
- assert(!node.isInteger() || node.checkedInput.isIntegerOrNull());
- js.Expression test = generateTest(node);
+ assert(!node.checkedType.isInteger() ||
+ node.checkedInput.isIntegerOrNull());
+ js.Expression test = generateTest(node.checkedInput, node.checkedType);
js.Block oldContainer = currentContainer;
js.Statement body = new js.Block.empty();
currentContainer = body;
@@ -2665,7 +2665,7 @@ class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
// Generate a type guard, something like "if (typeof t0 == 'number')" and the
// corresponding bailout call, something like "return $.foo$bailout(t0, t1);"
void visitTypeGuard(HTypeGuard node) {
- js.Expression test = generateTest(node);
+ js.Expression test = generateTest(node.checkedInput, node.instructionType);
pushStatement(new js.If.noElse(test, bailout(node)), node);
}

Powered by Google App Engine
This is Rietveld 408576698