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 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), | 835 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorOnly), |
836 masm->isolate()); | 836 masm->isolate()); |
837 __ PrepareCEntryArgs(6); | 837 __ PrepareCEntryArgs(6); |
838 __ PrepareCEntryFunction(ref); | 838 __ PrepareCEntryFunction(ref); |
839 | 839 |
840 CEntryStub stub(1); | 840 CEntryStub stub(1); |
841 __ CallStub(&stub); | 841 __ CallStub(&stub); |
842 } | 842 } |
843 | 843 |
844 | 844 |
845 static const int kFastApiCallArguments = 4; | 845 static const int kFastApiCallArguments = FunctionCallbackArguments::kArgsLength; |
846 | |
847 | 846 |
848 // Reserves space for the extra arguments to API function in the | 847 // Reserves space for the extra arguments to API function in the |
849 // caller's frame. | 848 // caller's frame. |
850 // | 849 // |
851 // These arguments are set by CheckPrototypes and GenerateFastApiDirectCall. | 850 // These arguments are set by CheckPrototypes and GenerateFastApiDirectCall. |
852 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, | 851 static void ReserveSpaceForFastApiCall(MacroAssembler* masm, |
853 Register scratch) { | 852 Register scratch) { |
854 ASSERT(Smi::FromInt(0) == 0); | 853 ASSERT(Smi::FromInt(0) == 0); |
855 for (int i = 0; i < kFastApiCallArguments; i++) { | 854 for (int i = 0; i < kFastApiCallArguments; i++) { |
856 __ push(zero_reg); | 855 __ push(zero_reg); |
857 } | 856 } |
858 } | 857 } |
859 | 858 |
860 | 859 |
861 // Undoes the effects of ReserveSpaceForFastApiCall. | 860 // Undoes the effects of ReserveSpaceForFastApiCall. |
862 static void FreeSpaceForFastApiCall(MacroAssembler* masm) { | 861 static void FreeSpaceForFastApiCall(MacroAssembler* masm) { |
863 __ Drop(kFastApiCallArguments); | 862 __ Drop(kFastApiCallArguments); |
864 } | 863 } |
865 | 864 |
866 | 865 |
867 static void GenerateFastApiDirectCall(MacroAssembler* masm, | 866 static void GenerateFastApiDirectCall(MacroAssembler* masm, |
868 const CallOptimization& optimization, | 867 const CallOptimization& optimization, |
869 int argc) { | 868 int argc) { |
870 // ----------- S t a t e ------------- | 869 // ----------- S t a t e ------------- |
871 // -- sp[0] : holder (set by CheckPrototypes) | 870 // -- sp[0] : holder (set by CheckPrototypes) |
872 // -- sp[4] : callee JS function | 871 // -- sp[4] : callee JS function |
873 // -- sp[8] : call data | 872 // -- sp[8] : call data |
874 // -- sp[12] : isolate | 873 // -- sp[12] : isolate |
875 // -- sp[16] : last JS argument | 874 // -- sp[16] : ReturnValue |
| 875 // -- sp[20] : last JS argument |
876 // -- ... | 876 // -- ... |
877 // -- sp[(argc + 3) * 4] : first JS argument | 877 // -- sp[(argc + 4) * 4] : first JS argument |
878 // -- sp[(argc + 4) * 4] : receiver | 878 // -- sp[(argc + 5) * 4] : receiver |
879 // ----------------------------------- | 879 // ----------------------------------- |
880 // Get the function and setup the context. | 880 // Get the function and setup the context. |
881 Handle<JSFunction> function = optimization.constant_function(); | 881 Handle<JSFunction> function = optimization.constant_function(); |
882 __ LoadHeapObject(t1, function); | 882 __ LoadHeapObject(t1, function); |
883 __ lw(cp, FieldMemOperand(t1, JSFunction::kContextOffset)); | 883 __ lw(cp, FieldMemOperand(t1, JSFunction::kContextOffset)); |
884 | 884 |
885 // Pass the additional arguments. | 885 // Pass the additional arguments. |
886 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 886 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
887 Handle<Object> call_data(api_call_info->data(), masm->isolate()); | 887 Handle<Object> call_data(api_call_info->data(), masm->isolate()); |
888 if (masm->isolate()->heap()->InNewSpace(*call_data)) { | 888 if (masm->isolate()->heap()->InNewSpace(*call_data)) { |
889 __ li(a0, api_call_info); | 889 __ li(a0, api_call_info); |
890 __ lw(t2, FieldMemOperand(a0, CallHandlerInfo::kDataOffset)); | 890 __ lw(t2, FieldMemOperand(a0, CallHandlerInfo::kDataOffset)); |
891 } else { | 891 } else { |
892 __ li(t2, call_data); | 892 __ li(t2, call_data); |
893 } | 893 } |
894 | 894 |
895 __ li(t3, Operand(ExternalReference::isolate_address(masm->isolate()))); | 895 __ li(t3, Operand(ExternalReference::isolate_address(masm->isolate()))); |
896 // Store JS function, call data and isolate. | 896 // Store JS function, call data, isolate and ReturnValue. |
897 __ sw(t1, MemOperand(sp, 1 * kPointerSize)); | 897 __ sw(t1, MemOperand(sp, 1 * kPointerSize)); |
898 __ sw(t2, MemOperand(sp, 2 * kPointerSize)); | 898 __ sw(t2, MemOperand(sp, 2 * kPointerSize)); |
899 __ sw(t3, MemOperand(sp, 3 * kPointerSize)); | 899 __ sw(t3, MemOperand(sp, 3 * kPointerSize)); |
| 900 __ LoadRoot(t1, Heap::kUndefinedValueRootIndex); |
| 901 __ sw(t1, MemOperand(sp, 4 * kPointerSize)); |
900 | 902 |
901 // Prepare arguments. | 903 // Prepare arguments. |
902 __ Addu(a2, sp, Operand(3 * kPointerSize)); | 904 __ Addu(a2, sp, Operand(4 * kPointerSize)); |
903 | 905 |
904 // Allocate the v8::Arguments structure in the arguments' space since | 906 // Allocate the v8::Arguments structure in the arguments' space since |
905 // it's not controlled by GC. | 907 // it's not controlled by GC. |
906 const int kApiStackSpace = 4; | 908 const int kApiStackSpace = 4; |
907 | 909 |
908 FrameScope frame_scope(masm, StackFrame::MANUAL); | 910 FrameScope frame_scope(masm, StackFrame::MANUAL); |
909 __ EnterExitFrame(false, kApiStackSpace); | 911 __ EnterExitFrame(false, kApiStackSpace); |
910 | 912 |
911 // NOTE: the O32 abi requires a0 to hold a special pointer when returning a | 913 // NOTE: the O32 abi requires a0 to hold a special pointer when returning a |
912 // struct from the function (which is currently the case). This means we pass | 914 // struct from the function (which is currently the case). This means we pass |
(...skipping 10 matching lines...) Expand all Loading... |
923 __ Addu(t0, a2, Operand(argc * kPointerSize)); | 925 __ Addu(t0, a2, Operand(argc * kPointerSize)); |
924 __ sw(t0, MemOperand(a1, 1 * kPointerSize)); | 926 __ sw(t0, MemOperand(a1, 1 * kPointerSize)); |
925 // v8::Arguments::length_ = argc | 927 // v8::Arguments::length_ = argc |
926 __ li(t0, Operand(argc)); | 928 __ li(t0, Operand(argc)); |
927 __ sw(t0, MemOperand(a1, 2 * kPointerSize)); | 929 __ sw(t0, MemOperand(a1, 2 * kPointerSize)); |
928 // v8::Arguments::is_construct_call = 0 | 930 // v8::Arguments::is_construct_call = 0 |
929 __ sw(zero_reg, MemOperand(a1, 3 * kPointerSize)); | 931 __ sw(zero_reg, MemOperand(a1, 3 * kPointerSize)); |
930 | 932 |
931 const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; | 933 const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; |
932 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 934 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
| 935 bool returns_handle = |
| 936 !CallbackTable::ReturnsVoid(masm->isolate(), function_address); |
933 ApiFunction fun(function_address); | 937 ApiFunction fun(function_address); |
934 ExternalReference ref = | 938 ExternalReference ref = |
935 ExternalReference(&fun, | 939 ExternalReference(&fun, |
936 ExternalReference::DIRECT_API_CALL, | 940 ExternalReference::DIRECT_API_CALL, |
937 masm->isolate()); | 941 masm->isolate()); |
938 AllowExternalCallThatCantCauseGC scope(masm); | 942 AllowExternalCallThatCantCauseGC scope(masm); |
939 __ CallApiFunctionAndReturn(ref, kStackUnwindSpace); | 943 __ CallApiFunctionAndReturn(ref, |
| 944 kStackUnwindSpace, |
| 945 returns_handle, |
| 946 kFastApiCallArguments + 1); |
940 } | 947 } |
941 | 948 |
942 class CallInterceptorCompiler BASE_EMBEDDED { | 949 class CallInterceptorCompiler BASE_EMBEDDED { |
943 public: | 950 public: |
944 CallInterceptorCompiler(StubCompiler* stub_compiler, | 951 CallInterceptorCompiler(StubCompiler* stub_compiler, |
945 const ParameterCount& arguments, | 952 const ParameterCount& arguments, |
946 Register name, | 953 Register name, |
947 Code::ExtraICState extra_ic_state) | 954 Code::ExtraICState extra_ic_state) |
948 : stub_compiler_(stub_compiler), | 955 : stub_compiler_(stub_compiler), |
949 arguments_(arguments), | 956 arguments_(arguments), |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1403 // the exit frame to make GC aware of them and store pointers to them. | 1410 // the exit frame to make GC aware of them and store pointers to them. |
1404 __ push(receiver()); | 1411 __ push(receiver()); |
1405 __ mov(scratch2(), sp); // scratch2 = AccessorInfo::args_ | 1412 __ mov(scratch2(), sp); // scratch2 = AccessorInfo::args_ |
1406 if (heap()->InNewSpace(callback->data())) { | 1413 if (heap()->InNewSpace(callback->data())) { |
1407 __ li(scratch3(), callback); | 1414 __ li(scratch3(), callback); |
1408 __ lw(scratch3(), FieldMemOperand(scratch3(), | 1415 __ lw(scratch3(), FieldMemOperand(scratch3(), |
1409 ExecutableAccessorInfo::kDataOffset)); | 1416 ExecutableAccessorInfo::kDataOffset)); |
1410 } else { | 1417 } else { |
1411 __ li(scratch3(), Handle<Object>(callback->data(), isolate())); | 1418 __ li(scratch3(), Handle<Object>(callback->data(), isolate())); |
1412 } | 1419 } |
1413 __ Subu(sp, sp, 4 * kPointerSize); | 1420 __ Subu(sp, sp, 5 * kPointerSize); |
1414 __ sw(reg, MemOperand(sp, 3 * kPointerSize)); | 1421 __ sw(reg, MemOperand(sp, 4 * kPointerSize)); |
1415 __ sw(scratch3(), MemOperand(sp, 2 * kPointerSize)); | 1422 __ sw(scratch3(), MemOperand(sp, 3 * kPointerSize)); |
1416 __ li(scratch3(), | 1423 __ li(scratch3(), |
1417 Operand(ExternalReference::isolate_address(isolate()))); | 1424 Operand(ExternalReference::isolate_address(isolate()))); |
1418 __ sw(scratch3(), MemOperand(sp, 1 * kPointerSize)); | 1425 __ LoadRoot(scratch4(), Heap::kUndefinedValueRootIndex); |
| 1426 __ sw(scratch3(), MemOperand(sp, 2 * kPointerSize)); |
| 1427 __ sw(scratch4(), MemOperand(sp, 1 * kPointerSize)); |
1419 __ sw(name(), MemOperand(sp, 0 * kPointerSize)); | 1428 __ sw(name(), MemOperand(sp, 0 * kPointerSize)); |
1420 | 1429 |
1421 __ mov(a2, scratch2()); // Saved in case scratch2 == a1. | 1430 __ mov(a2, scratch2()); // Saved in case scratch2 == a1. |
1422 __ mov(a1, sp); // a1 (first argument - see note below) = Handle<Name> | 1431 __ mov(a1, sp); // a1 (first argument - see note below) = Handle<Name> |
1423 | 1432 |
1424 // NOTE: the O32 abi requires a0 to hold a special pointer when returning a | 1433 // NOTE: the O32 abi requires a0 to hold a special pointer when returning a |
1425 // struct from the function (which is currently the case). This means we pass | 1434 // struct from the function (which is currently the case). This means we pass |
1426 // the arguments in a1-a2 instead of a0-a1. TryCallApiFunctionAndReturn | 1435 // the arguments in a1-a2 instead of a0-a1. TryCallApiFunctionAndReturn |
1427 // will handle setting up a0. | 1436 // will handle setting up a0. |
1428 | 1437 |
1429 const int kApiStackSpace = 1; | 1438 const int kApiStackSpace = 1; |
1430 FrameScope frame_scope(masm(), StackFrame::MANUAL); | 1439 FrameScope frame_scope(masm(), StackFrame::MANUAL); |
1431 __ EnterExitFrame(false, kApiStackSpace); | 1440 __ EnterExitFrame(false, kApiStackSpace); |
1432 | 1441 |
1433 // Create AccessorInfo instance on the stack above the exit frame with | 1442 // Create AccessorInfo instance on the stack above the exit frame with |
1434 // scratch2 (internal::Object** args_) as the data. | 1443 // scratch2 (internal::Object** args_) as the data. |
1435 __ sw(a2, MemOperand(sp, kPointerSize)); | 1444 __ sw(a2, MemOperand(sp, kPointerSize)); |
1436 // a2 (second argument - see note above) = AccessorInfo& | 1445 // a2 (second argument - see note above) = AccessorInfo& |
1437 __ Addu(a2, sp, kPointerSize); | 1446 __ Addu(a2, sp, kPointerSize); |
1438 | 1447 |
1439 const int kStackUnwindSpace = 5; | 1448 const int kStackUnwindSpace = kFastApiCallArguments + 1; |
1440 Address getter_address = v8::ToCData<Address>(callback->getter()); | 1449 Address getter_address = v8::ToCData<Address>(callback->getter()); |
| 1450 bool returns_handle = |
| 1451 !CallbackTable::ReturnsVoid(isolate(), getter_address); |
1441 ApiFunction fun(getter_address); | 1452 ApiFunction fun(getter_address); |
1442 ExternalReference ref = ExternalReference( | 1453 ExternalReference ref = ExternalReference( |
1443 &fun, ExternalReference::DIRECT_GETTER_CALL, isolate()); | 1454 &fun, ExternalReference::DIRECT_GETTER_CALL, isolate()); |
1444 __ CallApiFunctionAndReturn(ref, kStackUnwindSpace); | 1455 __ CallApiFunctionAndReturn(ref, |
| 1456 kStackUnwindSpace, |
| 1457 returns_handle, |
| 1458 3); |
1445 } | 1459 } |
1446 | 1460 |
1447 | 1461 |
1448 void BaseLoadStubCompiler::GenerateLoadInterceptor( | 1462 void BaseLoadStubCompiler::GenerateLoadInterceptor( |
1449 Register holder_reg, | 1463 Register holder_reg, |
1450 Handle<JSObject> object, | 1464 Handle<JSObject> object, |
1451 Handle<JSObject> interceptor_holder, | 1465 Handle<JSObject> interceptor_holder, |
1452 LookupResult* lookup, | 1466 LookupResult* lookup, |
1453 Handle<Name> name) { | 1467 Handle<Name> name) { |
1454 ASSERT(interceptor_holder->HasNamedInterceptor()); | 1468 ASSERT(interceptor_holder->HasNamedInterceptor()); |
(...skipping 2408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3863 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); | 3877 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); |
3864 } | 3878 } |
3865 } | 3879 } |
3866 | 3880 |
3867 | 3881 |
3868 #undef __ | 3882 #undef __ |
3869 | 3883 |
3870 } } // namespace v8::internal | 3884 } } // namespace v8::internal |
3871 | 3885 |
3872 #endif // V8_TARGET_ARCH_MIPS | 3886 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |