| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Save current Context pointer into Isolate structure. | 70 // Save current Context pointer into Isolate structure. |
| 71 __ movl(Address(EAX, Isolate::top_context_offset()), CTX); | 71 __ movl(Address(EAX, Isolate::top_context_offset()), CTX); |
| 72 | 72 |
| 73 // Cache Isolate pointer into CTX while executing runtime code. | 73 // Cache Isolate pointer into CTX while executing runtime code. |
| 74 __ movl(CTX, EAX); | 74 __ movl(CTX, EAX); |
| 75 | 75 |
| 76 #if defined(DEBUG) | 76 #if defined(DEBUG) |
| 77 { Label ok; | 77 { Label ok; |
| 78 // Check that we are always entering from Dart code. | 78 // Check that we are always entering from Dart code. |
| 79 __ movl(EAX, Address(CTX, Isolate::vm_tag_offset())); | 79 __ movl(EAX, Address(CTX, Isolate::vm_tag_offset())); |
| 80 __ cmpl(EAX, Immediate(VMTag::kScriptTagId)); | 80 __ cmpl(EAX, Immediate(VMTag::kDartTagId)); |
| 81 __ j(EQUAL, &ok, Assembler::kNearJump); | 81 __ j(EQUAL, &ok, Assembler::kNearJump); |
| 82 __ Stop("Not coming from Dart code."); | 82 __ Stop("Not coming from Dart code."); |
| 83 __ Bind(&ok); | 83 __ Bind(&ok); |
| 84 } | 84 } |
| 85 #endif | 85 #endif |
| 86 | 86 |
| 87 // Mark that the isolate is executing VM code. | 87 // Mark that the isolate is executing VM code. |
| 88 __ movl(Address(CTX, Isolate::vm_tag_offset()), ECX); | 88 __ movl(Address(CTX, Isolate::vm_tag_offset()), ECX); |
| 89 | 89 |
| 90 // Reserve space for arguments and align frame before entering C++ world. | 90 // Reserve space for arguments and align frame before entering C++ world. |
| 91 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments))); | 91 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments))); |
| 92 if (OS::ActivationFrameAlignment() > 1) { | 92 if (OS::ActivationFrameAlignment() > 1) { |
| 93 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 93 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
| 94 } | 94 } |
| 95 | 95 |
| 96 // Pass NativeArguments structure by value and call runtime. | 96 // Pass NativeArguments structure by value and call runtime. |
| 97 __ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs. | 97 __ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs. |
| 98 // There are no runtime calls to closures, so we do not need to set the tag | 98 // There are no runtime calls to closures, so we do not need to set the tag |
| 99 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. | 99 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. |
| 100 __ movl(Address(ESP, argc_tag_offset), EDX); // Set argc in NativeArguments. | 100 __ movl(Address(ESP, argc_tag_offset), EDX); // Set argc in NativeArguments. |
| 101 __ leal(EAX, Address(EBP, EDX, TIMES_4, 1 * kWordSize)); // Compute argv. | 101 __ leal(EAX, Address(EBP, EDX, TIMES_4, 1 * kWordSize)); // Compute argv. |
| 102 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. | 102 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. |
| 103 __ addl(EAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. | 103 __ addl(EAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. |
| 104 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. | 104 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. |
| 105 __ call(ECX); | 105 __ call(ECX); |
| 106 | 106 |
| 107 // Mark that the isolate is executing Dart code. | 107 // Mark that the isolate is executing Dart code. |
| 108 __ movl(Address(CTX, Isolate::vm_tag_offset()), | 108 __ movl(Address(CTX, Isolate::vm_tag_offset()), |
| 109 Immediate(VMTag::kScriptTagId)); | 109 Immediate(VMTag::kDartTagId)); |
| 110 | 110 |
| 111 // Reset exit frame information in Isolate structure. | 111 // Reset exit frame information in Isolate structure. |
| 112 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); | 112 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
| 113 | 113 |
| 114 // Load Context pointer from Isolate structure into ECX. | 114 // Load Context pointer from Isolate structure into ECX. |
| 115 __ movl(ECX, Address(CTX, Isolate::top_context_offset())); | 115 __ movl(ECX, Address(CTX, Isolate::top_context_offset())); |
| 116 | 116 |
| 117 // Reset Context pointer in Isolate structure. | 117 // Reset Context pointer in Isolate structure. |
| 118 const Immediate& raw_null = | 118 const Immediate& raw_null = |
| 119 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 119 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 // Save current Context pointer into Isolate structure. | 192 // Save current Context pointer into Isolate structure. |
| 193 __ movl(Address(EDI, Isolate::top_context_offset()), CTX); | 193 __ movl(Address(EDI, Isolate::top_context_offset()), CTX); |
| 194 | 194 |
| 195 // Cache Isolate pointer into CTX while executing native code. | 195 // Cache Isolate pointer into CTX while executing native code. |
| 196 __ movl(CTX, EDI); | 196 __ movl(CTX, EDI); |
| 197 | 197 |
| 198 #if defined(DEBUG) | 198 #if defined(DEBUG) |
| 199 { Label ok; | 199 { Label ok; |
| 200 // Check that we are always entering from Dart code. | 200 // Check that we are always entering from Dart code. |
| 201 __ movl(EDI, Address(CTX, Isolate::vm_tag_offset())); | 201 __ movl(EDI, Address(CTX, Isolate::vm_tag_offset())); |
| 202 __ cmpl(EDI, Immediate(VMTag::kScriptTagId)); | 202 __ cmpl(EDI, Immediate(VMTag::kDartTagId)); |
| 203 __ j(EQUAL, &ok, Assembler::kNearJump); | 203 __ j(EQUAL, &ok, Assembler::kNearJump); |
| 204 __ Stop("Not coming from Dart code."); | 204 __ Stop("Not coming from Dart code."); |
| 205 __ Bind(&ok); | 205 __ Bind(&ok); |
| 206 } | 206 } |
| 207 #endif | 207 #endif |
| 208 | 208 |
| 209 // Mark that the isolate is executing Native code. | 209 // Mark that the isolate is executing Native code. |
| 210 __ movl(Address(CTX, Isolate::vm_tag_offset()), ECX); | 210 __ movl(Address(CTX, Isolate::vm_tag_offset()), ECX); |
| 211 | 211 |
| 212 // Reserve space for the native arguments structure, the outgoing parameters | 212 // Reserve space for the native arguments structure, the outgoing parameters |
| (...skipping 11 matching lines...) Expand all Loading... |
| 224 __ leal(EAX, Address(EBP, 2 * kWordSize)); // Compute return value addr. | 224 __ leal(EAX, Address(EBP, 2 * kWordSize)); // Compute return value addr. |
| 225 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. | 225 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. |
| 226 __ leal(EAX, Address(ESP, 2 * kWordSize)); // Pointer to the NativeArguments. | 226 __ leal(EAX, Address(ESP, 2 * kWordSize)); // Pointer to the NativeArguments. |
| 227 __ movl(Address(ESP, 0), EAX); // Pass the pointer to the NativeArguments. | 227 __ movl(Address(ESP, 0), EAX); // Pass the pointer to the NativeArguments. |
| 228 | 228 |
| 229 __ movl(Address(ESP, kWordSize), ECX); // Function to call. | 229 __ movl(Address(ESP, kWordSize), ECX); // Function to call. |
| 230 __ call(&NativeEntry::NativeCallWrapperLabel()); | 230 __ call(&NativeEntry::NativeCallWrapperLabel()); |
| 231 | 231 |
| 232 // Mark that the isolate is executing Dart code. | 232 // Mark that the isolate is executing Dart code. |
| 233 __ movl(Address(CTX, Isolate::vm_tag_offset()), | 233 __ movl(Address(CTX, Isolate::vm_tag_offset()), |
| 234 Immediate(VMTag::kScriptTagId)); | 234 Immediate(VMTag::kDartTagId)); |
| 235 | 235 |
| 236 // Reset exit frame information in Isolate structure. | 236 // Reset exit frame information in Isolate structure. |
| 237 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); | 237 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
| 238 | 238 |
| 239 // Load Context pointer from Isolate structure into EDI. | 239 // Load Context pointer from Isolate structure into EDI. |
| 240 __ movl(EDI, Address(CTX, Isolate::top_context_offset())); | 240 __ movl(EDI, Address(CTX, Isolate::top_context_offset())); |
| 241 | 241 |
| 242 // Reset Context pointer in Isolate structure. | 242 // Reset Context pointer in Isolate structure. |
| 243 const Immediate& raw_null = | 243 const Immediate& raw_null = |
| 244 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 244 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // Save current Context pointer into Isolate structure. | 296 // Save current Context pointer into Isolate structure. |
| 297 __ movl(Address(EDI, Isolate::top_context_offset()), CTX); | 297 __ movl(Address(EDI, Isolate::top_context_offset()), CTX); |
| 298 | 298 |
| 299 // Cache Isolate pointer into CTX while executing native code. | 299 // Cache Isolate pointer into CTX while executing native code. |
| 300 __ movl(CTX, EDI); | 300 __ movl(CTX, EDI); |
| 301 | 301 |
| 302 #if defined(DEBUG) | 302 #if defined(DEBUG) |
| 303 { Label ok; | 303 { Label ok; |
| 304 // Check that we are always entering from Dart code. | 304 // Check that we are always entering from Dart code. |
| 305 __ movl(EDI, Address(CTX, Isolate::vm_tag_offset())); | 305 __ movl(EDI, Address(CTX, Isolate::vm_tag_offset())); |
| 306 __ cmpl(EDI, Immediate(VMTag::kScriptTagId)); | 306 __ cmpl(EDI, Immediate(VMTag::kDartTagId)); |
| 307 __ j(EQUAL, &ok, Assembler::kNearJump); | 307 __ j(EQUAL, &ok, Assembler::kNearJump); |
| 308 __ Stop("Not coming from Dart code."); | 308 __ Stop("Not coming from Dart code."); |
| 309 __ Bind(&ok); | 309 __ Bind(&ok); |
| 310 } | 310 } |
| 311 #endif | 311 #endif |
| 312 | 312 |
| 313 // Mark that the isolate is executing Native code. | 313 // Mark that the isolate is executing Native code. |
| 314 __ movl(Address(CTX, Isolate::vm_tag_offset()), ECX); | 314 __ movl(Address(CTX, Isolate::vm_tag_offset()), ECX); |
| 315 | 315 |
| 316 // Reserve space for the native arguments structure, the outgoing parameter | 316 // Reserve space for the native arguments structure, the outgoing parameter |
| 317 // (pointer to the native arguments structure) and align frame before | 317 // (pointer to the native arguments structure) and align frame before |
| 318 // entering the C++ world. | 318 // entering the C++ world. |
| 319 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments) - kWordSize)); | 319 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments) - kWordSize)); |
| 320 if (OS::ActivationFrameAlignment() > 1) { | 320 if (OS::ActivationFrameAlignment() > 1) { |
| 321 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 321 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
| 322 } | 322 } |
| 323 | 323 |
| 324 // Pass NativeArguments structure by value and call native function. | 324 // Pass NativeArguments structure by value and call native function. |
| 325 __ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs. | 325 __ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs. |
| 326 __ movl(Address(ESP, argc_tag_offset), EDX); // Set argc in NativeArguments. | 326 __ movl(Address(ESP, argc_tag_offset), EDX); // Set argc in NativeArguments. |
| 327 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. | 327 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. |
| 328 __ leal(EAX, Address(EBP, 2 * kWordSize)); // Compute return value addr. | 328 __ leal(EAX, Address(EBP, 2 * kWordSize)); // Compute return value addr. |
| 329 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. | 329 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. |
| 330 __ leal(EAX, Address(ESP, kWordSize)); // Pointer to the NativeArguments. | 330 __ leal(EAX, Address(ESP, kWordSize)); // Pointer to the NativeArguments. |
| 331 __ movl(Address(ESP, 0), EAX); // Pass the pointer to the NativeArguments. | 331 __ movl(Address(ESP, 0), EAX); // Pass the pointer to the NativeArguments. |
| 332 __ call(ECX); | 332 __ call(ECX); |
| 333 | 333 |
| 334 // Mark that the isolate is executing Dart code. | 334 // Mark that the isolate is executing Dart code. |
| 335 __ movl(Address(CTX, Isolate::vm_tag_offset()), | 335 __ movl(Address(CTX, Isolate::vm_tag_offset()), |
| 336 Immediate(VMTag::kScriptTagId)); | 336 Immediate(VMTag::kDartTagId)); |
| 337 | 337 |
| 338 // Reset exit frame information in Isolate structure. | 338 // Reset exit frame information in Isolate structure. |
| 339 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); | 339 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
| 340 | 340 |
| 341 // Load Context pointer from Isolate structure into EDI. | 341 // Load Context pointer from Isolate structure into EDI. |
| 342 __ movl(EDI, Address(CTX, Isolate::top_context_offset())); | 342 __ movl(EDI, Address(CTX, Isolate::top_context_offset())); |
| 343 | 343 |
| 344 // Reset Context pointer in Isolate structure. | 344 // Reset Context pointer in Isolate structure. |
| 345 const Immediate& raw_null = | 345 const Immediate& raw_null = |
| 346 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 346 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 // Load Isolate pointer from Context structure into EDI. | 761 // Load Isolate pointer from Context structure into EDI. |
| 762 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); | 762 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); |
| 763 | 763 |
| 764 // Save the current VMTag on the stack. | 764 // Save the current VMTag on the stack. |
| 765 ASSERT(kSavedVMTagSlotFromEntryFp == -4); | 765 ASSERT(kSavedVMTagSlotFromEntryFp == -4); |
| 766 __ movl(ECX, Address(EDI, Isolate::vm_tag_offset())); | 766 __ movl(ECX, Address(EDI, Isolate::vm_tag_offset())); |
| 767 __ pushl(ECX); | 767 __ pushl(ECX); |
| 768 | 768 |
| 769 // Mark that the isolate is executing Dart code. | 769 // Mark that the isolate is executing Dart code. |
| 770 __ movl(Address(EDI, Isolate::vm_tag_offset()), | 770 __ movl(Address(EDI, Isolate::vm_tag_offset()), |
| 771 Immediate(VMTag::kScriptTagId)); | 771 Immediate(VMTag::kDartTagId)); |
| 772 | 772 |
| 773 // Save the top exit frame info. Use EDX as a temporary register. | 773 // Save the top exit frame info. Use EDX as a temporary register. |
| 774 // StackFrameIterator reads the top exit frame info saved in this frame. | 774 // StackFrameIterator reads the top exit frame info saved in this frame. |
| 775 // The constant kExitLinkSlotFromEntryFp must be kept in sync with the | 775 // The constant kExitLinkSlotFromEntryFp must be kept in sync with the |
| 776 // code below. | 776 // code below. |
| 777 ASSERT(kExitLinkSlotFromEntryFp == -5); | 777 ASSERT(kExitLinkSlotFromEntryFp == -5); |
| 778 __ movl(EDX, Address(EDI, Isolate::top_exit_frame_info_offset())); | 778 __ movl(EDX, Address(EDI, Isolate::top_exit_frame_info_offset())); |
| 779 __ pushl(EDX); | 779 __ pushl(EDX); |
| 780 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), Immediate(0)); | 780 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
| 781 | 781 |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 ASSERT(kExceptionObjectReg == EAX); | 1791 ASSERT(kExceptionObjectReg == EAX); |
| 1792 ASSERT(kStackTraceObjectReg == EDX); | 1792 ASSERT(kStackTraceObjectReg == EDX); |
| 1793 __ movl(EDI, Address(ESP, 6 * kWordSize)); // Load target isolate. | 1793 __ movl(EDI, Address(ESP, 6 * kWordSize)); // Load target isolate. |
| 1794 __ movl(kStackTraceObjectReg, Address(ESP, 5 * kWordSize)); | 1794 __ movl(kStackTraceObjectReg, Address(ESP, 5 * kWordSize)); |
| 1795 __ movl(kExceptionObjectReg, Address(ESP, 4 * kWordSize)); | 1795 __ movl(kExceptionObjectReg, Address(ESP, 4 * kWordSize)); |
| 1796 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. | 1796 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. |
| 1797 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. | 1797 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. |
| 1798 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. | 1798 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. |
| 1799 // Set tag. | 1799 // Set tag. |
| 1800 __ movl(Address(EDI, Isolate::vm_tag_offset()), | 1800 __ movl(Address(EDI, Isolate::vm_tag_offset()), |
| 1801 Immediate(VMTag::kScriptTagId)); | 1801 Immediate(VMTag::kDartTagId)); |
| 1802 // Clear top exit frame. | 1802 // Clear top exit frame. |
| 1803 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), Immediate(0)); | 1803 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
| 1804 __ jmp(EBX); // Jump to the exception handler code. | 1804 __ jmp(EBX); // Jump to the exception handler code. |
| 1805 } | 1805 } |
| 1806 | 1806 |
| 1807 | 1807 |
| 1808 // Calls to the runtime to optimize the given function. | 1808 // Calls to the runtime to optimize the given function. |
| 1809 // EDI: function to be reoptimized. | 1809 // EDI: function to be reoptimized. |
| 1810 // EDX: argument descriptor (preserved). | 1810 // EDX: argument descriptor (preserved). |
| 1811 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { | 1811 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1940 const Register temp = ECX; | 1940 const Register temp = ECX; |
| 1941 __ movl(left, Address(ESP, 2 * kWordSize)); | 1941 __ movl(left, Address(ESP, 2 * kWordSize)); |
| 1942 __ movl(right, Address(ESP, 1 * kWordSize)); | 1942 __ movl(right, Address(ESP, 1 * kWordSize)); |
| 1943 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 1943 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
| 1944 __ ret(); | 1944 __ ret(); |
| 1945 } | 1945 } |
| 1946 | 1946 |
| 1947 } // namespace dart | 1947 } // namespace dart |
| 1948 | 1948 |
| 1949 #endif // defined TARGET_ARCH_IA32 | 1949 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |