| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); | 220 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
| 221 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 221 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 222 __ LeaveFrame(); | 222 __ LeaveFrame(); |
| 223 __ jmp(EAX); | 223 __ jmp(EAX); |
| 224 __ int3(); | 224 __ int3(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 | 227 |
| 228 // Input parameters: | 228 // Input parameters: |
| 229 // EDX: smi-tagged argument count, may be zero. | 229 // EDX: smi-tagged argument count, may be zero. |
| 230 // EBP[kParamEndSlotFromFp + 1]: last argument. |
| 230 // Uses EAX, EBX, ECX, EDX. | 231 // Uses EAX, EBX, ECX, EDX. |
| 231 static void PushArgumentsArray(Assembler* assembler, intptr_t arg_offset) { | 232 static void PushArgumentsArray(Assembler* assembler) { |
| 232 const Immediate& raw_null = | 233 const Immediate& raw_null = |
| 233 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 234 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 234 | 235 |
| 235 // Allocate array to store arguments of caller. | 236 // Allocate array to store arguments of caller. |
| 236 __ movl(ECX, raw_null); // Null element type for raw Array. | 237 __ movl(ECX, raw_null); // Null element type for raw Array. |
| 237 __ call(&StubCode::AllocateArrayLabel()); | 238 __ call(&StubCode::AllocateArrayLabel()); |
| 238 __ SmiUntag(EDX); | 239 __ SmiUntag(EDX); |
| 239 // EAX: newly allocated array. | 240 // EAX: newly allocated array. |
| 240 // EDX: length of the array (was preserved by the stub). | 241 // EDX: length of the array (was preserved by the stub). |
| 241 __ pushl(EAX); // Array is in EAX and on top of stack. | 242 __ pushl(EAX); // Array is in EAX and on top of stack. |
| 242 __ leal(EBX, Address(ESP, EDX, TIMES_4, arg_offset)); // Addr of first arg. | 243 __ leal(EBX, Address(EBP, EDX, TIMES_4, kParamEndSlotFromFp * kWordSize)); |
| 243 __ leal(ECX, FieldAddress(EAX, Array::data_offset())); | 244 __ leal(ECX, FieldAddress(EAX, Array::data_offset())); |
| 245 // EBX: address of first argument on stack. |
| 246 // ECX: address of first argument in array. |
| 244 Label loop, loop_condition; | 247 Label loop, loop_condition; |
| 245 __ jmp(&loop_condition, Assembler::kNearJump); | 248 __ jmp(&loop_condition, Assembler::kNearJump); |
| 246 __ Bind(&loop); | 249 __ Bind(&loop); |
| 247 __ movl(EAX, Address(EBX, 0)); | 250 __ movl(EAX, Address(EBX, 0)); |
| 248 __ movl(Address(ECX, 0), EAX); | 251 __ movl(Address(ECX, 0), EAX); |
| 249 __ AddImmediate(ECX, Immediate(kWordSize)); | 252 __ AddImmediate(ECX, Immediate(kWordSize)); |
| 250 __ AddImmediate(EBX, Immediate(-kWordSize)); | 253 __ AddImmediate(EBX, Immediate(-kWordSize)); |
| 251 __ Bind(&loop_condition); | 254 __ Bind(&loop_condition); |
| 252 __ decl(EDX); | 255 __ decl(EDX); |
| 253 __ j(POSITIVE, &loop, Assembler::kNearJump); | 256 __ j(POSITIVE, &loop, Assembler::kNearJump); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 273 // three words (null, stub's pc marker, saved fp) above the return | 276 // three words (null, stub's pc marker, saved fp) above the return |
| 274 // address. | 277 // address. |
| 275 __ movl(EDI, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); | 278 __ movl(EDI, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); |
| 276 __ pushl(Address(ESP, EDI, TIMES_2, (3 * kWordSize))); | 279 __ pushl(Address(ESP, EDI, TIMES_2, (3 * kWordSize))); |
| 277 | 280 |
| 278 __ pushl(ECX); // Pass IC data object. | 281 __ pushl(ECX); // Pass IC data object. |
| 279 __ pushl(EDX); // Pass arguments descriptor array. | 282 __ pushl(EDX); // Pass arguments descriptor array. |
| 280 | 283 |
| 281 // Pass the call's arguments array. | 284 // Pass the call's arguments array. |
| 282 __ movl(EDX, EDI); // Smi-tagged arguments array length. | 285 __ movl(EDX, EDI); // Smi-tagged arguments array length. |
| 283 PushArgumentsArray(assembler, (7 * kWordSize)); | 286 PushArgumentsArray(assembler); |
| 284 // Stack layout explaining "(7 * kWordSize)" offset. | |
| 285 // TOS + 0: Arguments array. | |
| 286 // TOS + 1: Arguments descriptor array. | |
| 287 // TOS + 2: IC data object. | |
| 288 // TOS + 3: Receiver. | |
| 289 // TOS + 4: Space for the result of the runtime call. | |
| 290 // TOS + 5: Stub's PC marker (0) | |
| 291 // TOS + 6: Saved FP | |
| 292 // TOS + 7: Dart code return address | |
| 293 // TOS + 8: Last argument of caller. | |
| 294 // .... | |
| 295 | 287 |
| 296 __ CallRuntime(kInstanceFunctionLookupRuntimeEntry); | 288 __ CallRuntime(kInstanceFunctionLookupRuntimeEntry); |
| 289 |
| 297 // Remove arguments. | 290 // Remove arguments. |
| 298 __ popl(EAX); | 291 __ Drop(4); |
| 299 __ popl(EAX); | |
| 300 __ popl(EAX); | |
| 301 __ popl(EAX); | |
| 302 __ popl(EAX); // Get result into EAX. | 292 __ popl(EAX); // Get result into EAX. |
| 303 __ LeaveFrame(); | 293 __ LeaveFrame(); |
| 304 __ ret(); | 294 __ ret(); |
| 305 } | 295 } |
| 306 | 296 |
| 307 | 297 |
| 308 DECLARE_LEAF_RUNTIME_ENTRY(intptr_t, DeoptimizeCopyFrame, | 298 DECLARE_LEAF_RUNTIME_ENTRY(intptr_t, DeoptimizeCopyFrame, |
| 309 intptr_t deopt_reason, | 299 intptr_t deopt_reason, |
| 310 uword saved_registers_address); | 300 uword saved_registers_address); |
| 311 | 301 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 // EDX: arguments descriptor array. | 674 // EDX: arguments descriptor array. |
| 685 | 675 |
| 686 // Create a stub frame as we are pushing some objects on the stack before | 676 // Create a stub frame as we are pushing some objects on the stack before |
| 687 // calling into the runtime. | 677 // calling into the runtime. |
| 688 __ EnterStubFrame(); | 678 __ EnterStubFrame(); |
| 689 | 679 |
| 690 __ pushl(raw_null); // Setup space on stack for result from error reporting. | 680 __ pushl(raw_null); // Setup space on stack for result from error reporting. |
| 691 __ pushl(EDX); // Arguments descriptor. | 681 __ pushl(EDX); // Arguments descriptor. |
| 692 // Load smi-tagged arguments array length, including the non-closure. | 682 // Load smi-tagged arguments array length, including the non-closure. |
| 693 __ movl(EDX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); | 683 __ movl(EDX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); |
| 694 // See stack layout below explaining "wordSize * 5" offset. | 684 PushArgumentsArray(assembler); |
| 695 PushArgumentsArray(assembler, (kWordSize * 5)); | |
| 696 | 685 |
| 697 // Stack: | |
| 698 // TOS + 0: Argument array. | |
| 699 // TOS + 1: Arguments descriptor array. | |
| 700 // TOS + 2: Place for result from the call. | |
| 701 // TOS + 3: PC marker => RawInstruction object. | |
| 702 // TOS + 4: Saved EBP of previous frame. <== EBP | |
| 703 // TOS + 5: Dart code return address | |
| 704 // TOS + 6: Last argument of caller. | |
| 705 // .... | |
| 706 __ CallRuntime(kInvokeNonClosureRuntimeEntry); | 686 __ CallRuntime(kInvokeNonClosureRuntimeEntry); |
| 707 // Remove arguments. | 687 // Remove arguments. |
| 708 __ popl(EAX); | 688 __ Drop(2); |
| 709 __ popl(EAX); | |
| 710 __ popl(EAX); // Get result into EAX. | 689 __ popl(EAX); // Get result into EAX. |
| 711 | 690 |
| 712 // Remove the stub frame as we are about to return. | 691 // Remove the stub frame as we are about to return. |
| 713 __ LeaveFrame(); | 692 __ LeaveFrame(); |
| 714 __ ret(); | 693 __ ret(); |
| 715 } | 694 } |
| 716 | 695 |
| 717 | 696 |
| 718 // Called when invoking dart code from C++ (VM code). | 697 // Called when invoking dart code from C++ (VM code). |
| 719 // Input parameters: | 698 // Input parameters: |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 } | 1328 } |
| 1350 __ popl(EAX); // Pop function object. | 1329 __ popl(EAX); // Pop function object. |
| 1351 __ popl(EAX); | 1330 __ popl(EAX); |
| 1352 // EAX: new object | 1331 // EAX: new object |
| 1353 // Restore the frame pointer. | 1332 // Restore the frame pointer. |
| 1354 __ LeaveFrame(); | 1333 __ LeaveFrame(); |
| 1355 __ ret(); | 1334 __ ret(); |
| 1356 } | 1335 } |
| 1357 | 1336 |
| 1358 | 1337 |
| 1359 // Called for invoking noSuchMethod function from the entry code of a dart | 1338 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function |
| 1360 // function after an error in passed named arguments is detected. | 1339 // from the entry code of a dart function after an error in passed argument |
| 1340 // name or number is detected. |
| 1361 // Input parameters: | 1341 // Input parameters: |
| 1362 // EBP - 4 : PC marker => RawInstruction object. | 1342 // ESP : points to return address. |
| 1363 // EBP : points to previous frame pointer. | 1343 // ESP + 4 : address of last argument. |
| 1364 // EBP + 4 : points to return address. | |
| 1365 // EBP + 8 : address of last argument (arg n-1). | |
| 1366 // EBP + 8 + 4*(n-1) : address of first argument (arg 0). | |
| 1367 // ECX : ic-data. | 1344 // ECX : ic-data. |
| 1368 // EDX : arguments descriptor array. | 1345 // EDX : arguments descriptor array. |
| 1369 // Uses EAX, EBX, EDI as temporary registers. | 1346 // Uses EAX, EBX, EDI as temporary registers. |
| 1370 void StubCode::GenerateCallNoSuchMethodFunctionStub(Assembler* assembler) { | 1347 void StubCode::GenerateCallNoSuchMethodFunctionStub(Assembler* assembler) { |
| 1371 // The target function was not found, so invoke method | 1348 __ EnterStubFrame(); |
| 1372 // "dynamic noSuchMethod(Invocation invocation)". | 1349 |
| 1350 // Load the receiver. |
| 1351 __ movl(EDI, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); |
| 1352 __ movl(EAX, Address(EBP, EDI, TIMES_2, kParamEndSlotFromFp * kWordSize)); |
| 1353 |
| 1373 const Immediate& raw_null = | 1354 const Immediate& raw_null = |
| 1374 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1355 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1375 __ movl(EDI, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); | |
| 1376 __ movl(EAX, Address(EBP, EDI, TIMES_2, kWordSize)); // Get receiver. | |
| 1377 | |
| 1378 // Create a stub frame as we are pushing some objects on the stack before | |
| 1379 // calling into the runtime. | |
| 1380 __ EnterStubFrame(); | |
| 1381 | |
| 1382 __ pushl(raw_null); // Setup space on stack for result from noSuchMethod. | 1356 __ pushl(raw_null); // Setup space on stack for result from noSuchMethod. |
| 1383 __ pushl(EAX); // Receiver. | 1357 __ pushl(EAX); // Receiver. |
| 1384 __ pushl(ECX); // IC data array. | 1358 __ pushl(ECX); // IC data array. |
| 1385 __ pushl(EDX); // Arguments descriptor array. | 1359 __ pushl(EDX); // Arguments descriptor array. |
| 1386 | 1360 |
| 1387 __ movl(EDX, EDI); | 1361 __ movl(EDX, EDI); |
| 1388 // See stack layout below explaining "wordSize * 10" offset. | 1362 // EDX: Smi-tagged arguments array length. |
| 1389 PushArgumentsArray(assembler, (kWordSize * 10)); | 1363 PushArgumentsArray(assembler); |
| 1390 | 1364 |
| 1391 // Stack: | |
| 1392 // TOS + 0: Argument array. | |
| 1393 // TOS + 1: Arguments descriptor array. | |
| 1394 // TOS + 2: Ic-data. | |
| 1395 // TOS + 3: Receiver. | |
| 1396 // TOS + 4: Place for result from noSuchMethod. | |
| 1397 // TOS + 5: PC marker => RawInstruction object. | |
| 1398 // TOS + 6: Saved EBP of previous frame. <== EBP | |
| 1399 // TOS + 7: Dart callee (or stub) code return address | |
| 1400 // TOS + 8: PC marker => RawInstruction object of dart caller frame. | |
| 1401 // TOS + 9: Saved EBP of dart caller frame. | |
| 1402 // TOS + 10: Dart caller code return address | |
| 1403 // TOS + 11: Last argument of caller. | |
| 1404 // .... | |
| 1405 __ CallRuntime(kInvokeNoSuchMethodFunctionRuntimeEntry); | 1365 __ CallRuntime(kInvokeNoSuchMethodFunctionRuntimeEntry); |
| 1366 |
| 1406 // Remove arguments. | 1367 // Remove arguments. |
| 1407 __ popl(EAX); | 1368 __ Drop(4); |
| 1408 __ popl(EAX); | |
| 1409 __ popl(EAX); | |
| 1410 __ popl(EAX); | |
| 1411 __ popl(EAX); // Get result into EAX. | 1369 __ popl(EAX); // Get result into EAX. |
| 1412 | 1370 |
| 1413 // Remove the stub frame as we are about to return. | 1371 // Remove the stub frame as we are about to return. |
| 1414 __ LeaveFrame(); | 1372 __ LeaveFrame(); |
| 1415 __ ret(); | 1373 __ ret(); |
| 1416 } | 1374 } |
| 1417 | 1375 |
| 1418 | 1376 |
| 1419 // Cannot use function object from ICData as it may be the inlined | 1377 // Cannot use function object from ICData as it may be the inlined |
| 1420 // function and not the top-scope function. | 1378 // function and not the top-scope function. |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 __ Bind(&done); | 2137 __ Bind(&done); |
| 2180 __ popl(temp); | 2138 __ popl(temp); |
| 2181 __ popl(right); | 2139 __ popl(right); |
| 2182 __ popl(left); | 2140 __ popl(left); |
| 2183 __ ret(); | 2141 __ ret(); |
| 2184 } | 2142 } |
| 2185 | 2143 |
| 2186 } // namespace dart | 2144 } // namespace dart |
| 2187 | 2145 |
| 2188 #endif // defined TARGET_ARCH_IA32 | 2146 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |