Commit 493fba88 authored by bradnelson's avatar bradnelson Committed by Commit bot

Refactor VisitProperty, add starting point for SIMD.js support.

SIMD.js potentially adds to the standard library passed into
asm.js modules. Splitting off the point where the SIMD object
would be referenced to allow work on SIMD typing to occur orthogonally.

Adding VariableInfo to allow tracking of simd constructors / check functions. Using this for fround.

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

Looking at simd.js

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

Cr-Commit-Position: refs/heads/master@{#32431}
parent 219794da
This diff is collapsed.
......@@ -22,28 +22,52 @@ class AsmTyper : public AstVisitor {
explicit AsmTyper(Isolate* isolate, Zone* zone, Script* script,
FunctionLiteral* root);
bool Validate();
void set_allow_simd(bool simd);
const char* error_message() { return error_message_; }
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
private:
Zone* zone_;
Isolate* isolate_;
Script* script_;
FunctionLiteral* root_;
bool valid_;
bool allow_simd_;
struct VariableInfo : public ZoneObject {
Type* type;
bool is_stdlib_object;
bool is_check_function;
bool is_constructor_function;
VariableInfo()
: type(NULL),
is_stdlib_object(false),
is_check_function(false),
is_constructor_function(false) {}
explicit VariableInfo(Type* t)
: type(t), is_check_function(false), is_constructor_function(false) {}
};
// Information for bi-directional typing with a cap on nesting depth.
Type* expected_type_;
Type* computed_type_;
VariableInfo* property_info_;
int intish_; // How many ops we've gone without a x|0.
Type* return_type_; // Return type of last function.
size_t array_size_; // Array size of last ArrayLiteral.
typedef ZoneMap<std::string, Type*> ObjectTypeMap;
typedef ZoneMap<std::string, VariableInfo*> ObjectTypeMap;
ObjectTypeMap stdlib_types_;
ObjectTypeMap stdlib_heap_types_;
ObjectTypeMap stdlib_math_types_;
#define V(NAME, Name, name, lane_count, lane_type) \
ObjectTypeMap stdlib_simd_##name##_types_; \
VariableInfo* stdlib_simd_##name##_constructor_type_;
SIMD128_TYPES(V)
#undef V
// Map from Variable* to global/local variable Type*.
ZoneHashMap global_variable_type_;
......@@ -61,6 +85,7 @@ class AsmTyper : public AstVisitor {
static const int kMaxUncombinedMultiplicativeSteps = 1;
void InitializeStdlib();
void InitializeStdlibSIMD();
void VisitDeclarations(ZoneList<Declaration*>* d) override;
void VisitStatements(ZoneList<Statement*>* s) override;
......@@ -71,13 +96,24 @@ class AsmTyper : public AstVisitor {
void VisitHeapAccess(Property* expr, bool assigning, Type* assignment_type);
Expression* GetReceiverOfPropertyAccess(Expression* expr, const char* name);
bool IsMathObject(Expression* expr);
bool IsSIMDObject(Expression* expr);
bool IsSIMDTypeObject(Expression* expr, const char* name);
bool IsStdlibObject(Expression* expr);
void VisitSIMDProperty(Property* expr);
int ElementShiftSize(Type* type);
Type* StorageType(Type* type);
void SetType(Variable* variable, Type* type);
Type* GetType(Variable* variable);
VariableInfo* GetVariableInfo(Variable* variable, bool setting);
void SetVariableInfo(Variable* variable, const VariableInfo* info);
Type* LibType(ObjectTypeMap map, Handle<String> name);
VariableInfo* LibType(ObjectTypeMap* map, Handle<String> name);
void VisitLibraryAccess(ObjectTypeMap* map, Property* expr);
void SetResult(Expression* expr, Type* type);
void IntersectResult(Expression* expr, Type* type);
......
......@@ -1530,7 +1530,7 @@ TEST(InvalidArgumentCount) {
CHECK_FUNC_ERROR(
"function bar(x) { return fround(4, 5); }\n"
"function foo() { bar(); }",
"asm: line 39: invalid argument count calling fround\n");
"asm: line 39: invalid argument count calling function\n");
}
......
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