| 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 806 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 817 // TODO(rossberg): implement | 817 // TODO(rossberg): implement | 
| 818 #define DEFINE_METHOD(x) \ | 818 #define DEFINE_METHOD(x) \ | 
| 819     Bounds Typer::Visitor::Type##x(Node* node) { return Bounds(Type::None()); } | 819     Bounds Typer::Visitor::Type##x(Node* node) { return Bounds(Type::None()); } | 
| 820 MACHINE_OP_LIST(DEFINE_METHOD) | 820 MACHINE_OP_LIST(DEFINE_METHOD) | 
| 821 #undef DEFINE_METHOD | 821 #undef DEFINE_METHOD | 
| 822 | 822 | 
| 823 | 823 | 
| 824 // Heap constants. | 824 // Heap constants. | 
| 825 | 825 | 
| 826 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 826 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 
| 827   if (value->IsJSFunction() && JSFunction::cast(*value)->IsBuiltin() && | 827   if (value->IsJSFunction()) { | 
| 828       !context().is_null()) { | 828     if (JSFunction::cast(*value)->shared()->HasBuiltinFunctionId()) { | 
| 829     Handle<Context> native = | 829       switch (JSFunction::cast(*value)->shared()->builtin_function_id()) { | 
| 830         handle(context().ToHandleChecked()->native_context(), isolate()); | 830         // TODO(rossberg): can't express overloading | 
| 831     if (*value == native->math_abs_fun()) { | 831         case kMathAbs: | 
| 832       return typer_->number_fun1_;  // TODO(rossberg): can't express overloading | 832           return typer_->number_fun1_; | 
| 833     } else if (*value == native->math_acos_fun()) { | 833         case kMathAcos: | 
| 834       return typer_->number_fun1_; | 834           return typer_->number_fun1_; | 
| 835     } else if (*value == native->math_asin_fun()) { | 835         case kMathAsin: | 
| 836       return typer_->number_fun1_; | 836           return typer_->number_fun1_; | 
| 837     } else if (*value == native->math_atan_fun()) { | 837         case kMathAtan: | 
| 838       return typer_->number_fun1_; | 838           return typer_->number_fun1_; | 
| 839     } else if (*value == native->math_atan2_fun()) { | 839         case kMathAtan2: | 
| 840       return typer_->number_fun2_; | 840           return typer_->number_fun2_; | 
| 841     } else if (*value == native->math_ceil_fun()) { | 841         case kMathCeil: | 
| 842       return typer_->weakint_fun1_; | 842           return typer_->weakint_fun1_; | 
| 843     } else if (*value == native->math_cos_fun()) { | 843         case kMathCos: | 
| 844       return typer_->number_fun1_; | 844           return typer_->number_fun1_; | 
| 845     } else if (*value == native->math_exp_fun()) { | 845         case kMathExp: | 
| 846       return typer_->number_fun1_; | 846           return typer_->number_fun1_; | 
| 847     } else if (*value == native->math_floor_fun()) { | 847         case kMathFloor: | 
| 848       return typer_->weakint_fun1_; | 848           return typer_->weakint_fun1_; | 
| 849     } else if (*value == native->math_imul_fun()) { | 849         case kMathImul: | 
| 850       return typer_->imul_fun_; | 850           return typer_->imul_fun_; | 
| 851     } else if (*value == native->math_log_fun()) { | 851         case kMathLog: | 
| 852       return typer_->number_fun1_; | 852           return typer_->number_fun1_; | 
| 853     } else if (*value == native->math_pow_fun()) { | 853         case kMathPow: | 
| 854       return typer_->number_fun2_; | 854           return typer_->number_fun2_; | 
| 855     } else if (*value == native->math_random_fun()) { | 855         case kMathRandom: | 
| 856       return typer_->random_fun_; | 856           return typer_->random_fun_; | 
| 857     } else if (*value == native->math_round_fun()) { | 857         case kMathRound: | 
| 858       return typer_->weakint_fun1_; | 858           return typer_->weakint_fun1_; | 
| 859     } else if (*value == native->math_sin_fun()) { | 859         case kMathSin: | 
| 860       return typer_->number_fun1_; | 860           return typer_->number_fun1_; | 
| 861     } else if (*value == native->math_sqrt_fun()) { | 861         case kMathSqrt: | 
| 862       return typer_->number_fun1_; | 862           return typer_->number_fun1_; | 
| 863     } else if (*value == native->math_tan_fun()) { | 863         case kMathTan: | 
| 864       return typer_->number_fun1_; | 864           return typer_->number_fun1_; | 
| 865     } else if (*value == native->array_buffer_fun()) { | 865         default: | 
| 866       return typer_->array_buffer_fun_; | 866           break; | 
| 867     } else if (*value == native->int8_array_fun()) { | 867       } | 
| 868       return typer_->int8_array_fun_; | 868     } else if (JSFunction::cast(*value)->IsBuiltin() && !context().is_null()) { | 
| 869     } else if (*value == native->int16_array_fun()) { | 869       Handle<Context> native = | 
| 870       return typer_->int16_array_fun_; | 870           handle(context().ToHandleChecked()->native_context(), isolate()); | 
| 871     } else if (*value == native->int32_array_fun()) { | 871       if (*value == native->array_buffer_fun()) { | 
| 872       return typer_->int32_array_fun_; | 872         return typer_->array_buffer_fun_; | 
| 873     } else if (*value == native->uint8_array_fun()) { | 873       } else if (*value == native->int8_array_fun()) { | 
| 874       return typer_->uint8_array_fun_; | 874         return typer_->int8_array_fun_; | 
| 875     } else if (*value == native->uint16_array_fun()) { | 875       } else if (*value == native->int16_array_fun()) { | 
| 876       return typer_->uint16_array_fun_; | 876         return typer_->int16_array_fun_; | 
| 877     } else if (*value == native->uint32_array_fun()) { | 877       } else if (*value == native->int32_array_fun()) { | 
| 878       return typer_->uint32_array_fun_; | 878         return typer_->int32_array_fun_; | 
| 879     } else if (*value == native->float32_array_fun()) { | 879       } else if (*value == native->uint8_array_fun()) { | 
| 880       return typer_->float32_array_fun_; | 880         return typer_->uint8_array_fun_; | 
| 881     } else if (*value == native->float64_array_fun()) { | 881       } else if (*value == native->uint16_array_fun()) { | 
| 882       return typer_->float64_array_fun_; | 882         return typer_->uint16_array_fun_; | 
|  | 883       } else if (*value == native->uint32_array_fun()) { | 
|  | 884         return typer_->uint32_array_fun_; | 
|  | 885       } else if (*value == native->float32_array_fun()) { | 
|  | 886         return typer_->float32_array_fun_; | 
|  | 887       } else if (*value == native->float64_array_fun()) { | 
|  | 888         return typer_->float64_array_fun_; | 
|  | 889       } | 
| 883     } | 890     } | 
| 884   } | 891   } | 
| 885   return Type::Constant(value, zone()); | 892   return Type::Constant(value, zone()); | 
| 886 } | 893 } | 
| 887 | 894 | 
| 888 | 895 | 
| 889 namespace { | 896 namespace { | 
| 890 | 897 | 
| 891 class TyperDecorator : public GraphDecorator { | 898 class TyperDecorator : public GraphDecorator { | 
| 892  public: | 899  public: | 
| 893   explicit TyperDecorator(Typer* typer) : typer_(typer) {} | 900   explicit TyperDecorator(Typer* typer) : typer_(typer) {} | 
| 894   virtual void Decorate(Node* node) { typer_->Init(node); } | 901   virtual void Decorate(Node* node) { typer_->Init(node); } | 
| 895 | 902 | 
| 896  private: | 903  private: | 
| 897   Typer* typer_; | 904   Typer* typer_; | 
| 898 }; | 905 }; | 
| 899 | 906 | 
| 900 } | 907 } | 
| 901 | 908 | 
| 902 | 909 | 
| 903 void Typer::DecorateGraph(Graph* graph) { | 910 void Typer::DecorateGraph(Graph* graph) { | 
| 904   graph->AddDecorator(new (zone()) TyperDecorator(this)); | 911   graph->AddDecorator(new (zone()) TyperDecorator(this)); | 
| 905 } | 912 } | 
| 906 | 913 | 
| 907 } | 914 } | 
| 908 } | 915 } | 
| 909 }  // namespace v8::internal::compiler | 916 }  // namespace v8::internal::compiler | 
| OLD | NEW | 
|---|