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