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

Side by Side Diff: runtime/vm/stub_code_arm.cc

Issue 1156143003: Refactor Isolate -> Thread in NativeArguments and exception handler jump. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix comment; remove unused accessor. Created 5 years, 7 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 | « runtime/vm/simulator_mips.cc ('k') | runtime/vm/stub_code_arm64.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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 19 matching lines...) Expand all
30 DECLARE_FLAG(bool, support_debugger); 30 DECLARE_FLAG(bool, support_debugger);
31 31
32 // Input parameters: 32 // Input parameters:
33 // LR : return address. 33 // LR : return address.
34 // SP : address of last argument in argument array. 34 // SP : address of last argument in argument array.
35 // SP + 4*R4 - 4 : address of first argument in argument array. 35 // SP + 4*R4 - 4 : address of first argument in argument array.
36 // SP + 4*R4 : address of return value. 36 // SP + 4*R4 : address of return value.
37 // R5 : address of the runtime function to call. 37 // R5 : address of the runtime function to call.
38 // R4 : number of arguments to the call. 38 // R4 : number of arguments to the call.
39 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { 39 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
40 const intptr_t isolate_offset = NativeArguments::isolate_offset(); 40 const intptr_t thread_offset = NativeArguments::thread_offset();
41 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); 41 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset();
42 const intptr_t argv_offset = NativeArguments::argv_offset(); 42 const intptr_t argv_offset = NativeArguments::argv_offset();
43 const intptr_t retval_offset = NativeArguments::retval_offset(); 43 const intptr_t retval_offset = NativeArguments::retval_offset();
44 const intptr_t exitframe_last_param_slot_from_fp = 2; 44 const intptr_t exitframe_last_param_slot_from_fp = 2;
45 45
46 __ mov(IP, Operand(0)); 46 __ mov(IP, Operand(0));
47 __ Push(IP); // Push 0 for the PC marker. 47 __ Push(IP); // Push 0 for the PC marker.
48 __ EnterFrame((1 << FP) | (1 << LR), 0); 48 __ EnterFrame((1 << FP) | (1 << LR), 0);
49 49
50 COMPILE_ASSERT((kAbiPreservedCpuRegs & (1 << R9)) != 0); 50 COMPILE_ASSERT((kAbiPreservedCpuRegs & (1 << R9)) != 0);
(...skipping 18 matching lines...) Expand all
69 __ StoreToOffset(kWord, R5, R9, Isolate::vm_tag_offset()); 69 __ StoreToOffset(kWord, R5, R9, Isolate::vm_tag_offset());
70 70
71 // Reserve space for arguments and align frame before entering C++ world. 71 // Reserve space for arguments and align frame before entering C++ world.
72 // NativeArguments are passed in registers. 72 // NativeArguments are passed in registers.
73 ASSERT(sizeof(NativeArguments) == 4 * kWordSize); 73 ASSERT(sizeof(NativeArguments) == 4 * kWordSize);
74 __ ReserveAlignedFrameSpace(0); 74 __ ReserveAlignedFrameSpace(0);
75 75
76 // Pass NativeArguments structure by value and call runtime. 76 // Pass NativeArguments structure by value and call runtime.
77 // Registers R0, R1, R2, and R3 are used. 77 // Registers R0, R1, R2, and R3 are used.
78 78
79 ASSERT(isolate_offset == 0 * kWordSize); 79 ASSERT(thread_offset == 0 * kWordSize);
80 // Set isolate in NativeArgs. 80 // Set thread in NativeArgs.
81 __ mov(R0, Operand(R9)); 81 __ mov(R0, Operand(THR));
82 82
83 // There are no runtime calls to closures, so we do not need to set the tag 83 // There are no runtime calls to closures, so we do not need to set the tag
84 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. 84 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
85 ASSERT(argc_tag_offset == 1 * kWordSize); 85 ASSERT(argc_tag_offset == 1 * kWordSize);
86 __ mov(R1, Operand(R4)); // Set argc in NativeArguments. 86 __ mov(R1, Operand(R4)); // Set argc in NativeArguments.
87 87
88 ASSERT(argv_offset == 2 * kWordSize); 88 ASSERT(argv_offset == 2 * kWordSize);
89 __ add(R2, FP, Operand(R4, LSL, 2)); // Compute argv. 89 __ add(R2, FP, Operand(R4, LSL, 2)); // Compute argv.
90 // Set argv in NativeArguments. 90 // Set argv in NativeArguments.
91 __ AddImmediate(R2, exitframe_last_param_slot_from_fp * kWordSize); 91 __ AddImmediate(R2, exitframe_last_param_slot_from_fp * kWordSize);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 131
132 132
133 // Input parameters: 133 // Input parameters:
134 // LR : return address. 134 // LR : return address.
135 // SP : address of return value. 135 // SP : address of return value.
136 // R5 : address of the native function to call. 136 // R5 : address of the native function to call.
137 // R2 : address of first argument in argument array. 137 // R2 : address of first argument in argument array.
138 // R1 : argc_tag including number of arguments and function kind. 138 // R1 : argc_tag including number of arguments and function kind.
139 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { 139 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
140 const intptr_t isolate_offset = NativeArguments::isolate_offset(); 140 const intptr_t thread_offset = NativeArguments::thread_offset();
141 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); 141 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset();
142 const intptr_t argv_offset = NativeArguments::argv_offset(); 142 const intptr_t argv_offset = NativeArguments::argv_offset();
143 const intptr_t retval_offset = NativeArguments::retval_offset(); 143 const intptr_t retval_offset = NativeArguments::retval_offset();
144 144
145 __ mov(IP, Operand(0)); 145 __ mov(IP, Operand(0));
146 __ Push(IP); // Push 0 for the PC marker. 146 __ Push(IP); // Push 0 for the PC marker.
147 __ EnterFrame((1 << FP) | (1 << LR), 0); 147 __ EnterFrame((1 << FP) | (1 << LR), 0);
148 148
149 COMPILE_ASSERT((kAbiPreservedCpuRegs & (1 << R9)) != 0); 149 COMPILE_ASSERT((kAbiPreservedCpuRegs & (1 << R9)) != 0);
150 __ LoadIsolate(R9); 150 __ LoadIsolate(R9);
(...skipping 17 matching lines...) Expand all
168 __ StoreToOffset(kWord, R5, R9, Isolate::vm_tag_offset()); 168 __ StoreToOffset(kWord, R5, R9, Isolate::vm_tag_offset());
169 169
170 // Reserve space for the native arguments structure passed on the stack (the 170 // Reserve space for the native arguments structure passed on the stack (the
171 // outgoing pointer parameter to the native arguments structure is passed in 171 // outgoing pointer parameter to the native arguments structure is passed in
172 // R0) and align frame before entering the C++ world. 172 // R0) and align frame before entering the C++ world.
173 __ ReserveAlignedFrameSpace(sizeof(NativeArguments)); 173 __ ReserveAlignedFrameSpace(sizeof(NativeArguments));
174 174
175 // Initialize NativeArguments structure and call native function. 175 // Initialize NativeArguments structure and call native function.
176 // Registers R0, R1, R2, and R3 are used. 176 // Registers R0, R1, R2, and R3 are used.
177 177
178 ASSERT(isolate_offset == 0 * kWordSize); 178 ASSERT(thread_offset == 0 * kWordSize);
179 // Set isolate in NativeArgs. 179 // Set thread in NativeArgs.
180 __ mov(R0, Operand(R9)); 180 __ mov(R0, Operand(THR));
181 181
182 // There are no native calls to closures, so we do not need to set the tag 182 // There are no native calls to closures, so we do not need to set the tag
183 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. 183 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
184 ASSERT(argc_tag_offset == 1 * kWordSize); 184 ASSERT(argc_tag_offset == 1 * kWordSize);
185 // Set argc in NativeArguments: R1 already contains argc. 185 // Set argc in NativeArguments: R1 already contains argc.
186 186
187 ASSERT(argv_offset == 2 * kWordSize); 187 ASSERT(argv_offset == 2 * kWordSize);
188 // Set argv in NativeArguments: R2 already contains argv. 188 // Set argv in NativeArguments: R2 already contains argv.
189 189
190 ASSERT(retval_offset == 3 * kWordSize); 190 ASSERT(retval_offset == 3 * kWordSize);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 225
226 // Input parameters: 226 // Input parameters:
227 // LR : return address. 227 // LR : return address.
228 // SP : address of return value. 228 // SP : address of return value.
229 // R5 : address of the native function to call. 229 // R5 : address of the native function to call.
230 // R2 : address of first argument in argument array. 230 // R2 : address of first argument in argument array.
231 // R1 : argc_tag including number of arguments and function kind. 231 // R1 : argc_tag including number of arguments and function kind.
232 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) { 232 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) {
233 const intptr_t isolate_offset = NativeArguments::isolate_offset(); 233 const intptr_t thread_offset = NativeArguments::thread_offset();
234 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); 234 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset();
235 const intptr_t argv_offset = NativeArguments::argv_offset(); 235 const intptr_t argv_offset = NativeArguments::argv_offset();
236 const intptr_t retval_offset = NativeArguments::retval_offset(); 236 const intptr_t retval_offset = NativeArguments::retval_offset();
237 237
238 __ mov(IP, Operand(0)); 238 __ mov(IP, Operand(0));
239 __ Push(IP); // Push 0 for the PC marker. 239 __ Push(IP); // Push 0 for the PC marker.
240 __ EnterFrame((1 << FP) | (1 << LR), 0); 240 __ EnterFrame((1 << FP) | (1 << LR), 0);
241 241
242 COMPILE_ASSERT((kAbiPreservedCpuRegs & (1 << R9)) != 0); 242 COMPILE_ASSERT((kAbiPreservedCpuRegs & (1 << R9)) != 0);
243 __ LoadIsolate(R9); 243 __ LoadIsolate(R9);
(...skipping 17 matching lines...) Expand all
261 __ StoreToOffset(kWord, R5, R9, Isolate::vm_tag_offset()); 261 __ StoreToOffset(kWord, R5, R9, Isolate::vm_tag_offset());
262 262
263 // Reserve space for the native arguments structure passed on the stack (the 263 // Reserve space for the native arguments structure passed on the stack (the
264 // outgoing pointer parameter to the native arguments structure is passed in 264 // outgoing pointer parameter to the native arguments structure is passed in
265 // R0) and align frame before entering the C++ world. 265 // R0) and align frame before entering the C++ world.
266 __ ReserveAlignedFrameSpace(sizeof(NativeArguments)); 266 __ ReserveAlignedFrameSpace(sizeof(NativeArguments));
267 267
268 // Initialize NativeArguments structure and call native function. 268 // Initialize NativeArguments structure and call native function.
269 // Registers R0, R1, R2, and R3 are used. 269 // Registers R0, R1, R2, and R3 are used.
270 270
271 ASSERT(isolate_offset == 0 * kWordSize); 271 ASSERT(thread_offset == 0 * kWordSize);
272 // Set isolate in NativeArgs. 272 // Set thread in NativeArgs.
273 __ mov(R0, Operand(R9)); 273 __ mov(R0, Operand(THR));
274 274
275 // There are no native calls to closures, so we do not need to set the tag 275 // There are no native calls to closures, so we do not need to set the tag
276 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. 276 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
277 ASSERT(argc_tag_offset == 1 * kWordSize); 277 ASSERT(argc_tag_offset == 1 * kWordSize);
278 // Set argc in NativeArguments: R1 already contains argc. 278 // Set argc in NativeArguments: R1 already contains argc.
279 279
280 ASSERT(argv_offset == 2 * kWordSize); 280 ASSERT(argv_offset == 2 * kWordSize);
281 // Set argv in NativeArguments: R2 already contains argv. 281 // Set argv in NativeArguments: R2 already contains argv.
282 282
283 ASSERT(retval_offset == 3 * kWordSize); 283 ASSERT(retval_offset == 3 * kWordSize);
(...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 } 1909 }
1910 1910
1911 1911
1912 // Jump to the exception or error handler. 1912 // Jump to the exception or error handler.
1913 // LR: return address. 1913 // LR: return address.
1914 // R0: program_counter. 1914 // R0: program_counter.
1915 // R1: stack_pointer. 1915 // R1: stack_pointer.
1916 // R2: frame_pointer. 1916 // R2: frame_pointer.
1917 // R3: error object. 1917 // R3: error object.
1918 // SP + 0: address of stacktrace object. 1918 // SP + 0: address of stacktrace object.
1919 // SP + 4: isolate 1919 // SP + 4: thread.
1920 // Does not return. 1920 // Does not return.
1921 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) { 1921 void StubCode::GenerateJumpToExceptionHandlerStub(Assembler* assembler) {
1922 ASSERT(kExceptionObjectReg == R0); 1922 ASSERT(kExceptionObjectReg == R0);
1923 ASSERT(kStackTraceObjectReg == R1); 1923 ASSERT(kStackTraceObjectReg == R1);
1924 __ mov(IP, Operand(R1)); // Copy Stack pointer into IP. 1924 __ mov(IP, Operand(R1)); // Copy Stack pointer into IP.
1925 __ mov(LR, Operand(R0)); // Program counter. 1925 __ mov(LR, Operand(R0)); // Program counter.
1926 __ mov(R0, Operand(R3)); // Exception object. 1926 __ mov(R0, Operand(R3)); // Exception object.
1927 __ ldr(R1, Address(SP, 0)); // StackTrace object. 1927 __ ldr(R1, Address(SP, 0)); // StackTrace object.
1928 __ ldr(R3, Address(SP, 4)); // Isolate. 1928 __ ldr(THR, Address(SP, 4)); // Thread.
1929 __ mov(FP, Operand(R2)); // Frame_pointer. 1929 __ mov(FP, Operand(R2)); // Frame_pointer.
1930 __ mov(SP, Operand(IP)); // Set Stack pointer. 1930 __ mov(SP, Operand(IP)); // Set Stack pointer.
1931 // TODO(koda): Pass thread instead of isolate. 1931 __ LoadIsolate(R3);
1932 __ LoadFromOffset(kWord, THR, R3, Isolate::mutator_thread_offset());
1933 // Set the tag. 1932 // Set the tag.
1934 __ LoadImmediate(R2, VMTag::kDartTagId); 1933 __ LoadImmediate(R2, VMTag::kDartTagId);
1935 __ StoreToOffset(kWord, R2, R3, Isolate::vm_tag_offset()); 1934 __ StoreToOffset(kWord, R2, R3, Isolate::vm_tag_offset());
1936 // Clear top exit frame. 1935 // Clear top exit frame.
1937 __ LoadImmediate(R2, 0); 1936 __ LoadImmediate(R2, 0);
1938 __ StoreToOffset(kWord, R2, R3, Isolate::top_exit_frame_info_offset()); 1937 __ StoreToOffset(kWord, R2, R3, Isolate::top_exit_frame_info_offset());
1939 __ bx(LR); // Jump to the exception handler code. 1938 __ bx(LR); // Jump to the exception handler code.
1940 } 1939 }
1941 1940
1942 1941
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 // Result: 2135 // Result:
2137 // R1: entry point. 2136 // R1: entry point.
2138 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2137 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2139 EmitMegamorphicLookup(assembler, R0, R1, R1); 2138 EmitMegamorphicLookup(assembler, R0, R1, R1);
2140 __ Ret(); 2139 __ Ret();
2141 } 2140 }
2142 2141
2143 } // namespace dart 2142 } // namespace dart
2144 2143
2145 #endif // defined TARGET_ARCH_ARM 2144 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/simulator_mips.cc ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698