| Index: src/asmjs/asm-typer.h
|
| diff --git a/src/asmjs/asm-typer.h b/src/asmjs/asm-typer.h
|
| index 0505481c25a0b3f0295239f29bf83fdb25b46ffd..c8e2722f0472dca3fbf9e8d1d0d3a03b1702eade 100644
|
| --- a/src/asmjs/asm-typer.h
|
| +++ b/src/asmjs/asm-typer.h
|
| @@ -25,6 +25,7 @@ namespace wasm {
|
|
|
| class AsmType;
|
| class AsmTyperHarnessBuilder;
|
| +class SourceLayoutTracker;
|
|
|
| class AsmTyper final {
|
| public:
|
| @@ -69,6 +70,11 @@ class AsmTyper final {
|
| AsmTyper(Isolate* isolate, Zone* zone, Script* script, FunctionLiteral* root);
|
|
|
| bool Validate();
|
| + // Do asm.js validation in phases (to interleave with conversion to wasm).
|
| + bool ValidateBeforeFunctionsPhase();
|
| + bool ValidateInnerFunction(FunctionDeclaration* decl);
|
| + bool ValidateAfterFunctionsPhase();
|
| + void ClearFunctionNodeTypes();
|
|
|
| const char* error_message() const { return error_message_; }
|
|
|
| @@ -199,6 +205,40 @@ class AsmTyper final {
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(FlattenedStatements);
|
| };
|
|
|
| + class SourceLayoutTracker {
|
| + public:
|
| + SourceLayoutTracker() = default;
|
| + bool IsValid() const;
|
| + void AddUseAsm(const AstNode& node) { use_asm_.AddNewElement(node); }
|
| + void AddGlobal(const AstNode& node) { globals_.AddNewElement(node); }
|
| + void AddFunction(const AstNode& node) { functions_.AddNewElement(node); }
|
| + void AddTable(const AstNode& node) { tables_.AddNewElement(node); }
|
| + void AddExport(const AstNode& node) { exports_.AddNewElement(node); }
|
| +
|
| + private:
|
| + class Section {
|
| + public:
|
| + Section() = default;
|
| + Section(const Section&) = default;
|
| + Section& operator=(const Section&) = default;
|
| +
|
| + void AddNewElement(const AstNode& node);
|
| + bool OverlapsWith(const Section& other) const;
|
| +
|
| + private:
|
| + int start_ = kNoSourcePosition;
|
| + int end_ = kNoSourcePosition;
|
| + };
|
| +
|
| + Section use_asm_;
|
| + Section globals_;
|
| + Section functions_;
|
| + Section tables_;
|
| + Section exports_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(SourceLayoutTracker);
|
| + };
|
| +
|
| using ObjectTypeMap = ZoneMap<std::string, VariableInfo*>;
|
| void InitializeStdlib();
|
| void SetTypeOf(AstNode* node, AsmType* type);
|
| @@ -220,7 +260,10 @@ class AsmTyper final {
|
| // validation failure.
|
|
|
| // 6.1 ValidateModule
|
| - AsmType* ValidateModule(FunctionLiteral* fun);
|
| + AsmType* ValidateModuleBeforeFunctionsPhase(FunctionLiteral* fun);
|
| + AsmType* ValidateModuleFunction(FunctionDeclaration* fun_decl);
|
| + AsmType* ValidateModuleFunctions(FunctionLiteral* fun);
|
| + AsmType* ValidateModuleAfterFunctionsPhase(FunctionLiteral* fun);
|
| AsmType* ValidateGlobalDeclaration(Assignment* assign);
|
| // 6.2 ValidateExport
|
| AsmType* ExportType(VariableProxy* fun_export);
|
| @@ -345,13 +388,18 @@ class AsmTyper final {
|
|
|
| std::uintptr_t stack_limit_;
|
| bool stack_overflow_ = false;
|
| - ZoneMap<AstNode*, AsmType*> node_types_;
|
| + ZoneMap<AstNode*, AsmType*> module_node_types_;
|
| + ZoneMap<AstNode*, AsmType*> function_node_types_;
|
| static const int kErrorMessageLimit = 128;
|
| AsmType* fround_type_;
|
| AsmType* ffi_type_;
|
| char error_message_[kErrorMessageLimit];
|
| StdlibSet stdlib_uses_;
|
|
|
| + SourceLayoutTracker source_layout_;
|
| + ReturnStatement* module_return_;
|
| + ZoneVector<Assignment*> function_pointer_tables_;
|
| +
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(AsmTyper);
|
| };
|
|
|
|
|