Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/builtins/builtins-date.cc

Issue 2263533002: [builtins] Migrate DatePrototype_GetField to TurboFan builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix C call return type Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins.h ('k') | src/builtins/ia32/builtins-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // static 911 // static
912 void Builtins::Generate_DatePrototypeGetDate(MacroAssembler* masm) { 912 void Builtins::Generate_DatePrototype_GetField(CodeStubAssembler* assembler,
913 Generate_DatePrototype_GetField(masm, JSDate::kDay); 913 int field_index) {
914 typedef CodeStubAssembler::Label Label;
915 typedef compiler::Node Node;
916
917 Node* receiver = assembler->Parameter(0);
918 Node* context = assembler->Parameter(3);
919
920 Label receiver_not_date(assembler, Label::kDeferred);
921
922 assembler->GotoIf(assembler->WordIsSmi(receiver), &receiver_not_date);
923 Node* receiver_instance_type = assembler->LoadInstanceType(receiver);
924 assembler->GotoIf(
925 assembler->Word32NotEqual(receiver_instance_type,
926 assembler->Int32Constant(JS_DATE_TYPE)),
927 &receiver_not_date);
928
929 // Load the specified date field, falling back to the runtime as necessary.
930 if (field_index == JSDate::kDateValue) {
931 assembler->Return(
932 assembler->LoadObjectField(receiver, JSDate::kValueOffset));
933 } else {
934 if (field_index < JSDate::kFirstUncachedField) {
935 Label stamp_mismatch(assembler, Label::kDeferred);
936 Node* date_cache_stamp = assembler->Load(
937 MachineType::AnyTagged(),
938 assembler->ExternalConstant(
939 ExternalReference::date_cache_stamp(assembler->isolate())));
940
941 Node* cache_stamp =
942 assembler->LoadObjectField(receiver, JSDate::kCacheStampOffset);
943 assembler->GotoIf(assembler->WordNotEqual(date_cache_stamp, cache_stamp),
944 &stamp_mismatch);
945 assembler->Return(assembler->LoadObjectField(
946 receiver, JSDate::kValueOffset + field_index * kPointerSize));
947
948 assembler->Bind(&stamp_mismatch);
949 }
950
951 Node* field_index_smi = assembler->SmiConstant(Smi::FromInt(field_index));
952 Node* function = assembler->ExternalConstant(
953 ExternalReference::get_date_field_function(assembler->isolate()));
954 Node* result = assembler->CallCFunction2(
955 MachineType::AnyTagged(), MachineType::Pointer(),
956 MachineType::AnyTagged(), function, receiver, field_index_smi);
957 assembler->Return(result);
958 }
959
960 // Raise a TypeError if the receiver is not a date.
961 assembler->Bind(&receiver_not_date);
962 {
963 Node* result = assembler->CallRuntime(Runtime::kThrowNotDateError, context);
964 assembler->Return(result);
965 }
914 } 966 }
915 967
916 // static 968 // static
917 void Builtins::Generate_DatePrototypeGetDay(MacroAssembler* masm) { 969 void Builtins::Generate_DatePrototypeGetDate(CodeStubAssembler* assembler) {
918 Generate_DatePrototype_GetField(masm, JSDate::kWeekday); 970 Generate_DatePrototype_GetField(assembler, JSDate::kDay);
919 } 971 }
920 972
921 // static 973 // static
922 void Builtins::Generate_DatePrototypeGetFullYear(MacroAssembler* masm) { 974 void Builtins::Generate_DatePrototypeGetDay(CodeStubAssembler* assembler) {
923 Generate_DatePrototype_GetField(masm, JSDate::kYear); 975 Generate_DatePrototype_GetField(assembler, JSDate::kWeekday);
924 } 976 }
925 977
926 // static 978 // static
927 void Builtins::Generate_DatePrototypeGetHours(MacroAssembler* masm) { 979 void Builtins::Generate_DatePrototypeGetFullYear(CodeStubAssembler* assembler) {
928 Generate_DatePrototype_GetField(masm, JSDate::kHour); 980 Generate_DatePrototype_GetField(assembler, JSDate::kYear);
929 } 981 }
930 982
931 // static 983 // static
932 void Builtins::Generate_DatePrototypeGetMilliseconds(MacroAssembler* masm) { 984 void Builtins::Generate_DatePrototypeGetHours(CodeStubAssembler* assembler) {
933 Generate_DatePrototype_GetField(masm, JSDate::kMillisecond); 985 Generate_DatePrototype_GetField(assembler, JSDate::kHour);
934 } 986 }
935 987
936 // static 988 // static
937 void Builtins::Generate_DatePrototypeGetMinutes(MacroAssembler* masm) { 989 void Builtins::Generate_DatePrototypeGetMilliseconds(
938 Generate_DatePrototype_GetField(masm, JSDate::kMinute); 990 CodeStubAssembler* assembler) {
991 Generate_DatePrototype_GetField(assembler, JSDate::kMillisecond);
939 } 992 }
940 993
941 // static 994 // static
942 void Builtins::Generate_DatePrototypeGetMonth(MacroAssembler* masm) { 995 void Builtins::Generate_DatePrototypeGetMinutes(CodeStubAssembler* assembler) {
943 Generate_DatePrototype_GetField(masm, JSDate::kMonth); 996 Generate_DatePrototype_GetField(assembler, JSDate::kMinute);
944 } 997 }
945 998
946 // static 999 // static
947 void Builtins::Generate_DatePrototypeGetSeconds(MacroAssembler* masm) { 1000 void Builtins::Generate_DatePrototypeGetMonth(CodeStubAssembler* assembler) {
948 Generate_DatePrototype_GetField(masm, JSDate::kSecond); 1001 Generate_DatePrototype_GetField(assembler, JSDate::kMonth);
949 } 1002 }
950 1003
951 // static 1004 // static
952 void Builtins::Generate_DatePrototypeGetTime(MacroAssembler* masm) { 1005 void Builtins::Generate_DatePrototypeGetSeconds(CodeStubAssembler* assembler) {
953 Generate_DatePrototype_GetField(masm, JSDate::kDateValue); 1006 Generate_DatePrototype_GetField(assembler, JSDate::kSecond);
954 } 1007 }
955 1008
956 // static 1009 // static
957 void Builtins::Generate_DatePrototypeGetTimezoneOffset(MacroAssembler* masm) { 1010 void Builtins::Generate_DatePrototypeGetTime(CodeStubAssembler* assembler) {
958 Generate_DatePrototype_GetField(masm, JSDate::kTimezoneOffset); 1011 Generate_DatePrototype_GetField(assembler, JSDate::kDateValue);
959 } 1012 }
960 1013
961 // static 1014 // static
962 void Builtins::Generate_DatePrototypeGetUTCDate(MacroAssembler* masm) { 1015 void Builtins::Generate_DatePrototypeGetTimezoneOffset(
963 Generate_DatePrototype_GetField(masm, JSDate::kDayUTC); 1016 CodeStubAssembler* assembler) {
1017 Generate_DatePrototype_GetField(assembler, JSDate::kTimezoneOffset);
964 } 1018 }
965 1019
966 // static 1020 // static
967 void Builtins::Generate_DatePrototypeGetUTCDay(MacroAssembler* masm) { 1021 void Builtins::Generate_DatePrototypeGetUTCDate(CodeStubAssembler* assembler) {
968 Generate_DatePrototype_GetField(masm, JSDate::kWeekdayUTC); 1022 Generate_DatePrototype_GetField(assembler, JSDate::kDayUTC);
969 } 1023 }
970 1024
971 // static 1025 // static
972 void Builtins::Generate_DatePrototypeGetUTCFullYear(MacroAssembler* masm) { 1026 void Builtins::Generate_DatePrototypeGetUTCDay(CodeStubAssembler* assembler) {
973 Generate_DatePrototype_GetField(masm, JSDate::kYearUTC); 1027 Generate_DatePrototype_GetField(assembler, JSDate::kWeekdayUTC);
974 } 1028 }
975 1029
976 // static 1030 // static
977 void Builtins::Generate_DatePrototypeGetUTCHours(MacroAssembler* masm) { 1031 void Builtins::Generate_DatePrototypeGetUTCFullYear(
978 Generate_DatePrototype_GetField(masm, JSDate::kHourUTC); 1032 CodeStubAssembler* assembler) {
1033 Generate_DatePrototype_GetField(assembler, JSDate::kYearUTC);
979 } 1034 }
980 1035
981 // static 1036 // static
982 void Builtins::Generate_DatePrototypeGetUTCMilliseconds(MacroAssembler* masm) { 1037 void Builtins::Generate_DatePrototypeGetUTCHours(CodeStubAssembler* assembler) {
983 Generate_DatePrototype_GetField(masm, JSDate::kMillisecondUTC); 1038 Generate_DatePrototype_GetField(assembler, JSDate::kHourUTC);
984 } 1039 }
985 1040
986 // static 1041 // static
987 void Builtins::Generate_DatePrototypeGetUTCMinutes(MacroAssembler* masm) { 1042 void Builtins::Generate_DatePrototypeGetUTCMilliseconds(
988 Generate_DatePrototype_GetField(masm, JSDate::kMinuteUTC); 1043 CodeStubAssembler* assembler) {
1044 Generate_DatePrototype_GetField(assembler, JSDate::kMillisecondUTC);
989 } 1045 }
990 1046
991 // static 1047 // static
992 void Builtins::Generate_DatePrototypeGetUTCMonth(MacroAssembler* masm) { 1048 void Builtins::Generate_DatePrototypeGetUTCMinutes(
993 Generate_DatePrototype_GetField(masm, JSDate::kMonthUTC); 1049 CodeStubAssembler* assembler) {
1050 Generate_DatePrototype_GetField(assembler, JSDate::kMinuteUTC);
994 } 1051 }
995 1052
996 // static 1053 // static
997 void Builtins::Generate_DatePrototypeGetUTCSeconds(MacroAssembler* masm) { 1054 void Builtins::Generate_DatePrototypeGetUTCMonth(CodeStubAssembler* assembler) {
998 Generate_DatePrototype_GetField(masm, JSDate::kSecondUTC); 1055 Generate_DatePrototype_GetField(assembler, JSDate::kMonthUTC);
1056 }
1057
1058 // static
1059 void Builtins::Generate_DatePrototypeGetUTCSeconds(
1060 CodeStubAssembler* assembler) {
1061 Generate_DatePrototype_GetField(assembler, JSDate::kSecondUTC);
999 } 1062 }
1000 1063
1001 } // namespace internal 1064 } // namespace internal
1002 } // namespace v8 1065 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/builtins/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698