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 <iomanip> | 7 #include <iomanip> |
8 | 8 |
9 #include "src/base/flags.h" | 9 #include "src/base/flags.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 Type* TypeOrNone(Node* node) { | 220 Type* TypeOrNone(Node* node) { |
221 return NodeProperties::IsTyped(node) ? NodeProperties::GetType(node) | 221 return NodeProperties::IsTyped(node) ? NodeProperties::GetType(node) |
222 : Type::None(); | 222 : Type::None(); |
223 } | 223 } |
224 | 224 |
225 Type* Operand(Node* node, int i) { | 225 Type* Operand(Node* node, int i) { |
226 Node* operand_node = NodeProperties::GetValueInput(node, i); | 226 Node* operand_node = NodeProperties::GetValueInput(node, i); |
227 return TypeOrNone(operand_node); | 227 return TypeOrNone(operand_node); |
228 } | 228 } |
229 | 229 |
230 Type* WrapContextTypeForInput(Node* node); | |
231 Type* Weaken(Node* node, Type* current_type, Type* previous_type); | 230 Type* Weaken(Node* node, Type* current_type, Type* previous_type); |
232 | 231 |
233 Zone* zone() { return typer_->zone(); } | 232 Zone* zone() { return typer_->zone(); } |
234 Isolate* isolate() { return typer_->isolate(); } | 233 Isolate* isolate() { return typer_->isolate(); } |
235 Graph* graph() { return typer_->graph(); } | 234 Graph* graph() { return typer_->graph(); } |
236 | 235 |
237 void SetWeakened(NodeId node_id) { weakened_nodes_.insert(node_id); } | 236 void SetWeakened(NodeId node_id) { weakened_nodes_.insert(node_id); } |
238 bool IsWeakened(NodeId node_id) { | 237 bool IsWeakened(NodeId node_id) { |
239 return weakened_nodes_.find(node_id) != weakened_nodes_.end(); | 238 return weakened_nodes_.find(node_id) != weakened_nodes_.end(); |
240 } | 239 } |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 | 1219 |
1221 Type* Typer::Visitor::TypeJSHasProperty(Node* node) { return Type::Boolean(); } | 1220 Type* Typer::Visitor::TypeJSHasProperty(Node* node) { return Type::Boolean(); } |
1222 | 1221 |
1223 Type* Typer::Visitor::TypeJSInstanceOf(Node* node) { return Type::Boolean(); } | 1222 Type* Typer::Visitor::TypeJSInstanceOf(Node* node) { return Type::Boolean(); } |
1224 | 1223 |
1225 // JS context operators. | 1224 // JS context operators. |
1226 | 1225 |
1227 | 1226 |
1228 Type* Typer::Visitor::TypeJSLoadContext(Node* node) { | 1227 Type* Typer::Visitor::TypeJSLoadContext(Node* node) { |
1229 ContextAccess const& access = ContextAccessOf(node->op()); | 1228 ContextAccess const& access = ContextAccessOf(node->op()); |
1230 if (access.index() == Context::EXTENSION_INDEX) { | 1229 switch (access.index()) { |
1231 return Type::TaggedPointer(); | 1230 case Context::PREVIOUS_INDEX: |
| 1231 case Context::NATIVE_CONTEXT_INDEX: |
| 1232 return Type::OtherInternal(); |
| 1233 case Context::CLOSURE_INDEX: |
| 1234 return Type::Function(); |
| 1235 default: |
| 1236 return Type::Any(); |
1232 } | 1237 } |
1233 // Since contexts are mutable, we just return the top. | |
1234 return Type::Any(); | |
1235 } | 1238 } |
1236 | 1239 |
1237 | 1240 |
1238 Type* Typer::Visitor::TypeJSStoreContext(Node* node) { | 1241 Type* Typer::Visitor::TypeJSStoreContext(Node* node) { |
1239 UNREACHABLE(); | 1242 UNREACHABLE(); |
1240 return nullptr; | 1243 return nullptr; |
1241 } | 1244 } |
1242 | 1245 |
1243 | 1246 |
1244 Type* Typer::Visitor::WrapContextTypeForInput(Node* node) { | |
1245 Type* outer = TypeOrNone(NodeProperties::GetContextInput(node)); | |
1246 if (outer->Is(Type::None())) { | |
1247 return Type::None(); | |
1248 } else { | |
1249 DCHECK(outer->Maybe(Type::OtherInternal())); | |
1250 return Type::Context(outer, zone()); | |
1251 } | |
1252 } | |
1253 | |
1254 | |
1255 Type* Typer::Visitor::TypeJSCreateFunctionContext(Node* node) { | 1247 Type* Typer::Visitor::TypeJSCreateFunctionContext(Node* node) { |
1256 return WrapContextTypeForInput(node); | 1248 return Type::OtherInternal(); |
1257 } | 1249 } |
1258 | 1250 |
1259 | |
1260 Type* Typer::Visitor::TypeJSCreateCatchContext(Node* node) { | 1251 Type* Typer::Visitor::TypeJSCreateCatchContext(Node* node) { |
1261 return WrapContextTypeForInput(node); | 1252 return Type::OtherInternal(); |
1262 } | 1253 } |
1263 | 1254 |
1264 | |
1265 Type* Typer::Visitor::TypeJSCreateWithContext(Node* node) { | 1255 Type* Typer::Visitor::TypeJSCreateWithContext(Node* node) { |
1266 return WrapContextTypeForInput(node); | 1256 return Type::OtherInternal(); |
1267 } | 1257 } |
1268 | 1258 |
1269 | |
1270 Type* Typer::Visitor::TypeJSCreateBlockContext(Node* node) { | 1259 Type* Typer::Visitor::TypeJSCreateBlockContext(Node* node) { |
1271 return WrapContextTypeForInput(node); | 1260 return Type::OtherInternal(); |
1272 } | 1261 } |
1273 | 1262 |
1274 | |
1275 Type* Typer::Visitor::TypeJSCreateScriptContext(Node* node) { | 1263 Type* Typer::Visitor::TypeJSCreateScriptContext(Node* node) { |
1276 return WrapContextTypeForInput(node); | 1264 return Type::OtherInternal(); |
1277 } | 1265 } |
1278 | 1266 |
1279 | |
1280 // JS other operators. | 1267 // JS other operators. |
1281 | 1268 |
1282 | 1269 |
1283 Type* Typer::Visitor::TypeJSCallConstruct(Node* node) { | 1270 Type* Typer::Visitor::TypeJSCallConstruct(Node* node) { |
1284 return Type::Receiver(); | 1271 return Type::Receiver(); |
1285 } | 1272 } |
1286 | 1273 |
1287 | 1274 |
1288 Type* Typer::Visitor::JSCallFunctionTyper(Type* fun, Typer* t) { | 1275 Type* Typer::Visitor::JSCallFunctionTyper(Type* fun, Typer* t) { |
1289 if (fun->IsFunction()) { | 1276 if (fun->IsFunction()) { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1706 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
1720 if (Type::IsInteger(*value)) { | 1707 if (Type::IsInteger(*value)) { |
1721 return Type::Range(value->Number(), value->Number(), zone()); | 1708 return Type::Range(value->Number(), value->Number(), zone()); |
1722 } | 1709 } |
1723 return Type::Constant(value, zone()); | 1710 return Type::Constant(value, zone()); |
1724 } | 1711 } |
1725 | 1712 |
1726 } // namespace compiler | 1713 } // namespace compiler |
1727 } // namespace internal | 1714 } // namespace internal |
1728 } // namespace v8 | 1715 } // namespace v8 |
OLD | NEW |