| 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/base/flags.h" | 5 #include "src/base/flags.h" |
| 6 #include "src/bootstrapper.h" | 6 #include "src/bootstrapper.h" |
| 7 #include "src/compiler/graph-reducer.h" | 7 #include "src/compiler/graph-reducer.h" |
| 8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 35 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 36 k##Type, k##Type##Array, k##Type##ArrayFunc, | 36 k##Type, k##Type##Array, k##Type##ArrayFunc, |
| 37 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 37 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 38 #undef TYPED_ARRAY_CASE | 38 #undef TYPED_ARRAY_CASE |
| 39 kNumLazyCachedTypes | 39 kNumLazyCachedTypes |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 | 42 |
| 43 // Constructs and caches types lazily. | 43 // Constructs and caches types lazily. |
| 44 // TODO(turbofan): these types could be globally cached or cached per isolate. | 44 // TODO(turbofan): these types could be globally cached or cached per isolate. |
| 45 class LazyTypeCache FINAL : public ZoneObject { | 45 class LazyTypeCache final : public ZoneObject { |
| 46 public: | 46 public: |
| 47 explicit LazyTypeCache(Isolate* isolate, Zone* zone) | 47 explicit LazyTypeCache(Isolate* isolate, Zone* zone) |
| 48 : isolate_(isolate), zone_(zone) { | 48 : isolate_(isolate), zone_(zone) { |
| 49 memset(cache_, 0, sizeof(cache_)); | 49 memset(cache_, 0, sizeof(cache_)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 inline Type* Get(LazyCachedType type) { | 52 inline Type* Get(LazyCachedType type) { |
| 53 int index = static_cast<int>(type); | 53 int index = static_cast<int>(type); |
| 54 DCHECK(index < kNumLazyCachedTypes); | 54 DCHECK(index < kNumLazyCachedTypes); |
| 55 if (cache_[index] == NULL) cache_[index] = Create(type); | 55 if (cache_[index] == NULL) cache_[index] = Create(type); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 Factory* factory() const { return isolate()->factory(); } | 134 Factory* factory() const { return isolate()->factory(); } |
| 135 Isolate* isolate() const { return isolate_; } | 135 Isolate* isolate() const { return isolate_; } |
| 136 Zone* zone() const { return zone_; } | 136 Zone* zone() const { return zone_; } |
| 137 | 137 |
| 138 Type* cache_[kNumLazyCachedTypes]; | 138 Type* cache_[kNumLazyCachedTypes]; |
| 139 Isolate* isolate_; | 139 Isolate* isolate_; |
| 140 Zone* zone_; | 140 Zone* zone_; |
| 141 }; | 141 }; |
| 142 | 142 |
| 143 | 143 |
| 144 class Typer::Decorator FINAL : public GraphDecorator { | 144 class Typer::Decorator final : public GraphDecorator { |
| 145 public: | 145 public: |
| 146 explicit Decorator(Typer* typer) : typer_(typer) {} | 146 explicit Decorator(Typer* typer) : typer_(typer) {} |
| 147 void Decorate(Node* node, bool incomplete) FINAL; | 147 void Decorate(Node* node, bool incomplete) final; |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 Typer* typer_; | 150 Typer* typer_; |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 | 153 |
| 154 Typer::Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context) | 154 Typer::Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context) |
| 155 : isolate_(isolate), | 155 : isolate_(isolate), |
| 156 graph_(graph), | 156 graph_(graph), |
| 157 context_(context), | 157 context_(context), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 Typer::~Typer() { | 208 Typer::~Typer() { |
| 209 graph_->RemoveDecorator(decorator_); | 209 graph_->RemoveDecorator(decorator_); |
| 210 } | 210 } |
| 211 | 211 |
| 212 | 212 |
| 213 class Typer::Visitor : public Reducer { | 213 class Typer::Visitor : public Reducer { |
| 214 public: | 214 public: |
| 215 explicit Visitor(Typer* typer) | 215 explicit Visitor(Typer* typer) |
| 216 : typer_(typer), weakened_nodes_(typer->zone()) {} | 216 : typer_(typer), weakened_nodes_(typer->zone()) {} |
| 217 | 217 |
| 218 Reduction Reduce(Node* node) OVERRIDE { | 218 Reduction Reduce(Node* node) override { |
| 219 if (node->op()->ValueOutputCount() == 0) return NoChange(); | 219 if (node->op()->ValueOutputCount() == 0) return NoChange(); |
| 220 switch (node->opcode()) { | 220 switch (node->opcode()) { |
| 221 #define DECLARE_CASE(x) \ | 221 #define DECLARE_CASE(x) \ |
| 222 case IrOpcode::k##x: \ | 222 case IrOpcode::k##x: \ |
| 223 return UpdateBounds(node, TypeBinaryOp(node, x##Typer)); | 223 return UpdateBounds(node, TypeBinaryOp(node, x##Typer)); |
| 224 JS_SIMPLE_BINOP_LIST(DECLARE_CASE) | 224 JS_SIMPLE_BINOP_LIST(DECLARE_CASE) |
| 225 #undef DECLARE_CASE | 225 #undef DECLARE_CASE |
| 226 | 226 |
| 227 #define DECLARE_CASE(x) \ | 227 #define DECLARE_CASE(x) \ |
| 228 case IrOpcode::k##x: \ | 228 case IrOpcode::k##x: \ |
| (...skipping 2117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2346 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 2346 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 2347 #undef TYPED_ARRAY_CASE | 2347 #undef TYPED_ARRAY_CASE |
| 2348 } | 2348 } |
| 2349 } | 2349 } |
| 2350 return Type::Constant(value, zone()); | 2350 return Type::Constant(value, zone()); |
| 2351 } | 2351 } |
| 2352 | 2352 |
| 2353 } // namespace compiler | 2353 } // namespace compiler |
| 2354 } // namespace internal | 2354 } // namespace internal |
| 2355 } // namespace v8 | 2355 } // namespace v8 |
| OLD | NEW |