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

Side by Side Diff: src/compiler/typer.cc

Issue 1631583002: [for-in] Further refactorings and unification around for-in. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/compiler/typer.h" 5 #include "src/compiler/typer.h"
6 6
7 #include "src/base/flags.h" 7 #include "src/base/flags.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 643
644 Type* Typer::Visitor::TypeTypedStateValues(Node* node) { 644 Type* Typer::Visitor::TypeTypedStateValues(Node* node) {
645 return Type::Internal(zone()); 645 return Type::Internal(zone());
646 } 646 }
647 647
648 648
649 Type* Typer::Visitor::TypeCall(Node* node) { return Type::Any(); } 649 Type* Typer::Visitor::TypeCall(Node* node) { return Type::Any(); }
650 650
651 651
652 Type* Typer::Visitor::TypeProjection(Node* node) { 652 Type* Typer::Visitor::TypeProjection(Node* node) {
653 // TODO(bmeurer): Make this beautiful! Use tuple type here. 653 Type* const type = Operand(node, 0);
654 if (node->InputAt(0)->opcode() == IrOpcode::kJSForInPrepare && 654 if (type->Is(Type::None())) return Type::None();
655 ProjectionIndexOf(node->op()) == 2) { 655 int const index = static_cast<int>(ProjectionIndexOf(node->op()));
656 return typer_->cache_.kSmi; 656 if (type->IsTuple() && index < type->AsTuple()->Arity()) {
657 return type->AsTuple()->Element(index);
657 } 658 }
658 // TODO(titzer): use the output type of the input to determine the bounds.
659 return Type::Any(); 659 return Type::Any();
660 } 660 }
661 661
662 662
663 Type* Typer::Visitor::TypeDead(Node* node) { return Type::Any(); } 663 Type* Typer::Visitor::TypeDead(Node* node) { return Type::Any(); }
664 664
665 665
666 // JS comparison operators. 666 // JS comparison operators.
667 667
668 668
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1611 return Type::Receiver(); 1611 return Type::Receiver();
1612 } 1612 }
1613 1613
1614 1614
1615 Type* Typer::Visitor::TypeJSForInNext(Node* node) { 1615 Type* Typer::Visitor::TypeJSForInNext(Node* node) {
1616 return Type::Union(Type::Name(), Type::Undefined(), zone()); 1616 return Type::Union(Type::Name(), Type::Undefined(), zone());
1617 } 1617 }
1618 1618
1619 1619
1620 Type* Typer::Visitor::TypeJSForInPrepare(Node* node) { 1620 Type* Typer::Visitor::TypeJSForInPrepare(Node* node) {
1621 // TODO(bmeurer): Return a tuple type here. 1621 STATIC_ASSERT(Map::EnumLengthBits::kMax <= FixedArray::kMaxLength);
1622 return Type::Any(); 1622 Factory* const f = isolate()->factory();
1623 Type* const cache_type = Type::Union(
1624 typer_->cache_.kSmi, Type::Class(f->meta_map(), zone()), zone());
1625 Type* const cache_array = Type::Class(f->fixed_array_map(), zone());
1626 Type* const cache_length = typer_->cache_.kFixedArrayLengthType;
1627 return Type::Tuple(cache_type, cache_array, cache_length, zone());
1623 } 1628 }
1624 1629
1625 1630
1626 Type* Typer::Visitor::TypeJSForInDone(Node* node) { 1631 Type* Typer::Visitor::TypeJSForInDone(Node* node) {
1627 return Type::Boolean(zone()); 1632 return Type::Boolean(zone());
1628 } 1633 }
1629 1634
1630 1635
1631 Type* Typer::Visitor::TypeJSForInStep(Node* node) { 1636 Type* Typer::Visitor::TypeJSForInStep(Node* node) {
1632 STATIC_ASSERT(Map::EnumLengthBits::kMax <= FixedArray::kMaxLength); 1637 STATIC_ASSERT(Map::EnumLengthBits::kMax <= FixedArray::kMaxLength);
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 } 2451 }
2447 if (Type::IsInteger(*value)) { 2452 if (Type::IsInteger(*value)) {
2448 return Type::Range(value->Number(), value->Number(), zone()); 2453 return Type::Range(value->Number(), value->Number(), zone());
2449 } 2454 }
2450 return Type::Constant(value, zone()); 2455 return Type::Constant(value, zone());
2451 } 2456 }
2452 2457
2453 } // namespace compiler 2458 } // namespace compiler
2454 } // namespace internal 2459 } // namespace internal
2455 } // namespace v8 2460 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698