OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
7 | 7 |
8 #include "src/dateparser-inl.h" | 8 #include "src/dateparser-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 Object::GetProperty(receiver_obj, name)); | 901 Object::GetProperty(receiver_obj, name)); |
902 if (!function->IsCallable()) { | 902 if (!function->IsCallable()) { |
903 THROW_NEW_ERROR_RETURN_FAILURE( | 903 THROW_NEW_ERROR_RETURN_FAILURE( |
904 isolate, NewTypeError(MessageTemplate::kCalledNonCallable, name)); | 904 isolate, NewTypeError(MessageTemplate::kCalledNonCallable, name)); |
905 } | 905 } |
906 RETURN_RESULT_OR_FAILURE( | 906 RETURN_RESULT_OR_FAILURE( |
907 isolate, Execution::Call(isolate, function, receiver_obj, 0, NULL)); | 907 isolate, Execution::Call(isolate, function, receiver_obj, 0, NULL)); |
908 } | 908 } |
909 } | 909 } |
910 | 910 |
911 namespace { | 911 // static |
912 | 912 void Builtins::Generate_DatePrototype_GetField(CodeStubAssembler* assembler, |
913 void Generate_DatePrototype_GetField(CodeStubAssembler* assembler, | 913 int field_index) { |
914 int field_index) { | |
915 typedef CodeStubAssembler::Label Label; | 914 typedef CodeStubAssembler::Label Label; |
916 typedef compiler::Node Node; | 915 typedef compiler::Node Node; |
917 | 916 |
918 Node* receiver = assembler->Parameter(0); | 917 Node* receiver = assembler->Parameter(0); |
919 Node* context = assembler->Parameter(3); | 918 Node* context = assembler->Parameter(3); |
920 | 919 |
921 Label receiver_not_date(assembler, Label::kDeferred); | 920 Label receiver_not_date(assembler, Label::kDeferred); |
922 | 921 |
923 assembler->GotoIf(assembler->TaggedIsSmi(receiver), &receiver_not_date); | 922 assembler->GotoIf(assembler->TaggedIsSmi(receiver), &receiver_not_date); |
924 Node* receiver_instance_type = assembler->LoadInstanceType(receiver); | 923 Node* receiver_instance_type = assembler->LoadInstanceType(receiver); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 } | 958 } |
960 | 959 |
961 // Raise a TypeError if the receiver is not a date. | 960 // Raise a TypeError if the receiver is not a date. |
962 assembler->Bind(&receiver_not_date); | 961 assembler->Bind(&receiver_not_date); |
963 { | 962 { |
964 Node* result = assembler->CallRuntime(Runtime::kThrowNotDateError, context); | 963 Node* result = assembler->CallRuntime(Runtime::kThrowNotDateError, context); |
965 assembler->Return(result); | 964 assembler->Return(result); |
966 } | 965 } |
967 } | 966 } |
968 | 967 |
969 } // namespace | |
970 | |
971 // static | 968 // static |
972 void Builtins::Generate_DatePrototypeGetDate( | 969 void Builtins::Generate_DatePrototypeGetDate(CodeStubAssembler* assembler) { |
973 compiler::CodeAssemblerState* state) { | 970 Generate_DatePrototype_GetField(assembler, JSDate::kDay); |
974 CodeStubAssembler assembler(state); | |
975 Generate_DatePrototype_GetField(&assembler, JSDate::kDay); | |
976 } | 971 } |
977 | 972 |
978 // static | 973 // static |
979 void Builtins::Generate_DatePrototypeGetDay( | 974 void Builtins::Generate_DatePrototypeGetDay(CodeStubAssembler* assembler) { |
980 compiler::CodeAssemblerState* state) { | 975 Generate_DatePrototype_GetField(assembler, JSDate::kWeekday); |
981 CodeStubAssembler assembler(state); | |
982 Generate_DatePrototype_GetField(&assembler, JSDate::kWeekday); | |
983 } | 976 } |
984 | 977 |
985 // static | 978 // static |
986 void Builtins::Generate_DatePrototypeGetFullYear( | 979 void Builtins::Generate_DatePrototypeGetFullYear(CodeStubAssembler* assembler) { |
987 compiler::CodeAssemblerState* state) { | 980 Generate_DatePrototype_GetField(assembler, JSDate::kYear); |
988 CodeStubAssembler assembler(state); | |
989 Generate_DatePrototype_GetField(&assembler, JSDate::kYear); | |
990 } | 981 } |
991 | 982 |
992 // static | 983 // static |
993 void Builtins::Generate_DatePrototypeGetHours( | 984 void Builtins::Generate_DatePrototypeGetHours(CodeStubAssembler* assembler) { |
994 compiler::CodeAssemblerState* state) { | 985 Generate_DatePrototype_GetField(assembler, JSDate::kHour); |
995 CodeStubAssembler assembler(state); | |
996 Generate_DatePrototype_GetField(&assembler, JSDate::kHour); | |
997 } | 986 } |
998 | 987 |
999 // static | 988 // static |
1000 void Builtins::Generate_DatePrototypeGetMilliseconds( | 989 void Builtins::Generate_DatePrototypeGetMilliseconds( |
1001 compiler::CodeAssemblerState* state) { | 990 CodeStubAssembler* assembler) { |
1002 CodeStubAssembler assembler(state); | 991 Generate_DatePrototype_GetField(assembler, JSDate::kMillisecond); |
1003 Generate_DatePrototype_GetField(&assembler, JSDate::kMillisecond); | |
1004 } | 992 } |
1005 | 993 |
1006 // static | 994 // static |
1007 void Builtins::Generate_DatePrototypeGetMinutes( | 995 void Builtins::Generate_DatePrototypeGetMinutes(CodeStubAssembler* assembler) { |
1008 compiler::CodeAssemblerState* state) { | 996 Generate_DatePrototype_GetField(assembler, JSDate::kMinute); |
1009 CodeStubAssembler assembler(state); | |
1010 Generate_DatePrototype_GetField(&assembler, JSDate::kMinute); | |
1011 } | 997 } |
1012 | 998 |
1013 // static | 999 // static |
1014 void Builtins::Generate_DatePrototypeGetMonth( | 1000 void Builtins::Generate_DatePrototypeGetMonth(CodeStubAssembler* assembler) { |
1015 compiler::CodeAssemblerState* state) { | 1001 Generate_DatePrototype_GetField(assembler, JSDate::kMonth); |
1016 CodeStubAssembler assembler(state); | |
1017 Generate_DatePrototype_GetField(&assembler, JSDate::kMonth); | |
1018 } | 1002 } |
1019 | 1003 |
1020 // static | 1004 // static |
1021 void Builtins::Generate_DatePrototypeGetSeconds( | 1005 void Builtins::Generate_DatePrototypeGetSeconds(CodeStubAssembler* assembler) { |
1022 compiler::CodeAssemblerState* state) { | 1006 Generate_DatePrototype_GetField(assembler, JSDate::kSecond); |
1023 CodeStubAssembler assembler(state); | |
1024 Generate_DatePrototype_GetField(&assembler, JSDate::kSecond); | |
1025 } | 1007 } |
1026 | 1008 |
1027 // static | 1009 // static |
1028 void Builtins::Generate_DatePrototypeGetTime( | 1010 void Builtins::Generate_DatePrototypeGetTime(CodeStubAssembler* assembler) { |
1029 compiler::CodeAssemblerState* state) { | 1011 Generate_DatePrototype_GetField(assembler, JSDate::kDateValue); |
1030 CodeStubAssembler assembler(state); | |
1031 Generate_DatePrototype_GetField(&assembler, JSDate::kDateValue); | |
1032 } | 1012 } |
1033 | 1013 |
1034 // static | 1014 // static |
1035 void Builtins::Generate_DatePrototypeGetTimezoneOffset( | 1015 void Builtins::Generate_DatePrototypeGetTimezoneOffset( |
1036 compiler::CodeAssemblerState* state) { | 1016 CodeStubAssembler* assembler) { |
1037 CodeStubAssembler assembler(state); | 1017 Generate_DatePrototype_GetField(assembler, JSDate::kTimezoneOffset); |
1038 Generate_DatePrototype_GetField(&assembler, JSDate::kTimezoneOffset); | |
1039 } | 1018 } |
1040 | 1019 |
1041 // static | 1020 // static |
1042 void Builtins::Generate_DatePrototypeGetUTCDate( | 1021 void Builtins::Generate_DatePrototypeGetUTCDate(CodeStubAssembler* assembler) { |
1043 compiler::CodeAssemblerState* state) { | 1022 Generate_DatePrototype_GetField(assembler, JSDate::kDayUTC); |
1044 CodeStubAssembler assembler(state); | |
1045 Generate_DatePrototype_GetField(&assembler, JSDate::kDayUTC); | |
1046 } | 1023 } |
1047 | 1024 |
1048 // static | 1025 // static |
1049 void Builtins::Generate_DatePrototypeGetUTCDay( | 1026 void Builtins::Generate_DatePrototypeGetUTCDay(CodeStubAssembler* assembler) { |
1050 compiler::CodeAssemblerState* state) { | 1027 Generate_DatePrototype_GetField(assembler, JSDate::kWeekdayUTC); |
1051 CodeStubAssembler assembler(state); | |
1052 Generate_DatePrototype_GetField(&assembler, JSDate::kWeekdayUTC); | |
1053 } | 1028 } |
1054 | 1029 |
1055 // static | 1030 // static |
1056 void Builtins::Generate_DatePrototypeGetUTCFullYear( | 1031 void Builtins::Generate_DatePrototypeGetUTCFullYear( |
1057 compiler::CodeAssemblerState* state) { | 1032 CodeStubAssembler* assembler) { |
1058 CodeStubAssembler assembler(state); | 1033 Generate_DatePrototype_GetField(assembler, JSDate::kYearUTC); |
1059 Generate_DatePrototype_GetField(&assembler, JSDate::kYearUTC); | |
1060 } | 1034 } |
1061 | 1035 |
1062 // static | 1036 // static |
1063 void Builtins::Generate_DatePrototypeGetUTCHours( | 1037 void Builtins::Generate_DatePrototypeGetUTCHours(CodeStubAssembler* assembler) { |
1064 compiler::CodeAssemblerState* state) { | 1038 Generate_DatePrototype_GetField(assembler, JSDate::kHourUTC); |
1065 CodeStubAssembler assembler(state); | |
1066 Generate_DatePrototype_GetField(&assembler, JSDate::kHourUTC); | |
1067 } | 1039 } |
1068 | 1040 |
1069 // static | 1041 // static |
1070 void Builtins::Generate_DatePrototypeGetUTCMilliseconds( | 1042 void Builtins::Generate_DatePrototypeGetUTCMilliseconds( |
1071 compiler::CodeAssemblerState* state) { | 1043 CodeStubAssembler* assembler) { |
1072 CodeStubAssembler assembler(state); | 1044 Generate_DatePrototype_GetField(assembler, JSDate::kMillisecondUTC); |
1073 Generate_DatePrototype_GetField(&assembler, JSDate::kMillisecondUTC); | |
1074 } | 1045 } |
1075 | 1046 |
1076 // static | 1047 // static |
1077 void Builtins::Generate_DatePrototypeGetUTCMinutes( | 1048 void Builtins::Generate_DatePrototypeGetUTCMinutes( |
1078 compiler::CodeAssemblerState* state) { | 1049 CodeStubAssembler* assembler) { |
1079 CodeStubAssembler assembler(state); | 1050 Generate_DatePrototype_GetField(assembler, JSDate::kMinuteUTC); |
1080 Generate_DatePrototype_GetField(&assembler, JSDate::kMinuteUTC); | |
1081 } | 1051 } |
1082 | 1052 |
1083 // static | 1053 // static |
1084 void Builtins::Generate_DatePrototypeGetUTCMonth( | 1054 void Builtins::Generate_DatePrototypeGetUTCMonth(CodeStubAssembler* assembler) { |
1085 compiler::CodeAssemblerState* state) { | 1055 Generate_DatePrototype_GetField(assembler, JSDate::kMonthUTC); |
1086 CodeStubAssembler assembler(state); | |
1087 Generate_DatePrototype_GetField(&assembler, JSDate::kMonthUTC); | |
1088 } | 1056 } |
1089 | 1057 |
1090 // static | 1058 // static |
1091 void Builtins::Generate_DatePrototypeGetUTCSeconds( | 1059 void Builtins::Generate_DatePrototypeGetUTCSeconds( |
1092 compiler::CodeAssemblerState* state) { | 1060 CodeStubAssembler* assembler) { |
1093 CodeStubAssembler assembler(state); | 1061 Generate_DatePrototype_GetField(assembler, JSDate::kSecondUTC); |
1094 Generate_DatePrototype_GetField(&assembler, JSDate::kSecondUTC); | |
1095 } | 1062 } |
1096 | 1063 |
1097 } // namespace internal | 1064 } // namespace internal |
1098 } // namespace v8 | 1065 } // namespace v8 |
OLD | NEW |