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

Side by Side Diff: src/x64/ic-x64.cc

Issue 21123008: Introduce StackArgumentsAccessor class for X64 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed nits Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/codegen-x64.cc ('k') | src/x64/stub-cache-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 // rcx : function name 897 // rcx : function name
898 // rsp[0] : return address 898 // rsp[0] : return address
899 // rsp[8] : argument argc 899 // rsp[8] : argument argc
900 // rsp[16] : argument argc - 1 900 // rsp[16] : argument argc - 1
901 // ... 901 // ...
902 // rsp[argc * 8] : argument 1 902 // rsp[argc * 8] : argument 1
903 // rsp[(argc + 1) * 8] : argument 0 = receiver 903 // rsp[(argc + 1) * 8] : argument 0 = receiver
904 // ----------------------------------- 904 // -----------------------------------
905 Label miss; 905 Label miss;
906 906
907 // Get the receiver of the function from the stack. 907 StackArgumentsAccessor args(rsp, argc);
908 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 908 __ movq(rdx, args.GetReceiverOperand());
909 909
910 GenerateNameDictionaryReceiverCheck(masm, rdx, rax, rbx, &miss); 910 GenerateNameDictionaryReceiverCheck(masm, rdx, rax, rbx, &miss);
911 911
912 // rax: elements 912 // rax: elements
913 // Search the dictionary placing the result in rdi. 913 // Search the dictionary placing the result in rdi.
914 GenerateDictionaryLoad(masm, &miss, rax, rcx, rbx, rdi, rdi); 914 GenerateDictionaryLoad(masm, &miss, rax, rcx, rbx, rdi, rdi);
915 915
916 GenerateFunctionTailCall(masm, argc, &miss); 916 GenerateFunctionTailCall(masm, argc, &miss);
917 917
918 __ bind(&miss); 918 __ bind(&miss);
(...skipping 14 matching lines...) Expand all
933 // rsp[(argc + 1) * 8] : argument 0 = receiver 933 // rsp[(argc + 1) * 8] : argument 0 = receiver
934 // ----------------------------------- 934 // -----------------------------------
935 935
936 Counters* counters = masm->isolate()->counters(); 936 Counters* counters = masm->isolate()->counters();
937 if (id == IC::kCallIC_Miss) { 937 if (id == IC::kCallIC_Miss) {
938 __ IncrementCounter(counters->call_miss(), 1); 938 __ IncrementCounter(counters->call_miss(), 1);
939 } else { 939 } else {
940 __ IncrementCounter(counters->keyed_call_miss(), 1); 940 __ IncrementCounter(counters->keyed_call_miss(), 1);
941 } 941 }
942 942
943 // Get the receiver of the function from the stack; 1 ~ return address. 943 StackArgumentsAccessor args(rsp, argc);
944 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 944 __ movq(rdx, args.GetReceiverOperand());
945 945
946 // Enter an internal frame. 946 // Enter an internal frame.
947 { 947 {
948 FrameScope scope(masm, StackFrame::INTERNAL); 948 FrameScope scope(masm, StackFrame::INTERNAL);
949 949
950 // Push the receiver and the name of the function. 950 // Push the receiver and the name of the function.
951 __ push(rdx); 951 __ push(rdx);
952 __ push(rcx); 952 __ push(rcx);
953 953
954 // Call the entry. 954 // Call the entry.
955 CEntryStub stub(1); 955 CEntryStub stub(1);
956 __ Set(rax, 2); 956 __ Set(rax, 2);
957 __ LoadAddress(rbx, ExternalReference(IC_Utility(id), masm->isolate())); 957 __ LoadAddress(rbx, ExternalReference(IC_Utility(id), masm->isolate()));
958 __ CallStub(&stub); 958 __ CallStub(&stub);
959 959
960 // Move result to rdi and exit the internal frame. 960 // Move result to rdi and exit the internal frame.
961 __ movq(rdi, rax); 961 __ movq(rdi, rax);
962 } 962 }
963 963
964 // Check if the receiver is a global object of some sort. 964 // Check if the receiver is a global object of some sort.
965 // This can happen only for regular CallIC but not KeyedCallIC. 965 // This can happen only for regular CallIC but not KeyedCallIC.
966 if (id == IC::kCallIC_Miss) { 966 if (id == IC::kCallIC_Miss) {
967 Label invoke, global; 967 Label invoke, global;
968 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); // receiver 968 __ movq(rdx, args.GetReceiverOperand());
969 __ JumpIfSmi(rdx, &invoke); 969 __ JumpIfSmi(rdx, &invoke);
970 __ CmpObjectType(rdx, JS_GLOBAL_OBJECT_TYPE, rcx); 970 __ CmpObjectType(rdx, JS_GLOBAL_OBJECT_TYPE, rcx);
971 __ j(equal, &global); 971 __ j(equal, &global);
972 __ CmpInstanceType(rcx, JS_BUILTINS_OBJECT_TYPE); 972 __ CmpInstanceType(rcx, JS_BUILTINS_OBJECT_TYPE);
973 __ j(not_equal, &invoke); 973 __ j(not_equal, &invoke);
974 974
975 // Patch the receiver on the stack. 975 // Patch the receiver on the stack.
976 __ bind(&global); 976 __ bind(&global);
977 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); 977 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset));
978 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); 978 __ movq(args.GetReceiverOperand(), rdx);
979 __ bind(&invoke); 979 __ bind(&invoke);
980 } 980 }
981 981
982 // Invoke the function. 982 // Invoke the function.
983 CallKind call_kind = CallICBase::Contextual::decode(extra_state) 983 CallKind call_kind = CallICBase::Contextual::decode(extra_state)
984 ? CALL_AS_FUNCTION 984 ? CALL_AS_FUNCTION
985 : CALL_AS_METHOD; 985 : CALL_AS_METHOD;
986 ParameterCount actual(argc); 986 ParameterCount actual(argc);
987 __ InvokeFunction(rdi, 987 __ InvokeFunction(rdi,
988 actual, 988 actual,
989 JUMP_FUNCTION, 989 JUMP_FUNCTION,
990 NullCallWrapper(), 990 NullCallWrapper(),
991 call_kind); 991 call_kind);
992 } 992 }
993 993
994 994
995 void CallIC::GenerateMegamorphic(MacroAssembler* masm, 995 void CallIC::GenerateMegamorphic(MacroAssembler* masm,
996 int argc, 996 int argc,
997 Code::ExtraICState extra_ic_state) { 997 Code::ExtraICState extra_ic_state) {
998 // ----------- S t a t e ------------- 998 // ----------- S t a t e -------------
999 // rcx : function name 999 // rcx : function name
1000 // rsp[0] : return address 1000 // rsp[0] : return address
1001 // rsp[8] : argument argc 1001 // rsp[8] : argument argc
1002 // rsp[16] : argument argc - 1 1002 // rsp[16] : argument argc - 1
1003 // ... 1003 // ...
1004 // rsp[argc * 8] : argument 1 1004 // rsp[argc * 8] : argument 1
1005 // rsp[(argc + 1) * 8] : argument 0 = receiver 1005 // rsp[(argc + 1) * 8] : argument 0 = receiver
1006 // ----------------------------------- 1006 // -----------------------------------
1007 1007
1008 // Get the receiver of the function from the stack; 1 ~ return address. 1008 StackArgumentsAccessor args(rsp, argc);
1009 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 1009 __ movq(rdx, args.GetReceiverOperand());
1010 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); 1010 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state);
1011 GenerateMiss(masm, argc, extra_ic_state); 1011 GenerateMiss(masm, argc, extra_ic_state);
1012 } 1012 }
1013 1013
1014 1014
1015 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { 1015 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) {
1016 // ----------- S t a t e ------------- 1016 // ----------- S t a t e -------------
1017 // rcx : function name 1017 // rcx : function name
1018 // rsp[0] : return address 1018 // rsp[0] : return address
1019 // rsp[8] : argument argc 1019 // rsp[8] : argument argc
1020 // rsp[16] : argument argc - 1 1020 // rsp[16] : argument argc - 1
1021 // ... 1021 // ...
1022 // rsp[argc * 8] : argument 1 1022 // rsp[argc * 8] : argument 1
1023 // rsp[(argc + 1) * 8] : argument 0 = receiver 1023 // rsp[(argc + 1) * 8] : argument 0 = receiver
1024 // ----------------------------------- 1024 // -----------------------------------
1025 1025
1026 // Get the receiver of the function from the stack; 1 ~ return address. 1026 StackArgumentsAccessor args(rsp, argc);
1027 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 1027 __ movq(rdx, args.GetReceiverOperand());
1028 1028
1029 Label do_call, slow_call, slow_load; 1029 Label do_call, slow_call, slow_load;
1030 Label check_number_dictionary, check_name, lookup_monomorphic_cache; 1030 Label check_number_dictionary, check_name, lookup_monomorphic_cache;
1031 Label index_smi, index_name; 1031 Label index_smi, index_name;
1032 1032
1033 // Check that the key is a smi. 1033 // Check that the key is a smi.
1034 __ JumpIfNotSmi(rcx, &check_name); 1034 __ JumpIfNotSmi(rcx, &check_name);
1035 1035
1036 __ bind(&index_smi); 1036 __ bind(&index_smi);
1037 // Now the key is known to be a smi. This place is also jumped to from below 1037 // Now the key is known to be a smi. This place is also jumped to from below
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 // ----------- S t a t e ------------- 1295 // ----------- S t a t e -------------
1296 // rcx : function name 1296 // rcx : function name
1297 // rsp[0] : return address 1297 // rsp[0] : return address
1298 // rsp[8] : argument argc 1298 // rsp[8] : argument argc
1299 // rsp[16] : argument argc - 1 1299 // rsp[16] : argument argc - 1
1300 // ... 1300 // ...
1301 // rsp[argc * 8] : argument 1 1301 // rsp[argc * 8] : argument 1
1302 // rsp[(argc + 1) * 8] : argument 0 = receiver 1302 // rsp[(argc + 1) * 8] : argument 0 = receiver
1303 // ----------------------------------- 1303 // -----------------------------------
1304 Label slow, notin; 1304 Label slow, notin;
1305 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 1305 StackArgumentsAccessor args(rsp, argc);
1306 __ movq(rdx, args.GetReceiverOperand());
1306 Operand mapped_location = GenerateMappedArgumentsLookup( 1307 Operand mapped_location = GenerateMappedArgumentsLookup(
1307 masm, rdx, rcx, rbx, rax, r8, &notin, &slow); 1308 masm, rdx, rcx, rbx, rax, r8, &notin, &slow);
1308 __ movq(rdi, mapped_location); 1309 __ movq(rdi, mapped_location);
1309 GenerateFunctionTailCall(masm, argc, &slow); 1310 GenerateFunctionTailCall(masm, argc, &slow);
1310 __ bind(&notin); 1311 __ bind(&notin);
1311 // The unmapped lookup expects that the parameter map is in rbx. 1312 // The unmapped lookup expects that the parameter map is in rbx.
1312 Operand unmapped_location = 1313 Operand unmapped_location =
1313 GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rax, &slow); 1314 GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rax, &slow);
1314 __ CompareRoot(unmapped_location, Heap::kTheHoleValueRootIndex); 1315 __ CompareRoot(unmapped_location, Heap::kTheHoleValueRootIndex);
1315 __ j(equal, &slow); 1316 __ j(equal, &slow);
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) 1678 Condition cc = (check == ENABLE_INLINED_SMI_CHECK)
1678 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) 1679 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero)
1679 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); 1680 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry);
1680 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); 1681 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc);
1681 } 1682 }
1682 1683
1683 1684
1684 } } // namespace v8::internal 1685 } } // namespace v8::internal
1685 1686
1686 #endif // V8_TARGET_ARCH_X64 1687 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/codegen-x64.cc ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698