| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 "Set to true for debugging & verifying the slow paths."); | 23 "Set to true for debugging & verifying the slow paths."); |
| 24 | 24 |
| 25 // Input parameters: | 25 // Input parameters: |
| 26 // RSP : points to return address. | 26 // RSP : points to return address. |
| 27 // RSP + 8 : address of last argument in argument array. | 27 // RSP + 8 : address of last argument in argument array. |
| 28 // RSP + 8*R10 : address of first argument in argument array. | 28 // RSP + 8*R10 : address of first argument in argument array. |
| 29 // RSP + 8*R10 + 8 : address of return value. | 29 // RSP + 8*R10 + 8 : address of return value. |
| 30 // RBX : address of the runtime function to call. | 30 // RBX : address of the runtime function to call. |
| 31 // R10 : number of arguments to the call. | 31 // R10 : number of arguments to the call. |
| 32 // Must preserve callee saved registers R12 and R13. | 32 // Must preserve callee saved registers R12 and R13. |
| 33 static void GenerateCallRuntimeStub(Assembler* assembler) { | 33 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { |
| 34 ASSERT((R12 != CTX) && (R13 != CTX)); | 34 ASSERT((R12 != CTX) && (R13 != CTX)); |
| 35 const intptr_t isolate_offset = NativeArguments::isolate_offset(); | 35 const intptr_t isolate_offset = NativeArguments::isolate_offset(); |
| 36 const intptr_t argc_offset = NativeArguments::argc_offset(); | 36 const intptr_t argc_offset = NativeArguments::argc_offset(); |
| 37 const intptr_t argv_offset = NativeArguments::argv_offset(); | 37 const intptr_t argv_offset = NativeArguments::argv_offset(); |
| 38 const intptr_t retval_offset = NativeArguments::retval_offset(); | 38 const intptr_t retval_offset = NativeArguments::retval_offset(); |
| 39 | 39 |
| 40 __ EnterFrame(0); | 40 __ EnterFrame(0); |
| 41 | 41 |
| 42 // Load current Isolate pointer from Context structure into RAX. | 42 // Load current Isolate pointer from Context structure into RAX. |
| 43 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); | 43 __ movq(RAX, FieldAddress(CTX, Context::isolate_offset())); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 __ movq(Address(CTX, Isolate::top_context_offset()), raw_null); | 79 __ movq(Address(CTX, Isolate::top_context_offset()), raw_null); |
| 80 | 80 |
| 81 // Cache Context pointer into CTX while executing Dart code. | 81 // Cache Context pointer into CTX while executing Dart code. |
| 82 __ movq(CTX, RBX); | 82 __ movq(CTX, RBX); |
| 83 | 83 |
| 84 __ LeaveFrame(); | 84 __ LeaveFrame(); |
| 85 __ ret(); | 85 __ ret(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 | 88 |
| 89 // Input parameters: | |
| 90 // RSP : points to return address. | |
| 91 // RSP + 8 : address of last argument in argument array. | |
| 92 // RSP + 8*R10 : address of first argument in argument array. | |
| 93 // RSP + 8*R10 + 8 : address of return value. | |
| 94 // RBX : address of the runtime function to call. | |
| 95 // R10 : number of arguments to the call. | |
| 96 // Must preserve callee saved registers R12 and R13. | |
| 97 void StubCode::GenerateDartCallToRuntimeStub(Assembler* assembler) { | |
| 98 GenerateCallRuntimeStub(assembler); | |
| 99 } | |
| 100 | |
| 101 | |
| 102 // Input parameters: | |
| 103 // RSP : points to return address. | |
| 104 // RSP + 8 : address of last argument in argument array. | |
| 105 // RSP + 8*R10 : address of first argument in argument array. | |
| 106 // RSP + 8*R10 + 8 : address of return value. | |
| 107 // RBX : address of the runtime function to call. | |
| 108 // R10 : number of arguments to the call. | |
| 109 // Must preserve callee saved registers R12 and R13. | |
| 110 void StubCode::GenerateStubCallToRuntimeStub(Assembler* assembler) { | |
| 111 GenerateCallRuntimeStub(assembler); | |
| 112 } | |
| 113 | |
| 114 | |
| 115 // Print the stop message. | 89 // Print the stop message. |
| 116 static void PrintStopMessage(const char* message) { | 90 static void PrintStopMessage(const char* message) { |
| 117 OS::Print("Stop message: %s\n", message); | 91 OS::Print("Stop message: %s\n", message); |
| 118 } | 92 } |
| 119 | 93 |
| 120 | 94 |
| 121 // Input parameters: | 95 // Input parameters: |
| 122 // RSP : points to return address. | 96 // RSP : points to return address. |
| 123 // RDI : stop message (const char*). | 97 // RDI : stop message (const char*). |
| 124 // Must preserve all registers, except RDI and TMP. | 98 // Must preserve all registers, except RDI and TMP. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 __ cmpq(RAX, raw_null); | 212 __ cmpq(RAX, raw_null); |
| 239 Label function_compiled; | 213 Label function_compiled; |
| 240 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump); | 214 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump); |
| 241 | 215 |
| 242 // Create a stub frame as we are pushing some objects on the stack before | 216 // Create a stub frame as we are pushing some objects on the stack before |
| 243 // calling into the runtime. | 217 // calling into the runtime. |
| 244 __ EnterFrame(0); | 218 __ EnterFrame(0); |
| 245 | 219 |
| 246 __ pushq(R10); // Preserve arguments descriptor array. | 220 __ pushq(R10); // Preserve arguments descriptor array. |
| 247 __ pushq(RBX); | 221 __ pushq(RBX); |
| 248 __ CallRuntimeFromStub(kCompileFunctionRuntimeEntry); | 222 __ CallRuntime(kCompileFunctionRuntimeEntry); |
| 249 __ popq(RBX); // Restore read-only function object argument in RBX. | 223 __ popq(RBX); // Restore read-only function object argument in RBX. |
| 250 __ popq(R10); // Restore arguments descriptor array. | 224 __ popq(R10); // Restore arguments descriptor array. |
| 251 // Restore RAX. | 225 // Restore RAX. |
| 252 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); | 226 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); |
| 253 | 227 |
| 254 // Remove the stub frame as we are about to jump to the dart function. | 228 // Remove the stub frame as we are about to jump to the dart function. |
| 255 __ LeaveFrame(); | 229 __ LeaveFrame(); |
| 256 | 230 |
| 257 __ Bind(&function_compiled); | 231 __ Bind(&function_compiled); |
| 258 // Patch caller. | 232 // Patch caller. |
| 259 __ EnterFrame(0); | 233 __ EnterFrame(0); |
| 260 | 234 |
| 261 __ pushq(R10); // Preserve arguments descriptor array. | 235 __ pushq(R10); // Preserve arguments descriptor array. |
| 262 __ pushq(RBX); // Preserve function object. | 236 __ pushq(RBX); // Preserve function object. |
| 263 __ CallRuntimeFromStub(kPatchStaticCallRuntimeEntry); | 237 __ CallRuntime(kPatchStaticCallRuntimeEntry); |
| 264 __ popq(RBX); // Restore function object argument in RBX. | 238 __ popq(RBX); // Restore function object argument in RBX. |
| 265 __ popq(R10); // Restore arguments descriptor array. | 239 __ popq(R10); // Restore arguments descriptor array. |
| 266 // Remove the stub frame as we are about to jump to the dart function. | 240 // Remove the stub frame as we are about to jump to the dart function. |
| 267 __ LeaveFrame(); | 241 __ LeaveFrame(); |
| 268 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); | 242 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); |
| 269 | 243 |
| 270 __ movq(RBX, FieldAddress(RAX, Code::instructions_offset())); | 244 __ movq(RBX, FieldAddress(RAX, Code::instructions_offset())); |
| 271 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 245 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 272 __ jmp(RBX); | 246 __ jmp(RBX); |
| 273 } | 247 } |
| 274 | 248 |
| 275 | 249 |
| 276 // Called from a static call only when an invalid code has been entered | 250 // Called from a static call only when an invalid code has been entered |
| 277 // (invalid because its function was optimized or deoptimized). | 251 // (invalid because its function was optimized or deoptimized). |
| 278 // RBX: function object. | 252 // RBX: function object. |
| 279 // R10: arguments descriptor array (num_args is first Smi element). | 253 // R10: arguments descriptor array (num_args is first Smi element). |
| 280 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { | 254 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { |
| 281 __ Untested("FixCallersTarget stub"); | 255 __ Untested("FixCallersTarget stub"); |
| 282 __ EnterFrame(0); | 256 __ EnterFrame(0); |
| 283 __ pushq(R10); // Preserve arguments descriptor array. | 257 __ pushq(R10); // Preserve arguments descriptor array. |
| 284 __ pushq(RBX); // Preserve target function. | 258 __ pushq(RBX); // Preserve target function. |
| 285 __ pushq(RBX); // Target function. | 259 __ pushq(RBX); // Target function. |
| 286 __ CallRuntimeFromStub(kFixCallersTargetRuntimeEntry); | 260 __ CallRuntime(kFixCallersTargetRuntimeEntry); |
| 287 __ popq(RAX); // discard argument. | 261 __ popq(RAX); // discard argument. |
| 288 __ popq(RAX); // Restore function. | 262 __ popq(RAX); // Restore function. |
| 289 __ popq(R10); // Restore arguments descriptor array. | 263 __ popq(R10); // Restore arguments descriptor array. |
| 290 __ movq(RAX, FieldAddress(RAX, Function::code_offset())); | 264 __ movq(RAX, FieldAddress(RAX, Function::code_offset())); |
| 291 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset())); | 265 __ movq(RAX, FieldAddress(RAX, Code::instructions_offset())); |
| 292 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 266 __ addq(RAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 293 __ LeaveFrame(); | 267 __ LeaveFrame(); |
| 294 __ jmp(RAX); | 268 __ jmp(RAX); |
| 295 __ int3(); | 269 __ int3(); |
| 296 } | 270 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // Total number of args is the first Smi in args descriptor array (R10). | 409 // Total number of args is the first Smi in args descriptor array (R10). |
| 436 __ movq(RAX, FieldAddress(R10, Array::data_offset())); | 410 __ movq(RAX, FieldAddress(R10, Array::data_offset())); |
| 437 __ movq(RAX, Address(RSP, RAX, TIMES_4, kWordSize)); // Get receiver. | 411 __ movq(RAX, Address(RSP, RAX, TIMES_4, kWordSize)); // Get receiver. |
| 438 __ pushq(R10); // Preserve arguments descriptor array. | 412 __ pushq(R10); // Preserve arguments descriptor array. |
| 439 __ pushq(RAX); // Preserve receiver. | 413 __ pushq(RAX); // Preserve receiver. |
| 440 __ pushq(RBX); // Preserve ic-data. | 414 __ pushq(RBX); // Preserve ic-data. |
| 441 // First resolve the function to get the function object. | 415 // First resolve the function to get the function object. |
| 442 | 416 |
| 443 __ pushq(raw_null); // Setup space on stack for return value. | 417 __ pushq(raw_null); // Setup space on stack for return value. |
| 444 __ pushq(RAX); // Push receiver. | 418 __ pushq(RAX); // Push receiver. |
| 445 __ CallRuntimeFromStub(kResolveCompileInstanceFunctionRuntimeEntry); | 419 __ CallRuntime(kResolveCompileInstanceFunctionRuntimeEntry); |
| 446 __ popq(RAX); // Remove receiver pushed earlier. | 420 __ popq(RAX); // Remove receiver pushed earlier. |
| 447 __ popq(RBX); // Pop returned code object into RBX. | 421 __ popq(RBX); // Pop returned code object into RBX. |
| 448 // Pop preserved values | 422 // Pop preserved values |
| 449 __ popq(R10); // Restore ic-data. | 423 __ popq(R10); // Restore ic-data. |
| 450 __ popq(RAX); // Restore receiver. | 424 __ popq(RAX); // Restore receiver. |
| 451 __ popq(R13); // Restore arguments descriptor array. | 425 __ popq(R13); // Restore arguments descriptor array. |
| 452 | 426 |
| 453 __ cmpq(RBX, raw_null); | 427 __ cmpq(RBX, raw_null); |
| 454 Label check_implicit_closure; | 428 Label check_implicit_closure; |
| 455 __ j(EQUAL, &check_implicit_closure, Assembler::kNearJump); | 429 __ j(EQUAL, &check_implicit_closure, Assembler::kNearJump); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 471 // First check to see if this is a getter function and we are | 445 // First check to see if this is a getter function and we are |
| 472 // trying to create a closure of an instance function. | 446 // trying to create a closure of an instance function. |
| 473 // Push values that need to be preserved across runtime call. | 447 // Push values that need to be preserved across runtime call. |
| 474 __ pushq(RAX); // Preserve receiver. | 448 __ pushq(RAX); // Preserve receiver. |
| 475 __ pushq(R10); // Preserve ic-data. | 449 __ pushq(R10); // Preserve ic-data. |
| 476 __ pushq(R13); // Preserve arguments descriptor array. | 450 __ pushq(R13); // Preserve arguments descriptor array. |
| 477 | 451 |
| 478 __ pushq(raw_null); // Setup space on stack for return value. | 452 __ pushq(raw_null); // Setup space on stack for return value. |
| 479 __ pushq(RAX); // Push receiver. | 453 __ pushq(RAX); // Push receiver. |
| 480 __ pushq(R10); // Ic-data array. | 454 __ pushq(R10); // Ic-data array. |
| 481 __ CallRuntimeFromStub(kResolveImplicitClosureFunctionRuntimeEntry); | 455 __ CallRuntime(kResolveImplicitClosureFunctionRuntimeEntry); |
| 482 __ popq(RAX); | 456 __ popq(RAX); |
| 483 __ popq(RAX); | 457 __ popq(RAX); |
| 484 __ popq(RBX); // Get return value into RBX, might be Closure object. | 458 __ popq(RBX); // Get return value into RBX, might be Closure object. |
| 485 | 459 |
| 486 // Pop preserved values. | 460 // Pop preserved values. |
| 487 __ popq(R13); // Restore arguments descriptor array. | 461 __ popq(R13); // Restore arguments descriptor array. |
| 488 __ popq(R10); // Restore ic-data. | 462 __ popq(R10); // Restore ic-data. |
| 489 __ popq(RAX); // Restore receiver. | 463 __ popq(RAX); // Restore receiver. |
| 490 | 464 |
| 491 __ cmpq(RBX, raw_null); | 465 __ cmpq(RBX, raw_null); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 506 // same name and see if we get a closure back which we are then | 480 // same name and see if we get a closure back which we are then |
| 507 // supposed to invoke. | 481 // supposed to invoke. |
| 508 // Push values that need to be preserved across runtime call. | 482 // Push values that need to be preserved across runtime call. |
| 509 __ pushq(RAX); // Preserve receiver. | 483 __ pushq(RAX); // Preserve receiver. |
| 510 __ pushq(R10); // Preserve ic-data. | 484 __ pushq(R10); // Preserve ic-data. |
| 511 __ pushq(R13); // Preserve arguments descriptor array. | 485 __ pushq(R13); // Preserve arguments descriptor array. |
| 512 | 486 |
| 513 __ pushq(raw_null); // Setup space on stack for return value. | 487 __ pushq(raw_null); // Setup space on stack for return value. |
| 514 __ pushq(RAX); // Push receiver. | 488 __ pushq(RAX); // Push receiver. |
| 515 __ pushq(R10); // Ic-data array. | 489 __ pushq(R10); // Ic-data array. |
| 516 __ CallRuntimeFromStub(kResolveImplicitClosureThroughGetterRuntimeEntry); | 490 __ CallRuntime(kResolveImplicitClosureThroughGetterRuntimeEntry); |
| 517 __ popq(R10); // Pop argument. | 491 __ popq(R10); // Pop argument. |
| 518 __ popq(RAX); // Pop argument. | 492 __ popq(RAX); // Pop argument. |
| 519 __ popq(RBX); // get return value into RBX, might be Closure object. | 493 __ popq(RBX); // get return value into RBX, might be Closure object. |
| 520 | 494 |
| 521 // Pop preserved values. | 495 // Pop preserved values. |
| 522 __ popq(R13); // Restore arguments descriptor array. | 496 __ popq(R13); // Restore arguments descriptor array. |
| 523 __ popq(R10); // Restore ic-data. | 497 __ popq(R10); // Restore ic-data. |
| 524 __ popq(RAX); // Restore receiver. | 498 __ popq(RAX); // Restore receiver. |
| 525 | 499 |
| 526 __ cmpq(RBX, raw_null); | 500 __ cmpq(RBX, raw_null); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 539 // Stack layout explaining "(kWordSize * 5)" offset. | 513 // Stack layout explaining "(kWordSize * 5)" offset. |
| 540 // TOS + 0: Argument array. | 514 // TOS + 0: Argument array. |
| 541 // TOS + 1: Arguments descriptor array. | 515 // TOS + 1: Arguments descriptor array. |
| 542 // TOS + 2: Closure object. | 516 // TOS + 2: Closure object. |
| 543 // TOS + 3: Place for result from closure function. | 517 // TOS + 3: Place for result from closure function. |
| 544 // TOS + 4: Saved RBP of previous frame. <== RBP | 518 // TOS + 4: Saved RBP of previous frame. <== RBP |
| 545 // TOS + 5: Dart code return address | 519 // TOS + 5: Dart code return address |
| 546 // TOS + 6: Last argument of caller. | 520 // TOS + 6: Last argument of caller. |
| 547 // .... | 521 // .... |
| 548 | 522 |
| 549 __ CallRuntimeFromStub(kInvokeImplicitClosureFunctionRuntimeEntry); | 523 __ CallRuntime(kInvokeImplicitClosureFunctionRuntimeEntry); |
| 550 // Remove arguments. | 524 // Remove arguments. |
| 551 __ popq(RAX); | 525 __ popq(RAX); |
| 552 __ popq(RAX); | 526 __ popq(RAX); |
| 553 __ popq(RAX); | 527 __ popq(RAX); |
| 554 __ popq(RAX); // Get result into RAX. | 528 __ popq(RAX); // Get result into RAX. |
| 555 | 529 |
| 556 // Remove the stub frame as we are about to return. | 530 // Remove the stub frame as we are about to return. |
| 557 __ LeaveFrame(); | 531 __ LeaveFrame(); |
| 558 __ ret(); | 532 __ ret(); |
| 559 | 533 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 579 // TOS + 0: Argument array. | 553 // TOS + 0: Argument array. |
| 580 // TOS + 1: Argument descriptor array. | 554 // TOS + 1: Argument descriptor array. |
| 581 // TOS + 2: IC-data array. | 555 // TOS + 2: IC-data array. |
| 582 // TOS + 3: Receiver. | 556 // TOS + 3: Receiver. |
| 583 // TOS + 4: Place for result from noSuchMethod. | 557 // TOS + 4: Place for result from noSuchMethod. |
| 584 // TOS + 5: Saved RBP of previous frame. <== RBP | 558 // TOS + 5: Saved RBP of previous frame. <== RBP |
| 585 // TOS + 6: Dart code return address | 559 // TOS + 6: Dart code return address |
| 586 // TOS + 7: Last argument of caller. | 560 // TOS + 7: Last argument of caller. |
| 587 // .... | 561 // .... |
| 588 | 562 |
| 589 __ CallRuntimeFromStub(kInvokeNoSuchMethodFunctionRuntimeEntry); | 563 __ CallRuntime(kInvokeNoSuchMethodFunctionRuntimeEntry); |
| 590 // Remove arguments. | 564 // Remove arguments. |
| 591 __ popq(RAX); | 565 __ popq(RAX); |
| 592 __ popq(RAX); | 566 __ popq(RAX); |
| 593 __ popq(RAX); | 567 __ popq(RAX); |
| 594 __ popq(RAX); | 568 __ popq(RAX); |
| 595 __ popq(RAX); // Get result into RAX. | 569 __ popq(RAX); // Get result into RAX. |
| 596 | 570 |
| 597 // Remove the stub frame as we are about to return. | 571 // Remove the stub frame as we are about to return. |
| 598 __ LeaveFrame(); | 572 __ LeaveFrame(); |
| 599 __ ret(); | 573 __ ret(); |
| 600 } | 574 } |
| 601 | 575 |
| 602 | 576 |
| 603 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { | 577 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { |
| 604 __ Untested("Deoptimize stub"); | 578 __ Untested("Deoptimize stub"); |
| 605 __ EnterFrame(0); | 579 __ EnterFrame(0); |
| 606 // RAX: deoptimization reason id. | 580 // RAX: deoptimization reason id. |
| 607 // Stack at this point: | 581 // Stack at this point: |
| 608 // TOS + 0: Saved EBP of function frame that will be deoptimized. <== EBP | 582 // TOS + 0: Saved EBP of function frame that will be deoptimized. <== EBP |
| 609 // TOS + 1: Deoptimization point (return address), will be patched. | 583 // TOS + 1: Deoptimization point (return address), will be patched. |
| 610 // TOS + 2: top-of-stack at deoptimization point (all arguments on stack). | 584 // TOS + 2: top-of-stack at deoptimization point (all arguments on stack). |
| 611 __ pushq(RAX); | 585 __ pushq(RAX); |
| 612 __ CallRuntimeFromStub(kDeoptimizeRuntimeEntry); | 586 __ CallRuntime(kDeoptimizeRuntimeEntry); |
| 613 __ popq(RAX); | 587 __ popq(RAX); |
| 614 __ LeaveFrame(); | 588 __ LeaveFrame(); |
| 615 __ ret(); | 589 __ ret(); |
| 616 } | 590 } |
| 617 | 591 |
| 618 | 592 |
| 619 // Called for inline allocation of arrays. | 593 // Called for inline allocation of arrays. |
| 620 // Input parameters: | 594 // Input parameters: |
| 621 // R10 : Array length as Smi. | 595 // R10 : Array length as Smi. |
| 622 // RBX : array element type (either NULL or an instantiated type). | 596 // RBX : array element type (either NULL or an instantiated type). |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 __ ret(); | 705 __ ret(); |
| 732 } | 706 } |
| 733 | 707 |
| 734 // Unable to allocate the array using the fast inline code, just call | 708 // Unable to allocate the array using the fast inline code, just call |
| 735 // into the runtime. | 709 // into the runtime. |
| 736 __ Bind(&slow_case); | 710 __ Bind(&slow_case); |
| 737 __ EnterFrame(0); | 711 __ EnterFrame(0); |
| 738 __ pushq(raw_null); // Setup space on stack for return value. | 712 __ pushq(raw_null); // Setup space on stack for return value. |
| 739 __ pushq(R10); // Array length as Smi. | 713 __ pushq(R10); // Array length as Smi. |
| 740 __ pushq(RBX); // Element type. | 714 __ pushq(RBX); // Element type. |
| 741 __ CallRuntimeFromStub(kAllocateArrayRuntimeEntry); | 715 __ CallRuntime(kAllocateArrayRuntimeEntry); |
| 742 __ popq(RAX); // Pop element type argument. | 716 __ popq(RAX); // Pop element type argument. |
| 743 __ popq(R10); // Pop array length argument. | 717 __ popq(R10); // Pop array length argument. |
| 744 __ popq(RAX); // Pop return value from return slot. | 718 __ popq(RAX); // Pop return value from return slot. |
| 745 __ LeaveFrame(); | 719 __ LeaveFrame(); |
| 746 __ ret(); | 720 __ ret(); |
| 747 } | 721 } |
| 748 | 722 |
| 749 | 723 |
| 750 // Input parameters: | 724 // Input parameters: |
| 751 // R10: Arguments descriptor array (num_args is first Smi element, closure | 725 // R10: Arguments descriptor array (num_args is first Smi element, closure |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 __ cmpq(RAX, raw_null); | 762 __ cmpq(RAX, raw_null); |
| 789 Label function_compiled; | 763 Label function_compiled; |
| 790 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump); | 764 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump); |
| 791 | 765 |
| 792 // Create a stub frame as we are pushing some objects on the stack before | 766 // Create a stub frame as we are pushing some objects on the stack before |
| 793 // calling into the runtime. | 767 // calling into the runtime. |
| 794 __ EnterFrame(0); | 768 __ EnterFrame(0); |
| 795 | 769 |
| 796 __ pushq(R10); // Preserve arguments descriptor array. | 770 __ pushq(R10); // Preserve arguments descriptor array. |
| 797 __ pushq(RBX); // Preserve read-only function object argument. | 771 __ pushq(RBX); // Preserve read-only function object argument. |
| 798 __ CallRuntimeFromStub(kCompileFunctionRuntimeEntry); | 772 __ CallRuntime(kCompileFunctionRuntimeEntry); |
| 799 __ popq(RBX); // Restore read-only function object argument in RBX. | 773 __ popq(RBX); // Restore read-only function object argument in RBX. |
| 800 __ popq(R10); // Restore arguments descriptor array. | 774 __ popq(R10); // Restore arguments descriptor array. |
| 801 // Restore RAX. | 775 // Restore RAX. |
| 802 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); | 776 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); |
| 803 | 777 |
| 804 // Remove the stub frame as we are about to jump to the closure function. | 778 // Remove the stub frame as we are about to jump to the closure function. |
| 805 __ LeaveFrame(); | 779 __ LeaveFrame(); |
| 806 | 780 |
| 807 __ Bind(&function_compiled); | 781 __ Bind(&function_compiled); |
| 808 // RAX: Code. | 782 // RAX: Code. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 833 PushArgumentsArray(assembler, (kWordSize * 4)); | 807 PushArgumentsArray(assembler, (kWordSize * 4)); |
| 834 | 808 |
| 835 // Stack: | 809 // Stack: |
| 836 // TOS + 0: Argument array. | 810 // TOS + 0: Argument array. |
| 837 // TOS + 1: Non-closure object. | 811 // TOS + 1: Non-closure object. |
| 838 // TOS + 2: Place for result from reporting the error. | 812 // TOS + 2: Place for result from reporting the error. |
| 839 // TOS + 3: Saved RBP of previous frame. <== RBP | 813 // TOS + 3: Saved RBP of previous frame. <== RBP |
| 840 // TOS + 4: Dart code return address | 814 // TOS + 4: Dart code return address |
| 841 // TOS + 5: Last argument of caller. | 815 // TOS + 5: Last argument of caller. |
| 842 // .... | 816 // .... |
| 843 __ CallRuntimeFromStub(kReportObjectNotClosureRuntimeEntry); | 817 __ CallRuntime(kReportObjectNotClosureRuntimeEntry); |
| 844 __ Stop("runtime call throws an exception"); | 818 __ Stop("runtime call throws an exception"); |
| 845 } | 819 } |
| 846 | 820 |
| 847 | 821 |
| 848 // Called when invoking Dart code from C++ (VM code). | 822 // Called when invoking Dart code from C++ (VM code). |
| 849 // Input parameters: | 823 // Input parameters: |
| 850 // RSP : points to return address. | 824 // RSP : points to return address. |
| 851 // RDI : entrypoint of the Dart function to call. | 825 // RDI : entrypoint of the Dart function to call. |
| 852 // RSI : arguments descriptor array. | 826 // RSI : arguments descriptor array. |
| 853 // RDX : pointer to the argument array. | 827 // RDX : pointer to the argument array. |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 // RAX: new object. | 1045 // RAX: new object. |
| 1072 __ ret(); | 1046 __ ret(); |
| 1073 | 1047 |
| 1074 __ Bind(&slow_case); | 1048 __ Bind(&slow_case); |
| 1075 } | 1049 } |
| 1076 // Create a stub frame. | 1050 // Create a stub frame. |
| 1077 __ EnterFrame(0); | 1051 __ EnterFrame(0); |
| 1078 __ pushq(raw_null); // Setup space on stack for the return value. | 1052 __ pushq(raw_null); // Setup space on stack for the return value. |
| 1079 __ SmiTag(R10); | 1053 __ SmiTag(R10); |
| 1080 __ pushq(R10); // Push number of context variables. | 1054 __ pushq(R10); // Push number of context variables. |
| 1081 __ CallRuntimeFromStub(kAllocateContextRuntimeEntry); // Allocate context. | 1055 __ CallRuntime(kAllocateContextRuntimeEntry); // Allocate context. |
| 1082 __ popq(RAX); // Pop number of context variables argument. | 1056 __ popq(RAX); // Pop number of context variables argument. |
| 1083 __ popq(RAX); // Pop the new context object. | 1057 __ popq(RAX); // Pop the new context object. |
| 1084 // RAX: new object | 1058 // RAX: new object |
| 1085 // Restore the frame pointer. | 1059 // Restore the frame pointer. |
| 1086 __ LeaveFrame(); | 1060 __ LeaveFrame(); |
| 1087 __ ret(); | 1061 __ ret(); |
| 1088 } | 1062 } |
| 1089 | 1063 |
| 1090 | 1064 |
| 1091 // Called for inline allocation of objects. | 1065 // Called for inline allocation of objects. |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 __ EnterFrame(0); | 1238 __ EnterFrame(0); |
| 1265 __ pushq(raw_null); // Setup space on stack for return value. | 1239 __ pushq(raw_null); // Setup space on stack for return value. |
| 1266 __ PushObject(cls); // Push class of object to be allocated. | 1240 __ PushObject(cls); // Push class of object to be allocated. |
| 1267 if (is_cls_parameterized) { | 1241 if (is_cls_parameterized) { |
| 1268 __ pushq(RAX); // Push type arguments of object to be allocated. | 1242 __ pushq(RAX); // Push type arguments of object to be allocated. |
| 1269 __ pushq(RDX); // Push type arguments of instantiator. | 1243 __ pushq(RDX); // Push type arguments of instantiator. |
| 1270 } else { | 1244 } else { |
| 1271 __ pushq(raw_null); // Push null type arguments. | 1245 __ pushq(raw_null); // Push null type arguments. |
| 1272 __ pushq(Immediate(Smi::RawValue(StubCode::kNoInstantiator))); | 1246 __ pushq(Immediate(Smi::RawValue(StubCode::kNoInstantiator))); |
| 1273 } | 1247 } |
| 1274 __ CallRuntimeFromStub(kAllocateObjectRuntimeEntry); // Allocate object. | 1248 __ CallRuntime(kAllocateObjectRuntimeEntry); // Allocate object. |
| 1275 __ popq(RAX); // Pop argument (instantiator). | 1249 __ popq(RAX); // Pop argument (instantiator). |
| 1276 __ popq(RAX); // Pop argument (type arguments of object). | 1250 __ popq(RAX); // Pop argument (type arguments of object). |
| 1277 __ popq(RAX); // Pop argument (class of object). | 1251 __ popq(RAX); // Pop argument (class of object). |
| 1278 __ popq(RAX); // Pop result (newly allocated object). | 1252 __ popq(RAX); // Pop result (newly allocated object). |
| 1279 // RAX: new object | 1253 // RAX: new object |
| 1280 // Restore the frame pointer. | 1254 // Restore the frame pointer. |
| 1281 __ LeaveFrame(); | 1255 __ LeaveFrame(); |
| 1282 __ ret(); | 1256 __ ret(); |
| 1283 } | 1257 } |
| 1284 | 1258 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 __ movq(RCX, Address(RSP, kTypeArgumentsOffset)); | 1386 __ movq(RCX, Address(RSP, kTypeArgumentsOffset)); |
| 1413 } | 1387 } |
| 1414 if (is_implicit_instance_closure) { | 1388 if (is_implicit_instance_closure) { |
| 1415 __ movq(RAX, Address(RSP, kReceiverOffset)); | 1389 __ movq(RAX, Address(RSP, kReceiverOffset)); |
| 1416 } | 1390 } |
| 1417 // Create the stub frame. | 1391 // Create the stub frame. |
| 1418 __ EnterFrame(0); | 1392 __ EnterFrame(0); |
| 1419 __ pushq(raw_null); // Setup space on stack for the return value. | 1393 __ pushq(raw_null); // Setup space on stack for the return value. |
| 1420 __ PushObject(func); | 1394 __ PushObject(func); |
| 1421 if (is_implicit_static_closure) { | 1395 if (is_implicit_static_closure) { |
| 1422 __ CallRuntimeFromStub(kAllocateImplicitStaticClosureRuntimeEntry); | 1396 __ CallRuntime(kAllocateImplicitStaticClosureRuntimeEntry); |
| 1423 } else { | 1397 } else { |
| 1424 if (is_implicit_instance_closure) { | 1398 if (is_implicit_instance_closure) { |
| 1425 __ pushq(RAX); // Receiver. | 1399 __ pushq(RAX); // Receiver. |
| 1426 } | 1400 } |
| 1427 if (has_type_arguments) { | 1401 if (has_type_arguments) { |
| 1428 __ pushq(RCX); // Push type arguments of closure to be allocated. | 1402 __ pushq(RCX); // Push type arguments of closure to be allocated. |
| 1429 } else { | 1403 } else { |
| 1430 __ pushq(raw_null); // Push null type arguments. | 1404 __ pushq(raw_null); // Push null type arguments. |
| 1431 } | 1405 } |
| 1432 if (is_implicit_instance_closure) { | 1406 if (is_implicit_instance_closure) { |
| 1433 __ CallRuntimeFromStub(kAllocateImplicitInstanceClosureRuntimeEntry); | 1407 __ CallRuntime(kAllocateImplicitInstanceClosureRuntimeEntry); |
| 1434 __ popq(RAX); // Pop type arguments. | 1408 __ popq(RAX); // Pop type arguments. |
| 1435 __ popq(RAX); // Pop receiver. | 1409 __ popq(RAX); // Pop receiver. |
| 1436 } else { | 1410 } else { |
| 1437 ASSERT(func.IsNonImplicitClosureFunction()); | 1411 ASSERT(func.IsNonImplicitClosureFunction()); |
| 1438 __ CallRuntimeFromStub(kAllocateClosureRuntimeEntry); | 1412 __ CallRuntime(kAllocateClosureRuntimeEntry); |
| 1439 __ popq(RAX); // Pop type arguments. | 1413 __ popq(RAX); // Pop type arguments. |
| 1440 } | 1414 } |
| 1441 } | 1415 } |
| 1442 __ popq(RAX); // Pop the function object. | 1416 __ popq(RAX); // Pop the function object. |
| 1443 __ popq(RAX); // Pop the result. | 1417 __ popq(RAX); // Pop the result. |
| 1444 // RAX: New closure object. | 1418 // RAX: New closure object. |
| 1445 // Restore the calling frame. | 1419 // Restore the calling frame. |
| 1446 __ LeaveFrame(); | 1420 __ LeaveFrame(); |
| 1447 __ ret(); | 1421 __ ret(); |
| 1448 } | 1422 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 // TOS + 1: Arguments descriptor array. | 1462 // TOS + 1: Arguments descriptor array. |
| 1489 // TOS + 2: Ic-data array. | 1463 // TOS + 2: Ic-data array. |
| 1490 // TOS + 3: Receiver. | 1464 // TOS + 3: Receiver. |
| 1491 // TOS + 4: Place for result from noSuchMethod. | 1465 // TOS + 4: Place for result from noSuchMethod. |
| 1492 // TOS + 5: Saved RBP of previous frame. <== RBP | 1466 // TOS + 5: Saved RBP of previous frame. <== RBP |
| 1493 // TOS + 6: Dart callee (or stub) code return address | 1467 // TOS + 6: Dart callee (or stub) code return address |
| 1494 // TOS + 7: Saved RBP of dart caller frame. | 1468 // TOS + 7: Saved RBP of dart caller frame. |
| 1495 // TOS + 8: Dart caller code return address | 1469 // TOS + 8: Dart caller code return address |
| 1496 // TOS + 9: Last argument of caller. | 1470 // TOS + 9: Last argument of caller. |
| 1497 // .... | 1471 // .... |
| 1498 __ CallRuntimeFromStub(kInvokeNoSuchMethodFunctionRuntimeEntry); | 1472 __ CallRuntime(kInvokeNoSuchMethodFunctionRuntimeEntry); |
| 1499 // Remove arguments. | 1473 // Remove arguments. |
| 1500 __ popq(RAX); | 1474 __ popq(RAX); |
| 1501 __ popq(RAX); | 1475 __ popq(RAX); |
| 1502 __ popq(RAX); | 1476 __ popq(RAX); |
| 1503 __ popq(RAX); | 1477 __ popq(RAX); |
| 1504 __ popq(RAX); // Get result into RAX. | 1478 __ popq(RAX); // Get result into RAX. |
| 1505 | 1479 |
| 1506 // Remove the stub frame as we are about to return. | 1480 // Remove the stub frame as we are about to return. |
| 1507 __ LeaveFrame(); | 1481 __ LeaveFrame(); |
| 1508 __ ret(); | 1482 __ ret(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1597 __ EnterFrame(0); | 1571 __ EnterFrame(0); |
| 1598 __ pushq(R10); // Preserve arguments array. | 1572 __ pushq(R10); // Preserve arguments array. |
| 1599 __ pushq(RBX); // Preserve IC data array | 1573 __ pushq(RBX); // Preserve IC data array |
| 1600 __ pushq(raw_null); // Setup space on stack for result (target code object). | 1574 __ pushq(raw_null); // Setup space on stack for result (target code object). |
| 1601 // Push call arguments. | 1575 // Push call arguments. |
| 1602 for (intptr_t i = 0; i < num_args; i++) { | 1576 for (intptr_t i = 0; i < num_args; i++) { |
| 1603 __ movq(R10, Address(RAX, -kWordSize * i)); | 1577 __ movq(R10, Address(RAX, -kWordSize * i)); |
| 1604 __ pushq(R10); | 1578 __ pushq(R10); |
| 1605 } | 1579 } |
| 1606 if (num_args == 1) { | 1580 if (num_args == 1) { |
| 1607 __ CallRuntimeFromStub(kInlineCacheMissHandlerOneArgRuntimeEntry); | 1581 __ CallRuntime(kInlineCacheMissHandlerOneArgRuntimeEntry); |
| 1608 } else if (num_args == 2) { | 1582 } else if (num_args == 2) { |
| 1609 __ CallRuntimeFromStub(kInlineCacheMissHandlerTwoArgsRuntimeEntry); | 1583 __ CallRuntime(kInlineCacheMissHandlerTwoArgsRuntimeEntry); |
| 1610 } else { | 1584 } else { |
| 1611 UNIMPLEMENTED(); | 1585 UNIMPLEMENTED(); |
| 1612 } | 1586 } |
| 1613 // Remove call arguments pushed earlier. | 1587 // Remove call arguments pushed earlier. |
| 1614 for (intptr_t i = 0; i < num_args; i++) { | 1588 for (intptr_t i = 0; i < num_args; i++) { |
| 1615 __ popq(RAX); | 1589 __ popq(RAX); |
| 1616 } | 1590 } |
| 1617 __ popq(RAX); // Pop returned code object into RAX (null if not found). | 1591 __ popq(RAX); // Pop returned code object into RAX (null if not found). |
| 1618 __ popq(RBX); // Restore IC data array. | 1592 __ popq(RBX); // Restore IC data array. |
| 1619 __ popq(R10); // Restore arguments array. | 1593 __ popq(R10); // Restore arguments array. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 } | 1646 } |
| 1673 | 1647 |
| 1674 | 1648 |
| 1675 // RBX: Function object. | 1649 // RBX: Function object. |
| 1676 // R10: Arguments array. | 1650 // R10: Arguments array. |
| 1677 // TOS(0): return address (Dart code). | 1651 // TOS(0): return address (Dart code). |
| 1678 void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) { | 1652 void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) { |
| 1679 __ EnterFrame(0); | 1653 __ EnterFrame(0); |
| 1680 __ pushq(R10); | 1654 __ pushq(R10); |
| 1681 __ pushq(RBX); | 1655 __ pushq(RBX); |
| 1682 __ CallRuntimeFromStub(kBreakpointStaticHandlerRuntimeEntry); | 1656 __ CallRuntime(kBreakpointStaticHandlerRuntimeEntry); |
| 1683 __ popq(RBX); | 1657 __ popq(RBX); |
| 1684 __ popq(R10); | 1658 __ popq(R10); |
| 1685 __ LeaveFrame(); | 1659 __ LeaveFrame(); |
| 1686 | 1660 |
| 1687 // Now call the static function. The breakpoint handler function | 1661 // Now call the static function. The breakpoint handler function |
| 1688 // ensures that the call target is compiled. | 1662 // ensures that the call target is compiled. |
| 1689 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); | 1663 __ movq(RAX, FieldAddress(RBX, Function::code_offset())); |
| 1690 __ movq(RBX, FieldAddress(RAX, Code::instructions_offset())); | 1664 __ movq(RBX, FieldAddress(RAX, Code::instructions_offset())); |
| 1691 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1665 __ addq(RBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1692 __ jmp(RBX); | 1666 __ jmp(RBX); |
| 1693 } | 1667 } |
| 1694 | 1668 |
| 1695 | 1669 |
| 1696 // TOS(0): return address (Dart code). | 1670 // TOS(0): return address (Dart code). |
| 1697 void StubCode::GenerateBreakpointReturnStub(Assembler* assembler) { | 1671 void StubCode::GenerateBreakpointReturnStub(Assembler* assembler) { |
| 1698 __ EnterFrame(0); | 1672 __ EnterFrame(0); |
| 1699 __ pushq(RAX); | 1673 __ pushq(RAX); |
| 1700 __ CallRuntimeFromStub(kBreakpointReturnHandlerRuntimeEntry); | 1674 __ CallRuntime(kBreakpointReturnHandlerRuntimeEntry); |
| 1701 __ popq(RAX); | 1675 __ popq(RAX); |
| 1702 __ LeaveFrame(); | 1676 __ LeaveFrame(); |
| 1703 | 1677 |
| 1704 __ popq(R11); // discard return address of call to this stub. | 1678 __ popq(R11); // discard return address of call to this stub. |
| 1705 __ LeaveFrame(); | 1679 __ LeaveFrame(); |
| 1706 __ ret(); | 1680 __ ret(); |
| 1707 } | 1681 } |
| 1708 | 1682 |
| 1709 | 1683 |
| 1710 // RBX: Inline cache data array. | 1684 // RBX: Inline cache data array. |
| 1711 // R10: Arguments array. | 1685 // R10: Arguments array. |
| 1712 // TOS(0): return address (Dart code). | 1686 // TOS(0): return address (Dart code). |
| 1713 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) { | 1687 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) { |
| 1714 __ EnterFrame(0); | 1688 __ EnterFrame(0); |
| 1715 __ pushq(RBX); | 1689 __ pushq(RBX); |
| 1716 __ pushq(R10); | 1690 __ pushq(R10); |
| 1717 __ CallRuntimeFromStub(kBreakpointDynamicHandlerRuntimeEntry); | 1691 __ CallRuntime(kBreakpointDynamicHandlerRuntimeEntry); |
| 1718 __ popq(R10); | 1692 __ popq(R10); |
| 1719 __ popq(RBX); | 1693 __ popq(RBX); |
| 1720 __ LeaveFrame(); | 1694 __ LeaveFrame(); |
| 1721 | 1695 |
| 1722 // Find out which dispatch stub to call. | 1696 // Find out which dispatch stub to call. |
| 1723 Label ic_cache_one_arg; | 1697 Label ic_cache_one_arg; |
| 1724 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); | 1698 __ movq(RCX, FieldAddress(RBX, ICData::num_args_tested_offset())); |
| 1725 __ cmpq(RCX, Immediate(1)); | 1699 __ cmpq(RCX, Immediate(1)); |
| 1726 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); | 1700 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); |
| 1727 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); | 1701 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 __ j(EQUAL, ¬_found, Assembler::kNearJump); | 1779 __ j(EQUAL, ¬_found, Assembler::kNearJump); |
| 1806 __ movq(R10, FieldAddress(R10, Type::type_class_offset())); | 1780 __ movq(R10, FieldAddress(R10, Type::type_class_offset())); |
| 1807 __ cmpq(RCX, R10); | 1781 __ cmpq(RCX, R10); |
| 1808 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); | 1782 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); |
| 1809 __ jmp(&found, Assembler::kNearJump); | 1783 __ jmp(&found, Assembler::kNearJump); |
| 1810 } | 1784 } |
| 1811 | 1785 |
| 1812 } // namespace dart | 1786 } // namespace dart |
| 1813 | 1787 |
| 1814 #endif // defined TARGET_ARCH_X64 | 1788 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |