OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/typing-asm.h" | 5 #include "src/asmjs/typing-asm.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 // Literal* right = bin->right()->AsLiteral(); | 756 // Literal* right = bin->right()->AsLiteral(); |
757 // if (right == nullptr || right->raw_value()->ContainsDot()) { | 757 // if (right == nullptr || right->raw_value()->ContainsDot()) { |
758 // FAIL(right, "call mask must be integer"); | 758 // FAIL(right, "call mask must be integer"); |
759 // } | 759 // } |
760 // RECURSE(VisitWithExpectation(bin->right(), cache_.kAsmSigned, | 760 // RECURSE(VisitWithExpectation(bin->right(), cache_.kAsmSigned, |
761 // "call mask expected to be integer")); | 761 // "call mask expected to be integer")); |
762 // if (static_cast<size_t>(right->raw_value()->AsNumber()) != size - 1) { | 762 // if (static_cast<size_t>(right->raw_value()->AsNumber()) != size - 1) { |
763 // FAIL(right, "call mask must match function table"); | 763 // FAIL(right, "call mask must match function table"); |
764 // } | 764 // } |
765 // bin->set_bounds(Bounds(cache_.kAsmSigned)); | 765 // bin->set_bounds(Bounds(cache_.kAsmSigned)); |
766 RECURSE(VisitWithExpectation(expr->key(), cache_.kAsmSigned, | 766 RECURSE( |
767 "must be integer")); | 767 VisitWithExpectation(expr->key(), cache_.kAsmSigned, "must be int")); |
768 RECURSE(IntersectResult(expr, type)); | 768 RECURSE(IntersectResult(expr, type)); |
769 } else { | 769 } else { |
770 Literal* literal = expr->key()->AsLiteral(); | 770 Literal* literal = expr->key()->AsLiteral(); |
771 if (literal) { | 771 if (literal) { |
772 RECURSE(VisitWithExpectation(literal, cache_.kAsmSigned, | 772 RECURSE(VisitWithExpectation(literal, cache_.kAsmUnsigned, |
773 "array index expected to be integer")); | 773 "array index expected to be unsigned")); |
774 } else { | 774 } else { |
775 int expected_shift = ElementShiftSize(type); | 775 int expected_shift = ElementShiftSize(type); |
776 if (expected_shift == 0) { | 776 if (expected_shift == 0) { |
777 RECURSE(Visit(expr->key())); | 777 RECURSE(Visit(expr->key())); |
778 } else { | 778 } else { |
779 BinaryOperation* bin = expr->key()->AsBinaryOperation(); | 779 BinaryOperation* bin = expr->key()->AsBinaryOperation(); |
780 if (bin == nullptr || bin->op() != Token::SAR) { | 780 if (bin == nullptr || bin->op() != Token::SAR) { |
781 FAIL(expr->key(), "expected >> in heap access"); | 781 FAIL(expr->key(), "expected >> in heap access"); |
782 } | 782 } |
783 RECURSE(VisitWithExpectation(bin->left(), cache_.kAsmSigned, | 783 RECURSE(VisitWithExpectation(bin->left(), cache_.kAsmInt, |
784 "array index expected to be integer")); | 784 "array index expected to be integer")); |
785 Literal* right = bin->right()->AsLiteral(); | 785 Literal* right = bin->right()->AsLiteral(); |
786 if (right == nullptr || right->raw_value()->ContainsDot()) { | 786 if (right == nullptr || right->raw_value()->ContainsDot()) { |
787 FAIL(bin->right(), "heap access shift must be integer"); | 787 FAIL(bin->right(), "heap access shift must be integer"); |
788 } | 788 } |
789 RECURSE(VisitWithExpectation(bin->right(), cache_.kAsmSigned, | 789 RECURSE(VisitWithExpectation(bin->right(), cache_.kAsmFixnum, |
790 "array shift expected to be integer")); | 790 "array shift expected to be Fixnum")); |
791 int n = static_cast<int>(right->raw_value()->AsNumber()); | 791 int n = static_cast<int>(right->raw_value()->AsNumber()); |
792 if (expected_shift < 0 || n != expected_shift) { | 792 if (expected_shift < 0 || n != expected_shift) { |
793 FAIL(right, "heap access shift must match element size"); | 793 FAIL(right, "heap access shift must match element size"); |
794 } | 794 } |
795 } | 795 } |
796 bounds_.set(expr->key(), Bounds(cache_.kAsmSigned)); | 796 bounds_.set(expr->key(), Bounds(cache_.kAsmUnsigned)); |
797 } | 797 } |
798 Type* result_type; | 798 Type* result_type; |
799 if (type->Is(cache_.kAsmIntArrayElement)) { | 799 if (type->Is(cache_.kAsmIntArrayElement)) { |
800 result_type = cache_.kAsmIntQ; | 800 result_type = cache_.kAsmIntQ; |
801 intish_ = kMaxUncombinedAdditiveSteps; | 801 intish_ = kMaxUncombinedAdditiveSteps; |
802 } else if (type->Is(cache_.kAsmFloat)) { | 802 } else if (type->Is(cache_.kAsmFloat)) { |
803 if (assigning) { | 803 if (assigning) { |
804 result_type = cache_.kAsmFloatDoubleQ; | 804 result_type = cache_.kAsmFloatDoubleQ; |
805 } else { | 805 } else { |
806 result_type = cache_.kAsmFloatQ; | 806 result_type = cache_.kAsmFloatQ; |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 } | 1597 } |
1598 expected_type_ = save; | 1598 expected_type_ = save; |
1599 } | 1599 } |
1600 | 1600 |
1601 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { | 1601 void AsmTyper::VisitRewritableExpression(RewritableExpression* expr) { |
1602 RECURSE(Visit(expr->expression())); | 1602 RECURSE(Visit(expr->expression())); |
1603 } | 1603 } |
1604 | 1604 |
1605 } // namespace internal | 1605 } // namespace internal |
1606 } // namespace v8 | 1606 } // namespace v8 |
OLD | NEW |