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

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

Issue 2239009: Direct load of global function prototype. (Closed)
Patch Set: Ports Created 10 years, 6 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/stub-cache.h ('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 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Load the function from the global context. 107 // Load the function from the global context.
108 __ movq(prototype, Operand(prototype, Context::SlotOffset(index))); 108 __ movq(prototype, Operand(prototype, Context::SlotOffset(index)));
109 // Load the initial map. The global functions all have initial maps. 109 // Load the initial map. The global functions all have initial maps.
110 __ movq(prototype, 110 __ movq(prototype,
111 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); 111 FieldOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset));
112 // Load the prototype from the initial map. 112 // Load the prototype from the initial map.
113 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset)); 113 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset));
114 } 114 }
115 115
116 116
117 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype(
118 MacroAssembler* masm, int index, Register prototype) {
119 // Get the global function with the given index.
120 JSFunction* function = JSFunction::cast(Top::global_context()->get(index));
121 // Load its initial map. The global functions all have initial maps.
122 __ Move(prototype, Handle<Map>(function->initial_map()));
123 // Load the prototype from the initial map.
124 __ movq(prototype, FieldOperand(prototype, Map::kPrototypeOffset));
125 }
126
127
117 // Load a fast property out of a holder object (src). In-object properties 128 // Load a fast property out of a holder object (src). In-object properties
118 // are loaded directly otherwise the property is loaded from the properties 129 // are loaded directly otherwise the property is loaded from the properties
119 // fixed array. 130 // fixed array.
120 void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm, 131 void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm,
121 Register dst, Register src, 132 Register dst, Register src,
122 JSObject* holder, int index) { 133 JSObject* holder, int index) {
123 // Adjust for the number of properties stored in the holder. 134 // Adjust for the number of properties stored in the holder.
124 index -= holder->map()->inobject_properties(); 135 index -= holder->map()->inobject_properties();
125 if (index < 0) { 136 if (index < 0) {
126 // Get the property straight out of the holder. 137 // Get the property straight out of the holder.
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 780
770 case STRING_CHECK: 781 case STRING_CHECK:
771 if (!function->IsBuiltin()) { 782 if (!function->IsBuiltin()) {
772 // Calling non-builtins with a value as receiver requires boxing. 783 // Calling non-builtins with a value as receiver requires boxing.
773 __ jmp(&miss); 784 __ jmp(&miss);
774 } else { 785 } else {
775 // Check that the object is a two-byte string or a symbol. 786 // Check that the object is a two-byte string or a symbol.
776 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rax); 787 __ CmpObjectType(rdx, FIRST_NONSTRING_TYPE, rax);
777 __ j(above_equal, &miss); 788 __ j(above_equal, &miss);
778 // Check that the maps starting from the prototype haven't changed. 789 // Check that the maps starting from the prototype haven't changed.
779 GenerateLoadGlobalFunctionPrototype(masm(), 790 GenerateDirectLoadGlobalFunctionPrototype(
780 Context::STRING_FUNCTION_INDEX, 791 masm(), Context::STRING_FUNCTION_INDEX, rax);
781 rax);
782 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, 792 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder,
783 rbx, rdx, name, &miss); 793 rbx, rdx, name, &miss);
784 } 794 }
785 break; 795 break;
786 796
787 case NUMBER_CHECK: { 797 case NUMBER_CHECK: {
788 if (!function->IsBuiltin()) { 798 if (!function->IsBuiltin()) {
789 // Calling non-builtins with a value as receiver requires boxing. 799 // Calling non-builtins with a value as receiver requires boxing.
790 __ jmp(&miss); 800 __ jmp(&miss);
791 } else { 801 } else {
792 Label fast; 802 Label fast;
793 // Check that the object is a smi or a heap number. 803 // Check that the object is a smi or a heap number.
794 __ JumpIfSmi(rdx, &fast); 804 __ JumpIfSmi(rdx, &fast);
795 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rax); 805 __ CmpObjectType(rdx, HEAP_NUMBER_TYPE, rax);
796 __ j(not_equal, &miss); 806 __ j(not_equal, &miss);
797 __ bind(&fast); 807 __ bind(&fast);
798 // Check that the maps starting from the prototype haven't changed. 808 // Check that the maps starting from the prototype haven't changed.
799 GenerateLoadGlobalFunctionPrototype(masm(), 809 GenerateDirectLoadGlobalFunctionPrototype(
800 Context::NUMBER_FUNCTION_INDEX, 810 masm(), Context::NUMBER_FUNCTION_INDEX, rax);
801 rax);
802 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, 811 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder,
803 rbx, rdx, name, &miss); 812 rbx, rdx, name, &miss);
804 } 813 }
805 break; 814 break;
806 } 815 }
807 816
808 case BOOLEAN_CHECK: { 817 case BOOLEAN_CHECK: {
809 if (!function->IsBuiltin()) { 818 if (!function->IsBuiltin()) {
810 // Calling non-builtins with a value as receiver requires boxing. 819 // Calling non-builtins with a value as receiver requires boxing.
811 __ jmp(&miss); 820 __ jmp(&miss);
812 } else { 821 } else {
813 Label fast; 822 Label fast;
814 // Check that the object is a boolean. 823 // Check that the object is a boolean.
815 __ CompareRoot(rdx, Heap::kTrueValueRootIndex); 824 __ CompareRoot(rdx, Heap::kTrueValueRootIndex);
816 __ j(equal, &fast); 825 __ j(equal, &fast);
817 __ CompareRoot(rdx, Heap::kFalseValueRootIndex); 826 __ CompareRoot(rdx, Heap::kFalseValueRootIndex);
818 __ j(not_equal, &miss); 827 __ j(not_equal, &miss);
819 __ bind(&fast); 828 __ bind(&fast);
820 // Check that the maps starting from the prototype haven't changed. 829 // Check that the maps starting from the prototype haven't changed.
821 GenerateLoadGlobalFunctionPrototype(masm(), 830 GenerateDirectLoadGlobalFunctionPrototype(
822 Context::BOOLEAN_FUNCTION_INDEX, 831 masm(), Context::BOOLEAN_FUNCTION_INDEX, rax);
823 rax);
824 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder, 832 CheckPrototypes(JSObject::cast(object->GetPrototype()), rax, holder,
825 rbx, rdx, name, &miss); 833 rbx, rdx, name, &miss);
826 } 834 }
827 break; 835 break;
828 } 836 }
829 837
830 default: 838 default:
831 UNREACHABLE(); 839 UNREACHABLE();
832 } 840 }
833 841
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 // Return the generated code. 2325 // Return the generated code.
2318 return GetCode(); 2326 return GetCode();
2319 } 2327 }
2320 2328
2321 2329
2322 #undef __ 2330 #undef __
2323 2331
2324 } } // namespace v8::internal 2332 } } // namespace v8::internal
2325 2333
2326 #endif // V8_TARGET_ARCH_X64 2334 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698