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

Side by Side Diff: src/x64/stub-cache-x64.cc

Issue 669061: First take on custom call generators. (Closed)
Patch Set: Ultimate version Created 10 years, 9 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
« no previous file with comments | « src/top.cc ('k') | test/mjsunit/array-push.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 const ParameterCount& arguments_; 648 const ParameterCount& arguments_;
649 Register name_; 649 Register name_;
650 }; 650 };
651 651
652 652
653 #undef __ 653 #undef __
654 654
655 #define __ ACCESS_MASM((masm())) 655 #define __ ACCESS_MASM((masm()))
656 656
657 657
658 Object* CallStubCompiler::CompileArrayPushCall(Object* object,
659 JSObject* holder,
660 JSFunction* function,
661 String* name,
662 CheckType check) {
663 // ----------- S t a t e -------------
664 // rcx : function name
665 // rsp[0] : return address
666 // rsp[8] : argument argc
667 // rsp[16] : argument argc - 1
668 // ...
669 // rsp[argc * 8] : argument 1
670 // rsp[(argc + 1) * 8] : argument 0 = receiver
671 // -----------------------------------
672
673 // TODO(639): faster implementation.
674 ASSERT(check == RECEIVER_MAP_CHECK);
675
676 Label miss;
677
678 // Get the receiver from the stack.
679 const int argc = arguments().immediate();
680 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
681
682 // Check that the receiver isn't a smi.
683 __ JumpIfSmi(rdx, &miss);
684
685 // Check that the maps haven't changed.
686 CheckPrototypes(JSObject::cast(object), rdx, holder,
687 rbx, rax, name, &miss);
688
689 // Patch the receiver on the stack with the global proxy if
690 // necessary.
691 if (object->IsGlobalObject()) {
692 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset));
693 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx);
694 }
695
696 __ TailCallExternalReference(ExternalReference(Builtins::c_ArrayPush),
697 argc + 1,
698 1);
699
700
701 // Handle call cache miss.
702 __ bind(&miss);
703 Handle<Code> ic = ComputeCallMiss(arguments().immediate());
704 __ Jump(ic, RelocInfo::CODE_TARGET);
705
706 // Return the generated code.
707 String* function_name = NULL;
708 if (function->shared()->name()->IsString()) {
709 function_name = String::cast(function->shared()->name());
710 }
711 return GetCode(CONSTANT_FUNCTION, function_name);
712 }
713
714
658 Object* CallStubCompiler::CompileCallConstant(Object* object, 715 Object* CallStubCompiler::CompileCallConstant(Object* object,
659 JSObject* holder, 716 JSObject* holder,
660 JSFunction* function, 717 JSFunction* function,
661 String* name, 718 String* name,
662 StubCompiler::CheckType check) { 719 StubCompiler::CheckType check) {
663 // ----------- S t a t e ------------- 720 // ----------- S t a t e -------------
664 // rcx : function name 721 // rcx : function name
665 // rsp[0] : return address 722 // rsp[0] : return address
666 // rsp[8] : argument argc 723 // rsp[8] : argument argc
667 // rsp[16] : argument argc - 1 724 // rsp[16] : argument argc - 1
668 // ... 725 // ...
669 // rsp[argc * 8] : argument 1 726 // rsp[argc * 8] : argument 1
670 // rsp[(argc + 1) * 8] : argument 0 = receiver 727 // rsp[(argc + 1) * 8] : argument 0 = receiver
671 // ----------------------------------- 728 // -----------------------------------
672 729
730 SharedFunctionInfo* function_info = function->shared();
731 if (function_info->HasCustomCallGenerator()) {
732 CustomCallGenerator generator =
733 ToCData<CustomCallGenerator>(function_info->function_data());
734 return generator(this, object, holder, function, name, check);
735 }
736
673 Label miss; 737 Label miss;
674 738
675 // Get the receiver from the stack. 739 // Get the receiver from the stack.
676 const int argc = arguments().immediate(); 740 const int argc = arguments().immediate();
677 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); 741 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize));
678 742
679 // Check that the receiver isn't a smi. 743 // Check that the receiver isn't a smi.
680 if (check != NUMBER_CHECK) { 744 if (check != NUMBER_CHECK) {
681 __ JumpIfSmi(rdx, &miss); 745 __ JumpIfSmi(rdx, &miss);
682 } 746 }
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); 1905 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET);
1842 1906
1843 // Return the generated code. 1907 // Return the generated code.
1844 return GetCode(); 1908 return GetCode();
1845 } 1909 }
1846 1910
1847 1911
1848 #undef __ 1912 #undef __
1849 1913
1850 } } // namespace v8::internal 1914 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/top.cc ('k') | test/mjsunit/array-push.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698