OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_TYPING_ASM_H_ | 5 #ifndef V8_TYPING_ASM_H_ |
6 #define V8_TYPING_ASM_H_ | 6 #define V8_TYPING_ASM_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/effects.h" | 10 #include "src/effects.h" |
11 #include "src/type-info.h" | 11 #include "src/type-info.h" |
12 #include "src/types.h" | 12 #include "src/types.h" |
13 #include "src/zone.h" | 13 #include "src/zone.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 class TypeCache; | 18 class TypeCache; |
19 | 19 |
20 class AsmTyper : public AstVisitor { | 20 class AsmTyper : public AstVisitor { |
21 public: | 21 public: |
22 explicit AsmTyper(Isolate* isolate, Zone* zone, Script* script, | 22 explicit AsmTyper(Isolate* isolate, Zone* zone, Script* script, |
23 FunctionLiteral* root); | 23 FunctionLiteral* root); |
24 bool Validate(); | 24 bool Validate(); |
25 void set_allow_simd(bool simd); | |
25 const char* error_message() { return error_message_; } | 26 const char* error_message() { return error_message_; } |
26 | 27 |
27 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 28 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
28 | 29 |
29 private: | 30 private: |
30 Zone* zone_; | 31 Zone* zone_; |
32 Isolate* isolate_; | |
31 Script* script_; | 33 Script* script_; |
32 FunctionLiteral* root_; | 34 FunctionLiteral* root_; |
33 bool valid_; | 35 bool valid_; |
36 bool allow_simd_; | |
37 | |
38 struct VariableInfo : public ZoneObject { | |
39 Type* type; | |
40 bool is_check_function; | |
41 bool is_constructor_function; | |
titzer
2015/11/25 18:36:42
Maybe we can mark the stdlib variable right away w
bradn
2015/11/30 18:22:38
Done.
| |
42 | |
43 VariableInfo() | |
44 : type(NULL), | |
45 is_check_function(false), | |
46 is_constructor_function(false) {} | |
47 explicit VariableInfo(Type* t) | |
48 : type(t), is_check_function(false), is_constructor_function(false) {} | |
49 }; | |
34 | 50 |
35 // Information for bi-directional typing with a cap on nesting depth. | 51 // Information for bi-directional typing with a cap on nesting depth. |
36 Type* expected_type_; | 52 Type* expected_type_; |
37 Type* computed_type_; | 53 Type* computed_type_; |
54 VariableInfo* property_info_; | |
38 int intish_; // How many ops we've gone without a x|0. | 55 int intish_; // How many ops we've gone without a x|0. |
39 | 56 |
40 Type* return_type_; // Return type of last function. | 57 Type* return_type_; // Return type of last function. |
41 size_t array_size_; // Array size of last ArrayLiteral. | 58 size_t array_size_; // Array size of last ArrayLiteral. |
42 | 59 |
43 typedef ZoneMap<std::string, Type*> ObjectTypeMap; | 60 typedef ZoneMap<std::string, VariableInfo*> ObjectTypeMap; |
44 ObjectTypeMap stdlib_types_; | 61 ObjectTypeMap stdlib_types_; |
45 ObjectTypeMap stdlib_heap_types_; | 62 ObjectTypeMap stdlib_heap_types_; |
46 ObjectTypeMap stdlib_math_types_; | 63 ObjectTypeMap stdlib_math_types_; |
64 #define V(NAME, Name, name, lane_count, lane_type) \ | |
65 ObjectTypeMap stdlib_simd_##name##_types_; \ | |
66 VariableInfo* stdlib_simd_##name##_constructor_type_; | |
67 SIMD128_TYPES(V) | |
68 #undef V | |
47 | 69 |
48 // Map from Variable* to global/local variable Type*. | 70 // Map from Variable* to global/local variable Type*. |
49 ZoneHashMap global_variable_type_; | 71 ZoneHashMap global_variable_type_; |
50 ZoneHashMap local_variable_type_; | 72 ZoneHashMap local_variable_type_; |
51 | 73 |
52 bool in_function_; // In module function? | 74 bool in_function_; // In module function? |
53 bool building_function_tables_; | 75 bool building_function_tables_; |
54 | 76 |
55 TypeCache const& cache_; | 77 TypeCache const& cache_; |
56 | 78 |
57 static const int kErrorMessageLimit = 100; | 79 static const int kErrorMessageLimit = 100; |
58 char error_message_[kErrorMessageLimit]; | 80 char error_message_[kErrorMessageLimit]; |
59 | 81 |
60 static const int kMaxUncombinedAdditiveSteps = 1 << 20; | 82 static const int kMaxUncombinedAdditiveSteps = 1 << 20; |
61 static const int kMaxUncombinedMultiplicativeSteps = 1; | 83 static const int kMaxUncombinedMultiplicativeSteps = 1; |
62 | 84 |
63 void InitializeStdlib(); | 85 void InitializeStdlib(); |
86 void InitializeStdlibSIMD(); | |
64 | 87 |
65 void VisitDeclarations(ZoneList<Declaration*>* d) override; | 88 void VisitDeclarations(ZoneList<Declaration*>* d) override; |
66 void VisitStatements(ZoneList<Statement*>* s) override; | 89 void VisitStatements(ZoneList<Statement*>* s) override; |
67 | 90 |
68 void VisitExpressionAnnotation(Expression* e, bool is_return); | 91 void VisitExpressionAnnotation(Expression* e, bool is_return, |
92 Variable* variable); | |
69 void VisitFunctionAnnotation(FunctionLiteral* f); | 93 void VisitFunctionAnnotation(FunctionLiteral* f); |
70 void VisitAsmModule(FunctionLiteral* f); | 94 void VisitAsmModule(FunctionLiteral* f); |
71 | 95 |
72 void VisitHeapAccess(Property* expr); | 96 void VisitHeapAccess(Property* expr); |
73 | 97 |
98 Expression* AsPropertyObjectWithKey(Expression* expr, const char* name); | |
99 bool IsMathObject(Expression* expr); | |
100 bool IsSIMDObject(Expression* expr); | |
101 bool IsSIMDTypeObject(Expression* expr, const char* name); | |
102 bool IsStdlibObject(Expression* expr); | |
103 | |
104 void VisitSIMDProperty(Property* expr); | |
105 | |
74 int ElementShiftSize(Type* type); | 106 int ElementShiftSize(Type* type); |
75 Type* StorageType(Type* type); | 107 Type* StorageType(Type* type); |
76 | 108 |
77 void SetType(Variable* variable, Type* type); | 109 void SetType(Variable* variable, Type* type); |
78 Type* GetType(Variable* variable); | 110 Type* GetType(Variable* variable); |
111 VariableInfo* GetVariableInfo(Variable* variable, bool setting); | |
112 void SetVariableInfo(Variable* variable, const VariableInfo* info); | |
79 | 113 |
80 Type* LibType(ObjectTypeMap map, Handle<String> name); | 114 VariableInfo* LibType(ObjectTypeMap map, Handle<String> name); |
81 | 115 |
82 void SetResult(Expression* expr, Type* type); | 116 void SetResult(Expression* expr, Type* type); |
83 void IntersectResult(Expression* expr, Type* type); | 117 void IntersectResult(Expression* expr, Type* type); |
84 | 118 |
85 void VisitWithExpectation(Expression* expr, Type* expected_type, | 119 void VisitWithExpectation(Expression* expr, Type* expected_type, |
86 const char* msg); | 120 const char* msg); |
87 | 121 |
88 void VisitLiteral(Literal* expr, bool is_return); | 122 void VisitLiteral(Literal* expr, bool is_return); |
89 | 123 |
90 void VisitIntegerBitwiseOperator(BinaryOperation* expr, Type* left_expected, | 124 void VisitIntegerBitwiseOperator(BinaryOperation* expr, Type* left_expected, |
91 Type* right_expected, Type* result_type, | 125 Type* right_expected, Type* result_type, |
92 bool conversion); | 126 bool conversion); |
93 | 127 |
94 Zone* zone() const { return zone_; } | 128 Zone* zone() const { return zone_; } |
95 | 129 |
96 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 130 #define DECLARE_VISIT(type) void Visit##type(type* node) override; |
97 AST_NODE_LIST(DECLARE_VISIT) | 131 AST_NODE_LIST(DECLARE_VISIT) |
98 #undef DECLARE_VISIT | 132 #undef DECLARE_VISIT |
99 | 133 |
100 DISALLOW_COPY_AND_ASSIGN(AsmTyper); | 134 DISALLOW_COPY_AND_ASSIGN(AsmTyper); |
101 }; | 135 }; |
102 } // namespace internal | 136 } // namespace internal |
103 } // namespace v8 | 137 } // namespace v8 |
104 | 138 |
105 #endif // V8_TYPING_ASM_H_ | 139 #endif // V8_TYPING_ASM_H_ |
OLD | NEW |