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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 static Type* ObjectIsSmi(Type*, Typer*); | 290 static Type* ObjectIsSmi(Type*, Typer*); |
291 static Type* ObjectIsString(Type*, Typer*); | 291 static Type* ObjectIsString(Type*, Typer*); |
292 static Type* ObjectIsUndetectable(Type*, Typer*); | 292 static Type* ObjectIsUndetectable(Type*, Typer*); |
293 | 293 |
294 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); | 294 static ComparisonOutcome JSCompareTyper(Type*, Type*, Typer*); |
295 | 295 |
296 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); | 296 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); |
297 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) | 297 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) |
298 #undef DECLARE_METHOD | 298 #undef DECLARE_METHOD |
299 | 299 |
300 static Type* JSCallFunctionTyper(Type*, Typer*); | 300 static Type* JSCallTyper(Type*, Typer*); |
301 | 301 |
302 static Type* ReferenceEqualTyper(Type*, Type*, Typer*); | 302 static Type* ReferenceEqualTyper(Type*, Type*, Typer*); |
303 static Type* StringFromCharCodeTyper(Type*, Typer*); | 303 static Type* StringFromCharCodeTyper(Type*, Typer*); |
304 static Type* StringFromCodePointTyper(Type*, Typer*); | 304 static Type* StringFromCodePointTyper(Type*, Typer*); |
305 | 305 |
306 Reduction UpdateType(Node* node, Type* current) { | 306 Reduction UpdateType(Node* node, Type* current) { |
307 if (NodeProperties::IsTyped(node)) { | 307 if (NodeProperties::IsTyped(node)) { |
308 // Widen the type of a previously typed node. | 308 // Widen the type of a previously typed node. |
309 Type* previous = NodeProperties::GetType(node); | 309 Type* previous = NodeProperties::GetType(node); |
310 if (node->opcode() == IrOpcode::kPhi || | 310 if (node->opcode() == IrOpcode::kPhi || |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 } | 1321 } |
1322 | 1322 |
1323 // JS other operators. | 1323 // JS other operators. |
1324 | 1324 |
1325 Type* Typer::Visitor::TypeJSConstruct(Node* node) { return Type::Receiver(); } | 1325 Type* Typer::Visitor::TypeJSConstruct(Node* node) { return Type::Receiver(); } |
1326 | 1326 |
1327 Type* Typer::Visitor::TypeJSConstructWithSpread(Node* node) { | 1327 Type* Typer::Visitor::TypeJSConstructWithSpread(Node* node) { |
1328 return Type::Receiver(); | 1328 return Type::Receiver(); |
1329 } | 1329 } |
1330 | 1330 |
1331 Type* Typer::Visitor::JSCallFunctionTyper(Type* fun, Typer* t) { | 1331 Type* Typer::Visitor::JSCallTyper(Type* fun, Typer* t) { |
1332 if (fun->IsHeapConstant() && fun->AsHeapConstant()->Value()->IsJSFunction()) { | 1332 if (fun->IsHeapConstant() && fun->AsHeapConstant()->Value()->IsJSFunction()) { |
1333 Handle<JSFunction> function = | 1333 Handle<JSFunction> function = |
1334 Handle<JSFunction>::cast(fun->AsHeapConstant()->Value()); | 1334 Handle<JSFunction>::cast(fun->AsHeapConstant()->Value()); |
1335 if (function->shared()->HasBuiltinFunctionId()) { | 1335 if (function->shared()->HasBuiltinFunctionId()) { |
1336 switch (function->shared()->builtin_function_id()) { | 1336 switch (function->shared()->builtin_function_id()) { |
1337 case kMathRandom: | 1337 case kMathRandom: |
1338 return Type::PlainNumber(); | 1338 return Type::PlainNumber(); |
1339 case kMathFloor: | 1339 case kMathFloor: |
1340 case kMathCeil: | 1340 case kMathCeil: |
1341 case kMathRound: | 1341 case kMathRound: |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 return Type::Boolean(); | 1572 return Type::Boolean(); |
1573 default: | 1573 default: |
1574 break; | 1574 break; |
1575 } | 1575 } |
1576 } | 1576 } |
1577 } | 1577 } |
1578 return Type::NonInternal(); | 1578 return Type::NonInternal(); |
1579 } | 1579 } |
1580 | 1580 |
1581 Type* Typer::Visitor::TypeJSCallForwardVarargs(Node* node) { | 1581 Type* Typer::Visitor::TypeJSCallForwardVarargs(Node* node) { |
1582 return TypeUnaryOp(node, JSCallFunctionTyper); | 1582 return TypeUnaryOp(node, JSCallTyper); |
1583 } | 1583 } |
1584 | 1584 |
1585 Type* Typer::Visitor::TypeJSCallFunction(Node* node) { | 1585 Type* Typer::Visitor::TypeJSCall(Node* node) { |
1586 // TODO(bmeurer): We could infer better types if we wouldn't ignore the | 1586 // TODO(bmeurer): We could infer better types if we wouldn't ignore the |
1587 // argument types for the JSCallFunctionTyper above. | 1587 // argument types for the JSCallTyper above. |
1588 return TypeUnaryOp(node, JSCallFunctionTyper); | 1588 return TypeUnaryOp(node, JSCallTyper); |
1589 } | 1589 } |
1590 | 1590 |
1591 Type* Typer::Visitor::TypeJSCallFunctionWithSpread(Node* node) { | 1591 Type* Typer::Visitor::TypeJSCallWithSpread(Node* node) { |
1592 return TypeUnaryOp(node, JSCallFunctionTyper); | 1592 return TypeUnaryOp(node, JSCallTyper); |
1593 } | 1593 } |
1594 | 1594 |
1595 Type* Typer::Visitor::TypeJSCallRuntime(Node* node) { | 1595 Type* Typer::Visitor::TypeJSCallRuntime(Node* node) { |
1596 switch (CallRuntimeParametersOf(node->op()).id()) { | 1596 switch (CallRuntimeParametersOf(node->op()).id()) { |
1597 case Runtime::kInlineIsJSReceiver: | 1597 case Runtime::kInlineIsJSReceiver: |
1598 return TypeUnaryOp(node, ObjectIsReceiver); | 1598 return TypeUnaryOp(node, ObjectIsReceiver); |
1599 case Runtime::kInlineIsSmi: | 1599 case Runtime::kInlineIsSmi: |
1600 return TypeUnaryOp(node, ObjectIsSmi); | 1600 return TypeUnaryOp(node, ObjectIsSmi); |
1601 case Runtime::kInlineIsArray: | 1601 case Runtime::kInlineIsArray: |
1602 case Runtime::kInlineIsDate: | 1602 case Runtime::kInlineIsDate: |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1943 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
1944 if (Type::IsInteger(*value)) { | 1944 if (Type::IsInteger(*value)) { |
1945 return Type::Range(value->Number(), value->Number(), zone()); | 1945 return Type::Range(value->Number(), value->Number(), zone()); |
1946 } | 1946 } |
1947 return Type::NewConstant(value, zone()); | 1947 return Type::NewConstant(value, zone()); |
1948 } | 1948 } |
1949 | 1949 |
1950 } // namespace compiler | 1950 } // namespace compiler |
1951 } // namespace internal | 1951 } // namespace internal |
1952 } // namespace v8 | 1952 } // namespace v8 |
OLD | NEW |