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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 zone_, kModuleParamInfo[ii].standard_member); | 590 zone_, kModuleParamInfo[ii].standard_member); |
591 | 591 |
592 if (!AddGlobal(param, param_info)) { | 592 if (!AddGlobal(param, param_info)) { |
593 FAIL(fun, "Redeclared identifier in module parameter."); | 593 FAIL(fun, "Redeclared identifier in module parameter."); |
594 } | 594 } |
595 } | 595 } |
596 | 596 |
597 ZoneVector<Assignment*> function_pointer_tables(zone_); | 597 ZoneVector<Assignment*> function_pointer_tables(zone_); |
598 FlattenedStatements iter(zone_, fun->body()); | 598 FlattenedStatements iter(zone_, fun->body()); |
599 auto* use_asm_directive = iter.Next(); | 599 auto* use_asm_directive = iter.Next(); |
600 if (use_asm_directive == nullptr || !IsUseAsmDirective(use_asm_directive)) { | 600 if (use_asm_directive == nullptr) { |
| 601 FAIL(fun, "Missing \"use asm\"."); |
| 602 } |
| 603 // Check for extra assignment inserted by the parser when in this form: |
| 604 // (function Module(a, b, c) {... }) |
| 605 ExpressionStatement* estatement = use_asm_directive->AsExpressionStatement(); |
| 606 if (estatement != nullptr) { |
| 607 Assignment* assignment = estatement->expression()->AsAssignment(); |
| 608 if (assignment != nullptr && assignment->target()->IsVariableProxy() && |
| 609 assignment->target()->AsVariableProxy()->var()->mode() == |
| 610 CONST_LEGACY) { |
| 611 use_asm_directive = iter.Next(); |
| 612 } |
| 613 } |
| 614 if (!IsUseAsmDirective(use_asm_directive)) { |
601 FAIL(fun, "Missing \"use asm\"."); | 615 FAIL(fun, "Missing \"use asm\"."); |
602 } | 616 } |
603 source_layout.AddUseAsm(*use_asm_directive); | 617 source_layout.AddUseAsm(*use_asm_directive); |
604 ReturnStatement* module_return = nullptr; | 618 ReturnStatement* module_return = nullptr; |
605 | 619 |
606 // *VIOLATION* The spec states that globals should be followed by function | 620 // *VIOLATION* The spec states that globals should be followed by function |
607 // declarations, which should be followed by function pointer tables, followed | 621 // declarations, which should be followed by function pointer tables, followed |
608 // by the module export (return) statement. Our AST might be rearraged by the | 622 // by the module export (return) statement. Our AST might be rearraged by the |
609 // parser, so we can't rely on it being in source code order. | 623 // parser, so we can't rely on it being in source code order. |
610 while (Statement* current = iter.Next()) { | 624 while (Statement* current = iter.Next()) { |
(...skipping 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 return true; | 2760 return true; |
2747 } | 2761 } |
2748 | 2762 |
2749 *error_message = typer.error_message(); | 2763 *error_message = typer.error_message(); |
2750 return false; | 2764 return false; |
2751 } | 2765 } |
2752 | 2766 |
2753 } // namespace wasm | 2767 } // namespace wasm |
2754 } // namespace internal | 2768 } // namespace internal |
2755 } // namespace v8 | 2769 } // namespace v8 |
OLD | NEW |