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