Commit c1da268e authored by bradnelson's avatar bradnelson Committed by Commit bot

Use asm style type names and improve asm typer.

The current typing-asm mishandles the relationship between
unsigned numbers and int. Restructuring and using type shortcuts
that approximate asm types.

BUG= https://code.google.com/p/v8/issues/detail?id=4203
TEST=test-asm-validator
R=titzer@chromium.org,aseemgarg@chromium.org
LOG=N

Review URL: https://codereview.chromium.org/1447133002

Cr-Commit-Position: refs/heads/master@{#32057}
parent e852c49e
......@@ -209,9 +209,10 @@ void AstExpressionVisitor::VisitDoExpression(DoExpression* expr) {
void AstExpressionVisitor::VisitConditional(Conditional* expr) {
RECURSE(Visit(expr->condition()));
RECURSE(Visit(expr->then_expression()));
RECURSE(Visit(expr->else_expression()));
VisitExpression(expr);
RECURSE_EXPRESSION(Visit(expr->condition()));
RECURSE_EXPRESSION(Visit(expr->then_expression()));
RECURSE_EXPRESSION(Visit(expr->else_expression()));
}
......
......@@ -54,7 +54,25 @@ class TypeCache final {
Type* const kPositiveSafeInteger = CreateRange(0.0, kMaxSafeInteger);
Type* const kIntegral32 = Type::Union(kInt32, kUint32, zone());
// Asm.js related types.
Type* const kAsmSigned = kInt32;
Type* const kAsmUnsigned = kUint32;
Type* const kAsmInt = Type::Union(kAsmSigned, kAsmUnsigned, zone());
Type* const kAsmFixnum = Type::Intersect(kAsmSigned, kAsmUnsigned, zone());
Type* const kAsmFloat = kFloat32;
Type* const kAsmDouble = kFloat64;
// Asm.js size unions.
Type* const kAsmSize8 = Type::Union(kInt8, kUint8, zone());
Type* const kAsmSize16 = Type::Union(kInt16, kUint16, zone());
Type* const kAsmSize32 =
Type::Union(Type::Union(kInt32, kUint32, zone()), kAsmFloat, zone());
Type* const kAsmSize64 = kFloat64;
// Asm.js other types.
Type* const kAsmComparable = Type::Union(
kAsmSigned,
Type::Union(kAsmUnsigned, Type::Union(kAsmDouble, kAsmFloat, zone()),
zone()),
zone());
// The FixedArray::length property always containts a smi in the range
// [0, FixedArray::kMaxLength].
......
This diff is collapsed.
......@@ -65,13 +65,14 @@ class AsmTyper : public AstVisitor {
void VisitDeclarations(ZoneList<Declaration*>* d) override;
void VisitStatements(ZoneList<Statement*>* s) override;
void VisitExpressionAnnotation(Expression* e);
void VisitExpressionAnnotation(Expression* e, bool is_return);
void VisitFunctionAnnotation(FunctionLiteral* f);
void VisitAsmModule(FunctionLiteral* f);
void VisitHeapAccess(Property* expr);
int ElementShiftSize(Type* type);
Type* StorageType(Type* type);
void SetType(Variable* variable, Type* type);
Type* GetType(Variable* variable);
......@@ -84,6 +85,8 @@ class AsmTyper : public AstVisitor {
void VisitWithExpectation(Expression* expr, Type* expected_type,
const char* msg);
void VisitLiteral(Literal* expr, bool is_return);
void VisitIntegerBitwiseOperator(BinaryOperation* expr, Type* left_expected,
Type* right_expected, Type* result_type,
bool conversion);
......
This diff is collapsed.
......@@ -273,6 +273,33 @@ TEST(VisitExpressions) {
}
TEST(VisitConditional) {
v8::V8::Initialize();
HandleAndZoneScope handles;
ZoneVector<ExpressionTypeEntry> types(handles.main_zone());
// Check that traversing the ternary operator works.
const char test_function[] =
"function foo() {\n"
" var a, b, c;\n"
" var x = a ? b : c;\n"
"}\n";
CollectTypes(&handles, test_function, &types);
CHECK_TYPES_BEGIN {
CHECK_EXPR(FunctionLiteral, Bounds::Unbounded()) {
CHECK_EXPR(Assignment, Bounds::Unbounded()) {
CHECK_VAR(x, Bounds::Unbounded());
CHECK_EXPR(Conditional, Bounds::Unbounded()) {
CHECK_VAR(a, Bounds::Unbounded());
CHECK_VAR(b, Bounds::Unbounded());
CHECK_VAR(c, Bounds::Unbounded());
}
}
}
}
CHECK_TYPES_END
}
TEST(VisitEmptyForStatment) {
v8::V8::Initialize();
HandleAndZoneScope handles;
......
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