Index: src/asmjs/asm-typer.h |
diff --git a/src/asmjs/asm-typer.h b/src/asmjs/asm-typer.h |
index 4fb402949d8aaa81605b43c34a6806c8bad42062..ec2d51fc45d4c25c6507b46b1d9d8cba2dc492b9 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,10 @@ 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 ValidatePhase1of2(); |
+ bool ValidateInnerFunction(FunctionDeclaration* decl); |
+ bool ValidatePhase2of2(); |
const char* error_message() const { return error_message_; } |
@@ -191,6 +196,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); |
@@ -212,7 +251,10 @@ class AsmTyper final { |
// validation failure. |
// 6.1 ValidateModule |
- AsmType* ValidateModule(FunctionLiteral* fun); |
+ AsmType* ValidateModulePhase1of2(FunctionLiteral* fun); |
titzer
2016/10/07 12:56:59
Can we get some more descriptive names for these p
bradn
2016/11/25 09:19:36
Done.
|
+ AsmType* ValidateModuleFunction(FunctionDeclaration* fun_decl); |
+ AsmType* ValidateModuleFunctions(FunctionLiteral* fun); |
+ AsmType* ValidateModulePhase2of2(FunctionLiteral* fun); |
AsmType* ValidateGlobalDeclaration(Assignment* assign); |
// 6.2 ValidateExport |
AsmType* ExportType(VariableProxy* fun_export); |
@@ -342,6 +384,10 @@ class AsmTyper final { |
char error_message_[kErrorMessageLimit]; |
StdlibSet stdlib_uses_; |
+ SourceLayoutTracker source_layout_; |
+ ReturnStatement* module_return_; |
+ ZoneVector<Assignment*> function_pointer_tables_; |
+ |
DISALLOW_IMPLICIT_CONSTRUCTORS(AsmTyper); |
}; |