| 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 #include "src/asmjs/asm-typer.h" | 5 #include "src/asmjs/asm-typer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 static const uint32_t LargestFixNum = std::numeric_limits<int32_t>::max(); | 53 static const uint32_t LargestFixNum = std::numeric_limits<int32_t>::max(); |
| 54 } // namespace | 54 } // namespace |
| 55 | 55 |
| 56 using v8::internal::AstNode; | 56 using v8::internal::AstNode; |
| 57 using v8::internal::GetCurrentStackPosition; | 57 using v8::internal::GetCurrentStackPosition; |
| 58 | 58 |
| 59 // ---------------------------------------------------------------------------- | 59 // ---------------------------------------------------------------------------- |
| 60 // Implementation of AsmTyper::FlattenedStatements | 60 // Implementation of AsmTyper::FlattenedStatements |
| 61 | 61 |
| 62 AsmTyper::FlattenedStatements::FlattenedStatements(Zone* zone, | 62 AsmTyper::FlattenedStatements::FlattenedStatements(Zone* zone, |
| 63 ZoneList<Statement*>* s) | 63 ZoneChunkList<Statement*>* s) |
| 64 : context_stack_(zone) { | 64 : context_stack_(zone) { |
| 65 context_stack_.emplace_back(Context(s)); | 65 context_stack_.emplace_back(Context(s)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 Statement* AsmTyper::FlattenedStatements::Next() { | 68 Statement* AsmTyper::FlattenedStatements::Next() { |
| 69 for (;;) { | 69 for (;;) { |
| 70 if (context_stack_.empty()) { | 70 if (context_stack_.empty()) { |
| 71 return nullptr; | 71 return nullptr; |
| 72 } | 72 } |
| 73 | 73 |
| 74 Context* current = &context_stack_.back(); | 74 Context* current = &context_stack_.back(); |
| 75 | 75 |
| 76 if (current->statements_->length() <= current->next_index_) { | 76 if (current->current_ == current->end_) { |
| 77 context_stack_.pop_back(); | 77 context_stack_.pop_back(); |
| 78 continue; | 78 continue; |
| 79 } | 79 } |
| 80 | 80 |
| 81 Statement* current_statement = | 81 Statement* current_statement = *(current->current_++); |
| 82 current->statements_->at(current->next_index_++); | |
| 83 if (current_statement->IsBlock()) { | 82 if (current_statement->IsBlock()) { |
| 84 context_stack_.emplace_back( | 83 context_stack_.emplace_back( |
| 85 Context(current_statement->AsBlock()->statements())); | 84 Context(current_statement->AsBlock()->statements())); |
| 86 continue; | 85 continue; |
| 87 } | 86 } |
| 88 | 87 |
| 89 return current_statement; | 88 return current_statement; |
| 90 } | 89 } |
| 91 } | 90 } |
| 92 | 91 |
| (...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 FAIL(initializer, "Redeclared local."); | 1132 FAIL(initializer, "Redeclared local."); |
| 1134 } | 1133 } |
| 1135 | 1134 |
| 1136 SetTypeOf(local, type); | 1135 SetTypeOf(local, type); |
| 1137 SetTypeOf(initializer, type); | 1136 SetTypeOf(initializer, type); |
| 1138 } | 1137 } |
| 1139 | 1138 |
| 1140 // 5.2 Return Type Annotations | 1139 // 5.2 Return Type Annotations |
| 1141 // *VIOLATION* we peel blocks to find the last statement in the asm module | 1140 // *VIOLATION* we peel blocks to find the last statement in the asm module |
| 1142 // because the parser may introduce synthetic blocks. | 1141 // because the parser may introduce synthetic blocks. |
| 1143 ZoneList<Statement*>* statements = fun->body(); | 1142 ZoneChunkList<Statement*>* statements = fun->body(); |
| 1144 | 1143 |
| 1145 do { | 1144 do { |
| 1146 if (statements->length() == 0) { | 1145 if (statements->size() == 0) { |
| 1147 return_type_ = AsmType::Void(); | 1146 return_type_ = AsmType::Void(); |
| 1148 } else { | 1147 } else { |
| 1149 auto* last_statement = statements->last(); | 1148 auto* last_statement = statements->back(); |
| 1150 auto* as_block = last_statement->AsBlock(); | 1149 auto* as_block = last_statement->AsBlock(); |
| 1151 if (as_block != nullptr) { | 1150 if (as_block != nullptr) { |
| 1152 statements = as_block->statements(); | 1151 statements = as_block->statements(); |
| 1153 } else { | 1152 } else { |
| 1154 // We don't check whether AsReturnStatement() below returns non-null -- | 1153 // We don't check whether AsReturnStatement() below returns non-null -- |
| 1155 // we leave that to the ReturnTypeAnnotations method. | 1154 // we leave that to the ReturnTypeAnnotations method. |
| 1156 RECURSE(return_type_ = | 1155 RECURSE(return_type_ = |
| 1157 ReturnTypeAnnotations(last_statement->AsReturnStatement())); | 1156 ReturnTypeAnnotations(last_statement->AsReturnStatement())); |
| 1158 } | 1157 } |
| 1159 } | 1158 } |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2858 return true; | 2857 return true; |
| 2859 } | 2858 } |
| 2860 | 2859 |
| 2861 *error_message = typer.error_message(); | 2860 *error_message = typer.error_message(); |
| 2862 return false; | 2861 return false; |
| 2863 } | 2862 } |
| 2864 | 2863 |
| 2865 } // namespace wasm | 2864 } // namespace wasm |
| 2866 } // namespace internal | 2865 } // namespace internal |
| 2867 } // namespace v8 | 2866 } // namespace v8 |
| OLD | NEW |