| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 SRC_ASMJS_ASM_TYPER_H_ | 5 #ifndef SRC_ASMJS_ASM_TYPER_H_ |
| 6 #define SRC_ASMJS_ASM_TYPER_H_ | 6 #define SRC_ASMJS_ASM_TYPER_H_ |
| 7 | 7 |
| 8 #include <cstdint> | 8 #include <cstdint> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <unordered_set> | 10 #include <unordered_set> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 friend class v8::internal::wasm::AsmTyperHarnessBuilder; | 97 friend class v8::internal::wasm::AsmTyperHarnessBuilder; |
| 98 | 98 |
| 99 class VariableInfo : public ZoneObject { | 99 class VariableInfo : public ZoneObject { |
| 100 public: | 100 public: |
| 101 enum Mutability { | 101 enum Mutability { |
| 102 kInvalidMutability, | 102 kInvalidMutability, |
| 103 kLocal, | 103 kLocal, |
| 104 kMutableGlobal, | 104 kMutableGlobal, |
| 105 // *VIOLATION* We support const variables in asm.js, as per the |
| 106 // |
| 107 // https://discourse.wicg.io/t/allow-const-global-variables/684 |
| 108 // |
| 109 // Global const variables are treated as if they were numeric literals, |
| 110 // and can be used anywhere a literal can be used. |
| 111 kConstGlobal, |
| 105 kImmutableGlobal, | 112 kImmutableGlobal, |
| 106 }; | 113 }; |
| 107 | 114 |
| 108 explicit VariableInfo(AsmType* t) : type_(t) {} | 115 explicit VariableInfo(AsmType* t) : type_(t) {} |
| 109 | 116 |
| 110 VariableInfo* Clone(Zone* zone) const; | 117 VariableInfo* Clone(Zone* zone) const; |
| 111 | 118 |
| 112 bool IsMutable() const { | 119 bool IsMutable() const { |
| 113 return mutability_ == kLocal || mutability_ == kMutableGlobal; | 120 return mutability_ == kLocal || mutability_ == kMutableGlobal; |
| 114 } | 121 } |
| 115 | 122 |
| 116 bool IsGlobal() const { | 123 bool IsGlobal() const { |
| 117 return mutability_ == kImmutableGlobal || mutability_ == kMutableGlobal; | 124 return mutability_ == kImmutableGlobal || mutability_ == kConstGlobal || |
| 125 mutability_ == kMutableGlobal; |
| 118 } | 126 } |
| 119 | 127 |
| 120 bool IsStdlib() const { return standard_member_ == kStdlib; } | 128 bool IsStdlib() const { return standard_member_ == kStdlib; } |
| 121 bool IsFFI() const { return standard_member_ == kFFI; } | 129 bool IsFFI() const { return standard_member_ == kFFI; } |
| 122 bool IsHeap() const { return standard_member_ == kHeap; } | 130 bool IsHeap() const { return standard_member_ == kHeap; } |
| 123 | 131 |
| 124 void MarkDefined() { missing_definition_ = false; } | 132 void MarkDefined() { missing_definition_ = false; } |
| 125 void FirstForwardUseIs(VariableProxy* var); | 133 void FirstForwardUseIs(VariableProxy* var); |
| 126 | 134 |
| 127 StandardMember standard_member() const { return standard_member_; } | 135 StandardMember standard_member() const { return standard_member_; } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 bool IsCallToFround(Call* call); | 308 bool IsCallToFround(Call* call); |
| 301 AsmType* ValidateFloatCoercion(Call* call); | 309 AsmType* ValidateFloatCoercion(Call* call); |
| 302 | 310 |
| 303 // 5.1 ParameterTypeAnnotations | 311 // 5.1 ParameterTypeAnnotations |
| 304 AsmType* ParameterTypeAnnotations(Variable* parameter, | 312 AsmType* ParameterTypeAnnotations(Variable* parameter, |
| 305 Expression* annotation); | 313 Expression* annotation); |
| 306 // 5.2 ReturnTypeAnnotations | 314 // 5.2 ReturnTypeAnnotations |
| 307 AsmType* ReturnTypeAnnotations(ReturnStatement* statement); | 315 AsmType* ReturnTypeAnnotations(ReturnStatement* statement); |
| 308 // 5.4 VariableTypeAnnotations | 316 // 5.4 VariableTypeAnnotations |
| 309 // 5.5 GlobalVariableTypeAnnotations | 317 // 5.5 GlobalVariableTypeAnnotations |
| 310 AsmType* VariableTypeAnnotations(Expression* initializer, | 318 AsmType* VariableTypeAnnotations( |
| 311 bool global = false); | 319 Expression* initializer, |
| 320 VariableInfo::Mutability global = VariableInfo::kLocal); |
| 312 AsmType* ImportExpression(Property* import); | 321 AsmType* ImportExpression(Property* import); |
| 313 AsmType* NewHeapView(CallNew* new_heap_view); | 322 AsmType* NewHeapView(CallNew* new_heap_view); |
| 314 | 323 |
| 315 Isolate* isolate_; | 324 Isolate* isolate_; |
| 316 Zone* zone_; | 325 Zone* zone_; |
| 317 Script* script_; | 326 Script* script_; |
| 318 FunctionLiteral* root_; | 327 FunctionLiteral* root_; |
| 319 bool in_function_ = false; | 328 bool in_function_ = false; |
| 320 | 329 |
| 321 AsmType* return_type_ = nullptr; | 330 AsmType* return_type_ = nullptr; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 344 StdlibSet stdlib_uses_; | 353 StdlibSet stdlib_uses_; |
| 345 | 354 |
| 346 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmTyper); | 355 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmTyper); |
| 347 }; | 356 }; |
| 348 | 357 |
| 349 } // namespace wasm | 358 } // namespace wasm |
| 350 } // namespace internal | 359 } // namespace internal |
| 351 } // namespace v8 | 360 } // namespace v8 |
| 352 | 361 |
| 353 #endif // SRC_ASMJS_ASM_TYPER_H_ | 362 #endif // SRC_ASMJS_ASM_TYPER_H_ |
| OLD | NEW |