| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 Register name, | 762 Register name, |
| 763 Handle<JSObject> holder_obj, | 763 Handle<JSObject> holder_obj, |
| 764 IC::UtilityId id) { | 764 IC::UtilityId id) { |
| 765 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 765 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
| 766 __ CallExternalReference( | 766 __ CallExternalReference( |
| 767 ExternalReference(IC_Utility(id), masm->isolate()), | 767 ExternalReference(IC_Utility(id), masm->isolate()), |
| 768 StubCache::kInterceptorArgsLength); | 768 StubCache::kInterceptorArgsLength); |
| 769 } | 769 } |
| 770 | 770 |
| 771 | 771 |
| 772 static void GenerateFastApiCallBody(MacroAssembler* masm, | 772 // Generate call to api function. |
| 773 const CallOptimization& optimization, | 773 static void GenerateFastApiCall(MacroAssembler* masm, |
| 774 int argc, | 774 const CallOptimization& optimization, |
| 775 Register holder_in, | 775 Handle<Map> receiver_map, |
| 776 bool restore_context) { | 776 Register receiver, |
| 777 Register scratch_in, |
| 778 int argc, |
| 779 Register* values) { |
| 780 ASSERT(!receiver.is(scratch_in)); |
| 781 __ push(receiver); |
| 782 // Write the arguments to stack frame. |
| 783 for (int i = 0; i < argc; i++) { |
| 784 Register arg = values[argc-1-i]; |
| 785 ASSERT(!receiver.is(arg)); |
| 786 ASSERT(!scratch_in.is(arg)); |
| 787 __ push(arg); |
| 788 } |
| 777 ASSERT(optimization.is_simple_api_call()); | 789 ASSERT(optimization.is_simple_api_call()); |
| 778 | 790 |
| 779 // Abi for CallApiFunctionStub. | 791 // Abi for CallApiFunctionStub. |
| 780 Register callee = a0; | 792 Register callee = a0; |
| 781 Register call_data = t0; | 793 Register call_data = t0; |
| 782 Register holder = a2; | 794 Register holder = a2; |
| 783 Register api_function_address = a1; | 795 Register api_function_address = a1; |
| 784 | 796 |
| 785 // Put holder in place. | 797 // Put holder in place. |
| 786 __ mov(holder, holder_in); | 798 CallOptimization::HolderLookup holder_lookup; |
| 799 Handle<JSObject> api_holder = optimization.LookupHolderOfExpectedType( |
| 800 receiver_map, |
| 801 &holder_lookup); |
| 802 switch (holder_lookup) { |
| 803 case CallOptimization::kHolderIsReceiver: |
| 804 __ Move(holder, receiver); |
| 805 break; |
| 806 case CallOptimization::kHolderFound: |
| 807 __ li(holder, api_holder); |
| 808 break; |
| 809 case CallOptimization::kHolderNotFound: |
| 810 UNREACHABLE(); |
| 811 break; |
| 812 } |
| 787 | 813 |
| 788 Isolate* isolate = masm->isolate(); | 814 Isolate* isolate = masm->isolate(); |
| 789 Handle<JSFunction> function = optimization.constant_function(); | 815 Handle<JSFunction> function = optimization.constant_function(); |
| 790 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 816 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
| 791 Handle<Object> call_data_obj(api_call_info->data(), isolate); | 817 Handle<Object> call_data_obj(api_call_info->data(), isolate); |
| 792 | 818 |
| 793 // Put callee in place. | 819 // Put callee in place. |
| 794 __ li(callee, function); | 820 __ li(callee, function); |
| 795 | 821 |
| 796 bool call_data_undefined = false; | 822 bool call_data_undefined = false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 808 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 834 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
| 809 ApiFunction fun(function_address); | 835 ApiFunction fun(function_address); |
| 810 ExternalReference::Type type = ExternalReference::DIRECT_API_CALL; | 836 ExternalReference::Type type = ExternalReference::DIRECT_API_CALL; |
| 811 ExternalReference ref = | 837 ExternalReference ref = |
| 812 ExternalReference(&fun, | 838 ExternalReference(&fun, |
| 813 type, | 839 type, |
| 814 masm->isolate()); | 840 masm->isolate()); |
| 815 __ li(api_function_address, Operand(ref)); | 841 __ li(api_function_address, Operand(ref)); |
| 816 | 842 |
| 817 // Jump to stub. | 843 // Jump to stub. |
| 818 CallApiFunctionStub stub(restore_context, call_data_undefined, argc); | 844 CallApiFunctionStub stub(true, call_data_undefined, argc); |
| 819 __ TailCallStub(&stub); | 845 __ TailCallStub(&stub); |
| 820 } | 846 } |
| 821 | 847 |
| 822 | 848 |
| 823 // Generate call to api function. | |
| 824 static void GenerateFastApiCall(MacroAssembler* masm, | |
| 825 const CallOptimization& optimization, | |
| 826 Register receiver, | |
| 827 Register scratch, | |
| 828 int argc, | |
| 829 Register* values) { | |
| 830 ASSERT(!receiver.is(scratch)); | |
| 831 __ push(receiver); | |
| 832 // Write the arguments to stack frame. | |
| 833 for (int i = 0; i < argc; i++) { | |
| 834 Register arg = values[argc-1-i]; | |
| 835 ASSERT(!receiver.is(arg)); | |
| 836 ASSERT(!scratch.is(arg)); | |
| 837 __ push(arg); | |
| 838 } | |
| 839 | |
| 840 // Stack now matches JSFunction abi. | |
| 841 GenerateFastApiCallBody(masm, | |
| 842 optimization, | |
| 843 argc, | |
| 844 receiver, | |
| 845 true); | |
| 846 } | |
| 847 | |
| 848 | |
| 849 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 849 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
| 850 __ Jump(code, RelocInfo::CODE_TARGET); | 850 __ Jump(code, RelocInfo::CODE_TARGET); |
| 851 } | 851 } |
| 852 | 852 |
| 853 | 853 |
| 854 #undef __ | 854 #undef __ |
| 855 #define __ ACCESS_MASM(masm()) | 855 #define __ ACCESS_MASM(masm()) |
| 856 | 856 |
| 857 | 857 |
| 858 Register StubCompiler::CheckPrototypes(Handle<HeapType> type, | 858 Register StubCompiler::CheckPrototypes(Handle<HeapType> type, |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 | 1055 |
| 1056 | 1056 |
| 1057 void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { | 1057 void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { |
| 1058 // Return the constant value. | 1058 // Return the constant value. |
| 1059 __ li(v0, value); | 1059 __ li(v0, value); |
| 1060 __ Ret(); | 1060 __ Ret(); |
| 1061 } | 1061 } |
| 1062 | 1062 |
| 1063 | 1063 |
| 1064 void LoadStubCompiler::GenerateLoadCallback( | 1064 void LoadStubCompiler::GenerateLoadCallback( |
| 1065 const CallOptimization& call_optimization) { | 1065 const CallOptimization& call_optimization, |
| 1066 Handle<Map> receiver_map) { |
| 1066 GenerateFastApiCall( | 1067 GenerateFastApiCall( |
| 1067 masm(), call_optimization, receiver(), scratch3(), 0, NULL); | 1068 masm(), call_optimization, receiver_map, |
| 1069 receiver(), scratch3(), 0, NULL); |
| 1068 } | 1070 } |
| 1069 | 1071 |
| 1070 | 1072 |
| 1071 void LoadStubCompiler::GenerateLoadCallback( | 1073 void LoadStubCompiler::GenerateLoadCallback( |
| 1072 Register reg, | 1074 Register reg, |
| 1073 Handle<ExecutableAccessorInfo> callback) { | 1075 Handle<ExecutableAccessorInfo> callback) { |
| 1074 // Build AccessorInfo::args_ list on the stack and push property name below | 1076 // Build AccessorInfo::args_ list on the stack and push property name below |
| 1075 // the exit frame to make GC aware of them and store pointers to them. | 1077 // the exit frame to make GC aware of them and store pointers to them. |
| 1076 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); | 1078 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); |
| 1077 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); | 1079 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 Handle<Code> StoreStubCompiler::CompileStoreCallback( | 1248 Handle<Code> StoreStubCompiler::CompileStoreCallback( |
| 1247 Handle<JSObject> object, | 1249 Handle<JSObject> object, |
| 1248 Handle<JSObject> holder, | 1250 Handle<JSObject> holder, |
| 1249 Handle<Name> name, | 1251 Handle<Name> name, |
| 1250 const CallOptimization& call_optimization) { | 1252 const CallOptimization& call_optimization) { |
| 1251 HandlerFrontend(IC::CurrentTypeOf(object, isolate()), | 1253 HandlerFrontend(IC::CurrentTypeOf(object, isolate()), |
| 1252 receiver(), holder, name); | 1254 receiver(), holder, name); |
| 1253 | 1255 |
| 1254 Register values[] = { value() }; | 1256 Register values[] = { value() }; |
| 1255 GenerateFastApiCall( | 1257 GenerateFastApiCall( |
| 1256 masm(), call_optimization, receiver(), scratch3(), 1, values); | 1258 masm(), call_optimization, handle(object->map()), |
| 1259 receiver(), scratch3(), 1, values); |
| 1257 | 1260 |
| 1258 // Return the generated code. | 1261 // Return the generated code. |
| 1259 return GetCode(kind(), Code::FAST, name); | 1262 return GetCode(kind(), Code::FAST, name); |
| 1260 } | 1263 } |
| 1261 | 1264 |
| 1262 | 1265 |
| 1263 #undef __ | 1266 #undef __ |
| 1264 #define __ ACCESS_MASM(masm) | 1267 #define __ ACCESS_MASM(masm) |
| 1265 | 1268 |
| 1266 | 1269 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 // ----------------------------------- | 1580 // ----------------------------------- |
| 1578 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1581 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1579 } | 1582 } |
| 1580 | 1583 |
| 1581 | 1584 |
| 1582 #undef __ | 1585 #undef __ |
| 1583 | 1586 |
| 1584 } } // namespace v8::internal | 1587 } } // namespace v8::internal |
| 1585 | 1588 |
| 1586 #endif // V8_TARGET_ARCH_MIPS | 1589 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |