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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 __ subq(RSP, Immediate(sizeof(NativeArguments))); | 72 __ subq(RSP, Immediate(sizeof(NativeArguments))); |
73 if (OS::ActivationFrameAlignment() > 1) { | 73 if (OS::ActivationFrameAlignment() > 1) { |
74 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 74 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
75 } | 75 } |
76 | 76 |
77 // Pass NativeArguments structure by value and call runtime. | 77 // Pass NativeArguments structure by value and call runtime. |
78 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. | 78 __ movq(Address(RSP, thread_offset), THR); // Set thread in NativeArgs. |
79 // There are no runtime calls to closures, so we do not need to set the tag | 79 // There are no runtime calls to closures, so we do not need to set the tag |
80 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. | 80 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. |
81 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. | 81 __ movq(Address(RSP, argc_tag_offset), R10); // Set argc in NativeArguments. |
82 __ leaq(RAX, Address(RBP, R10, TIMES_8, 1 * kWordSize)); // Compute argv. | 82 // Compute argv. |
| 83 __ leaq(RAX, Address(RBP, R10, TIMES_8, kParamEndSlotFromFp * kWordSize)); |
83 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. | 84 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. |
84 __ addq(RAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. | 85 __ addq(RAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. |
85 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. | 86 __ movq(Address(RSP, retval_offset), RAX); // Set retval in NativeArguments. |
86 #if defined(_WIN64) | 87 #if defined(_WIN64) |
87 ASSERT(sizeof(NativeArguments) > CallingConventions::kRegisterTransferLimit); | 88 ASSERT(sizeof(NativeArguments) > CallingConventions::kRegisterTransferLimit); |
88 __ movq(CallingConventions::kArg1Reg, RSP); | 89 __ movq(CallingConventions::kArg1Reg, RSP); |
89 #endif | 90 #endif |
90 __ CallCFunction(RBX); | 91 __ CallCFunction(RBX); |
91 | 92 |
92 // Mark that the isolate is executing Dart code. | 93 // Mark that the isolate is executing Dart code. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 274 |
274 | 275 |
275 // Input parameters: | 276 // Input parameters: |
276 // R10: arguments descriptor array. | 277 // R10: arguments descriptor array. |
277 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { | 278 void StubCode::GenerateCallStaticFunctionStub(Assembler* assembler) { |
278 __ EnterStubFrame(); | 279 __ EnterStubFrame(); |
279 __ pushq(R10); // Preserve arguments descriptor array. | 280 __ pushq(R10); // Preserve arguments descriptor array. |
280 // Setup space on stack for return value. | 281 // Setup space on stack for return value. |
281 __ PushObject(Object::null_object()); | 282 __ PushObject(Object::null_object()); |
282 __ CallRuntime(kPatchStaticCallRuntimeEntry, 0); | 283 __ CallRuntime(kPatchStaticCallRuntimeEntry, 0); |
283 __ popq(RAX); // Get Code object result. | 284 __ popq(CODE_REG); // Get Code object result. |
284 __ popq(R10); // Restore arguments descriptor array. | 285 __ popq(R10); // Restore arguments descriptor array. |
285 // Remove the stub frame as we are about to jump to the dart function. | 286 // Remove the stub frame as we are about to jump to the dart function. |
286 __ LeaveStubFrame(); | 287 __ LeaveStubFrame(); |
287 | 288 |
288 __ movq(RBX, FieldAddress(RAX, Code::entry_point_offset())); | 289 __ movq(RBX, FieldAddress(CODE_REG, Code::entry_point_offset())); |
289 __ jmp(RBX); | 290 __ jmp(RBX); |
290 } | 291 } |
291 | 292 |
292 | 293 |
293 // Called from a static call only when an invalid code has been entered | 294 // Called from a static call only when an invalid code has been entered |
294 // (invalid because its function was optimized or deoptimized). | 295 // (invalid because its function was optimized or deoptimized). |
295 // R10: arguments descriptor array. | 296 // R10: arguments descriptor array. |
296 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { | 297 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { |
| 298 // Load code pointer to this stub from the thread: |
| 299 // The one that is passed in, is not correct - it points to the code object |
| 300 // that needs to be replaced. |
| 301 __ movq(CODE_REG, Address(THR, Thread::fix_callers_target_code_offset())); |
297 __ EnterStubFrame(); | 302 __ EnterStubFrame(); |
298 __ pushq(R10); // Preserve arguments descriptor array. | 303 __ pushq(R10); // Preserve arguments descriptor array. |
299 // Setup space on stack for return value. | 304 // Setup space on stack for return value. |
300 __ PushObject(Object::null_object()); | 305 __ PushObject(Object::null_object()); |
301 __ CallRuntime(kFixCallersTargetRuntimeEntry, 0); | 306 __ CallRuntime(kFixCallersTargetRuntimeEntry, 0); |
302 __ popq(RAX); // Get Code object. | 307 __ popq(CODE_REG); // Get Code object. |
303 __ popq(R10); // Restore arguments descriptor array. | 308 __ popq(R10); // Restore arguments descriptor array. |
304 __ movq(RAX, FieldAddress(RAX, Code::entry_point_offset())); | 309 __ movq(RAX, FieldAddress(CODE_REG, Code::entry_point_offset())); |
305 __ LeaveStubFrame(); | 310 __ LeaveStubFrame(); |
306 __ jmp(RAX); | 311 __ jmp(RAX); |
307 __ int3(); | 312 __ int3(); |
308 } | 313 } |
309 | 314 |
310 | 315 |
311 // Called from object allocate instruction when the allocation stub has been | 316 // Called from object allocate instruction when the allocation stub has been |
312 // disabled. | 317 // disabled. |
313 void StubCode::GenerateFixAllocationStubTargetStub(Assembler* assembler) { | 318 void StubCode::GenerateFixAllocationStubTargetStub(Assembler* assembler) { |
| 319 // Load code pointer to this stub from the thread: |
| 320 // The one that is passed in, is not correct - it points to the code object |
| 321 // that needs to be replaced. |
| 322 __ movq(CODE_REG, Address(THR, Thread::fix_allocation_stub_code_offset())); |
314 __ EnterStubFrame(); | 323 __ EnterStubFrame(); |
315 // Setup space on stack for return value. | 324 // Setup space on stack for return value. |
316 __ PushObject(Object::null_object()); | 325 __ PushObject(Object::null_object()); |
317 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0); | 326 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0); |
318 __ popq(RAX); // Get Code object. | 327 __ popq(CODE_REG); // Get Code object. |
319 __ movq(RAX, FieldAddress(RAX, Code::entry_point_offset())); | 328 __ movq(RAX, FieldAddress(CODE_REG, Code::entry_point_offset())); |
320 __ LeaveStubFrame(); | 329 __ LeaveStubFrame(); |
321 __ jmp(RAX); | 330 __ jmp(RAX); |
322 __ int3(); | 331 __ int3(); |
323 } | 332 } |
324 | 333 |
325 | 334 |
326 // Input parameters: | 335 // Input parameters: |
327 // R10: smi-tagged argument count, may be zero. | 336 // R10: smi-tagged argument count, may be zero. |
328 // RBP[kParamEndSlotFromFp + 1]: last argument. | 337 // RBP[kParamEndSlotFromFp + 1]: last argument. |
329 static void PushArgumentsArray(Assembler* assembler) { | 338 static void PushArgumentsArray(Assembler* assembler) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // Stack after EnterDartFrame(0, PP, kNoRegister) below: | 381 // Stack after EnterDartFrame(0, PP, kNoRegister) below: |
373 // +------------------+ | 382 // +------------------+ |
374 // | Saved PP | <- PP | 383 // | Saved PP | <- PP |
375 // +------------------+ | 384 // +------------------+ |
376 // | PC marker | <- TOS | 385 // | PC marker | <- TOS |
377 // +------------------+ | 386 // +------------------+ |
378 // | Saved FP | <- FP of stub | 387 // | Saved FP | <- FP of stub |
379 // +------------------+ | 388 // +------------------+ |
380 // | return-address | (deoptimization point) | 389 // | return-address | (deoptimization point) |
381 // +------------------+ | 390 // +------------------+ |
| 391 // | Saved CODE_REG | |
| 392 // +------------------+ |
382 // | ... | <- SP of optimized frame | 393 // | ... | <- SP of optimized frame |
383 // | 394 // |
384 // Parts of the code cannot GC, part of the code can GC. | 395 // Parts of the code cannot GC, part of the code can GC. |
385 static void GenerateDeoptimizationSequence(Assembler* assembler, | 396 static void GenerateDeoptimizationSequence(Assembler* assembler, |
386 bool preserve_result) { | 397 DeoptStubKind kind) { |
387 // DeoptimizeCopyFrame expects a Dart frame, i.e. EnterDartFrame(0), but there | 398 // DeoptimizeCopyFrame expects a Dart frame, i.e. EnterDartFrame(0), but there |
388 // is no need to set the correct PC marker or load PP, since they get patched. | 399 // is no need to set the correct PC marker or load PP, since they get patched. |
389 __ EnterStubFrame(); | 400 __ EnterStubFrame(); |
390 | 401 |
391 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry | 402 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry |
392 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls. | 403 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls. |
393 const intptr_t saved_result_slot_from_fp = | 404 const intptr_t saved_result_slot_from_fp = |
394 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - RAX); | 405 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - RAX); |
395 // Result in RAX is preserved as part of pushing all registers below. | 406 // Result in RAX is preserved as part of pushing all registers below. |
396 | 407 |
397 // Push registers in their enumeration order: lowest register number at | 408 // Push registers in their enumeration order: lowest register number at |
398 // lowest address. | 409 // lowest address. |
399 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { | 410 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { |
400 __ pushq(static_cast<Register>(i)); | 411 if (i == CODE_REG) { |
| 412 __ pushq(Address(RBP, 2 * kWordSize)); |
| 413 } else { |
| 414 __ pushq(static_cast<Register>(i)); |
| 415 } |
401 } | 416 } |
402 __ subq(RSP, Immediate(kNumberOfXmmRegisters * kFpuRegisterSize)); | 417 __ subq(RSP, Immediate(kNumberOfXmmRegisters * kFpuRegisterSize)); |
403 intptr_t offset = 0; | 418 intptr_t offset = 0; |
404 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { | 419 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { |
405 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); | 420 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); |
406 __ movups(Address(RSP, offset), xmm_reg); | 421 __ movups(Address(RSP, offset), xmm_reg); |
407 offset += kFpuRegisterSize; | 422 offset += kFpuRegisterSize; |
408 } | 423 } |
409 | 424 |
410 // Pass address of saved registers block. | 425 // Pass address of saved registers block. |
411 __ movq(CallingConventions::kArg1Reg, RSP); | 426 __ movq(CallingConventions::kArg1Reg, RSP); |
| 427 __ movq(CallingConventions::kArg2Reg, Immediate(kind == kLazyDeopt ? 1 : 0)); |
412 __ ReserveAlignedFrameSpace(0); // Ensure stack is aligned before the call. | 428 __ ReserveAlignedFrameSpace(0); // Ensure stack is aligned before the call. |
413 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 1); | 429 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 2); |
414 // Result (RAX) is stack-size (FP - SP) in bytes. | 430 // Result (RAX) is stack-size (FP - SP) in bytes. |
415 | 431 |
| 432 const bool preserve_result = (kind == kLazyDeopt); |
416 if (preserve_result) { | 433 if (preserve_result) { |
417 // Restore result into RBX temporarily. | 434 // Restore result into RBX temporarily. |
418 __ movq(RBX, Address(RBP, saved_result_slot_from_fp * kWordSize)); | 435 __ movq(RBX, Address(RBP, saved_result_slot_from_fp * kWordSize)); |
419 } | 436 } |
420 | 437 |
421 // There is a Dart Frame on the stack. We must restore PP and leave frame. | 438 // There is a Dart Frame on the stack. We must restore PP and leave frame. |
| 439 __ RestoreCodePointer(); |
422 __ LeaveStubFrame(); | 440 __ LeaveStubFrame(); |
423 | 441 |
424 __ popq(RCX); // Preserve return address. | 442 __ popq(RCX); // Preserve return address. |
425 __ movq(RSP, RBP); // Discard optimized frame. | 443 __ movq(RSP, RBP); // Discard optimized frame. |
426 __ subq(RSP, RAX); // Reserve space for deoptimized frame. | 444 __ subq(RSP, RAX); // Reserve space for deoptimized frame. |
427 __ pushq(RCX); // Restore return address. | 445 __ pushq(RCX); // Restore return address. |
428 | 446 |
429 // DeoptimizeFillFrame expects a Dart frame, i.e. EnterDartFrame(0), but there | 447 // DeoptimizeFillFrame expects a Dart frame, i.e. EnterDartFrame(0), but there |
430 // is no need to set the correct PC marker or load PP, since they get patched. | 448 // is no need to set the correct PC marker or load PP, since they get patched. |
431 __ EnterStubFrame(); | 449 __ EnterStubFrame(); |
432 | 450 |
433 if (preserve_result) { | 451 if (preserve_result) { |
434 __ pushq(RBX); // Preserve result as first local. | 452 __ pushq(RBX); // Preserve result as first local. |
435 } | 453 } |
436 __ ReserveAlignedFrameSpace(0); | 454 __ ReserveAlignedFrameSpace(0); |
437 // Pass last FP as a parameter. | 455 // Pass last FP as a parameter. |
438 __ movq(CallingConventions::kArg1Reg, RBP); | 456 __ movq(CallingConventions::kArg1Reg, RBP); |
439 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry, 1); | 457 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry, 1); |
440 if (preserve_result) { | 458 if (preserve_result) { |
441 // Restore result into RBX. | 459 // Restore result into RBX. |
442 __ movq(RBX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); | 460 __ movq(RBX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); |
443 } | 461 } |
444 // Code above cannot cause GC. | 462 // Code above cannot cause GC. |
445 // There is a Dart Frame on the stack. We must restore PP and leave frame. | 463 // There is a Dart Frame on the stack. We must restore PP and leave frame. |
| 464 __ RestoreCodePointer(); |
446 __ LeaveStubFrame(); | 465 __ LeaveStubFrame(); |
447 | 466 |
448 // Frame is fully rewritten at this point and it is safe to perform a GC. | 467 // Frame is fully rewritten at this point and it is safe to perform a GC. |
449 // Materialize any objects that were deferred by FillFrame because they | 468 // Materialize any objects that were deferred by FillFrame because they |
450 // require allocation. | 469 // require allocation. |
451 // Enter stub frame with loading PP. The caller's PP is not materialized yet. | 470 // Enter stub frame with loading PP. The caller's PP is not materialized yet. |
452 __ EnterStubFrame(); | 471 __ EnterStubFrame(); |
453 if (preserve_result) { | 472 if (preserve_result) { |
454 __ pushq(RBX); // Preserve result, it will be GC-d here. | 473 __ pushq(RBX); // Preserve result, it will be GC-d here. |
455 } | 474 } |
(...skipping 15 matching lines...) Expand all Loading... |
471 } | 490 } |
472 | 491 |
473 | 492 |
474 // TOS: return address + call-instruction-size (5 bytes). | 493 // TOS: return address + call-instruction-size (5 bytes). |
475 // RAX: result, must be preserved | 494 // RAX: result, must be preserved |
476 void StubCode::GenerateDeoptimizeLazyStub(Assembler* assembler) { | 495 void StubCode::GenerateDeoptimizeLazyStub(Assembler* assembler) { |
477 // Correct return address to point just after the call that is being | 496 // Correct return address to point just after the call that is being |
478 // deoptimized. | 497 // deoptimized. |
479 __ popq(RBX); | 498 __ popq(RBX); |
480 __ subq(RBX, Immediate(ShortCallPattern::pattern_length_in_bytes())); | 499 __ subq(RBX, Immediate(ShortCallPattern::pattern_length_in_bytes())); |
| 500 // Push zap value instead of CODE_REG for lazy deopt. |
| 501 __ pushq(Immediate(0xf1f1f1f1)); |
481 __ pushq(RBX); | 502 __ pushq(RBX); |
482 GenerateDeoptimizationSequence(assembler, true); // Preserve RAX. | 503 GenerateDeoptimizationSequence(assembler, kLazyDeopt); |
483 } | 504 } |
484 | 505 |
485 | 506 |
486 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { | 507 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { |
487 GenerateDeoptimizationSequence(assembler, false); // Don't preserve RAX. | 508 GenerateDeoptimizationSequence(assembler, kEagerDeopt); |
488 } | 509 } |
489 | 510 |
490 | 511 |
491 static void GenerateDispatcherCode(Assembler* assembler, | 512 static void GenerateDispatcherCode(Assembler* assembler, |
492 Label* call_target_function) { | 513 Label* call_target_function) { |
493 __ Comment("NoSuchMethodDispatch"); | 514 __ Comment("NoSuchMethodDispatch"); |
494 // When lazily generated invocation dispatchers are disabled, the | 515 // When lazily generated invocation dispatchers are disabled, the |
495 // miss-handler may return null. | 516 // miss-handler may return null. |
496 __ CompareObject(RAX, Object::null_object()); | 517 __ CompareObject(RAX, Object::null_object()); |
497 __ j(NOT_EQUAL, call_target_function); | 518 __ j(NOT_EQUAL, call_target_function); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 __ pushq(RBX); // IC data. | 556 __ pushq(RBX); // IC data. |
536 __ pushq(R10); // Arguments descriptor. | 557 __ pushq(R10); // Arguments descriptor. |
537 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); | 558 __ CallRuntime(kMegamorphicCacheMissHandlerRuntimeEntry, 3); |
538 // Discard arguments. | 559 // Discard arguments. |
539 __ popq(RAX); | 560 __ popq(RAX); |
540 __ popq(RAX); | 561 __ popq(RAX); |
541 __ popq(RAX); | 562 __ popq(RAX); |
542 __ popq(RAX); // Return value from the runtime call (function). | 563 __ popq(RAX); // Return value from the runtime call (function). |
543 __ popq(R10); // Restore arguments descriptor. | 564 __ popq(R10); // Restore arguments descriptor. |
544 __ popq(RBX); // Restore IC data. | 565 __ popq(RBX); // Restore IC data. |
| 566 __ RestoreCodePointer(); |
545 __ LeaveStubFrame(); | 567 __ LeaveStubFrame(); |
546 | |
547 if (!FLAG_lazy_dispatchers) { | 568 if (!FLAG_lazy_dispatchers) { |
548 Label call_target_function; | 569 Label call_target_function; |
549 GenerateDispatcherCode(assembler, &call_target_function); | 570 GenerateDispatcherCode(assembler, &call_target_function); |
550 __ Bind(&call_target_function); | 571 __ Bind(&call_target_function); |
551 } | 572 } |
552 | 573 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset())); |
553 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); | 574 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); |
554 __ jmp(RCX); | 575 __ jmp(RCX); |
555 } | 576 } |
556 | 577 |
557 | 578 |
558 // Called for inline allocation of arrays. | 579 // Called for inline allocation of arrays. |
559 // Input parameters: | 580 // Input parameters: |
560 // R10 : Array length as Smi. | 581 // R10 : Array length as Smi. |
561 // RBX : array element type (either NULL or an instantiated type). | 582 // RBX : array element type (either NULL or an instantiated type). |
562 // NOTE: R10 cannot be clobbered here as the caller relies on it being saved. | 583 // NOTE: R10 cannot be clobbered here as the caller relies on it being saved. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 __ popq(R10); // Pop array length argument. | 707 __ popq(R10); // Pop array length argument. |
687 __ popq(RAX); // Pop return value from return slot. | 708 __ popq(RAX); // Pop return value from return slot. |
688 __ LeaveStubFrame(); | 709 __ LeaveStubFrame(); |
689 __ ret(); | 710 __ ret(); |
690 } | 711 } |
691 | 712 |
692 | 713 |
693 // Called when invoking Dart code from C++ (VM code). | 714 // Called when invoking Dart code from C++ (VM code). |
694 // Input parameters: | 715 // Input parameters: |
695 // RSP : points to return address. | 716 // RSP : points to return address. |
696 // RDI : entrypoint of the Dart function to call. | 717 // RDI : target code |
697 // RSI : arguments descriptor array. | 718 // RSI : arguments descriptor array. |
698 // RDX : arguments array. | 719 // RDX : arguments array. |
699 // RCX : current thread. | 720 // RCX : current thread. |
700 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { | 721 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { |
701 // Save frame pointer coming in. | 722 // Save frame pointer coming in. |
702 __ EnterFrame(0); | 723 __ EnterFrame(0); |
703 | 724 |
704 const Register kEntryPointReg = CallingConventions::kArg1Reg; | 725 const Register kTargetCodeReg = CallingConventions::kArg1Reg; |
705 const Register kArgDescReg = CallingConventions::kArg2Reg; | 726 const Register kArgDescReg = CallingConventions::kArg2Reg; |
706 const Register kArgsReg = CallingConventions::kArg3Reg; | 727 const Register kArgsReg = CallingConventions::kArg3Reg; |
707 const Register kThreadReg = CallingConventions::kArg4Reg; | 728 const Register kThreadReg = CallingConventions::kArg4Reg; |
708 | 729 |
709 // At this point, the stack looks like: | 730 // At this point, the stack looks like: |
710 // | saved RBP | <-- RBP | 731 // | saved RBP | <-- RBP |
711 // | saved PC (return to DartEntry::InvokeFunction) | | 732 // | saved PC (return to DartEntry::InvokeFunction) | |
712 | 733 |
713 const intptr_t kInitialOffset = 1; | 734 const intptr_t kInitialOffset = 1; |
714 // Save arguments descriptor array. | 735 // Save arguments descriptor array. |
715 const intptr_t kArgumentsDescOffset = -(kInitialOffset) * kWordSize; | 736 const intptr_t kArgumentsDescOffset = -(kInitialOffset) * kWordSize; |
716 __ pushq(kArgDescReg); | 737 __ pushq(kArgDescReg); |
717 | 738 |
718 // Save C++ ABI callee-saved registers. | 739 // Save C++ ABI callee-saved registers. |
719 __ PushRegisters(CallingConventions::kCalleeSaveCpuRegisters, | 740 __ PushRegisters(CallingConventions::kCalleeSaveCpuRegisters, |
720 CallingConventions::kCalleeSaveXmmRegisters); | 741 CallingConventions::kCalleeSaveXmmRegisters); |
721 | 742 |
722 // We now load the pool pointer(PP) as we are about to invoke dart code and we | |
723 // could potentially invoke some intrinsic functions which need the PP to be | |
724 // set up. | |
725 __ LoadPoolPointer(); | |
726 | |
727 // If any additional (or fewer) values are pushed, the offsets in | 743 // If any additional (or fewer) values are pushed, the offsets in |
728 // kExitLinkSlotFromEntryFp will need to be changed. | 744 // kExitLinkSlotFromEntryFp will need to be changed. |
729 | 745 |
730 // Set up THR, which caches the current thread in Dart code. | 746 // Set up THR, which caches the current thread in Dart code. |
731 if (THR != kThreadReg) { | 747 if (THR != kThreadReg) { |
732 __ movq(THR, kThreadReg); | 748 __ movq(THR, kThreadReg); |
733 } | 749 } |
734 // Load Isolate pointer into kIsolateReg. | 750 // Load Isolate pointer into kIsolateReg. |
735 const Register kIsolateReg = RBX; | 751 const Register kIsolateReg = RBX; |
736 __ LoadIsolate(kIsolateReg); | 752 __ LoadIsolate(kIsolateReg); |
(...skipping 25 matching lines...) Expand all Loading... |
762 __ Stop("kExitLinkSlotFromEntryFp mismatch"); | 778 __ Stop("kExitLinkSlotFromEntryFp mismatch"); |
763 __ Bind(&ok); | 779 __ Bind(&ok); |
764 } | 780 } |
765 #endif | 781 #endif |
766 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), | 782 __ movq(Address(THR, Thread::top_exit_frame_info_offset()), |
767 Immediate(0)); | 783 Immediate(0)); |
768 | 784 |
769 // Load arguments descriptor array into R10, which is passed to Dart code. | 785 // Load arguments descriptor array into R10, which is passed to Dart code. |
770 __ movq(R10, Address(kArgDescReg, VMHandles::kOffsetOfRawPtrInHandle)); | 786 __ movq(R10, Address(kArgDescReg, VMHandles::kOffsetOfRawPtrInHandle)); |
771 | 787 |
772 // Push arguments. At this point we only need to preserve kEntryPointReg. | 788 // Push arguments. At this point we only need to preserve kTargetCodeReg. |
773 ASSERT(kEntryPointReg != RDX); | 789 ASSERT(kTargetCodeReg != RDX); |
774 | 790 |
775 // Load number of arguments into RBX. | 791 // Load number of arguments into RBX. |
776 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 792 __ movq(RBX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
777 __ SmiUntag(RBX); | 793 __ SmiUntag(RBX); |
778 | 794 |
779 // Compute address of 'arguments array' data area into RDX. | 795 // Compute address of 'arguments array' data area into RDX. |
780 __ movq(RDX, Address(kArgsReg, VMHandles::kOffsetOfRawPtrInHandle)); | 796 __ movq(RDX, Address(kArgsReg, VMHandles::kOffsetOfRawPtrInHandle)); |
781 __ leaq(RDX, FieldAddress(RDX, Array::data_offset())); | 797 __ leaq(RDX, FieldAddress(RDX, Array::data_offset())); |
782 | 798 |
783 // Set up arguments for the Dart call. | 799 // Set up arguments for the Dart call. |
784 Label push_arguments; | 800 Label push_arguments; |
785 Label done_push_arguments; | 801 Label done_push_arguments; |
786 __ testq(RBX, RBX); // check if there are arguments. | 802 __ testq(RBX, RBX); // check if there are arguments. |
787 __ j(ZERO, &done_push_arguments, Assembler::kNearJump); | 803 __ j(ZERO, &done_push_arguments, Assembler::kNearJump); |
788 __ movq(RAX, Immediate(0)); | 804 __ movq(RAX, Immediate(0)); |
789 __ Bind(&push_arguments); | 805 __ Bind(&push_arguments); |
790 __ pushq(Address(RDX, RAX, TIMES_8, 0)); | 806 __ pushq(Address(RDX, RAX, TIMES_8, 0)); |
791 __ incq(RAX); | 807 __ incq(RAX); |
792 __ cmpq(RAX, RBX); | 808 __ cmpq(RAX, RBX); |
793 __ j(LESS, &push_arguments, Assembler::kNearJump); | 809 __ j(LESS, &push_arguments, Assembler::kNearJump); |
794 __ Bind(&done_push_arguments); | 810 __ Bind(&done_push_arguments); |
795 | 811 |
796 // Call the Dart code entrypoint. | 812 // Call the Dart code entrypoint. |
797 __ call(kEntryPointReg); // R10 is the arguments descriptor array. | 813 __ xorq(PP, PP); // GC-safe value into PP. |
| 814 __ movq(CODE_REG, |
| 815 Address(kTargetCodeReg, VMHandles::kOffsetOfRawPtrInHandle)); |
| 816 __ movq(kTargetCodeReg, FieldAddress(CODE_REG, Code::entry_point_offset())); |
| 817 __ call(kTargetCodeReg); // R10 is the arguments descriptor array. |
798 | 818 |
799 // Read the saved arguments descriptor array to obtain the number of passed | 819 // Read the saved arguments descriptor array to obtain the number of passed |
800 // arguments. | 820 // arguments. |
801 __ movq(kArgDescReg, Address(RBP, kArgumentsDescOffset)); | 821 __ movq(kArgDescReg, Address(RBP, kArgumentsDescOffset)); |
802 __ movq(R10, Address(kArgDescReg, VMHandles::kOffsetOfRawPtrInHandle)); | 822 __ movq(R10, Address(kArgDescReg, VMHandles::kOffsetOfRawPtrInHandle)); |
803 __ movq(RDX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 823 __ movq(RDX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
804 // Get rid of arguments pushed on the stack. | 824 // Get rid of arguments pushed on the stack. |
805 __ leaq(RSP, Address(RSP, RDX, TIMES_4, 0)); // RDX is a Smi. | 825 __ leaq(RSP, Address(RSP, RDX, TIMES_4, 0)); // RDX is a Smi. |
806 | 826 |
807 // Restore the saved top exit frame info and top resource back into the | 827 // Restore the saved top exit frame info and top resource back into the |
(...skipping 16 matching lines...) Expand all Loading... |
824 __ ret(); | 844 __ ret(); |
825 } | 845 } |
826 | 846 |
827 | 847 |
828 // Called for inline allocation of contexts. | 848 // Called for inline allocation of contexts. |
829 // Input: | 849 // Input: |
830 // R10: number of context variables. | 850 // R10: number of context variables. |
831 // Output: | 851 // Output: |
832 // RAX: new allocated RawContext object. | 852 // RAX: new allocated RawContext object. |
833 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { | 853 void StubCode::GenerateAllocateContextStub(Assembler* assembler) { |
834 __ LoadObject(R12, Object::null_object()); | 854 __ LoadObject(R9, Object::null_object()); |
835 if (FLAG_inline_alloc) { | 855 if (FLAG_inline_alloc) { |
836 Label slow_case; | 856 Label slow_case; |
837 // First compute the rounded instance size. | 857 // First compute the rounded instance size. |
838 // R10: number of context variables. | 858 // R10: number of context variables. |
839 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); | 859 intptr_t fixed_size = (sizeof(RawContext) + kObjectAlignment - 1); |
840 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); | 860 __ leaq(R13, Address(R10, TIMES_8, fixed_size)); |
841 __ andq(R13, Immediate(-kObjectAlignment)); | 861 __ andq(R13, Immediate(-kObjectAlignment)); |
842 | 862 |
843 // Check for allocation tracing. | 863 // Check for allocation tracing. |
844 __ MaybeTraceAllocation(kContextCid, | 864 __ MaybeTraceAllocation(kContextCid, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 // RAX: new object. | 928 // RAX: new object. |
909 // R10: number of context variables as integer value (not object). | 929 // R10: number of context variables as integer value (not object). |
910 __ movq(FieldAddress(RAX, Context::num_variables_offset()), R10); | 930 __ movq(FieldAddress(RAX, Context::num_variables_offset()), R10); |
911 | 931 |
912 // Setup the parent field. | 932 // Setup the parent field. |
913 // RAX: new object. | 933 // RAX: new object. |
914 // R10: number of context variables. | 934 // R10: number of context variables. |
915 // No generational barrier needed, since we are storing null. | 935 // No generational barrier needed, since we are storing null. |
916 __ InitializeFieldNoBarrier(RAX, | 936 __ InitializeFieldNoBarrier(RAX, |
917 FieldAddress(RAX, Context::parent_offset()), | 937 FieldAddress(RAX, Context::parent_offset()), |
918 R12); | 938 R9); |
919 | 939 |
920 // Initialize the context variables. | 940 // Initialize the context variables. |
921 // RAX: new object. | 941 // RAX: new object. |
922 // R10: number of context variables. | 942 // R10: number of context variables. |
923 { | 943 { |
924 Label loop, entry; | 944 Label loop, entry; |
925 __ leaq(R13, FieldAddress(RAX, Context::variable_offset(0))); | 945 __ leaq(R13, FieldAddress(RAX, Context::variable_offset(0))); |
926 #if defined(DEBUG) | 946 #if defined(DEBUG) |
927 static const bool kJumpLength = Assembler::kFarJump; | 947 static const bool kJumpLength = Assembler::kFarJump; |
928 #else | 948 #else |
929 static const bool kJumpLength = Assembler::kNearJump; | 949 static const bool kJumpLength = Assembler::kNearJump; |
930 #endif // DEBUG | 950 #endif // DEBUG |
931 __ jmp(&entry, kJumpLength); | 951 __ jmp(&entry, kJumpLength); |
932 __ Bind(&loop); | 952 __ Bind(&loop); |
933 __ decq(R10); | 953 __ decq(R10); |
934 // No generational barrier needed, since we are storing null. | 954 // No generational barrier needed, since we are storing null. |
935 __ InitializeFieldNoBarrier(RAX, | 955 __ InitializeFieldNoBarrier(RAX, |
936 Address(R13, R10, TIMES_8, 0), | 956 Address(R13, R10, TIMES_8, 0), |
937 R12); | 957 R9); |
938 __ Bind(&entry); | 958 __ Bind(&entry); |
939 __ cmpq(R10, Immediate(0)); | 959 __ cmpq(R10, Immediate(0)); |
940 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); | 960 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); |
941 } | 961 } |
942 | 962 |
943 // Done allocating and initializing the context. | 963 // Done allocating and initializing the context. |
944 // RAX: new object. | 964 // RAX: new object. |
945 __ ret(); | 965 __ ret(); |
946 | 966 |
947 __ Bind(&slow_case); | 967 __ Bind(&slow_case); |
948 } | 968 } |
949 // Create a stub frame. | 969 // Create a stub frame. |
950 __ EnterStubFrame(); | 970 __ EnterStubFrame(); |
951 __ pushq(R12); // Setup space on stack for the return value. | 971 __ pushq(R9); // Setup space on stack for the return value. |
952 __ SmiTag(R10); | 972 __ SmiTag(R10); |
953 __ pushq(R10); // Push number of context variables. | 973 __ pushq(R10); // Push number of context variables. |
954 __ CallRuntime(kAllocateContextRuntimeEntry, 1); // Allocate context. | 974 __ CallRuntime(kAllocateContextRuntimeEntry, 1); // Allocate context. |
955 __ popq(RAX); // Pop number of context variables argument. | 975 __ popq(RAX); // Pop number of context variables argument. |
956 __ popq(RAX); // Pop the new context object. | 976 __ popq(RAX); // Pop the new context object. |
957 // RAX: new object | 977 // RAX: new object |
958 // Restore the frame pointer. | 978 // Restore the frame pointer. |
959 __ LeaveStubFrame(); | 979 __ LeaveStubFrame(); |
960 __ ret(); | 980 __ ret(); |
961 } | 981 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry, 1); | 1041 __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry, 1); |
1022 __ LeaveCallRuntimeFrame(); | 1042 __ LeaveCallRuntimeFrame(); |
1023 __ ret(); | 1043 __ ret(); |
1024 } | 1044 } |
1025 | 1045 |
1026 | 1046 |
1027 // Called for inline allocation of objects. | 1047 // Called for inline allocation of objects. |
1028 // Input parameters: | 1048 // Input parameters: |
1029 // RSP + 8 : type arguments object (only if class is parameterized). | 1049 // RSP + 8 : type arguments object (only if class is parameterized). |
1030 // RSP : points to return address. | 1050 // RSP : points to return address. |
1031 void StubCode::GenerateAllocationStubForClass( | 1051 void StubCode::GenerateAllocationStubForClass(Assembler* assembler, |
1032 Assembler* assembler, const Class& cls, | 1052 const Class& cls) { |
1033 uword* entry_patch_offset, uword* patch_code_pc_offset) { | |
1034 // Must load pool pointer before being able to patch. | |
1035 Register new_pp = R13; | |
1036 __ LoadPoolPointer(new_pp); | |
1037 *entry_patch_offset = assembler->CodeSize(); | |
1038 | |
1039 const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize; | 1053 const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize; |
1040 // The generated code is different if the class is parameterized. | 1054 // The generated code is different if the class is parameterized. |
1041 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; | 1055 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; |
1042 ASSERT(!is_cls_parameterized || | 1056 ASSERT(!is_cls_parameterized || |
1043 (cls.type_arguments_field_offset() != Class::kNoTypeArguments)); | 1057 (cls.type_arguments_field_offset() != Class::kNoTypeArguments)); |
1044 // kInlineInstanceSize is a constant used as a threshold for determining | 1058 // kInlineInstanceSize is a constant used as a threshold for determining |
1045 // when the object initialization should be done as a loop or as | 1059 // when the object initialization should be done as a loop or as |
1046 // straight line code. | 1060 // straight line code. |
1047 const int kInlineInstanceSize = 12; // In words. | 1061 const int kInlineInstanceSize = 12; // In words. |
1048 const intptr_t instance_size = cls.instance_size(); | 1062 const intptr_t instance_size = cls.instance_size(); |
1049 ASSERT(instance_size > 0); | 1063 ASSERT(instance_size > 0); |
1050 __ LoadObject(R12, Object::null_object()); | 1064 __ LoadObject(R9, Object::null_object()); |
1051 if (is_cls_parameterized) { | 1065 if (is_cls_parameterized) { |
1052 __ movq(RDX, Address(RSP, kObjectTypeArgumentsOffset)); | 1066 __ movq(RDX, Address(RSP, kObjectTypeArgumentsOffset)); |
1053 // RDX: instantiated type arguments. | 1067 // RDX: instantiated type arguments. |
1054 } | 1068 } |
1055 Isolate* isolate = Isolate::Current(); | 1069 Isolate* isolate = Isolate::Current(); |
1056 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && | 1070 if (FLAG_inline_alloc && Heap::IsAllocatableInNewSpace(instance_size) && |
1057 !cls.TraceAllocation(isolate)) { | 1071 !cls.TraceAllocation(isolate)) { |
1058 Label slow_case; | 1072 Label slow_case; |
1059 // Allocate the object and update top to point to | 1073 // Allocate the object and update top to point to |
1060 // next object start and initialize the allocated object. | 1074 // next object start and initialize the allocated object. |
(...skipping 23 matching lines...) Expand all Loading... |
1084 tags = RawObject::SizeTag::update(instance_size, tags); | 1098 tags = RawObject::SizeTag::update(instance_size, tags); |
1085 ASSERT(cls.id() != kIllegalCid); | 1099 ASSERT(cls.id() != kIllegalCid); |
1086 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1100 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
1087 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); | 1101 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); |
1088 __ addq(RAX, Immediate(kHeapObjectTag)); | 1102 __ addq(RAX, Immediate(kHeapObjectTag)); |
1089 | 1103 |
1090 // Initialize the remaining words of the object. | 1104 // Initialize the remaining words of the object. |
1091 // RAX: new object (tagged). | 1105 // RAX: new object (tagged). |
1092 // RBX: next object start. | 1106 // RBX: next object start. |
1093 // RDX: new object type arguments (if is_cls_parameterized). | 1107 // RDX: new object type arguments (if is_cls_parameterized). |
1094 // R12: raw null. | 1108 // R9: raw null. |
1095 // First try inlining the initialization without a loop. | 1109 // First try inlining the initialization without a loop. |
1096 if (instance_size < (kInlineInstanceSize * kWordSize)) { | 1110 if (instance_size < (kInlineInstanceSize * kWordSize)) { |
1097 // Check if the object contains any non-header fields. | 1111 // Check if the object contains any non-header fields. |
1098 // Small objects are initialized using a consecutive set of writes. | 1112 // Small objects are initialized using a consecutive set of writes. |
1099 for (intptr_t current_offset = Instance::NextFieldOffset(); | 1113 for (intptr_t current_offset = Instance::NextFieldOffset(); |
1100 current_offset < instance_size; | 1114 current_offset < instance_size; |
1101 current_offset += kWordSize) { | 1115 current_offset += kWordSize) { |
1102 __ InitializeFieldNoBarrier(RAX, | 1116 __ InitializeFieldNoBarrier(RAX, |
1103 FieldAddress(RAX, current_offset), | 1117 FieldAddress(RAX, current_offset), |
1104 R12); | 1118 R9); |
1105 } | 1119 } |
1106 } else { | 1120 } else { |
1107 __ leaq(RCX, FieldAddress(RAX, Instance::NextFieldOffset())); | 1121 __ leaq(RCX, FieldAddress(RAX, Instance::NextFieldOffset())); |
1108 // Loop until the whole object is initialized. | 1122 // Loop until the whole object is initialized. |
1109 // RAX: new object (tagged). | 1123 // RAX: new object (tagged). |
1110 // RBX: next object start. | 1124 // RBX: next object start. |
1111 // RCX: next word to be initialized. | 1125 // RCX: next word to be initialized. |
1112 // RDX: new object type arguments (if is_cls_parameterized). | 1126 // RDX: new object type arguments (if is_cls_parameterized). |
1113 Label init_loop; | 1127 Label init_loop; |
1114 Label done; | 1128 Label done; |
1115 __ Bind(&init_loop); | 1129 __ Bind(&init_loop); |
1116 __ cmpq(RCX, RBX); | 1130 __ cmpq(RCX, RBX); |
1117 #if defined(DEBUG) | 1131 #if defined(DEBUG) |
1118 static const bool kJumpLength = Assembler::kFarJump; | 1132 static const bool kJumpLength = Assembler::kFarJump; |
1119 #else | 1133 #else |
1120 static const bool kJumpLength = Assembler::kNearJump; | 1134 static const bool kJumpLength = Assembler::kNearJump; |
1121 #endif // DEBUG | 1135 #endif // DEBUG |
1122 __ j(ABOVE_EQUAL, &done, kJumpLength); | 1136 __ j(ABOVE_EQUAL, &done, kJumpLength); |
1123 __ InitializeFieldNoBarrier(RAX, Address(RCX, 0), R12); | 1137 __ InitializeFieldNoBarrier(RAX, Address(RCX, 0), R9); |
1124 __ addq(RCX, Immediate(kWordSize)); | 1138 __ addq(RCX, Immediate(kWordSize)); |
1125 __ jmp(&init_loop, Assembler::kNearJump); | 1139 __ jmp(&init_loop, Assembler::kNearJump); |
1126 __ Bind(&done); | 1140 __ Bind(&done); |
1127 } | 1141 } |
1128 if (is_cls_parameterized) { | 1142 if (is_cls_parameterized) { |
1129 // RDX: new object type arguments. | 1143 // RDX: new object type arguments. |
1130 // Set the type arguments in the new object. | 1144 // Set the type arguments in the new object. |
1131 intptr_t offset = cls.type_arguments_field_offset(); | 1145 intptr_t offset = cls.type_arguments_field_offset(); |
1132 __ InitializeFieldNoBarrier(RAX, FieldAddress(RAX, offset), RDX); | 1146 __ InitializeFieldNoBarrier(RAX, FieldAddress(RAX, offset), RDX); |
1133 } | 1147 } |
1134 // Done allocating and initializing the instance. | 1148 // Done allocating and initializing the instance. |
1135 // RAX: new object (tagged). | 1149 // RAX: new object (tagged). |
1136 __ ret(); | 1150 __ ret(); |
1137 | 1151 |
1138 __ Bind(&slow_case); | 1152 __ Bind(&slow_case); |
1139 } | 1153 } |
1140 // If is_cls_parameterized: | 1154 // If is_cls_parameterized: |
1141 // RDX: new object type arguments. | 1155 // RDX: new object type arguments. |
1142 // Create a stub frame. | 1156 // Create a stub frame. |
1143 __ EnterStubFrame(); // Uses PP to access class object. | 1157 __ EnterStubFrame(); // Uses PP to access class object. |
1144 __ pushq(R12); // Setup space on stack for return value. | 1158 __ pushq(R9); // Setup space on stack for return value. |
1145 __ PushObject(cls); // Push class of object to be allocated. | 1159 __ PushObject(cls); // Push class of object to be allocated. |
1146 if (is_cls_parameterized) { | 1160 if (is_cls_parameterized) { |
1147 __ pushq(RDX); // Push type arguments of object to be allocated. | 1161 __ pushq(RDX); // Push type arguments of object to be allocated. |
1148 } else { | 1162 } else { |
1149 __ pushq(R12); // Push null type arguments. | 1163 __ pushq(R9); // Push null type arguments. |
1150 } | 1164 } |
1151 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object. | 1165 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object. |
1152 __ popq(RAX); // Pop argument (type arguments of object). | 1166 __ popq(RAX); // Pop argument (type arguments of object). |
1153 __ popq(RAX); // Pop argument (class of object). | 1167 __ popq(RAX); // Pop argument (class of object). |
1154 __ popq(RAX); // Pop result (newly allocated object). | 1168 __ popq(RAX); // Pop result (newly allocated object). |
1155 // RAX: new object | 1169 // RAX: new object |
1156 // Restore the frame pointer. | 1170 // Restore the frame pointer. |
1157 __ LeaveStubFrame(); | 1171 __ LeaveStubFrame(); |
1158 __ ret(); | 1172 __ ret(); |
1159 *patch_code_pc_offset = assembler->CodeSize(); | |
1160 __ JmpPatchable(*StubCode::FixAllocationStubTarget_entry(), new_pp); | |
1161 } | 1173 } |
1162 | 1174 |
1163 | 1175 |
1164 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function | 1176 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function |
1165 // from the entry code of a dart function after an error in passed argument | 1177 // from the entry code of a dart function after an error in passed argument |
1166 // name or number is detected. | 1178 // name or number is detected. |
1167 // Input parameters: | 1179 // Input parameters: |
1168 // RSP : points to return address. | 1180 // RSP : points to return address. |
1169 // RSP + 8 : address of last argument. | 1181 // RSP + 8 : address of last argument. |
1170 // R10 : arguments descriptor array. | 1182 // R10 : arguments descriptor array. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 Label* not_smi_or_overflow, | 1248 Label* not_smi_or_overflow, |
1237 bool should_update_result_range) { | 1249 bool should_update_result_range) { |
1238 __ Comment("Fast Smi op"); | 1250 __ Comment("Fast Smi op"); |
1239 if (FLAG_throw_on_javascript_int_overflow) { | 1251 if (FLAG_throw_on_javascript_int_overflow) { |
1240 // The overflow check is more complex than implemented below. | 1252 // The overflow check is more complex than implemented below. |
1241 return; | 1253 return; |
1242 } | 1254 } |
1243 ASSERT(num_args == 2); | 1255 ASSERT(num_args == 2); |
1244 __ movq(RCX, Address(RSP, + 1 * kWordSize)); // Right | 1256 __ movq(RCX, Address(RSP, + 1 * kWordSize)); // Right |
1245 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // Left. | 1257 __ movq(RAX, Address(RSP, + 2 * kWordSize)); // Left. |
1246 __ movq(R12, RCX); | 1258 __ movq(R13, RCX); |
1247 __ orq(R12, RAX); | 1259 __ orq(R13, RAX); |
1248 __ testq(R12, Immediate(kSmiTagMask)); | 1260 __ testq(R13, Immediate(kSmiTagMask)); |
1249 __ j(NOT_ZERO, not_smi_or_overflow); | 1261 __ j(NOT_ZERO, not_smi_or_overflow); |
1250 switch (kind) { | 1262 switch (kind) { |
1251 case Token::kADD: { | 1263 case Token::kADD: { |
1252 __ addq(RAX, RCX); | 1264 __ addq(RAX, RCX); |
1253 __ j(OVERFLOW, not_smi_or_overflow); | 1265 __ j(OVERFLOW, not_smi_or_overflow); |
1254 break; | 1266 break; |
1255 } | 1267 } |
1256 case Token::kSUB: { | 1268 case Token::kSUB: { |
1257 __ subq(RAX, RCX); | 1269 __ subq(RAX, RCX); |
1258 __ j(OVERFLOW, not_smi_or_overflow); | 1270 __ j(OVERFLOW, not_smi_or_overflow); |
(...skipping 15 matching lines...) Expand all Loading... |
1274 | 1286 |
1275 | 1287 |
1276 if (should_update_result_range) { | 1288 if (should_update_result_range) { |
1277 Label done; | 1289 Label done; |
1278 __ movq(RSI, RAX); | 1290 __ movq(RSI, RAX); |
1279 __ UpdateRangeFeedback(RSI, 2, RBX, RCX, &done); | 1291 __ UpdateRangeFeedback(RSI, 2, RBX, RCX, &done); |
1280 __ Bind(&done); | 1292 __ Bind(&done); |
1281 } | 1293 } |
1282 | 1294 |
1283 // RBX: IC data object (preserved). | 1295 // RBX: IC data object (preserved). |
1284 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset())); | 1296 __ movq(R13, FieldAddress(RBX, ICData::ic_data_offset())); |
1285 // R12: ic_data_array with check entries: classes and target functions. | 1297 // R13: ic_data_array with check entries: classes and target functions. |
1286 __ leaq(R12, FieldAddress(R12, Array::data_offset())); | 1298 __ leaq(R13, FieldAddress(R13, Array::data_offset())); |
1287 // R12: points directly to the first ic data array element. | 1299 // R13: points directly to the first ic data array element. |
1288 #if defined(DEBUG) | 1300 #if defined(DEBUG) |
1289 // Check that first entry is for Smi/Smi. | 1301 // Check that first entry is for Smi/Smi. |
1290 Label error, ok; | 1302 Label error, ok; |
1291 const Immediate& imm_smi_cid = | 1303 const Immediate& imm_smi_cid = |
1292 Immediate(reinterpret_cast<intptr_t>(Smi::New(kSmiCid))); | 1304 Immediate(reinterpret_cast<intptr_t>(Smi::New(kSmiCid))); |
1293 __ cmpq(Address(R12, 0 * kWordSize), imm_smi_cid); | 1305 __ cmpq(Address(R13, 0 * kWordSize), imm_smi_cid); |
1294 __ j(NOT_EQUAL, &error, Assembler::kNearJump); | 1306 __ j(NOT_EQUAL, &error, Assembler::kNearJump); |
1295 __ cmpq(Address(R12, 1 * kWordSize), imm_smi_cid); | 1307 __ cmpq(Address(R13, 1 * kWordSize), imm_smi_cid); |
1296 __ j(EQUAL, &ok, Assembler::kNearJump); | 1308 __ j(EQUAL, &ok, Assembler::kNearJump); |
1297 __ Bind(&error); | 1309 __ Bind(&error); |
1298 __ Stop("Incorrect IC data"); | 1310 __ Stop("Incorrect IC data"); |
1299 __ Bind(&ok); | 1311 __ Bind(&ok); |
1300 #endif | 1312 #endif |
1301 | 1313 |
1302 if (FLAG_optimization_counter_threshold >= 0) { | 1314 if (FLAG_optimization_counter_threshold >= 0) { |
1303 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; | 1315 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; |
1304 // Update counter. | 1316 // Update counter. |
1305 __ movq(R8, Address(R12, count_offset)); | 1317 __ movq(R8, Address(R13, count_offset)); |
1306 __ addq(R8, Immediate(Smi::RawValue(1))); | 1318 __ addq(R8, Immediate(Smi::RawValue(1))); |
1307 __ movq(R13, Immediate(Smi::RawValue(Smi::kMaxValue))); | 1319 __ movq(R9, Immediate(Smi::RawValue(Smi::kMaxValue))); |
1308 __ cmovnoq(R13, R8); | 1320 __ cmovnoq(R9, R8); |
1309 __ StoreIntoSmiField(Address(R12, count_offset), R13); | 1321 __ StoreIntoSmiField(Address(R13, count_offset), R9); |
1310 } | 1322 } |
1311 | 1323 |
1312 __ ret(); | 1324 __ ret(); |
1313 } | 1325 } |
1314 | 1326 |
1315 | 1327 |
1316 // Generate inline cache check for 'num_args'. | 1328 // Generate inline cache check for 'num_args'. |
1317 // RBX: Inline cache data object. | 1329 // RBX: Inline cache data object. |
1318 // TOS(0): return address | 1330 // TOS(0): return address |
1319 // Control flow: | 1331 // Control flow: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 range_collection_mode == kCollectRanges); | 1387 range_collection_mode == kCollectRanges); |
1376 } | 1388 } |
1377 __ Bind(¬_smi_or_overflow); | 1389 __ Bind(¬_smi_or_overflow); |
1378 | 1390 |
1379 __ Comment("Extract ICData initial values and receiver cid"); | 1391 __ Comment("Extract ICData initial values and receiver cid"); |
1380 // Load arguments descriptor into R10. | 1392 // Load arguments descriptor into R10. |
1381 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); | 1393 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); |
1382 // Loop that checks if there is an IC data match. | 1394 // Loop that checks if there is an IC data match. |
1383 Label loop, update, test, found; | 1395 Label loop, update, test, found; |
1384 // RBX: IC data object (preserved). | 1396 // RBX: IC data object (preserved). |
1385 __ movq(R12, FieldAddress(RBX, ICData::ic_data_offset())); | 1397 __ movq(R13, FieldAddress(RBX, ICData::ic_data_offset())); |
1386 // R12: ic_data_array with check entries: classes and target functions. | 1398 // R13: ic_data_array with check entries: classes and target functions. |
1387 __ leaq(R12, FieldAddress(R12, Array::data_offset())); | 1399 __ leaq(R13, FieldAddress(R13, Array::data_offset())); |
1388 // R12: points directly to the first ic data array element. | 1400 // R13: points directly to the first ic data array element. |
1389 | 1401 |
1390 // Get the receiver's class ID (first read number of arguments from | 1402 // Get the receiver's class ID (first read number of arguments from |
1391 // arguments descriptor array and then access the receiver from the stack). | 1403 // arguments descriptor array and then access the receiver from the stack). |
1392 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 1404 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
1393 __ movq(R13, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. | 1405 __ movq(R9, Address(RSP, RAX, TIMES_4, 0)); // RAX (argument count) is Smi. |
1394 __ LoadTaggedClassIdMayBeSmi(RAX, R13); | 1406 __ LoadTaggedClassIdMayBeSmi(RAX, R9); |
1395 // RAX: receiver's class ID as smi. | 1407 // RAX: receiver's class ID as smi. |
1396 __ movq(R13, Address(R12, 0)); // First class ID (Smi) to check. | 1408 __ movq(R9, Address(R13, 0)); // First class ID (Smi) to check. |
1397 __ jmp(&test); | 1409 __ jmp(&test); |
1398 | 1410 |
1399 __ Comment("ICData loop"); | 1411 __ Comment("ICData loop"); |
1400 __ Bind(&loop); | 1412 __ Bind(&loop); |
1401 for (int i = 0; i < num_args; i++) { | 1413 for (int i = 0; i < num_args; i++) { |
1402 if (i > 0) { | 1414 if (i > 0) { |
1403 // If not the first, load the next argument's class ID. | 1415 // If not the first, load the next argument's class ID. |
1404 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 1416 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
1405 __ movq(R13, Address(RSP, RAX, TIMES_4, - i * kWordSize)); | 1417 __ movq(R9, Address(RSP, RAX, TIMES_4, - i * kWordSize)); |
1406 __ LoadTaggedClassIdMayBeSmi(RAX, R13); | 1418 __ LoadTaggedClassIdMayBeSmi(RAX, R9); |
1407 // RAX: next argument class ID (smi). | 1419 // RAX: next argument class ID (smi). |
1408 __ movq(R13, Address(R12, i * kWordSize)); | 1420 __ movq(R9, Address(R13, i * kWordSize)); |
1409 // R13: next class ID to check (smi). | 1421 // R9: next class ID to check (smi). |
1410 } | 1422 } |
1411 __ cmpq(RAX, R13); // Class id match? | 1423 __ cmpq(RAX, R9); // Class id match? |
1412 if (i < (num_args - 1)) { | 1424 if (i < (num_args - 1)) { |
1413 __ j(NOT_EQUAL, &update); // Continue. | 1425 __ j(NOT_EQUAL, &update); // Continue. |
1414 } else { | 1426 } else { |
1415 // Last check, all checks before matched. | 1427 // Last check, all checks before matched. |
1416 __ j(EQUAL, &found); // Break. | 1428 __ j(EQUAL, &found); // Break. |
1417 } | 1429 } |
1418 } | 1430 } |
1419 __ Bind(&update); | 1431 __ Bind(&update); |
1420 // Reload receiver class ID. It has not been destroyed when num_args == 1. | 1432 // Reload receiver class ID. It has not been destroyed when num_args == 1. |
1421 if (num_args > 1) { | 1433 if (num_args > 1) { |
1422 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 1434 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
1423 __ movq(R13, Address(RSP, RAX, TIMES_4, 0)); | 1435 __ movq(R9, Address(RSP, RAX, TIMES_4, 0)); |
1424 __ LoadTaggedClassIdMayBeSmi(RAX, R13); | 1436 __ LoadTaggedClassIdMayBeSmi(RAX, R9); |
1425 } | 1437 } |
1426 | 1438 |
1427 const intptr_t entry_size = ICData::TestEntryLengthFor(num_args) * kWordSize; | 1439 const intptr_t entry_size = ICData::TestEntryLengthFor(num_args) * kWordSize; |
1428 __ addq(R12, Immediate(entry_size)); // Next entry. | 1440 __ addq(R13, Immediate(entry_size)); // Next entry. |
1429 __ movq(R13, Address(R12, 0)); // Next class ID. | 1441 __ movq(R9, Address(R13, 0)); // Next class ID. |
1430 | 1442 |
1431 __ Bind(&test); | 1443 __ Bind(&test); |
1432 __ cmpq(R13, Immediate(Smi::RawValue(kIllegalCid))); // Done? | 1444 __ cmpq(R9, Immediate(Smi::RawValue(kIllegalCid))); // Done? |
1433 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); | 1445 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); |
1434 | 1446 |
1435 __ Comment("IC miss"); | 1447 __ Comment("IC miss"); |
1436 __ LoadObject(R12, Object::null_object()); | 1448 __ LoadObject(R13, Object::null_object()); |
1437 // Compute address of arguments (first read number of arguments from | 1449 // Compute address of arguments (first read number of arguments from |
1438 // arguments descriptor array and then compute address on the stack). | 1450 // arguments descriptor array and then compute address on the stack). |
1439 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); | 1451 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset())); |
1440 __ leaq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi. | 1452 __ leaq(RAX, Address(RSP, RAX, TIMES_4, 0)); // RAX is Smi. |
1441 __ EnterStubFrame(); | 1453 __ EnterStubFrame(); |
1442 __ pushq(R10); // Preserve arguments descriptor array. | 1454 __ pushq(R10); // Preserve arguments descriptor array. |
1443 __ pushq(RBX); // Preserve IC data object. | 1455 __ pushq(RBX); // Preserve IC data object. |
1444 __ pushq(R12); // Setup space on stack for result (target code object). | 1456 __ pushq(R13); // Setup space on stack for result (target code object). |
1445 // Push call arguments. | 1457 // Push call arguments. |
1446 for (intptr_t i = 0; i < num_args; i++) { | 1458 for (intptr_t i = 0; i < num_args; i++) { |
1447 __ movq(RCX, Address(RAX, -kWordSize * i)); | 1459 __ movq(RCX, Address(RAX, -kWordSize * i)); |
1448 __ pushq(RCX); | 1460 __ pushq(RCX); |
1449 } | 1461 } |
1450 __ pushq(RBX); // Pass IC data object. | 1462 __ pushq(RBX); // Pass IC data object. |
1451 __ CallRuntime(handle_ic_miss, num_args + 1); | 1463 __ CallRuntime(handle_ic_miss, num_args + 1); |
1452 // Remove the call arguments pushed earlier, including the IC data object. | 1464 // Remove the call arguments pushed earlier, including the IC data object. |
1453 for (intptr_t i = 0; i < num_args + 1; i++) { | 1465 for (intptr_t i = 0; i < num_args + 1; i++) { |
1454 __ popq(RAX); | 1466 __ popq(RAX); |
1455 } | 1467 } |
1456 __ popq(RAX); // Pop returned function object into RAX. | 1468 __ popq(RAX); // Pop returned function object into RAX. |
1457 __ popq(RBX); // Restore IC data array. | 1469 __ popq(RBX); // Restore IC data array. |
1458 __ popq(R10); // Restore arguments descriptor array. | 1470 __ popq(R10); // Restore arguments descriptor array. |
| 1471 if (range_collection_mode == kCollectRanges) { |
| 1472 __ RestoreCodePointer(); |
| 1473 } |
1459 __ LeaveStubFrame(); | 1474 __ LeaveStubFrame(); |
1460 Label call_target_function; | 1475 Label call_target_function; |
1461 if (!FLAG_lazy_dispatchers) { | 1476 if (!FLAG_lazy_dispatchers) { |
1462 GenerateDispatcherCode(assembler, &call_target_function); | 1477 GenerateDispatcherCode(assembler, &call_target_function); |
1463 } else { | 1478 } else { |
1464 __ jmp(&call_target_function); | 1479 __ jmp(&call_target_function); |
1465 } | 1480 } |
1466 | 1481 |
1467 __ Bind(&found); | 1482 __ Bind(&found); |
1468 // R12: Pointer to an IC data check group. | 1483 // R13: Pointer to an IC data check group. |
1469 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; | 1484 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; |
1470 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; | 1485 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; |
1471 __ movq(RAX, Address(R12, target_offset)); | 1486 __ movq(RAX, Address(R13, target_offset)); |
1472 | 1487 |
1473 if (FLAG_optimization_counter_threshold >= 0) { | 1488 if (FLAG_optimization_counter_threshold >= 0) { |
1474 // Update counter. | 1489 // Update counter. |
1475 __ Comment("Update caller's counter"); | 1490 __ Comment("Update caller's counter"); |
1476 __ movq(R8, Address(R12, count_offset)); | 1491 __ movq(R8, Address(R13, count_offset)); |
1477 __ addq(R8, Immediate(Smi::RawValue(1))); | 1492 __ addq(R8, Immediate(Smi::RawValue(1))); |
1478 __ movq(R13, Immediate(Smi::RawValue(Smi::kMaxValue))); | 1493 __ movq(R9, Immediate(Smi::RawValue(Smi::kMaxValue))); |
1479 __ cmovnoq(R13, R8); | 1494 __ cmovnoq(R9, R8); |
1480 __ StoreIntoSmiField(Address(R12, count_offset), R13); | 1495 __ StoreIntoSmiField(Address(R13, count_offset), R9); |
1481 } | 1496 } |
1482 | 1497 |
1483 __ Comment("Call target"); | 1498 __ Comment("Call target"); |
1484 __ Bind(&call_target_function); | 1499 __ Bind(&call_target_function); |
1485 // RAX: Target function. | 1500 // RAX: Target function. |
1486 Label is_compiled; | 1501 Label is_compiled; |
1487 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); | |
1488 if (range_collection_mode == kCollectRanges) { | 1502 if (range_collection_mode == kCollectRanges) { |
| 1503 __ movq(R13, FieldAddress(RAX, Function::code_offset())); |
| 1504 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); |
1489 __ movq(R8, Address(RSP, + 1 * kWordSize)); | 1505 __ movq(R8, Address(RSP, + 1 * kWordSize)); |
1490 if (num_args == 2) { | 1506 if (num_args == 2) { |
1491 __ movq(R13, Address(RSP, + 2 * kWordSize)); | 1507 __ movq(R9, Address(RSP, + 2 * kWordSize)); |
1492 } | 1508 } |
1493 __ EnterStubFrame(); | 1509 __ EnterStubFrame(); |
1494 __ pushq(RBX); | 1510 __ pushq(RBX); |
1495 if (num_args == 2) { | 1511 if (num_args == 2) { |
1496 __ pushq(R13); | 1512 __ pushq(R9); |
1497 } | 1513 } |
1498 __ pushq(R8); | 1514 __ pushq(R8); |
| 1515 __ movq(CODE_REG, R13); |
1499 __ call(RCX); | 1516 __ call(RCX); |
1500 | 1517 |
1501 Label done; | 1518 Label done; |
1502 __ movq(RDX, RAX); | 1519 __ movq(RDX, RAX); |
1503 __ movq(RBX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); | 1520 __ movq(RBX, Address(RBP, kFirstLocalSlotFromFp * kWordSize)); |
1504 __ UpdateRangeFeedback(RDX, 2, RBX, RCX, &done); | 1521 __ UpdateRangeFeedback(RDX, 2, RBX, RCX, &done); |
1505 __ Bind(&done); | 1522 __ Bind(&done); |
1506 __ LeaveStubFrame(); | 1523 __ LeaveStubFrame(); |
1507 __ ret(); | 1524 __ ret(); |
1508 } else { | 1525 } else { |
| 1526 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset())); |
| 1527 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); |
1509 __ jmp(RCX); | 1528 __ jmp(RCX); |
1510 } | 1529 } |
1511 | 1530 |
1512 if (FLAG_support_debugger && !optimized) { | 1531 if (FLAG_support_debugger && !optimized) { |
1513 __ Bind(&stepping); | 1532 __ Bind(&stepping); |
1514 __ EnterStubFrame(); | 1533 __ EnterStubFrame(); |
1515 __ pushq(RBX); | 1534 __ pushq(RBX); |
1516 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1535 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1517 __ popq(RBX); | 1536 __ popq(RBX); |
| 1537 __ RestoreCodePointer(); |
1518 __ LeaveStubFrame(); | 1538 __ LeaveStubFrame(); |
1519 __ jmp(&done_stepping); | 1539 __ jmp(&done_stepping); |
1520 } | 1540 } |
1521 } | 1541 } |
1522 | 1542 |
1523 | 1543 |
1524 // Use inline cache data array to invoke the target or continue in inline | 1544 // Use inline cache data array to invoke the target or continue in inline |
1525 // cache miss handler. Stub for 1-argument check (receiver class). | 1545 // cache miss handler. Stub for 1-argument check (receiver class). |
1526 // RBX: Inline cache data object. | 1546 // RBX: Inline cache data object. |
1527 // TOS(0): Return address. | 1547 // TOS(0): Return address. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 __ movq(R13, Immediate(Smi::RawValue(Smi::kMaxValue))); | 1696 __ movq(R13, Immediate(Smi::RawValue(Smi::kMaxValue))); |
1677 __ cmovnoq(R13, R8); | 1697 __ cmovnoq(R13, R8); |
1678 __ StoreIntoSmiField(Address(R12, count_offset), R13); | 1698 __ StoreIntoSmiField(Address(R12, count_offset), R13); |
1679 } | 1699 } |
1680 | 1700 |
1681 // Load arguments descriptor into R10. | 1701 // Load arguments descriptor into R10. |
1682 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); | 1702 __ movq(R10, FieldAddress(RBX, ICData::arguments_descriptor_offset())); |
1683 | 1703 |
1684 // Get function and call it, if possible. | 1704 // Get function and call it, if possible. |
1685 __ movq(RAX, Address(R12, target_offset)); | 1705 __ movq(RAX, Address(R12, target_offset)); |
| 1706 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset())); |
1686 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); | 1707 __ movq(RCX, FieldAddress(RAX, Function::entry_point_offset())); |
1687 __ jmp(RCX); | 1708 __ jmp(RCX); |
1688 | 1709 |
1689 if (FLAG_support_debugger) { | 1710 if (FLAG_support_debugger) { |
1690 __ Bind(&stepping); | 1711 __ Bind(&stepping); |
1691 __ EnterStubFrame(); | 1712 __ EnterStubFrame(); |
1692 __ pushq(RBX); // Preserve IC data object. | 1713 __ pushq(RBX); // Preserve IC data object. |
1693 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 1714 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
1694 __ popq(RBX); | 1715 __ popq(RBX); |
| 1716 __ RestoreCodePointer(); |
1695 __ LeaveStubFrame(); | 1717 __ LeaveStubFrame(); |
1696 __ jmp(&done_stepping, Assembler::kNearJump); | 1718 __ jmp(&done_stepping, Assembler::kNearJump); |
1697 } | 1719 } |
1698 } | 1720 } |
1699 | 1721 |
1700 | 1722 |
1701 void StubCode::GenerateOneArgUnoptimizedStaticCallStub(Assembler* assembler) { | 1723 void StubCode::GenerateOneArgUnoptimizedStaticCallStub(Assembler* assembler) { |
1702 GenerateUsageCounterIncrement(assembler, RCX); | 1724 GenerateUsageCounterIncrement(assembler, RCX); |
1703 GenerateNArgsCheckInlineCacheStub( | 1725 GenerateNArgsCheckInlineCacheStub( |
1704 assembler, | 1726 assembler, |
(...skipping 22 matching lines...) Expand all Loading... |
1727 __ EnterStubFrame(); | 1749 __ EnterStubFrame(); |
1728 __ pushq(R10); // Preserve arguments descriptor array. | 1750 __ pushq(R10); // Preserve arguments descriptor array. |
1729 __ pushq(RBX); // Preserve IC data object. | 1751 __ pushq(RBX); // Preserve IC data object. |
1730 __ pushq(RAX); // Pass function. | 1752 __ pushq(RAX); // Pass function. |
1731 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); | 1753 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); |
1732 __ popq(RAX); // Restore function. | 1754 __ popq(RAX); // Restore function. |
1733 __ popq(RBX); // Restore IC data array. | 1755 __ popq(RBX); // Restore IC data array. |
1734 __ popq(R10); // Restore arguments descriptor array. | 1756 __ popq(R10); // Restore arguments descriptor array. |
1735 __ LeaveStubFrame(); | 1757 __ LeaveStubFrame(); |
1736 | 1758 |
| 1759 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset())); |
1737 __ movq(RAX, FieldAddress(RAX, Function::entry_point_offset())); | 1760 __ movq(RAX, FieldAddress(RAX, Function::entry_point_offset())); |
1738 __ jmp(RAX); | 1761 __ jmp(RAX); |
1739 } | 1762 } |
1740 | 1763 |
1741 | 1764 |
1742 // RBX: Contains an ICData. | 1765 // RBX: Contains an ICData. |
1743 // TOS(0): return address (Dart code). | 1766 // TOS(0): return address (Dart code). |
1744 void StubCode::GenerateICCallBreakpointStub(Assembler* assembler) { | 1767 void StubCode::GenerateICCallBreakpointStub(Assembler* assembler) { |
1745 __ EnterStubFrame(); | 1768 __ EnterStubFrame(); |
1746 // Preserve IC data. | 1769 // Preserve IC data. |
1747 __ pushq(RBX); | 1770 __ pushq(RBX); |
1748 // Room for result. Debugger stub returns address of the | 1771 // Room for result. Debugger stub returns address of the |
1749 // unpatched runtime stub. | 1772 // unpatched runtime stub. |
1750 __ LoadObject(R12, Object::null_object()); | 1773 __ LoadObject(R12, Object::null_object()); |
1751 __ pushq(R12); // Room for result. | 1774 __ pushq(R12); // Room for result. |
1752 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); | 1775 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
1753 __ popq(RAX); // Address of original. | 1776 __ popq(CODE_REG); // Address of original. |
1754 __ popq(RBX); // Restore IC data. | 1777 __ popq(RBX); // Restore IC data. |
1755 __ LeaveStubFrame(); | 1778 __ LeaveStubFrame(); |
| 1779 |
| 1780 __ movq(RAX, FieldAddress(CODE_REG, Code::entry_point_offset())); |
1756 __ jmp(RAX); // Jump to original stub. | 1781 __ jmp(RAX); // Jump to original stub. |
1757 } | 1782 } |
1758 | 1783 |
1759 | 1784 |
1760 // TOS(0): return address (Dart code). | 1785 // TOS(0): return address (Dart code). |
1761 void StubCode::GenerateRuntimeCallBreakpointStub(Assembler* assembler) { | 1786 void StubCode::GenerateRuntimeCallBreakpointStub(Assembler* assembler) { |
1762 __ EnterStubFrame(); | 1787 __ EnterStubFrame(); |
1763 // Room for result. Debugger stub returns address of the | 1788 // Room for result. Debugger stub returns address of the |
1764 // unpatched runtime stub. | 1789 // unpatched runtime stub. |
1765 __ LoadObject(R12, Object::null_object()); | 1790 __ LoadObject(R12, Object::null_object()); |
1766 __ pushq(R12); // Room for result. | 1791 __ pushq(R12); // Room for result. |
1767 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); | 1792 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); |
1768 __ popq(RAX); // Address of original. | 1793 __ popq(CODE_REG); // Address of original. |
1769 __ LeaveStubFrame(); | 1794 __ LeaveStubFrame(); |
| 1795 |
| 1796 __ movq(RAX, FieldAddress(CODE_REG, Code::entry_point_offset())); |
1770 __ jmp(RAX); // Jump to original stub. | 1797 __ jmp(RAX); // Jump to original stub. |
1771 } | 1798 } |
1772 | 1799 |
1773 | 1800 |
1774 // Called only from unoptimized code. | 1801 // Called only from unoptimized code. |
1775 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { | 1802 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { |
1776 // Check single stepping. | 1803 // Check single stepping. |
1777 Label stepping, done_stepping; | 1804 Label stepping, done_stepping; |
1778 __ LoadIsolate(RAX); | 1805 __ LoadIsolate(RAX); |
1779 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); | 1806 __ movzxb(RAX, Address(RAX, Isolate::single_step_offset())); |
(...skipping 15 matching lines...) Expand all Loading... |
1795 // TOS + 1: instantiator type arguments (can be NULL). | 1822 // TOS + 1: instantiator type arguments (can be NULL). |
1796 // TOS + 2: instance. | 1823 // TOS + 2: instance. |
1797 // TOS + 3: SubtypeTestCache. | 1824 // TOS + 3: SubtypeTestCache. |
1798 // Result in RCX: null -> not found, otherwise result (true or false). | 1825 // Result in RCX: null -> not found, otherwise result (true or false). |
1799 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { | 1826 static void GenerateSubtypeNTestCacheStub(Assembler* assembler, int n) { |
1800 ASSERT((1 <= n) && (n <= 3)); | 1827 ASSERT((1 <= n) && (n <= 3)); |
1801 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; | 1828 const intptr_t kInstantiatorTypeArgumentsInBytes = 1 * kWordSize; |
1802 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; | 1829 const intptr_t kInstanceOffsetInBytes = 2 * kWordSize; |
1803 const intptr_t kCacheOffsetInBytes = 3 * kWordSize; | 1830 const intptr_t kCacheOffsetInBytes = 3 * kWordSize; |
1804 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes)); | 1831 __ movq(RAX, Address(RSP, kInstanceOffsetInBytes)); |
1805 __ LoadObject(R12, Object::null_object()); | 1832 __ LoadObject(R9, Object::null_object()); |
1806 if (n > 1) { | 1833 if (n > 1) { |
1807 __ LoadClass(R10, RAX); | 1834 __ LoadClass(R10, RAX); |
1808 // Compute instance type arguments into R13. | 1835 // Compute instance type arguments into R13. |
1809 Label has_no_type_arguments; | 1836 Label has_no_type_arguments; |
1810 __ movq(R13, R12); | 1837 __ movq(R13, R9); |
1811 __ movl(RDI, FieldAddress(R10, | 1838 __ movl(RDI, FieldAddress(R10, |
1812 Class::type_arguments_field_offset_in_words_offset())); | 1839 Class::type_arguments_field_offset_in_words_offset())); |
1813 __ cmpl(RDI, Immediate(Class::kNoTypeArguments)); | 1840 __ cmpl(RDI, Immediate(Class::kNoTypeArguments)); |
1814 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); | 1841 __ j(EQUAL, &has_no_type_arguments, Assembler::kNearJump); |
1815 __ movq(R13, FieldAddress(RAX, RDI, TIMES_8, 0)); | 1842 __ movq(R13, FieldAddress(RAX, RDI, TIMES_8, 0)); |
1816 __ Bind(&has_no_type_arguments); | 1843 __ Bind(&has_no_type_arguments); |
1817 } | 1844 } |
1818 __ LoadClassId(R10, RAX); | 1845 __ LoadClassId(R10, RAX); |
1819 // RAX: instance, R10: instance class id. | 1846 // RAX: instance, R10: instance class id. |
1820 // R13: instance type arguments or null, used only if n > 1. | 1847 // R13: instance type arguments or null, used only if n > 1. |
1821 __ movq(RDX, Address(RSP, kCacheOffsetInBytes)); | 1848 __ movq(RDX, Address(RSP, kCacheOffsetInBytes)); |
1822 // RDX: SubtypeTestCache. | 1849 // RDX: SubtypeTestCache. |
1823 __ movq(RDX, FieldAddress(RDX, SubtypeTestCache::cache_offset())); | 1850 __ movq(RDX, FieldAddress(RDX, SubtypeTestCache::cache_offset())); |
1824 __ addq(RDX, Immediate(Array::data_offset() - kHeapObjectTag)); | 1851 __ addq(RDX, Immediate(Array::data_offset() - kHeapObjectTag)); |
1825 // RDX: Entry start. | 1852 // RDX: Entry start. |
1826 // R10: instance class id. | 1853 // R10: instance class id. |
1827 // R13: instance type arguments. | 1854 // R13: instance type arguments. |
1828 Label loop, found, not_found, next_iteration; | 1855 Label loop, found, not_found, next_iteration; |
1829 __ SmiTag(R10); | 1856 __ SmiTag(R10); |
1830 __ Bind(&loop); | 1857 __ Bind(&loop); |
1831 __ movq(RDI, Address(RDX, kWordSize * SubtypeTestCache::kInstanceClassId)); | 1858 __ movq(RDI, Address(RDX, kWordSize * SubtypeTestCache::kInstanceClassId)); |
1832 __ cmpq(RDI, R12); | 1859 __ cmpq(RDI, R9); |
1833 __ j(EQUAL, ¬_found, Assembler::kNearJump); | 1860 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
1834 __ cmpq(RDI, R10); | 1861 __ cmpq(RDI, R10); |
1835 if (n == 1) { | 1862 if (n == 1) { |
1836 __ j(EQUAL, &found, Assembler::kNearJump); | 1863 __ j(EQUAL, &found, Assembler::kNearJump); |
1837 } else { | 1864 } else { |
1838 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); | 1865 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
1839 __ movq(RDI, | 1866 __ movq(RDI, |
1840 Address(RDX, kWordSize * SubtypeTestCache::kInstanceTypeArguments)); | 1867 Address(RDX, kWordSize * SubtypeTestCache::kInstanceTypeArguments)); |
1841 __ cmpq(RDI, R13); | 1868 __ cmpq(RDI, R13); |
1842 if (n == 2) { | 1869 if (n == 2) { |
1843 __ j(EQUAL, &found, Assembler::kNearJump); | 1870 __ j(EQUAL, &found, Assembler::kNearJump); |
1844 } else { | 1871 } else { |
1845 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); | 1872 __ j(NOT_EQUAL, &next_iteration, Assembler::kNearJump); |
1846 __ movq(RDI, | 1873 __ movq(RDI, |
1847 Address(RDX, | 1874 Address(RDX, |
1848 kWordSize * SubtypeTestCache::kInstantiatorTypeArguments)); | 1875 kWordSize * SubtypeTestCache::kInstantiatorTypeArguments)); |
1849 __ cmpq(RDI, Address(RSP, kInstantiatorTypeArgumentsInBytes)); | 1876 __ cmpq(RDI, Address(RSP, kInstantiatorTypeArgumentsInBytes)); |
1850 __ j(EQUAL, &found, Assembler::kNearJump); | 1877 __ j(EQUAL, &found, Assembler::kNearJump); |
1851 } | 1878 } |
1852 } | 1879 } |
1853 | 1880 |
1854 __ Bind(&next_iteration); | 1881 __ Bind(&next_iteration); |
1855 __ addq(RDX, Immediate(kWordSize * SubtypeTestCache::kTestEntryLength)); | 1882 __ addq(RDX, Immediate(kWordSize * SubtypeTestCache::kTestEntryLength)); |
1856 __ jmp(&loop, Assembler::kNearJump); | 1883 __ jmp(&loop, Assembler::kNearJump); |
1857 // Fall through to not found. | 1884 // Fall through to not found. |
1858 __ Bind(¬_found); | 1885 __ Bind(¬_found); |
1859 __ movq(RCX, R12); | 1886 __ movq(RCX, R9); |
1860 __ ret(); | 1887 __ ret(); |
1861 | 1888 |
1862 __ Bind(&found); | 1889 __ Bind(&found); |
1863 __ movq(RCX, Address(RDX, kWordSize * SubtypeTestCache::kTestResult)); | 1890 __ movq(RCX, Address(RDX, kWordSize * SubtypeTestCache::kTestResult)); |
1864 __ ret(); | 1891 __ ret(); |
1865 } | 1892 } |
1866 | 1893 |
1867 | 1894 |
1868 // Used to check class and type arguments. Arguments passed on stack: | 1895 // Used to check class and type arguments. Arguments passed on stack: |
1869 // TOS + 0: return address. | 1896 // TOS + 0: return address. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 // RDI: function to be reoptimized. | 1979 // RDI: function to be reoptimized. |
1953 // R10: argument descriptor (preserved). | 1980 // R10: argument descriptor (preserved). |
1954 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { | 1981 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { |
1955 __ EnterStubFrame(); | 1982 __ EnterStubFrame(); |
1956 __ LoadObject(R12, Object::null_object()); | 1983 __ LoadObject(R12, Object::null_object()); |
1957 __ pushq(R10); | 1984 __ pushq(R10); |
1958 __ pushq(R12); // Setup space on stack for return value. | 1985 __ pushq(R12); // Setup space on stack for return value. |
1959 __ pushq(RDI); | 1986 __ pushq(RDI); |
1960 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); | 1987 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); |
1961 __ popq(RAX); // Disard argument. | 1988 __ popq(RAX); // Disard argument. |
1962 __ popq(RAX); // Get Code object. | 1989 __ popq(CODE_REG); // Get Code object. |
1963 __ popq(R10); // Restore argument descriptor. | 1990 __ popq(R10); // Restore argument descriptor. |
1964 __ movq(RAX, FieldAddress(RAX, Code::entry_point_offset())); | 1991 __ movq(RAX, FieldAddress(CODE_REG, Code::entry_point_offset())); |
1965 __ LeaveStubFrame(); | 1992 __ LeaveStubFrame(); |
1966 __ jmp(RAX); | 1993 __ jmp(RAX); |
1967 __ int3(); | 1994 __ int3(); |
1968 } | 1995 } |
1969 | 1996 |
1970 | 1997 |
1971 // Does identical check (object references are equal or not equal) with special | 1998 // Does identical check (object references are equal or not equal) with special |
1972 // checks for boxed numbers. | 1999 // checks for boxed numbers. |
1973 // Left and right are pushed on stack. | 2000 // Left and right are pushed on stack. |
1974 // Return ZF set. | 2001 // Return ZF set. |
1975 // Note: A Mint cannot contain a value that would fit in Smi, a Bigint | 2002 // Note: A Mint cannot contain a value that would fit in Smi, a Bigint |
1976 // cannot contain a value that fits in Mint or Smi. | 2003 // cannot contain a value that fits in Mint or Smi. |
1977 static void GenerateIdenticalWithNumberCheckStub(Assembler* assembler, | 2004 static void GenerateIdenticalWithNumberCheckStub(Assembler* assembler, |
1978 const Register left, | 2005 const Register left, |
1979 const Register right) { | 2006 const Register right) { |
1980 Label reference_compare, done, check_mint, check_bigint; | 2007 Label reference_compare, done, check_mint, check_bigint; |
1981 // If any of the arguments is Smi do reference compare. | 2008 // If any of the arguments is Smi do reference compare. |
1982 __ testq(left, Immediate(kSmiTagMask)); | 2009 __ testq(left, Immediate(kSmiTagMask)); |
1983 __ j(ZERO, &reference_compare); | 2010 __ j(ZERO, &reference_compare); |
1984 __ testq(right, Immediate(kSmiTagMask)); | 2011 __ testq(right, Immediate(kSmiTagMask)); |
1985 __ j(ZERO, &reference_compare); | 2012 __ j(ZERO, &reference_compare); |
1986 | 2013 |
1987 // Value compare for two doubles. | 2014 // Value compare for two doubles. |
1988 __ CompareClassId(left, kDoubleCid); | 2015 __ CompareClassId(left, kDoubleCid); |
1989 __ j(NOT_EQUAL, &check_mint, Assembler::kNearJump); | 2016 __ j(NOT_EQUAL, &check_mint, Assembler::kNearJump); |
1990 __ CompareClassId(right, kDoubleCid); | 2017 __ CompareClassId(right, kDoubleCid); |
1991 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 2018 __ j(NOT_EQUAL, &done, Assembler::kFarJump); |
1992 | 2019 |
1993 // Double values bitwise compare. | 2020 // Double values bitwise compare. |
1994 __ movq(left, FieldAddress(left, Double::value_offset())); | 2021 __ movq(left, FieldAddress(left, Double::value_offset())); |
1995 __ cmpq(left, FieldAddress(right, Double::value_offset())); | 2022 __ cmpq(left, FieldAddress(right, Double::value_offset())); |
1996 __ jmp(&done, Assembler::kNearJump); | 2023 __ jmp(&done, Assembler::kFarJump); |
1997 | 2024 |
1998 __ Bind(&check_mint); | 2025 __ Bind(&check_mint); |
1999 __ CompareClassId(left, kMintCid); | 2026 __ CompareClassId(left, kMintCid); |
2000 __ j(NOT_EQUAL, &check_bigint, Assembler::kNearJump); | 2027 __ j(NOT_EQUAL, &check_bigint, Assembler::kNearJump); |
2001 __ CompareClassId(right, kMintCid); | 2028 __ CompareClassId(right, kMintCid); |
2002 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 2029 __ j(NOT_EQUAL, &done, Assembler::kFarJump); |
2003 __ movq(left, FieldAddress(left, Mint::value_offset())); | 2030 __ movq(left, FieldAddress(left, Mint::value_offset())); |
2004 __ cmpq(left, FieldAddress(right, Mint::value_offset())); | 2031 __ cmpq(left, FieldAddress(right, Mint::value_offset())); |
2005 __ jmp(&done, Assembler::kNearJump); | 2032 __ jmp(&done, Assembler::kFarJump); |
2006 | 2033 |
2007 __ Bind(&check_bigint); | 2034 __ Bind(&check_bigint); |
2008 __ CompareClassId(left, kBigintCid); | 2035 __ CompareClassId(left, kBigintCid); |
2009 __ j(NOT_EQUAL, &reference_compare, Assembler::kNearJump); | 2036 __ j(NOT_EQUAL, &reference_compare, Assembler::kFarJump); |
2010 __ CompareClassId(right, kBigintCid); | 2037 __ CompareClassId(right, kBigintCid); |
2011 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 2038 __ j(NOT_EQUAL, &done, Assembler::kFarJump); |
2012 __ EnterStubFrame(); | 2039 __ EnterStubFrame(); |
2013 __ ReserveAlignedFrameSpace(0); | 2040 __ ReserveAlignedFrameSpace(0); |
2014 __ movq(CallingConventions::kArg1Reg, left); | 2041 __ movq(CallingConventions::kArg1Reg, left); |
2015 __ movq(CallingConventions::kArg2Reg, right); | 2042 __ movq(CallingConventions::kArg2Reg, right); |
2016 __ CallRuntime(kBigintCompareRuntimeEntry, 2); | 2043 __ CallRuntime(kBigintCompareRuntimeEntry, 2); |
2017 // Result in RAX, 0 means equal. | 2044 // Result in RAX, 0 means equal. |
2018 __ LeaveStubFrame(); | 2045 __ LeaveStubFrame(); |
2019 __ cmpq(RAX, Immediate(0)); | 2046 __ cmpq(RAX, Immediate(0)); |
2020 __ jmp(&done); | 2047 __ jmp(&done); |
2021 | 2048 |
(...skipping 25 matching lines...) Expand all Loading... |
2047 | 2074 |
2048 __ movq(left, Address(RSP, 2 * kWordSize)); | 2075 __ movq(left, Address(RSP, 2 * kWordSize)); |
2049 __ movq(right, Address(RSP, 1 * kWordSize)); | 2076 __ movq(right, Address(RSP, 1 * kWordSize)); |
2050 GenerateIdenticalWithNumberCheckStub(assembler, left, right); | 2077 GenerateIdenticalWithNumberCheckStub(assembler, left, right); |
2051 __ ret(); | 2078 __ ret(); |
2052 | 2079 |
2053 if (FLAG_support_debugger) { | 2080 if (FLAG_support_debugger) { |
2054 __ Bind(&stepping); | 2081 __ Bind(&stepping); |
2055 __ EnterStubFrame(); | 2082 __ EnterStubFrame(); |
2056 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); | 2083 __ CallRuntime(kSingleStepHandlerRuntimeEntry, 0); |
| 2084 __ RestoreCodePointer(); |
2057 __ LeaveStubFrame(); | 2085 __ LeaveStubFrame(); |
2058 __ jmp(&done_stepping); | 2086 __ jmp(&done_stepping); |
2059 } | 2087 } |
2060 } | 2088 } |
2061 | 2089 |
2062 | 2090 |
2063 // Called from optimized code only. | 2091 // Called from optimized code only. |
2064 // TOS + 0: return address | 2092 // TOS + 0: return address |
2065 // TOS + 1: right argument. | 2093 // TOS + 1: right argument. |
2066 // TOS + 2: left argument. | 2094 // TOS + 2: left argument. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 __ j(ZERO, &call_target_function, Assembler::kNearJump); | 2132 __ j(ZERO, &call_target_function, Assembler::kNearJump); |
2105 __ cmpq(RDX, RAX); | 2133 __ cmpq(RDX, RAX); |
2106 __ j(NOT_EQUAL, &update, Assembler::kNearJump); | 2134 __ j(NOT_EQUAL, &update, Assembler::kNearJump); |
2107 | 2135 |
2108 __ Bind(&call_target_function); | 2136 __ Bind(&call_target_function); |
2109 // Call the target found in the cache. For a class id match, this is a | 2137 // Call the target found in the cache. For a class id match, this is a |
2110 // proper target for the given name and arguments descriptor. If the | 2138 // proper target for the given name and arguments descriptor. If the |
2111 // illegal class id was found, the target is a cache miss handler that can | 2139 // illegal class id was found, the target is a cache miss handler that can |
2112 // be invoked as a normal Dart function. | 2140 // be invoked as a normal Dart function. |
2113 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); | 2141 __ movq(RAX, FieldAddress(RDI, RCX, TIMES_8, base + kWordSize)); |
| 2142 __ movq(CODE_REG, FieldAddress(RAX, Function::code_offset())); |
2114 __ movq(target, FieldAddress(RAX, Function::entry_point_offset())); | 2143 __ movq(target, FieldAddress(RAX, Function::entry_point_offset())); |
2115 } | 2144 } |
2116 | 2145 |
2117 | 2146 |
2118 // Called from megamorphic calls. | 2147 // Called from megamorphic calls. |
2119 // RDI: receiver. | 2148 // RDI: receiver. |
2120 // RBX: lookup cache. | 2149 // RBX: lookup cache. |
2121 // Result: | 2150 // Result: |
2122 // RCX: entry point. | 2151 // RCX: entry point. |
2123 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { | 2152 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { |
2124 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); | 2153 EmitMegamorphicLookup(assembler, RDI, RBX, RCX); |
2125 __ ret(); | 2154 __ ret(); |
2126 } | 2155 } |
2127 | 2156 |
2128 } // namespace dart | 2157 } // namespace dart |
2129 | 2158 |
2130 #endif // defined TARGET_ARCH_X64 | 2159 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |