Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: runtime/vm/stub_code_x64.cc

Issue 227723002: VM: Implement closure calls as instance calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: adjust inlining of dispatchers Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 __ pushq(RBX); // Element type. 686 __ pushq(RBX); // Element type.
687 __ CallRuntime(kAllocateArrayRuntimeEntry, 2); 687 __ CallRuntime(kAllocateArrayRuntimeEntry, 2);
688 __ popq(RAX); // Pop element type argument. 688 __ popq(RAX); // Pop element type argument.
689 __ popq(R10); // Pop array length argument. 689 __ popq(R10); // Pop array length argument.
690 __ popq(RAX); // Pop return value from return slot. 690 __ popq(RAX); // Pop return value from return slot.
691 __ LeaveStubFrame(); 691 __ LeaveStubFrame();
692 __ ret(); 692 __ ret();
693 } 693 }
694 694
695 695
696 // Input parameters:
697 // R10: Arguments descriptor array.
698 // Note: The closure object is the first argument to the function being
699 // called, the stub accesses the closure from this location directly
700 // when trying to resolve the call.
701 void StubCode::GenerateCallClosureFunctionStub(Assembler* assembler) {
702 // Load num_args.
703 __ movq(RAX, FieldAddress(R10, ArgumentsDescriptor::count_offset()));
704 // Load closure object in R13.
705 __ movq(R13, Address(RSP, RAX, TIMES_4, 0)); // RAX is a Smi.
706
707 __ LoadObject(R12, Object::null_object(), PP);
708
709 // Verify that R13 is a closure by checking its class.
710 Label not_closure;
711 __ cmpq(R13, R12);
712 // Not a closure, but null object.
713 __ j(EQUAL, &not_closure);
714 __ testq(R13, Immediate(kSmiTagMask));
715 __ j(ZERO, &not_closure); // Not a closure, but a smi.
716 // Verify that the class of the object is a closure class by checking that
717 // class.signature_function() is not null.
718 __ LoadClass(RAX, R13);
719 __ movq(RAX, FieldAddress(RAX, Class::signature_function_offset()));
720 __ cmpq(RAX, R12);
721 // Actual class is not a closure class.
722 __ j(EQUAL, &not_closure, Assembler::kNearJump);
723
724 // RAX is just the signature function. Load the actual closure function.
725 __ movq(RAX, FieldAddress(R13, Closure::function_offset()));
726
727 // Load closure context in CTX; note that CTX has already been preserved.
728 __ movq(CTX, FieldAddress(R13, Closure::context_offset()));
729
730 // Load closure function code in RAX.
731 __ movq(RCX, FieldAddress(RAX, Function::code_offset()));
732
733 // RAX: Function.
734 // R10: Arguments descriptor array.
735 // RBX: Smi 0 (no IC data; the lazy-compile stub expects a GC-safe value).
736 __ xorq(RBX, RBX);
737 __ movq(RCX, FieldAddress(RCX, Code::instructions_offset()));
738 __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
739 __ jmp(RCX);
740
741 __ Bind(&not_closure);
742 // Call runtime to attempt to resolve and invoke a call method on a
743 // non-closure object, passing the non-closure object and its arguments array,
744 // returning here.
745 // If no call method exists, throw a NoSuchMethodError.
746 // R13: non-closure object.
747 // R10: arguments descriptor array.
748
749 // Create a stub frame as we are pushing some objects on the stack before
750 // calling into the runtime.
751 __ EnterStubFrame();
752 // Setup space on stack for result from call.
753 __ pushq(R12);
754 __ pushq(R10); // Arguments descriptor.
755 // Load smi-tagged arguments array length, including the non-closure.
756 __ movq(R10, FieldAddress(R10, ArgumentsDescriptor::count_offset()));
757 PushArgumentsArray(assembler);
758
759 __ CallRuntime(kInvokeNonClosureRuntimeEntry, 2);
760
761 // Remove arguments.
762 __ Drop(2);
763 __ popq(RAX); // Get result into RAX.
764
765 // Remove the stub frame as we are about to return.
766 __ LeaveStubFrame();
767 __ ret();
768 }
769
770
771 // Called when invoking Dart code from C++ (VM code). 696 // Called when invoking Dart code from C++ (VM code).
772 // Input parameters: 697 // Input parameters:
773 // RSP : points to return address. 698 // RSP : points to return address.
774 // RDI : entrypoint of the Dart function to call. 699 // RDI : entrypoint of the Dart function to call.
775 // RSI : arguments descriptor array. 700 // RSI : arguments descriptor array.
776 // RDX : arguments array. 701 // RDX : arguments array.
777 // RCX : new context containing the current isolate pointer. 702 // RCX : new context containing the current isolate pointer.
778 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { 703 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
779 // Save frame pointer coming in. 704 // Save frame pointer coming in.
780 __ EnterFrame(0); 705 __ EnterFrame(0);
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 1843
1919 __ movq(left, Address(RSP, 2 * kWordSize)); 1844 __ movq(left, Address(RSP, 2 * kWordSize));
1920 __ movq(right, Address(RSP, 1 * kWordSize)); 1845 __ movq(right, Address(RSP, 1 * kWordSize));
1921 GenerateIdenticalWithNumberCheckStub(assembler, left, right); 1846 GenerateIdenticalWithNumberCheckStub(assembler, left, right);
1922 __ ret(); 1847 __ ret();
1923 } 1848 }
1924 1849
1925 } // namespace dart 1850 } // namespace dart
1926 1851
1927 #endif // defined TARGET_ARCH_X64 1852 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698