| OLD | NEW |
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 VALUE_OP_LIST(DECLARE_METHOD) | 90 VALUE_OP_LIST(DECLARE_METHOD) |
| 91 #undef DECLARE_METHOD | 91 #undef DECLARE_METHOD |
| 92 | 92 |
| 93 Bounds OperandType(Node* node, int i) { | 93 Bounds OperandType(Node* node, int i) { |
| 94 return NodeProperties::GetBounds(NodeProperties::GetValueInput(node, i)); | 94 return NodeProperties::GetBounds(NodeProperties::GetValueInput(node, i)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 Type* ContextType(Node* node) { | 97 Type* ContextType(Node* node) { |
| 98 Bounds result = | 98 Bounds result = |
| 99 NodeProperties::GetBounds(NodeProperties::GetContextInput(node)); | 99 NodeProperties::GetBounds(NodeProperties::GetContextInput(node)); |
| 100 ASSERT(result.upper->Is(Type::Internal())); | 100 DCHECK(result.upper->Is(Type::Internal())); |
| 101 ASSERT(result.lower->Equals(result.upper)); | 101 DCHECK(result.lower->Equals(result.upper)); |
| 102 return result.upper; | 102 return result.upper; |
| 103 } | 103 } |
| 104 | 104 |
| 105 Zone* zone() { return typer_->zone(); } | 105 Zone* zone() { return typer_->zone(); } |
| 106 Isolate* isolate() { return typer_->isolate(); } | 106 Isolate* isolate() { return typer_->isolate(); } |
| 107 MaybeHandle<Context> context() { return context_; } | 107 MaybeHandle<Context> context() { return context_; } |
| 108 | 108 |
| 109 private: | 109 private: |
| 110 Typer* typer_; | 110 Typer* typer_; |
| 111 MaybeHandle<Context> context_; | 111 MaybeHandle<Context> context_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 class Typer::NarrowVisitor : public Typer::Visitor { | 145 class Typer::NarrowVisitor : public Typer::Visitor { |
| 146 public: | 146 public: |
| 147 NarrowVisitor(Typer* typer, MaybeHandle<Context> context) | 147 NarrowVisitor(Typer* typer, MaybeHandle<Context> context) |
| 148 : Visitor(typer, context) {} | 148 : Visitor(typer, context) {} |
| 149 | 149 |
| 150 GenericGraphVisit::Control Pre(Node* node) { | 150 GenericGraphVisit::Control Pre(Node* node) { |
| 151 Bounds previous = NodeProperties::GetBounds(node); | 151 Bounds previous = NodeProperties::GetBounds(node); |
| 152 Bounds bounds = TypeNode(node); | 152 Bounds bounds = TypeNode(node); |
| 153 NodeProperties::SetBounds(node, Bounds::Both(bounds, previous, zone())); | 153 NodeProperties::SetBounds(node, Bounds::Both(bounds, previous, zone())); |
| 154 ASSERT(bounds.Narrows(previous)); | 154 DCHECK(bounds.Narrows(previous)); |
| 155 // Stop when nothing changed (but allow reentry in case it does later). | 155 // Stop when nothing changed (but allow reentry in case it does later). |
| 156 return previous.Narrows(bounds) ? GenericGraphVisit::DEFER | 156 return previous.Narrows(bounds) ? GenericGraphVisit::DEFER |
| 157 : GenericGraphVisit::REENTER; | 157 : GenericGraphVisit::REENTER; |
| 158 } | 158 } |
| 159 | 159 |
| 160 GenericGraphVisit::Control Post(Node* node) { | 160 GenericGraphVisit::Control Post(Node* node) { |
| 161 return GenericGraphVisit::REENTER; | 161 return GenericGraphVisit::REENTER; |
| 162 } | 162 } |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 | 165 |
| 166 class Typer::WidenVisitor : public Typer::Visitor { | 166 class Typer::WidenVisitor : public Typer::Visitor { |
| 167 public: | 167 public: |
| 168 WidenVisitor(Typer* typer, MaybeHandle<Context> context) | 168 WidenVisitor(Typer* typer, MaybeHandle<Context> context) |
| 169 : Visitor(typer, context) {} | 169 : Visitor(typer, context) {} |
| 170 | 170 |
| 171 GenericGraphVisit::Control Pre(Node* node) { | 171 GenericGraphVisit::Control Pre(Node* node) { |
| 172 Bounds previous = NodeProperties::GetBounds(node); | 172 Bounds previous = NodeProperties::GetBounds(node); |
| 173 Bounds bounds = TypeNode(node); | 173 Bounds bounds = TypeNode(node); |
| 174 ASSERT(previous.lower->Is(bounds.lower)); | 174 DCHECK(previous.lower->Is(bounds.lower)); |
| 175 ASSERT(previous.upper->Is(bounds.upper)); | 175 DCHECK(previous.upper->Is(bounds.upper)); |
| 176 NodeProperties::SetBounds(node, bounds); // TODO(rossberg): Either? | 176 NodeProperties::SetBounds(node, bounds); // TODO(rossberg): Either? |
| 177 // Stop when nothing changed (but allow reentry in case it does later). | 177 // Stop when nothing changed (but allow reentry in case it does later). |
| 178 return bounds.Narrows(previous) ? GenericGraphVisit::DEFER | 178 return bounds.Narrows(previous) ? GenericGraphVisit::DEFER |
| 179 : GenericGraphVisit::REENTER; | 179 : GenericGraphVisit::REENTER; |
| 180 } | 180 } |
| 181 | 181 |
| 182 GenericGraphVisit::Control Post(Node* node) { | 182 GenericGraphVisit::Control Post(Node* node) { |
| 183 return GenericGraphVisit::REENTER; | 183 return GenericGraphVisit::REENTER; |
| 184 } | 184 } |
| 185 }; | 185 }; |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 475 |
| 476 Bounds Typer::Visitor::TypeJSInstanceOf(Node* node) { | 476 Bounds Typer::Visitor::TypeJSInstanceOf(Node* node) { |
| 477 return Bounds(Type::Boolean(zone())); | 477 return Bounds(Type::Boolean(zone())); |
| 478 } | 478 } |
| 479 | 479 |
| 480 | 480 |
| 481 // JS context operators. | 481 // JS context operators. |
| 482 | 482 |
| 483 Bounds Typer::Visitor::TypeJSLoadContext(Node* node) { | 483 Bounds Typer::Visitor::TypeJSLoadContext(Node* node) { |
| 484 Bounds outer = OperandType(node, 0); | 484 Bounds outer = OperandType(node, 0); |
| 485 ASSERT(outer.upper->Is(Type::Internal())); | 485 DCHECK(outer.upper->Is(Type::Internal())); |
| 486 ASSERT(outer.lower->Equals(outer.upper)); | 486 DCHECK(outer.lower->Equals(outer.upper)); |
| 487 ContextAccess access = OpParameter<ContextAccess>(node); | 487 ContextAccess access = OpParameter<ContextAccess>(node); |
| 488 Type* context_type = outer.upper; | 488 Type* context_type = outer.upper; |
| 489 MaybeHandle<Context> context; | 489 MaybeHandle<Context> context; |
| 490 if (context_type->IsConstant()) { | 490 if (context_type->IsConstant()) { |
| 491 context = Handle<Context>::cast(context_type->AsConstant()->Value()); | 491 context = Handle<Context>::cast(context_type->AsConstant()->Value()); |
| 492 } | 492 } |
| 493 // Walk context chain (as far as known), mirroring dynamic lookup. | 493 // Walk context chain (as far as known), mirroring dynamic lookup. |
| 494 // Since contexts are mutable, the information is only useful as a lower | 494 // Since contexts are mutable, the information is only useful as a lower |
| 495 // bound. | 495 // bound. |
| 496 // TODO(rossberg): Could use scope info to fix upper bounds for constant | 496 // TODO(rossberg): Could use scope info to fix upper bounds for constant |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 }; | 833 }; |
| 834 } | 834 } |
| 835 | 835 |
| 836 | 836 |
| 837 void Typer::DecorateGraph(Graph* graph) { | 837 void Typer::DecorateGraph(Graph* graph) { |
| 838 graph->AddDecorator(new (zone()) TyperDecorator(this)); | 838 graph->AddDecorator(new (zone()) TyperDecorator(this)); |
| 839 } | 839 } |
| 840 } | 840 } |
| 841 } | 841 } |
| 842 } // namespace v8::internal::compiler | 842 } // namespace v8::internal::compiler |
| OLD | NEW |