Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: src/typing-asm.cc

Issue 1405993009: Allow constant heap accesses in asm typer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/typing-asm.h" 7 #include "src/typing-asm.h"
8 8
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 if (right == NULL || right->raw_value()->ContainsDot()) { 603 if (right == NULL || right->raw_value()->ContainsDot()) {
604 FAIL(right, "call mask must be integer"); 604 FAIL(right, "call mask must be integer");
605 } 605 }
606 RECURSE(VisitWithExpectation(bin->right(), cache_.kInt32, 606 RECURSE(VisitWithExpectation(bin->right(), cache_.kInt32,
607 "call mask expected to be integer")); 607 "call mask expected to be integer"));
608 if (static_cast<size_t>(right->raw_value()->AsNumber()) != size - 1) { 608 if (static_cast<size_t>(right->raw_value()->AsNumber()) != size - 1) {
609 FAIL(right, "call mask must match function table"); 609 FAIL(right, "call mask must match function table");
610 } 610 }
611 bin->set_bounds(Bounds(cache_.kInt32)); 611 bin->set_bounds(Bounds(cache_.kInt32));
612 } else { 612 } else {
613 BinaryOperation* bin = expr->key()->AsBinaryOperation(); 613 Literal* literal = expr->key()->AsLiteral();
614 if (bin == NULL || bin->op() != Token::SAR) { 614 if (literal) {
615 FAIL(expr->key(), "expected >> in heap access"); 615 RECURSE(VisitWithExpectation(literal, cache_.kInt32,
616 "array index expected to be integer"));
617 } else {
618 BinaryOperation* bin = expr->key()->AsBinaryOperation();
619 if (bin == NULL || bin->op() != Token::SAR) {
620 FAIL(expr->key(), "expected >> in heap access");
621 }
622 RECURSE(VisitWithExpectation(bin->left(), cache_.kInt32,
623 "array index expected to be integer"));
624 Literal* right = bin->right()->AsLiteral();
625 if (right == NULL || right->raw_value()->ContainsDot()) {
626 FAIL(right, "heap access shift must be integer");
627 }
628 RECURSE(VisitWithExpectation(bin->right(), cache_.kInt32,
629 "array shift expected to be integer"));
630 int n = static_cast<int>(right->raw_value()->AsNumber());
631 int expected_shift = ElementShiftSize(type);
632 if (expected_shift < 0 || n != expected_shift) {
633 FAIL(right, "heap access shift must match element size");
634 }
635 bin->set_bounds(Bounds(cache_.kInt32));
616 } 636 }
617 RECURSE(VisitWithExpectation(bin->left(), cache_.kInt32,
618 "array index expected to be integer"));
619 Literal* right = bin->right()->AsLiteral();
620 if (right == NULL || right->raw_value()->ContainsDot()) {
621 FAIL(right, "heap access shift must be integer");
622 }
623 RECURSE(VisitWithExpectation(bin->right(), cache_.kInt32,
624 "array shift expected to be integer"));
625 int n = static_cast<int>(right->raw_value()->AsNumber());
626 int expected_shift = ElementShiftSize(type);
627 if (expected_shift < 0 || n != expected_shift) {
628 FAIL(right, "heap access shift must match element size");
629 }
630 bin->set_bounds(Bounds(cache_.kInt32));
631 } 637 }
632 IntersectResult(expr, type); 638 IntersectResult(expr, type);
633 } 639 }
634 640
635 641
636 void AsmTyper::VisitProperty(Property* expr) { 642 void AsmTyper::VisitProperty(Property* expr) {
637 // stdlib.Math.x 643 // stdlib.Math.x
638 Property* inner_prop = expr->obj()->AsProperty(); 644 Property* inner_prop = expr->obj()->AsProperty();
639 if (inner_prop != NULL) { 645 if (inner_prop != NULL) {
640 // Get property name. 646 // Get property name.
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 computed_type_->Print(); 1106 computed_type_->Print();
1101 PrintF("Expected type: "); 1107 PrintF("Expected type: ");
1102 expected_type_->Print(); 1108 expected_type_->Print();
1103 #endif 1109 #endif
1104 FAIL(expr, msg); 1110 FAIL(expr, msg);
1105 } 1111 }
1106 expected_type_ = save; 1112 expected_type_ = save;
1107 } 1113 }
1108 } // namespace internal 1114 } // namespace internal
1109 } // namespace v8 1115 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-asm-validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698