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

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

Issue 1319703006: When typing phi nodes, weaken union of integer constants to a range. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed superfluous argument. Created 5 years, 3 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
« no previous file with comments | « no previous file | src/types.h » ('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 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/base/lazy-instance.h" 8 #include "src/base/lazy-instance.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/compiler/common-operator.h" 10 #include "src/compiler/common-operator.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 : Bounds(Type::None()); 190 : Bounds(Type::None());
191 } 191 }
192 192
193 Bounds Operand(Node* node, int i) { 193 Bounds Operand(Node* node, int i) {
194 Node* operand_node = NodeProperties::GetValueInput(node, i); 194 Node* operand_node = NodeProperties::GetValueInput(node, i);
195 return BoundsOrNone(operand_node); 195 return BoundsOrNone(operand_node);
196 } 196 }
197 197
198 Bounds WrapContextBoundsForInput(Node* node); 198 Bounds WrapContextBoundsForInput(Node* node);
199 Type* Weaken(Node* node, Type* current_type, Type* previous_type); 199 Type* Weaken(Node* node, Type* current_type, Type* previous_type);
200 Type* WeakenConstants(Type* type);
200 201
201 Zone* zone() { return typer_->zone(); } 202 Zone* zone() { return typer_->zone(); }
202 Isolate* isolate() { return typer_->isolate(); } 203 Isolate* isolate() { return typer_->isolate(); }
203 Graph* graph() { return typer_->graph(); } 204 Graph* graph() { return typer_->graph(); }
204 205
205 void SetWeakened(NodeId node_id) { weakened_nodes_.insert(node_id); } 206 void SetWeakened(NodeId node_id) { weakened_nodes_.insert(node_id); }
206 bool IsWeakened(NodeId node_id) { 207 bool IsWeakened(NodeId node_id) {
207 return weakened_nodes_.find(node_id) != weakened_nodes_.end(); 208 return weakened_nodes_.find(node_id) != weakened_nodes_.end();
208 } 209 }
209 210
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 Bounds Typer::Visitor::TypeExternalConstant(Node* node) { 549 Bounds Typer::Visitor::TypeExternalConstant(Node* node) {
549 return Bounds(Type::None(zone()), Type::Internal(zone())); 550 return Bounds(Type::None(zone()), Type::Internal(zone()));
550 } 551 }
551 552
552 553
553 Bounds Typer::Visitor::TypeSelect(Node* node) { 554 Bounds Typer::Visitor::TypeSelect(Node* node) {
554 return Bounds::Either(Operand(node, 1), Operand(node, 2), zone()); 555 return Bounds::Either(Operand(node, 1), Operand(node, 2), zone());
555 } 556 }
556 557
557 558
559 Type* Typer::Visitor::WeakenConstants(Type* type) {
560 Type* const integer = typer_->cache_.kInteger;
561 if (!type->Maybe(integer)) return type;
562 Type* myinteger = Type::Intersect(type, integer, zone());
Jarin 2015/09/14 08:06:29 Could you come up with a better name than myintege
563 if (myinteger->NumConstants() <= 1) return type;
564 return Type::Union(
565 type, Type::Range(myinteger->Min(), myinteger->Max(), typer_->zone()),
566 typer_->zone());
567 }
568
569
558 Bounds Typer::Visitor::TypePhi(Node* node) { 570 Bounds Typer::Visitor::TypePhi(Node* node) {
559 int arity = node->op()->ValueInputCount(); 571 int arity = node->op()->ValueInputCount();
560 Bounds bounds = Operand(node, 0); 572 Bounds bounds = Operand(node, 0);
561 for (int i = 1; i < arity; ++i) { 573 for (int i = 1; i < arity; ++i) {
562 bounds = Bounds::Either(bounds, Operand(node, i), zone()); 574 bounds = Bounds::Either(bounds, Operand(node, i), zone());
575 // In order to avoid huge unions, we weaken multiple integer constants
576 // to a single range.
577 bounds.upper = WeakenConstants(bounds.upper);
578 bounds.lower = WeakenConstants(bounds.lower);
563 } 579 }
564 return bounds; 580 return bounds;
565 } 581 }
566 582
567 583
568 Bounds Typer::Visitor::TypeEffectPhi(Node* node) { 584 Bounds Typer::Visitor::TypeEffectPhi(Node* node) {
569 UNREACHABLE(); 585 UNREACHABLE();
570 return Bounds(); 586 return Bounds();
571 } 587 }
572 588
(...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 TYPED_ARRAYS(TYPED_ARRAY_CASE) 2303 TYPED_ARRAYS(TYPED_ARRAY_CASE)
2288 #undef TYPED_ARRAY_CASE 2304 #undef TYPED_ARRAY_CASE
2289 } 2305 }
2290 } 2306 }
2291 return Type::Constant(value, zone()); 2307 return Type::Constant(value, zone());
2292 } 2308 }
2293 2309
2294 } // namespace compiler 2310 } // namespace compiler
2295 } // namespace internal 2311 } // namespace internal
2296 } // namespace v8 2312 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698