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

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

Issue 549133002: Fix lower bound in JSLoadContext typer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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/graph-inl.h" 5 #include "src/compiler/graph-inl.h"
6 #include "src/compiler/js-operator.h" 6 #include "src/compiler/js-operator.h"
7 #include "src/compiler/node.h" 7 #include "src/compiler/node.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/compiler/simplified-operator.h" 10 #include "src/compiler/simplified-operator.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 478
479 479
480 Bounds Typer::Visitor::TypeJSInstanceOf(Node* node) { 480 Bounds Typer::Visitor::TypeJSInstanceOf(Node* node) {
481 return Bounds(Type::Boolean(zone())); 481 return Bounds(Type::Boolean(zone()));
482 } 482 }
483 483
484 484
485 // JS context operators. 485 // JS context operators.
486 486
487 Bounds Typer::Visitor::TypeJSLoadContext(Node* node) { 487 Bounds Typer::Visitor::TypeJSLoadContext(Node* node) {
488 // TODO(rossberg): Fix this once we actually use the lower bound anywhere.
489 #if 0
490 Bounds outer = OperandType(node, 0); 488 Bounds outer = OperandType(node, 0);
491 DCHECK(outer.upper->Maybe(Type::Internal())); 489 DCHECK(outer.upper->Maybe(Type::Internal()));
492 // TODO(rossberg): More precisely, instead of the above assertion, we should 490 // TODO(rossberg): More precisely, instead of the above assertion, we should
493 // back-propagate the constraint that it has to be a subtype of Internal. 491 // back-propagate the constraint that it has to be a subtype of Internal.
494 492
495 ContextAccess access = OpParameter<ContextAccess>(node); 493 ContextAccess access = OpParameter<ContextAccess>(node);
496 Type* context_type = outer.upper; 494 Type* context_type = outer.upper;
497 MaybeHandle<Context> context; 495 MaybeHandle<Context> context;
498 if (context_type->IsConstant()) { 496 if (context_type->IsConstant()) {
499 context = Handle<Context>::cast(context_type->AsConstant()->Value()); 497 context = Handle<Context>::cast(context_type->AsConstant()->Value());
500 } 498 }
501 // Walk context chain (as far as known), mirroring dynamic lookup. 499 // Walk context chain (as far as known), mirroring dynamic lookup.
502 // Since contexts are mutable, the information is only useful as a lower 500 // Since contexts are mutable, the information is only useful as a lower
503 // bound. 501 // bound.
504 // TODO(rossberg): Could use scope info to fix upper bounds for constant 502 // TODO(rossberg): Could use scope info to fix upper bounds for constant
505 // bindings if we know that this code is never shared. 503 // bindings if we know that this code is never shared.
506 for (int i = access.depth(); i > 0; --i) { 504 for (int i = access.depth(); i > 0; --i) {
507 if (context_type->IsContext()) { 505 if (context_type->IsContext()) {
508 context_type = context_type->AsContext()->Outer(); 506 context_type = context_type->AsContext()->Outer();
509 if (context_type->IsConstant()) { 507 if (context_type->IsConstant()) {
510 context = Handle<Context>::cast(context_type->AsConstant()->Value()); 508 context = Handle<Context>::cast(context_type->AsConstant()->Value());
511 } 509 }
512 } else { 510 } else if (!context.is_null()) {
513 context = handle(context.ToHandleChecked()->previous(), isolate()); 511 context = handle(context.ToHandleChecked()->previous(), isolate());
514 } 512 }
515 } 513 }
516 if (context.is_null()) { 514 if (context.is_null()) {
517 return Bounds::Unbounded(zone()); 515 return Bounds::Unbounded(zone());
518 } else { 516 } else {
519 Handle<Object> value = 517 Handle<Object> value =
520 handle(context.ToHandleChecked()->get(access.index()), isolate()); 518 handle(context.ToHandleChecked()->get(access.index()), isolate());
521 Type* lower = TypeConstant(value); 519 Type* lower = TypeConstant(value);
522 return Bounds(lower, Type::Any(zone())); 520 return Bounds(lower, Type::Any(zone()));
523 } 521 }
524 #else
525 return Bounds::Unbounded(zone());
526 #endif
527 } 522 }
528 523
529 524
530 Bounds Typer::Visitor::TypeJSStoreContext(Node* node) { 525 Bounds Typer::Visitor::TypeJSStoreContext(Node* node) {
531 return Bounds(Type::None(zone())); 526 return Bounds(Type::None(zone()));
532 } 527 }
533 528
534 529
535 Bounds Typer::Visitor::TypeJSCreateFunctionContext(Node* node) { 530 Bounds Typer::Visitor::TypeJSCreateFunctionContext(Node* node) {
536 Type* outer = ContextType(node); 531 Type* outer = ContextType(node);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 } 841 }
847 842
848 843
849 void Typer::DecorateGraph(Graph* graph) { 844 void Typer::DecorateGraph(Graph* graph) {
850 graph->AddDecorator(new (zone()) TyperDecorator(this)); 845 graph->AddDecorator(new (zone()) TyperDecorator(this));
851 } 846 }
852 847
853 } 848 }
854 } 849 }
855 } // namespace v8::internal::compiler 850 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698