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/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 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 } | 1255 } |
1256 return Type::Any(); | 1256 return Type::Any(); |
1257 } | 1257 } |
1258 | 1258 |
1259 | 1259 |
1260 Type* Typer::Visitor::TypeJSLoadProperty(Node* node) { | 1260 Type* Typer::Visitor::TypeJSLoadProperty(Node* node) { |
1261 return TypeBinaryOp(node, JSLoadPropertyTyper); | 1261 return TypeBinaryOp(node, JSLoadPropertyTyper); |
1262 } | 1262 } |
1263 | 1263 |
1264 | 1264 |
1265 Type* Typer::Visitor::TypeJSLoadNamed(Node* node) { return Type::Any(); } | 1265 Type* Typer::Visitor::TypeJSLoadNamed(Node* node) { |
| 1266 Factory* const f = isolate()->factory(); |
| 1267 Handle<Name> name = NamedAccessOf(node->op()).name(); |
| 1268 if (name.is_identical_to(f->prototype_string())) { |
| 1269 Type* receiver = Operand(node, 0); |
| 1270 if (receiver->Is(Type::None())) return Type::None(); |
| 1271 if (receiver->IsConstant() && |
| 1272 receiver->AsConstant()->Value()->IsJSFunction()) { |
| 1273 Handle<JSFunction> function = |
| 1274 Handle<JSFunction>::cast(receiver->AsConstant()->Value()); |
| 1275 if (function->has_prototype()) { |
| 1276 // We need to add a code dependency on the initial map of the {function} |
| 1277 // in order to be notified about changes to "prototype" of {function}, |
| 1278 // so we can only infer a constant type if deoptimization is enabled. |
| 1279 if (flags() & kDeoptimizationEnabled) { |
| 1280 JSFunction::EnsureHasInitialMap(function); |
| 1281 Handle<Map> initial_map(function->initial_map(), isolate()); |
| 1282 dependencies()->AssumeInitialMapCantChange(initial_map); |
| 1283 return Type::Constant(handle(initial_map->prototype(), isolate()), |
| 1284 zone()); |
| 1285 } |
| 1286 } |
| 1287 } else if (receiver->IsClass() && |
| 1288 receiver->AsClass()->Map()->IsJSFunctionMap()) { |
| 1289 Handle<Map> map = receiver->AsClass()->Map(); |
| 1290 return map->has_non_instance_prototype() ? Type::Primitive(zone()) |
| 1291 : Type::Receiver(zone()); |
| 1292 } |
| 1293 } |
| 1294 return Type::Any(); |
| 1295 } |
1266 | 1296 |
1267 | 1297 |
1268 Type* Typer::Visitor::TypeJSLoadGlobal(Node* node) { return Type::Any(); } | 1298 Type* Typer::Visitor::TypeJSLoadGlobal(Node* node) { return Type::Any(); } |
1269 | 1299 |
1270 | 1300 |
1271 // Returns a somewhat larger range if we previously assigned | 1301 // Returns a somewhat larger range if we previously assigned |
1272 // a (smaller) range to this node. This is used to speed up | 1302 // a (smaller) range to this node. This is used to speed up |
1273 // the fixpoint calculation in case there appears to be a loop | 1303 // the fixpoint calculation in case there appears to be a loop |
1274 // in the graph. In the current implementation, we are | 1304 // in the graph. In the current implementation, we are |
1275 // increasing the limits to the closest power of two. | 1305 // increasing the limits to the closest power of two. |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2383 } | 2413 } |
2384 if (Type::IsInteger(*value)) { | 2414 if (Type::IsInteger(*value)) { |
2385 return Type::Range(value->Number(), value->Number(), zone()); | 2415 return Type::Range(value->Number(), value->Number(), zone()); |
2386 } | 2416 } |
2387 return Type::Constant(value, zone()); | 2417 return Type::Constant(value, zone()); |
2388 } | 2418 } |
2389 | 2419 |
2390 } // namespace compiler | 2420 } // namespace compiler |
2391 } // namespace internal | 2421 } // namespace internal |
2392 } // namespace v8 | 2422 } // namespace v8 |
OLD | NEW |