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

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

Issue 466283003: Use LookupIterator for CompileLoadInterceptor and delete Object::Lookup (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add ports Created 6 years, 4 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
« src/ia32/stub-cache-ia32.cc ('K') | « src/stub-cache.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 720 }
721 721
722 722
723 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) { 723 void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
724 // Return the constant value. 724 // Return the constant value.
725 __ Move(rax, value); 725 __ Move(rax, value);
726 __ ret(0); 726 __ ret(0);
727 } 727 }
728 728
729 729
730 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg, 730 void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup(
731 LookupResult* lookup, 731 LookupIterator* it, Register holder_reg) {
732 Handle<Name> name) {
733 DCHECK(holder()->HasNamedInterceptor()); 732 DCHECK(holder()->HasNamedInterceptor());
734 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); 733 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined());
735 734
736 // So far the most popular follow ups for interceptor loads are FIELD 735 // Compile the interceptor call, followed by inline code to load the
737 // and CALLBACKS, so inline only them, other cases may be added 736 // property from further up the prototype chain if the call fails.
738 // later. 737 // Check that the maps haven't changed.
739 bool compile_followup_inline = false; 738 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1()));
740 if (lookup->IsFound() && lookup->IsCacheable()) { 739
741 if (lookup->IsField()) { 740 // Preserve the receiver register explicitly whenever it is different from the
742 compile_followup_inline = true; 741 // holder and it is needed should the interceptor return without any result.
743 } else if (lookup->type() == CALLBACKS && 742 // The ACCESSOR case needs the receiver to be passed into C++ code, the FIELD
744 lookup->GetCallbackObject()->IsExecutableAccessorInfo()) { 743 // case might cause a miss during the prototype check.
745 Handle<ExecutableAccessorInfo> callback( 744 bool must_perfrom_prototype_check =
746 ExecutableAccessorInfo::cast(lookup->GetCallbackObject())); 745 !holder().is_identical_to(it->GetHolder<JSObject>());
747 compile_followup_inline = 746 bool must_preserve_receiver_reg =
748 callback->getter() != NULL && 747 !receiver().is(holder_reg) &&
749 ExecutableAccessorInfo::IsCompatibleReceiverType(isolate(), callback, 748 (it->property_kind() == LookupIterator::ACCESSOR ||
750 type()); 749 must_perfrom_prototype_check);
750
751 // Save necessary data before invoking an interceptor.
752 // Requires a frame to make GC aware of pushed pointers.
753 {
754 FrameScope frame_scope(masm(), StackFrame::INTERNAL);
755
756 if (must_preserve_receiver_reg) {
757 __ Push(receiver());
751 } 758 }
759 __ Push(holder_reg);
760 __ Push(this->name());
761
762 // Invoke an interceptor. Note: map checks from receiver to
763 // interceptor's holder has been compiled before (see a caller
764 // of this method.)
765 CompileCallLoadPropertyWithInterceptor(
766 masm(), receiver(), holder_reg, this->name(), holder(),
767 IC::kLoadPropertyWithInterceptorOnly);
768
769 // Check if interceptor provided a value for property. If it's
770 // the case, return immediately.
771 Label interceptor_failed;
772 __ CompareRoot(rax, Heap::kNoInterceptorResultSentinelRootIndex);
773 __ j(equal, &interceptor_failed);
774 frame_scope.GenerateLeaveFrame();
775 __ ret(0);
776
777 __ bind(&interceptor_failed);
778 __ Pop(this->name());
779 __ Pop(holder_reg);
780 if (must_preserve_receiver_reg) {
781 __ Pop(receiver());
782 }
783
784 // Leave the internal frame.
752 } 785 }
753 786
754 if (compile_followup_inline) { 787 GenerateLoadPostInterceptor(it, holder_reg);
755 // Compile the interceptor call, followed by inline code to load the
756 // property from further up the prototype chain if the call fails.
757 // Check that the maps haven't changed.
758 DCHECK(holder_reg.is(receiver()) || holder_reg.is(scratch1()));
759
760 // Preserve the receiver register explicitly whenever it is different from
761 // the holder and it is needed should the interceptor return without any
762 // result. The CALLBACKS case needs the receiver to be passed into C++ code,
763 // the FIELD case might cause a miss during the prototype check.
764 bool must_perfrom_prototype_check = *holder() != lookup->holder();
765 bool must_preserve_receiver_reg = !receiver().is(holder_reg) &&
766 (lookup->type() == CALLBACKS || must_perfrom_prototype_check);
767
768 // Save necessary data before invoking an interceptor.
769 // Requires a frame to make GC aware of pushed pointers.
770 {
771 FrameScope frame_scope(masm(), StackFrame::INTERNAL);
772
773 if (must_preserve_receiver_reg) {
774 __ Push(receiver());
775 }
776 __ Push(holder_reg);
777 __ Push(this->name());
778
779 // Invoke an interceptor. Note: map checks from receiver to
780 // interceptor's holder has been compiled before (see a caller
781 // of this method.)
782 CompileCallLoadPropertyWithInterceptor(
783 masm(), receiver(), holder_reg, this->name(), holder(),
784 IC::kLoadPropertyWithInterceptorOnly);
785
786 // Check if interceptor provided a value for property. If it's
787 // the case, return immediately.
788 Label interceptor_failed;
789 __ CompareRoot(rax, Heap::kNoInterceptorResultSentinelRootIndex);
790 __ j(equal, &interceptor_failed);
791 frame_scope.GenerateLeaveFrame();
792 __ ret(0);
793
794 __ bind(&interceptor_failed);
795 __ Pop(this->name());
796 __ Pop(holder_reg);
797 if (must_preserve_receiver_reg) {
798 __ Pop(receiver());
799 }
800
801 // Leave the internal frame.
802 }
803
804 GenerateLoadPostInterceptor(holder_reg, name, lookup);
805 } else { // !compile_followup_inline
806 // Call the runtime system to load the interceptor.
807 // Check that the maps haven't changed.
808 __ PopReturnAddressTo(scratch2());
809 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(),
810 holder());
811 __ PushReturnAddressFrom(scratch2());
812
813 ExternalReference ref = ExternalReference(
814 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate());
815 __ TailCallExternalReference(
816 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
817 }
818 } 788 }
819 789
820 790
791 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
792 // Call the runtime system to load the interceptor.
793 DCHECK(holder()->HasNamedInterceptor());
794 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined());
795 __ PopReturnAddressTo(scratch2());
796 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(),
797 holder());
798 __ PushReturnAddressFrom(scratch2());
799
800 ExternalReference ref = ExternalReference(
801 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate());
802 __ TailCallExternalReference(
803 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
804 }
805
806
821 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( 807 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
822 Handle<JSObject> object, Handle<Name> name, 808 Handle<JSObject> object, Handle<Name> name,
823 Handle<ExecutableAccessorInfo> callback) { 809 Handle<ExecutableAccessorInfo> callback) {
824 Register holder_reg = Frontend(receiver(), name); 810 Register holder_reg = Frontend(receiver(), name);
825 811
826 __ PopReturnAddressTo(scratch1()); 812 __ PopReturnAddressTo(scratch1());
827 __ Push(receiver()); 813 __ Push(receiver());
828 __ Push(holder_reg); 814 __ Push(holder_reg);
829 __ Push(callback); // callback info 815 __ Push(callback); // callback info
830 __ Push(name); 816 __ Push(name);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 // ----------------------------------- 1125 // -----------------------------------
1140 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); 1126 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss);
1141 } 1127 }
1142 1128
1143 1129
1144 #undef __ 1130 #undef __
1145 1131
1146 } } // namespace v8::internal 1132 } } // namespace v8::internal
1147 1133
1148 #endif // V8_TARGET_ARCH_X64 1134 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/ia32/stub-cache-ia32.cc ('K') | « src/stub-cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698