OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
550 | 550 |
551 // Undoes the effects of ReserveSpaceForFastApiCall. | 551 // Undoes the effects of ReserveSpaceForFastApiCall. |
552 static void FreeSpaceForFastApiCall(MacroAssembler* masm) { | 552 static void FreeSpaceForFastApiCall(MacroAssembler* masm) { |
553 __ Drop(kFastApiCallArguments); | 553 __ Drop(kFastApiCallArguments); |
554 } | 554 } |
555 | 555 |
556 | 556 |
557 static MaybeObject* GenerateFastApiDirectCall(MacroAssembler* masm, | 557 static MaybeObject* GenerateFastApiDirectCall( |
558 const CallOptimization& optimization, | 558 MacroAssembler* masm, |
559 int argc) { | 559 const CallOptimization& optimization, |
| 560 int argc) { |
560 // ----------- S t a t e ------------- | 561 // ----------- S t a t e ------------- |
561 // -- sp[0] : holder (set by CheckPrototypes) | 562 // -- sp[0] : holder (set by CheckPrototypes) |
562 // -- sp[4] : callee js function | 563 // -- sp[4] : callee js function |
563 // -- sp[8] : call data | 564 // -- sp[8] : call data |
564 // -- sp[12] : last js argument | 565 // -- sp[12] : last js argument |
565 // -- ... | 566 // -- ... |
566 // -- sp[(argc + 3) * 4] : first js argument | 567 // -- sp[(argc + 3) * 4] : first js argument |
567 // -- sp[(argc + 4) * 4] : receiver | 568 // -- sp[(argc + 4) * 4] : receiver |
568 // ----------------------------------- | 569 // ----------------------------------- |
569 // Get the function and setup the context. | 570 // Get the function and setup the context. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 | 620 |
620 // Emitting a stub call may try to allocate (if the code is not | 621 // Emitting a stub call may try to allocate (if the code is not |
621 // already generated). Do not allow the assembler to perform a | 622 // already generated). Do not allow the assembler to perform a |
622 // garbage collection but instead return the allocation failure | 623 // garbage collection but instead return the allocation failure |
623 // object. | 624 // object. |
624 const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; | 625 const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; |
625 ExternalReference ref = | 626 ExternalReference ref = |
626 ExternalReference(&fun, | 627 ExternalReference(&fun, |
627 ExternalReference::DIRECT_API_CALL, | 628 ExternalReference::DIRECT_API_CALL, |
628 masm->isolate()); | 629 masm->isolate()); |
| 630 AllowExternalCallThatCantCauseGC scope(masm); |
629 return masm->TryCallApiFunctionAndReturn(ref, kStackUnwindSpace); | 631 return masm->TryCallApiFunctionAndReturn(ref, kStackUnwindSpace); |
630 } | 632 } |
631 | 633 |
632 class CallInterceptorCompiler BASE_EMBEDDED { | 634 class CallInterceptorCompiler BASE_EMBEDDED { |
633 public: | 635 public: |
634 CallInterceptorCompiler(StubCompiler* stub_compiler, | 636 CallInterceptorCompiler(StubCompiler* stub_compiler, |
635 const ParameterCount& arguments, | 637 const ParameterCount& arguments, |
636 Register name, | 638 Register name, |
637 Code::ExtraICState extra_ic_state) | 639 Code::ExtraICState extra_ic_state) |
638 : stub_compiler_(stub_compiler), | 640 : stub_compiler_(stub_compiler), |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 Register scratch3, | 799 Register scratch3, |
798 String* name, | 800 String* name, |
799 JSObject* interceptor_holder, | 801 JSObject* interceptor_holder, |
800 Label* miss_label) { | 802 Label* miss_label) { |
801 Register holder = | 803 Register holder = |
802 stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder, | 804 stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder, |
803 scratch1, scratch2, scratch3, name, | 805 scratch1, scratch2, scratch3, name, |
804 miss_label); | 806 miss_label); |
805 | 807 |
806 // Call a runtime function to load the interceptor property. | 808 // Call a runtime function to load the interceptor property. |
807 __ EnterInternalFrame(); | 809 FrameScope scope(masm, StackFrame::INTERNAL); |
808 // Save the name_ register across the call. | 810 // Save the name_ register across the call. |
809 __ push(name_); | 811 __ push(name_); |
810 | 812 |
811 PushInterceptorArguments(masm, | 813 PushInterceptorArguments(masm, |
812 receiver, | 814 receiver, |
813 holder, | 815 holder, |
814 name_, | 816 name_, |
815 interceptor_holder); | 817 interceptor_holder); |
816 | 818 |
817 __ CallExternalReference( | 819 __ CallExternalReference( |
818 ExternalReference( | 820 ExternalReference( |
819 IC_Utility(IC::kLoadPropertyWithInterceptorForCall), | 821 IC_Utility(IC::kLoadPropertyWithInterceptorForCall), |
820 masm->isolate()), | 822 masm->isolate()), |
821 5); | 823 5); |
822 | 824 |
823 // Restore the name_ register. | 825 // Restore the name_ register. |
824 __ pop(name_); | 826 __ pop(name_); |
825 __ LeaveInternalFrame(); | 827 |
| 828 // Leave the internal frame. |
826 } | 829 } |
827 | 830 |
828 void LoadWithInterceptor(MacroAssembler* masm, | 831 void LoadWithInterceptor(MacroAssembler* masm, |
829 Register receiver, | 832 Register receiver, |
830 Register holder, | 833 Register holder, |
831 JSObject* holder_obj, | 834 JSObject* holder_obj, |
832 Register scratch, | 835 Register scratch, |
833 Label* interceptor_succeeded) { | 836 Label* interceptor_succeeded) { |
834 __ EnterInternalFrame(); | 837 { |
| 838 FrameScope scope(masm, StackFrame::INTERNAL); |
835 | 839 |
836 __ Push(holder, name_); | 840 __ Push(holder, name_); |
837 | 841 |
838 CompileCallLoadPropertyWithInterceptor(masm, | 842 CompileCallLoadPropertyWithInterceptor(masm, |
839 receiver, | 843 receiver, |
840 holder, | 844 holder, |
841 name_, | 845 name_, |
842 holder_obj); | 846 holder_obj); |
843 | 847 |
844 __ pop(name_); // Restore the name. | 848 __ pop(name_); // Restore the name. |
845 __ pop(receiver); // Restore the holder. | 849 __ pop(receiver); // Restore the holder. |
846 __ LeaveInternalFrame(); | 850 } |
847 | 851 |
848 // If interceptor returns no-result sentinel, call the constant function. | 852 // If interceptor returns no-result sentinel, call the constant function. |
849 __ LoadRoot(scratch, Heap::kNoInterceptorResultSentinelRootIndex); | 853 __ LoadRoot(scratch, Heap::kNoInterceptorResultSentinelRootIndex); |
850 __ Branch(interceptor_succeeded, ne, v0, Operand(scratch)); | 854 __ Branch(interceptor_succeeded, ne, v0, Operand(scratch)); |
851 } | 855 } |
852 | 856 |
853 StubCompiler* stub_compiler_; | 857 StubCompiler* stub_compiler_; |
854 const ParameterCount& arguments_; | 858 const ParameterCount& arguments_; |
855 Register name_; | 859 Register name_; |
856 Code::ExtraICState extra_ic_state_; | 860 Code::ExtraICState extra_ic_state_; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 // Compile the interceptor call, followed by inline code to load the | 1314 // Compile the interceptor call, followed by inline code to load the |
1311 // property from further up the prototype chain if the call fails. | 1315 // property from further up the prototype chain if the call fails. |
1312 // Check that the maps haven't changed. | 1316 // Check that the maps haven't changed. |
1313 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, | 1317 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, |
1314 scratch1, scratch2, scratch3, | 1318 scratch1, scratch2, scratch3, |
1315 name, miss); | 1319 name, miss); |
1316 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); | 1320 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); |
1317 | 1321 |
1318 // Save necessary data before invoking an interceptor. | 1322 // Save necessary data before invoking an interceptor. |
1319 // Requires a frame to make GC aware of pushed pointers. | 1323 // Requires a frame to make GC aware of pushed pointers. |
1320 __ EnterInternalFrame(); | 1324 { |
| 1325 FrameScope frame_scope(masm(), StackFrame::INTERNAL); |
1321 | 1326 |
1322 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | 1327 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { |
1323 // CALLBACKS case needs a receiver to be passed into C++ callback. | 1328 // CALLBACKS case needs a receiver to be passed into C++ callback. |
1324 __ Push(receiver, holder_reg, name_reg); | 1329 __ Push(receiver, holder_reg, name_reg); |
1325 } else { | 1330 } else { |
1326 __ Push(holder_reg, name_reg); | 1331 __ Push(holder_reg, name_reg); |
| 1332 } |
| 1333 |
| 1334 // Invoke an interceptor. Note: map checks from receiver to |
| 1335 // interceptor's holder has been compiled before (see a caller |
| 1336 // of this method). |
| 1337 CompileCallLoadPropertyWithInterceptor(masm(), |
| 1338 receiver, |
| 1339 holder_reg, |
| 1340 name_reg, |
| 1341 interceptor_holder); |
| 1342 |
| 1343 // Check if interceptor provided a value for property. If it's |
| 1344 // the case, return immediately. |
| 1345 Label interceptor_failed; |
| 1346 __ LoadRoot(scratch1, Heap::kNoInterceptorResultSentinelRootIndex); |
| 1347 __ Branch(&interceptor_failed, eq, v0, Operand(scratch1)); |
| 1348 frame_scope.GenerateLeaveFrame(); |
| 1349 __ Ret(); |
| 1350 |
| 1351 __ bind(&interceptor_failed); |
| 1352 __ pop(name_reg); |
| 1353 __ pop(holder_reg); |
| 1354 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { |
| 1355 __ pop(receiver); |
| 1356 } |
| 1357 |
| 1358 // Leave the internal frame. |
1327 } | 1359 } |
1328 | 1360 |
1329 // Invoke an interceptor. Note: map checks from receiver to | |
1330 // interceptor's holder has been compiled before (see a caller | |
1331 // of this method). | |
1332 CompileCallLoadPropertyWithInterceptor(masm(), | |
1333 receiver, | |
1334 holder_reg, | |
1335 name_reg, | |
1336 interceptor_holder); | |
1337 | |
1338 // Check if interceptor provided a value for property. If it's | |
1339 // the case, return immediately. | |
1340 Label interceptor_failed; | |
1341 __ LoadRoot(scratch1, Heap::kNoInterceptorResultSentinelRootIndex); | |
1342 __ Branch(&interceptor_failed, eq, v0, Operand(scratch1)); | |
1343 __ LeaveInternalFrame(); | |
1344 __ Ret(); | |
1345 | |
1346 __ bind(&interceptor_failed); | |
1347 __ pop(name_reg); | |
1348 __ pop(holder_reg); | |
1349 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | |
1350 __ pop(receiver); | |
1351 } | |
1352 | |
1353 __ LeaveInternalFrame(); | |
1354 | |
1355 // Check that the maps from interceptor's holder to lookup's holder | 1361 // Check that the maps from interceptor's holder to lookup's holder |
1356 // haven't changed. And load lookup's holder into |holder| register. | 1362 // haven't changed. And load lookup's holder into |holder| register. |
1357 if (interceptor_holder != lookup->holder()) { | 1363 if (interceptor_holder != lookup->holder()) { |
1358 holder_reg = CheckPrototypes(interceptor_holder, | 1364 holder_reg = CheckPrototypes(interceptor_holder, |
1359 holder_reg, | 1365 holder_reg, |
1360 lookup->holder(), | 1366 lookup->holder(), |
1361 scratch1, | 1367 scratch1, |
1362 scratch2, | 1368 scratch2, |
1363 scratch3, | 1369 scratch3, |
1364 name, | 1370 name, |
(...skipping 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4488 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 4494 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
4489 __ Jump(ic, RelocInfo::CODE_TARGET); | 4495 __ Jump(ic, RelocInfo::CODE_TARGET); |
4490 } | 4496 } |
4491 | 4497 |
4492 | 4498 |
4493 #undef __ | 4499 #undef __ |
4494 | 4500 |
4495 } } // namespace v8::internal | 4501 } } // namespace v8::internal |
4496 | 4502 |
4497 #endif // V8_TARGET_ARCH_MIPS | 4503 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |