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

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

Issue 18607002: Format stack layout comments for X64 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 5 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 | « no previous file | src/x64/code-stubs-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 26 matching lines...) Expand all
37 namespace internal { 37 namespace internal {
38 38
39 39
40 #define __ ACCESS_MASM(masm) 40 #define __ ACCESS_MASM(masm)
41 41
42 42
43 void Builtins::Generate_Adaptor(MacroAssembler* masm, 43 void Builtins::Generate_Adaptor(MacroAssembler* masm,
44 CFunctionId id, 44 CFunctionId id,
45 BuiltinExtraArguments extra_args) { 45 BuiltinExtraArguments extra_args) {
46 // ----------- S t a t e ------------- 46 // ----------- S t a t e -------------
47 // -- rax : number of arguments excluding receiver 47 // -- rax : number of arguments excluding receiver
48 // -- rdi : called function (only guaranteed when 48 // -- rdi : called function (only guaranteed when
49 // extra_args requires it) 49 // extra_args requires it)
50 // -- rsi : context 50 // -- rsi : context
51 // -- rsp[0] : return address 51 // -- rsp[0] : return address
52 // -- rsp[8] : last argument 52 // -- rsp[8] : last argument
53 // -- ... 53 // -- ...
54 // -- rsp[8 * argc] : first argument (argc == rax) 54 // -- rsp[8 * argc] : first argument (argc == rax)
55 // -- rsp[8 * (argc +1)] : receiver 55 // -- rsp[8 * (argc + 1)] : receiver
56 // ----------------------------------- 56 // -----------------------------------
57 57
58 // Insert extra arguments. 58 // Insert extra arguments.
59 int num_extra_args = 0; 59 int num_extra_args = 0;
60 if (extra_args == NEEDS_CALLED_FUNCTION) { 60 if (extra_args == NEEDS_CALLED_FUNCTION) {
61 num_extra_args = 1; 61 num_extra_args = 1;
62 __ pop(kScratchRegister); // Save return address. 62 __ pop(kScratchRegister); // Save return address.
63 __ push(rdi); 63 __ push(rdi);
64 __ push(kScratchRegister); // Restore return address. 64 __ push(kScratchRegister); // Restore return address.
65 } else { 65 } else {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 468
469 // Open a C++ scope for the FrameScope. 469 // Open a C++ scope for the FrameScope.
470 { 470 {
471 // Platform specific argument handling. After this, the stack contains 471 // Platform specific argument handling. After this, the stack contains
472 // an internal frame and the pushed function and receiver, and 472 // an internal frame and the pushed function and receiver, and
473 // register rax and rbx holds the argument count and argument array, 473 // register rax and rbx holds the argument count and argument array,
474 // while rdi holds the function pointer and rsi the context. 474 // while rdi holds the function pointer and rsi the context.
475 475
476 #ifdef _WIN64 476 #ifdef _WIN64
477 // MSVC parameters in: 477 // MSVC parameters in:
478 // rcx : entry (ignored) 478 // rcx : entry (ignored)
479 // rdx : function 479 // rdx : function
480 // r8 : receiver 480 // r8 : receiver
481 // r9 : argc 481 // r9 : argc
482 // [rsp+0x20] : argv 482 // [rsp+0x20] : argv
483 483
484 // Clear the context before we push it when entering the internal frame. 484 // Clear the context before we push it when entering the internal frame.
485 __ Set(rsi, 0); 485 __ Set(rsi, 0);
486 // Enter an internal frame. 486 // Enter an internal frame.
487 FrameScope scope(masm, StackFrame::INTERNAL); 487 FrameScope scope(masm, StackFrame::INTERNAL);
488 488
489 // Load the function context into rsi. 489 // Load the function context into rsi.
490 __ movq(rsi, FieldOperand(rdx, JSFunction::kContextOffset)); 490 __ movq(rsi, FieldOperand(rdx, JSFunction::kContextOffset));
491 491
(...skipping 28 matching lines...) Expand all
520 __ push(rdi); 520 __ push(rdi);
521 __ push(rdx); 521 __ push(rdx);
522 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 522 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
523 523
524 // Load the number of arguments and setup pointer to the arguments. 524 // Load the number of arguments and setup pointer to the arguments.
525 __ movq(rax, rcx); 525 __ movq(rax, rcx);
526 __ movq(rbx, r8); 526 __ movq(rbx, r8);
527 #endif // _WIN64 527 #endif // _WIN64
528 528
529 // Current stack contents: 529 // Current stack contents:
530 // [rsp + 2 * kPointerSize ... ]: Internal frame 530 // [rsp + 2 * kPointerSize ... ] : Internal frame
531 // [rsp + kPointerSize] : function 531 // [rsp + kPointerSize] : function
532 // [rsp] : receiver 532 // [rsp] : receiver
533 // Current register contents: 533 // Current register contents:
534 // rax : argc 534 // rax : argc
535 // rbx : argv 535 // rbx : argv
536 // rsi : context 536 // rsi : context
537 // rdi : function 537 // rdi : function
538 538
539 // Copy arguments to the stack in a loop. 539 // Copy arguments to the stack in a loop.
540 // Register rbx points to array of pointers to handle locations. 540 // Register rbx points to array of pointers to handle locations.
541 // Push the values of these handles. 541 // Push the values of these handles.
542 Label loop, entry; 542 Label loop, entry;
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 FrameScope scope(masm, StackFrame::INTERNAL); 751 FrameScope scope(masm, StackFrame::INTERNAL);
752 __ CallRuntime(Runtime::kNotifyOSR, 0); 752 __ CallRuntime(Runtime::kNotifyOSR, 0);
753 } 753 }
754 __ Popad(); 754 __ Popad();
755 __ ret(0); 755 __ ret(0);
756 } 756 }
757 757
758 758
759 void Builtins::Generate_FunctionCall(MacroAssembler* masm) { 759 void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
760 // Stack Layout: 760 // Stack Layout:
761 // rsp[0]: Return address 761 // rsp[0] : Return address
762 // rsp[1]: Argument n 762 // rsp[8] : Argument n
763 // rsp[2]: Argument n-1 763 // rsp[16] : Argument n-1
764 // ... 764 // ...
765 // rsp[n]: Argument 1 765 // rsp[8 * n] : Argument 1
766 // rsp[n+1]: Receiver (function to call) 766 // rsp[8 * (n + 1)] : Receiver (function to call)
767 // 767 //
768 // rax contains the number of arguments, n, not counting the receiver. 768 // rax contains the number of arguments, n, not counting the receiver.
769 // 769 //
770 // 1. Make sure we have at least one argument. 770 // 1. Make sure we have at least one argument.
771 { Label done; 771 { Label done;
772 __ testq(rax, rax); 772 __ testq(rax, rax);
773 __ j(not_zero, &done); 773 __ j(not_zero, &done);
774 __ pop(rbx); 774 __ pop(rbx);
775 __ Push(masm->isolate()->factory()->undefined_value()); 775 __ Push(masm->isolate()->factory()->undefined_value());
776 __ push(rbx); 776 __ push(rbx);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
924 RelocInfo::CODE_TARGET); 924 RelocInfo::CODE_TARGET);
925 925
926 ParameterCount expected(0); 926 ParameterCount expected(0);
927 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION, 927 __ InvokeCode(rdx, expected, expected, JUMP_FUNCTION,
928 NullCallWrapper(), CALL_AS_METHOD); 928 NullCallWrapper(), CALL_AS_METHOD);
929 } 929 }
930 930
931 931
932 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { 932 void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
933 // Stack at entry: 933 // Stack at entry:
934 // rsp: return address 934 // rsp : return address
935 // rsp+8: arguments 935 // rsp[8] : arguments
936 // rsp+16: receiver ("this") 936 // rsp[16] : receiver ("this")
937 // rsp+24: function 937 // rsp[24] : function
938 { 938 {
939 FrameScope frame_scope(masm, StackFrame::INTERNAL); 939 FrameScope frame_scope(masm, StackFrame::INTERNAL);
940 // Stack frame: 940 // Stack frame:
941 // rbp: Old base pointer 941 // rbp : Old base pointer
942 // rbp[1]: return address 942 // rbp[8] : return address
943 // rbp[2]: function arguments 943 // rbp[16] : function arguments
944 // rbp[3]: receiver 944 // rbp[24] : receiver
945 // rbp[4]: function 945 // rbp[32] : function
946 static const int kArgumentsOffset = 2 * kPointerSize; 946 static const int kArgumentsOffset = 2 * kPointerSize;
947 static const int kReceiverOffset = 3 * kPointerSize; 947 static const int kReceiverOffset = 3 * kPointerSize;
948 static const int kFunctionOffset = 4 * kPointerSize; 948 static const int kFunctionOffset = 4 * kPointerSize;
949 949
950 __ push(Operand(rbp, kFunctionOffset)); 950 __ push(Operand(rbp, kFunctionOffset));
951 __ push(Operand(rbp, kArgumentsOffset)); 951 __ push(Operand(rbp, kArgumentsOffset));
952 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION); 952 __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_FUNCTION);
953 953
954 // Check the stack for overflow. We are not trying to catch 954 // Check the stack for overflow. We are not trying to catch
955 // interruptions (e.g. debug break and preemption) here, so the "real stack 955 // interruptions (e.g. debug break and preemption) here, so the "real stack
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 RelocInfo::CODE_TARGET); 1090 RelocInfo::CODE_TARGET);
1091 1091
1092 // Leave internal frame. 1092 // Leave internal frame.
1093 } 1093 }
1094 __ ret(3 * kPointerSize); // remove this, receiver, and arguments 1094 __ ret(3 * kPointerSize); // remove this, receiver, and arguments
1095 } 1095 }
1096 1096
1097 1097
1098 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { 1098 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
1099 // ----------- S t a t e ------------- 1099 // ----------- S t a t e -------------
1100 // -- rax : argc 1100 // -- rax : argc
1101 // -- rsp[0] : return address 1101 // -- rsp[0] : return address
1102 // -- rsp[8] : last argument 1102 // -- rsp[8] : last argument
1103 // ----------------------------------- 1103 // -----------------------------------
1104 Label generic_array_code; 1104 Label generic_array_code;
1105 1105
1106 // Get the InternalArray function. 1106 // Get the InternalArray function.
1107 __ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, rdi); 1107 __ LoadGlobalFunction(Context::INTERNAL_ARRAY_FUNCTION_INDEX, rdi);
1108 1108
1109 if (FLAG_debug_code) { 1109 if (FLAG_debug_code) {
1110 // Initial map for the builtin InternalArray functions should be maps. 1110 // Initial map for the builtin InternalArray functions should be maps.
1111 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset)); 1111 __ movq(rbx, FieldOperand(rdi, JSFunction::kPrototypeOrInitialMapOffset));
1112 // Will both indicate a NULL and a Smi. 1112 // Will both indicate a NULL and a Smi.
1113 STATIC_ASSERT(kSmiTag == 0); 1113 STATIC_ASSERT(kSmiTag == 0);
1114 Condition not_smi = NegateCondition(masm->CheckSmi(rbx)); 1114 Condition not_smi = NegateCondition(masm->CheckSmi(rbx));
1115 __ Check(not_smi, "Unexpected initial map for InternalArray function"); 1115 __ Check(not_smi, "Unexpected initial map for InternalArray function");
1116 __ CmpObjectType(rbx, MAP_TYPE, rcx); 1116 __ CmpObjectType(rbx, MAP_TYPE, rcx);
1117 __ Check(equal, "Unexpected initial map for InternalArray function"); 1117 __ Check(equal, "Unexpected initial map for InternalArray function");
1118 } 1118 }
1119 1119
1120 // Run the native code for the InternalArray function called as a normal 1120 // Run the native code for the InternalArray function called as a normal
1121 // function. 1121 // function.
1122 // tail call a stub 1122 // tail call a stub
1123 InternalArrayConstructorStub stub(masm->isolate()); 1123 InternalArrayConstructorStub stub(masm->isolate());
1124 __ TailCallStub(&stub); 1124 __ TailCallStub(&stub);
1125 } 1125 }
1126 1126
1127 1127
1128 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { 1128 void Builtins::Generate_ArrayCode(MacroAssembler* masm) {
1129 // ----------- S t a t e ------------- 1129 // ----------- S t a t e -------------
1130 // -- rax : argc 1130 // -- rax : argc
1131 // -- rsp[0] : return address 1131 // -- rsp[0] : return address
1132 // -- rsp[8] : last argument 1132 // -- rsp[8] : last argument
1133 // ----------------------------------- 1133 // -----------------------------------
1134 Label generic_array_code; 1134 Label generic_array_code;
1135 1135
1136 // Get the Array function. 1136 // Get the Array function.
1137 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rdi); 1137 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rdi);
1138 1138
1139 if (FLAG_debug_code) { 1139 if (FLAG_debug_code) {
1140 // Initial map for the builtin Array functions should be maps. 1140 // Initial map for the builtin Array functions should be maps.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); 1434 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR);
1435 generator.Generate(); 1435 generator.Generate();
1436 } 1436 }
1437 1437
1438 1438
1439 #undef __ 1439 #undef __
1440 1440
1441 } } // namespace v8::internal 1441 } } // namespace v8::internal
1442 1442
1443 #endif // V8_TARGET_ARCH_X64 1443 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « no previous file | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698