OLD | NEW |
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_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // Must preserve callee saved registers R12 and R13. | 37 // Must preserve callee saved registers R12 and R13. |
38 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { | 38 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
39 ASSERT((R12 != CTX) && (R13 != CTX)); | 39 ASSERT((R12 != CTX) && (R13 != CTX)); |
40 const intptr_t isolate_offset = NativeArguments::isolate_offset(); | 40 const intptr_t isolate_offset = NativeArguments::isolate_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 | 44 |
45 __ EnterFrame(0); | 45 __ EnterFrame(0); |
46 | 46 |
47 // Load current Isolate pointer from Context structure into RAX. | 47 __ LoadIsolate(RAX); |
48 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | |
49 | 48 |
50 // Save exit frame information to enable stack walking as we are about | 49 // Save exit frame information to enable stack walking as we are about |
51 // to transition to Dart VM C++ code. | 50 // to transition to Dart VM C++ code. |
52 __ movq(Address(RAX, Isolate::top_exit_frame_info_offset()), RSP); | 51 __ movq(Address(RAX, Isolate::top_exit_frame_info_offset()), RSP); |
53 | 52 |
54 // Save current Context pointer into Isolate structure. | 53 // Save current Context pointer into Isolate structure. |
55 __ movq(Address(RAX, Isolate::top_context_offset()), CTX); | 54 __ movq(Address(RAX, Isolate::top_context_offset()), CTX); |
56 | 55 |
57 // Cache Isolate pointer into CTX while executing runtime code. | 56 // Cache Isolate pointer into CTX while executing runtime code. |
58 __ movq(CTX, RAX); | 57 __ movq(CTX, RAX); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 NativeArguments::isolate_offset() + native_args_struct_offset; | 148 NativeArguments::isolate_offset() + native_args_struct_offset; |
150 const intptr_t argc_tag_offset = | 149 const intptr_t argc_tag_offset = |
151 NativeArguments::argc_tag_offset() + native_args_struct_offset; | 150 NativeArguments::argc_tag_offset() + native_args_struct_offset; |
152 const intptr_t argv_offset = | 151 const intptr_t argv_offset = |
153 NativeArguments::argv_offset() + native_args_struct_offset; | 152 NativeArguments::argv_offset() + native_args_struct_offset; |
154 const intptr_t retval_offset = | 153 const intptr_t retval_offset = |
155 NativeArguments::retval_offset() + native_args_struct_offset; | 154 NativeArguments::retval_offset() + native_args_struct_offset; |
156 | 155 |
157 __ EnterFrame(0); | 156 __ EnterFrame(0); |
158 | 157 |
159 // Load current Isolate pointer from Context structure into R8. | 158 __ LoadIsolate(R8); |
160 __ movq(R8, FieldAddress(CTX, Context::isolate_offset())); | |
161 | 159 |
162 // Save exit frame information to enable stack walking as we are about | 160 // Save exit frame information to enable stack walking as we are about |
163 // to transition to native code. | 161 // to transition to native code. |
164 __ movq(Address(R8, Isolate::top_exit_frame_info_offset()), RSP); | 162 __ movq(Address(R8, Isolate::top_exit_frame_info_offset()), RSP); |
165 | 163 |
166 // Save current Context pointer into Isolate structure. | 164 // Save current Context pointer into Isolate structure. |
167 __ movq(Address(R8, Isolate::top_context_offset()), CTX); | 165 __ movq(Address(R8, Isolate::top_context_offset()), CTX); |
168 | 166 |
169 // Cache Isolate pointer into CTX while executing native code. | 167 // Cache Isolate pointer into CTX while executing native code. |
170 __ movq(CTX, R8); | 168 __ movq(CTX, R8); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 NativeArguments::isolate_offset() + native_args_struct_offset; | 236 NativeArguments::isolate_offset() + native_args_struct_offset; |
239 const intptr_t argc_tag_offset = | 237 const intptr_t argc_tag_offset = |
240 NativeArguments::argc_tag_offset() + native_args_struct_offset; | 238 NativeArguments::argc_tag_offset() + native_args_struct_offset; |
241 const intptr_t argv_offset = | 239 const intptr_t argv_offset = |
242 NativeArguments::argv_offset() + native_args_struct_offset; | 240 NativeArguments::argv_offset() + native_args_struct_offset; |
243 const intptr_t retval_offset = | 241 const intptr_t retval_offset = |
244 NativeArguments::retval_offset() + native_args_struct_offset; | 242 NativeArguments::retval_offset() + native_args_struct_offset; |
245 | 243 |
246 __ EnterFrame(0); | 244 __ EnterFrame(0); |
247 | 245 |
248 // Load current Isolate pointer from Context structure into R8. | 246 __ LoadIsolate(R8); |
249 __ movq(R8, FieldAddress(CTX, Context::isolate_offset())); | |
250 | 247 |
251 // Save exit frame information to enable stack walking as we are about | 248 // Save exit frame information to enable stack walking as we are about |
252 // to transition to native code. | 249 // to transition to native code. |
253 __ movq(Address(R8, Isolate::top_exit_frame_info_offset()), RSP); | 250 __ movq(Address(R8, Isolate::top_exit_frame_info_offset()), RSP); |
254 | 251 |
255 // Save current Context pointer into Isolate structure. | 252 // Save current Context pointer into Isolate structure. |
256 __ movq(Address(R8, Isolate::top_context_offset()), CTX); | 253 __ movq(Address(R8, Isolate::top_context_offset()), CTX); |
257 | 254 |
258 // Cache Isolate pointer into CTX while executing native code. | 255 // Cache Isolate pointer into CTX while executing native code. |
259 __ movq(CTX, R8); | 256 __ movq(CTX, R8); |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 __ orq(R13, | 969 __ orq(R13, |
973 Immediate(RawObject::ClassIdTag::encode(cid))); | 970 Immediate(RawObject::ClassIdTag::encode(cid))); |
974 __ movq(FieldAddress(RAX, Context::tags_offset()), R13); // Tags. | 971 __ movq(FieldAddress(RAX, Context::tags_offset()), R13); // Tags. |
975 } | 972 } |
976 | 973 |
977 // Setup up number of context variables field. | 974 // Setup up number of context variables field. |
978 // RAX: new object. | 975 // RAX: new object. |
979 // R10: number of context variables as integer value (not object). | 976 // R10: number of context variables as integer value (not object). |
980 __ movq(FieldAddress(RAX, Context::num_variables_offset()), R10); | 977 __ movq(FieldAddress(RAX, Context::num_variables_offset()), R10); |
981 | 978 |
982 // Setup isolate field. | |
983 // RAX: new object. | |
984 // R10: number of context variables. | |
985 // R13: Isolate, not an object. | |
986 __ LoadIsolate(R13); | |
987 __ movq(FieldAddress(RAX, Context::isolate_offset()), R13); | |
988 | |
989 // Setup the parent field. | 979 // Setup the parent field. |
990 // RAX: new object. | 980 // RAX: new object. |
991 // R10: number of context variables. | 981 // R10: number of context variables. |
992 __ movq(FieldAddress(RAX, Context::parent_offset()), R12); | 982 __ movq(FieldAddress(RAX, Context::parent_offset()), R12); |
993 | 983 |
994 // Initialize the context variables. | 984 // Initialize the context variables. |
995 // RAX: new object. | 985 // RAX: new object. |
996 // R10: number of context variables. | 986 // R10: number of context variables. |
997 { | 987 { |
998 Label loop, entry; | 988 Label loop, entry; |
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 __ popq(RAX); // Address of original. | 1737 __ popq(RAX); // Address of original. |
1748 __ LeaveStubFrame(); | 1738 __ LeaveStubFrame(); |
1749 __ jmp(RAX); // Jump to original stub. | 1739 __ jmp(RAX); // Jump to original stub. |
1750 } | 1740 } |
1751 | 1741 |
1752 | 1742 |
1753 // Called only from unoptimized code. | 1743 // Called only from unoptimized code. |
1754 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { | 1744 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { |
1755 // Check single stepping. | 1745 // Check single stepping. |
1756 Label stepping, done_stepping; | 1746 Label stepping, done_stepping; |
1757 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 1747 __ LoadIsolate(RAX); |
1758 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); | 1748 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); |
1759 __ cmpq(RAX, Immediate(0)); | 1749 __ cmpq(RAX, Immediate(0)); |
1760 __ j(NOT_EQUAL, &stepping, Assembler::kNearJump); | 1750 __ j(NOT_EQUAL, &stepping, Assembler::kNearJump); |
1761 __ Bind(&done_stepping); | 1751 __ Bind(&done_stepping); |
1762 __ ret(); | 1752 __ ret(); |
1763 | 1753 |
1764 __ Bind(&stepping); | 1754 __ Bind(&stepping); |
1765 __ EnterStubFrame(); | 1755 __ EnterStubFrame(); |
1766 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1756 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1767 __ LeaveStubFrame(); | 1757 __ LeaveStubFrame(); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 | 2004 |
2015 // Called only from unoptimized code. All relevant registers have been saved. | 2005 // Called only from unoptimized code. All relevant registers have been saved. |
2016 // TOS + 0: return address | 2006 // TOS + 0: return address |
2017 // TOS + 1: right argument. | 2007 // TOS + 1: right argument. |
2018 // TOS + 2: left argument. | 2008 // TOS + 2: left argument. |
2019 // Returns ZF set. | 2009 // Returns ZF set. |
2020 void StubCode::GenerateUnoptimizedIdenticalWithNumberCheckStub( | 2010 void StubCode::GenerateUnoptimizedIdenticalWithNumberCheckStub( |
2021 Assembler* assembler) { | 2011 Assembler* assembler) { |
2022 // Check single stepping. | 2012 // Check single stepping. |
2023 Label stepping, done_stepping; | 2013 Label stepping, done_stepping; |
2024 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 2014 __ LoadIsolate(RAX); |
2025 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); | 2015 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); |
2026 __ cmpq(RAX, Immediate(0)); | 2016 __ cmpq(RAX, Immediate(0)); |
2027 __ j(NOT_EQUAL, &stepping); | 2017 __ j(NOT_EQUAL, &stepping); |
2028 __ Bind(&done_stepping); | 2018 __ Bind(&done_stepping); |
2029 | 2019 |
2030 const Register left = RAX; | 2020 const Register left = RAX; |
2031 const Register right = RDX; | 2021 const Register right = RDX; |
2032 | 2022 |
2033 __ movq(left, Address(RSP, 2 * kWordSize)); | 2023 __ movq(left, Address(RSP, 2 * kWordSize)); |
2034 __ movq(right, Address(RSP, 1 * kWordSize)); | 2024 __ movq(right, Address(RSP, 1 * kWordSize)); |
(...skipping 20 matching lines...) Expand all Loading... |
2055 | 2045 |
2056 __ movq(left, Address(RSP, 2 * kWordSize)); | 2046 __ movq(left, Address(RSP, 2 * kWordSize)); |
2057 __ movq(right, Address(RSP, 1 * kWordSize)); | 2047 __ movq(right, Address(RSP, 1 * kWordSize)); |
2058 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 2048 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
2059 __ ret(); | 2049 __ ret(); |
2060 } | 2050 } |
2061 | 2051 |
2062 } // namespace dart | 2052 } // namespace dart |
2063 | 2053 |
2064 #endif // defined TARGET_ARCH_X64 | 2054 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |