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

Side by Side Diff: vm/stub_code_x64.cc

Issue 10542123: Add support for leaf runtime calls (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/assembler_macros.h" 9 #include "vm/assembler_macros.h"
10 #include "vm/code_generator.h" 10 #include "vm/code_generator.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 __ movq(Address(CTX, Isolate::top_context_offset()), raw_null); 83 __ movq(Address(CTX, Isolate::top_context_offset()), raw_null);
84 84
85 // Cache Context pointer into CTX while executing Dart code. 85 // Cache Context pointer into CTX while executing Dart code.
86 __ movq(CTX, RBX); 86 __ movq(CTX, RBX);
87 87
88 __ LeaveFrame(); 88 __ LeaveFrame();
89 __ ret(); 89 __ ret();
90 } 90 }
91 91
92 92
93 // Input parameters:
94 // RSP : points to return address.
95 // RSP + 8 : address of last argument in argument array.
96 // RSP + 8*R10 : address of first argument in argument array.
97 // RSP + 8*R10 + 8 : address of return value.
98 // RBX : address of the runtime function to call.
99 // R10 : number of arguments to the call.
100 // Must preserve callee saved registers R12 and R13.
101 void StubCode::GenerateCallToLeafRuntimeStub(Assembler* assembler) {
102 ASSERT((R12 != CTX) && (R13 != CTX));
103 const intptr_t isolate_offset = NativeArguments::isolate_offset();
104 const intptr_t argc_offset = NativeArguments::argc_offset();
105 const intptr_t argv_offset = NativeArguments::argv_offset();
106
107 __ EnterFrame(0);
108
109 // Reserve space for arguments and align frame before entering C++ world.
110 __ AddImmediate(RSP, Immediate(-sizeof(NativeArguments)));
111 if (OS::ActivationFrameAlignment() > 0) {
112 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1)));
113 }
114
115 // Pass NativeArguments structure by value.
116 // NOTE: the retvalue area in the NativeArguments structure is not setup
117 // as leaf routines return the value in RAX.
118 __ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs.
119 __ movq(Address(RSP, argc_offset), R10); // Set argc in NativeArguments.
120 __ leaq(RAX, Address(RBP, R10, TIMES_8, 1 * kWordSize)); // Compute argv.
121 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments.
122
123 // Make call to leaf runtime entry.
124 __ call(RBX);
125
126 // Set return value in caller's frame.
127 __ movq(RBX, Address(RSP, argv_offset));
128 __ addq(RBX, Immediate(1 * kWordSize)); // Retval is next to 1st argument.
129 __ movq(Address(RBX, 0), RAX);
130
131 __ LeaveFrame();
132 __ ret();
133 }
134
135
93 // Print the stop message. 136 // Print the stop message.
94 static void PrintStopMessage(const char* message) { 137 static void PrintStopMessage(const char* message) {
95 OS::Print("Stop message: %s\n", message); 138 OS::Print("Stop message: %s\n", message);
96 } 139 }
97 140
98 141
99 // Input parameters: 142 // Input parameters:
100 // RSP : points to return address. 143 // RSP : points to return address.
101 // RDI : stop message (const char*). 144 // RDI : stop message (const char*).
102 // Must preserve all registers, except RDI and TMP. 145 // Must preserve all registers, except RDI and TMP.
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 // TOS + 2: instance. 1867 // TOS + 2: instance.
1825 // TOS + 3: cache array. 1868 // TOS + 3: cache array.
1826 // Result in RCX: null -> not found, otherwise result (true or false). 1869 // Result in RCX: null -> not found, otherwise result (true or false).
1827 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { 1870 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) {
1828 GenerateSubtypeNTestCacheStub(assembler, 3); 1871 GenerateSubtypeNTestCacheStub(assembler, 3);
1829 } 1872 }
1830 1873
1831 } // namespace dart 1874 } // namespace dart
1832 1875
1833 #endif // defined TARGET_ARCH_X64 1876 #endif // defined TARGET_ARCH_X64
OLDNEW
« vm/stub_code_ia32.cc ('K') | « vm/stub_code_ia32_test.cc ('k') | vm/stub_code_x64_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698