| 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 | 549 |
| 550 // Undoes the effects of ReserveSpaceForFastApiCall. | 550 // Undoes the effects of ReserveSpaceForFastApiCall. |
| 551 static void FreeSpaceForFastApiCall(MacroAssembler* masm) { | 551 static void FreeSpaceForFastApiCall(MacroAssembler* masm) { |
| 552 __ Drop(kFastApiCallArguments); | 552 __ Drop(kFastApiCallArguments); |
| 553 } | 553 } |
| 554 | 554 |
| 555 | 555 |
| 556 static MaybeObject* GenerateFastApiDirectCall(MacroAssembler* masm, | 556 static MaybeObject* GenerateFastApiDirectCall( |
| 557 const CallOptimization& optimization, | 557 MacroAssembler* masm, |
| 558 int argc) { | 558 const CallOptimization& optimization, |
| 559 int argc) { |
| 559 // ----------- S t a t e ------------- | 560 // ----------- S t a t e ------------- |
| 560 // -- sp[0] : holder (set by CheckPrototypes) | 561 // -- sp[0] : holder (set by CheckPrototypes) |
| 561 // -- sp[4] : callee js function | 562 // -- sp[4] : callee js function |
| 562 // -- sp[8] : call data | 563 // -- sp[8] : call data |
| 563 // -- sp[12] : last js argument | 564 // -- sp[12] : last js argument |
| 564 // -- ... | 565 // -- ... |
| 565 // -- sp[(argc + 3) * 4] : first js argument | 566 // -- sp[(argc + 3) * 4] : first js argument |
| 566 // -- sp[(argc + 4) * 4] : receiver | 567 // -- sp[(argc + 4) * 4] : receiver |
| 567 // ----------------------------------- | 568 // ----------------------------------- |
| 568 // Get the function and setup the context. | 569 // Get the function and setup the context. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 __ str(ip, MemOperand(r0, 3 * kPointerSize)); | 610 __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
| 610 | 611 |
| 611 // Emitting a stub call may try to allocate (if the code is not | 612 // Emitting a stub call may try to allocate (if the code is not |
| 612 // already generated). Do not allow the assembler to perform a | 613 // already generated). Do not allow the assembler to perform a |
| 613 // garbage collection but instead return the allocation failure | 614 // garbage collection but instead return the allocation failure |
| 614 // object. | 615 // object. |
| 615 const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; | 616 const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; |
| 616 ExternalReference ref = ExternalReference(&fun, | 617 ExternalReference ref = ExternalReference(&fun, |
| 617 ExternalReference::DIRECT_API_CALL, | 618 ExternalReference::DIRECT_API_CALL, |
| 618 masm->isolate()); | 619 masm->isolate()); |
| 620 AllowExternalCallThatCantCauseGC scope(masm); |
| 619 return masm->TryCallApiFunctionAndReturn(ref, kStackUnwindSpace); | 621 return masm->TryCallApiFunctionAndReturn(ref, kStackUnwindSpace); |
| 620 } | 622 } |
| 621 | 623 |
| 624 |
| 622 class CallInterceptorCompiler BASE_EMBEDDED { | 625 class CallInterceptorCompiler BASE_EMBEDDED { |
| 623 public: | 626 public: |
| 624 CallInterceptorCompiler(StubCompiler* stub_compiler, | 627 CallInterceptorCompiler(StubCompiler* stub_compiler, |
| 625 const ParameterCount& arguments, | 628 const ParameterCount& arguments, |
| 626 Register name, | 629 Register name, |
| 627 Code::ExtraICState extra_ic_state) | 630 Code::ExtraICState extra_ic_state) |
| 628 : stub_compiler_(stub_compiler), | 631 : stub_compiler_(stub_compiler), |
| 629 arguments_(arguments), | 632 arguments_(arguments), |
| 630 name_(name), | 633 name_(name), |
| 631 extra_ic_state_(extra_ic_state) {} | 634 extra_ic_state_(extra_ic_state) {} |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 Register scratch3, | 790 Register scratch3, |
| 788 String* name, | 791 String* name, |
| 789 JSObject* interceptor_holder, | 792 JSObject* interceptor_holder, |
| 790 Label* miss_label) { | 793 Label* miss_label) { |
| 791 Register holder = | 794 Register holder = |
| 792 stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder, | 795 stub_compiler_->CheckPrototypes(object, receiver, interceptor_holder, |
| 793 scratch1, scratch2, scratch3, name, | 796 scratch1, scratch2, scratch3, name, |
| 794 miss_label); | 797 miss_label); |
| 795 | 798 |
| 796 // Call a runtime function to load the interceptor property. | 799 // Call a runtime function to load the interceptor property. |
| 797 __ EnterInternalFrame(); | 800 FrameScope scope(masm, StackFrame::INTERNAL); |
| 798 // Save the name_ register across the call. | 801 // Save the name_ register across the call. |
| 799 __ push(name_); | 802 __ push(name_); |
| 800 | 803 |
| 801 PushInterceptorArguments(masm, | 804 PushInterceptorArguments(masm, |
| 802 receiver, | 805 receiver, |
| 803 holder, | 806 holder, |
| 804 name_, | 807 name_, |
| 805 interceptor_holder); | 808 interceptor_holder); |
| 806 | 809 |
| 807 __ CallExternalReference( | 810 __ CallExternalReference( |
| 808 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall), | 811 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall), |
| 809 masm->isolate()), | 812 masm->isolate()), |
| 810 5); | 813 5); |
| 811 | 814 |
| 812 // Restore the name_ register. | 815 // Restore the name_ register. |
| 813 __ pop(name_); | 816 __ pop(name_); |
| 814 __ LeaveInternalFrame(); | 817 |
| 818 // Leave the internal frame. |
| 815 } | 819 } |
| 816 | 820 |
| 817 void LoadWithInterceptor(MacroAssembler* masm, | 821 void LoadWithInterceptor(MacroAssembler* masm, |
| 818 Register receiver, | 822 Register receiver, |
| 819 Register holder, | 823 Register holder, |
| 820 JSObject* holder_obj, | 824 JSObject* holder_obj, |
| 821 Register scratch, | 825 Register scratch, |
| 822 Label* interceptor_succeeded) { | 826 Label* interceptor_succeeded) { |
| 823 __ EnterInternalFrame(); | 827 { |
| 824 __ Push(holder, name_); | 828 FrameScope scope(masm, StackFrame::INTERNAL); |
| 829 __ Push(holder, name_); |
| 825 | 830 |
| 826 CompileCallLoadPropertyWithInterceptor(masm, | 831 CompileCallLoadPropertyWithInterceptor(masm, |
| 827 receiver, | 832 receiver, |
| 828 holder, | 833 holder, |
| 829 name_, | 834 name_, |
| 830 holder_obj); | 835 holder_obj); |
| 831 | 836 |
| 832 __ pop(name_); // Restore the name. | 837 __ pop(name_); // Restore the name. |
| 833 __ pop(receiver); // Restore the holder. | 838 __ pop(receiver); // Restore the holder. |
| 834 __ LeaveInternalFrame(); | 839 } |
| 835 | 840 |
| 836 // If interceptor returns no-result sentinel, call the constant function. | 841 // If interceptor returns no-result sentinel, call the constant function. |
| 837 __ LoadRoot(scratch, Heap::kNoInterceptorResultSentinelRootIndex); | 842 __ LoadRoot(scratch, Heap::kNoInterceptorResultSentinelRootIndex); |
| 838 __ cmp(r0, scratch); | 843 __ cmp(r0, scratch); |
| 839 __ b(ne, interceptor_succeeded); | 844 __ b(ne, interceptor_succeeded); |
| 840 } | 845 } |
| 841 | 846 |
| 842 StubCompiler* stub_compiler_; | 847 StubCompiler* stub_compiler_; |
| 843 const ParameterCount& arguments_; | 848 const ParameterCount& arguments_; |
| 844 Register name_; | 849 Register name_; |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 // Compile the interceptor call, followed by inline code to load the | 1286 // Compile the interceptor call, followed by inline code to load the |
| 1282 // property from further up the prototype chain if the call fails. | 1287 // property from further up the prototype chain if the call fails. |
| 1283 // Check that the maps haven't changed. | 1288 // Check that the maps haven't changed. |
| 1284 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, | 1289 Register holder_reg = CheckPrototypes(object, receiver, interceptor_holder, |
| 1285 scratch1, scratch2, scratch3, | 1290 scratch1, scratch2, scratch3, |
| 1286 name, miss); | 1291 name, miss); |
| 1287 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); | 1292 ASSERT(holder_reg.is(receiver) || holder_reg.is(scratch1)); |
| 1288 | 1293 |
| 1289 // Save necessary data before invoking an interceptor. | 1294 // Save necessary data before invoking an interceptor. |
| 1290 // Requires a frame to make GC aware of pushed pointers. | 1295 // Requires a frame to make GC aware of pushed pointers. |
| 1291 __ EnterInternalFrame(); | 1296 { |
| 1297 FrameScope frame_scope(masm(), StackFrame::INTERNAL); |
| 1292 | 1298 |
| 1293 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | 1299 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { |
| 1294 // CALLBACKS case needs a receiver to be passed into C++ callback. | 1300 // CALLBACKS case needs a receiver to be passed into C++ callback. |
| 1295 __ Push(receiver, holder_reg, name_reg); | 1301 __ Push(receiver, holder_reg, name_reg); |
| 1296 } else { | 1302 } else { |
| 1297 __ Push(holder_reg, name_reg); | 1303 __ Push(holder_reg, name_reg); |
| 1304 } |
| 1305 |
| 1306 // Invoke an interceptor. Note: map checks from receiver to |
| 1307 // interceptor's holder has been compiled before (see a caller |
| 1308 // of this method.) |
| 1309 CompileCallLoadPropertyWithInterceptor(masm(), |
| 1310 receiver, |
| 1311 holder_reg, |
| 1312 name_reg, |
| 1313 interceptor_holder); |
| 1314 |
| 1315 // Check if interceptor provided a value for property. If it's |
| 1316 // the case, return immediately. |
| 1317 Label interceptor_failed; |
| 1318 __ LoadRoot(scratch1, Heap::kNoInterceptorResultSentinelRootIndex); |
| 1319 __ cmp(r0, scratch1); |
| 1320 __ b(eq, &interceptor_failed); |
| 1321 frame_scope.GenerateLeaveFrame(); |
| 1322 __ Ret(); |
| 1323 |
| 1324 __ bind(&interceptor_failed); |
| 1325 __ pop(name_reg); |
| 1326 __ pop(holder_reg); |
| 1327 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { |
| 1328 __ pop(receiver); |
| 1329 } |
| 1330 |
| 1331 // Leave the internal frame. |
| 1298 } | 1332 } |
| 1299 | 1333 |
| 1300 // Invoke an interceptor. Note: map checks from receiver to | |
| 1301 // interceptor's holder has been compiled before (see a caller | |
| 1302 // of this method.) | |
| 1303 CompileCallLoadPropertyWithInterceptor(masm(), | |
| 1304 receiver, | |
| 1305 holder_reg, | |
| 1306 name_reg, | |
| 1307 interceptor_holder); | |
| 1308 | |
| 1309 // Check if interceptor provided a value for property. If it's | |
| 1310 // the case, return immediately. | |
| 1311 Label interceptor_failed; | |
| 1312 __ LoadRoot(scratch1, Heap::kNoInterceptorResultSentinelRootIndex); | |
| 1313 __ cmp(r0, scratch1); | |
| 1314 __ b(eq, &interceptor_failed); | |
| 1315 __ LeaveInternalFrame(); | |
| 1316 __ Ret(); | |
| 1317 | |
| 1318 __ bind(&interceptor_failed); | |
| 1319 __ pop(name_reg); | |
| 1320 __ pop(holder_reg); | |
| 1321 if (lookup->type() == CALLBACKS && !receiver.is(holder_reg)) { | |
| 1322 __ pop(receiver); | |
| 1323 } | |
| 1324 | |
| 1325 __ LeaveInternalFrame(); | |
| 1326 | |
| 1327 // Check that the maps from interceptor's holder to lookup's holder | 1334 // Check that the maps from interceptor's holder to lookup's holder |
| 1328 // haven't changed. And load lookup's holder into |holder| register. | 1335 // haven't changed. And load lookup's holder into |holder| register. |
| 1329 if (interceptor_holder != lookup->holder()) { | 1336 if (interceptor_holder != lookup->holder()) { |
| 1330 holder_reg = CheckPrototypes(interceptor_holder, | 1337 holder_reg = CheckPrototypes(interceptor_holder, |
| 1331 holder_reg, | 1338 holder_reg, |
| 1332 lookup->holder(), | 1339 lookup->holder(), |
| 1333 scratch1, | 1340 scratch1, |
| 1334 scratch2, | 1341 scratch2, |
| 1335 scratch3, | 1342 scratch3, |
| 1336 name, | 1343 name, |
| (...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4421 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); | 4428 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); |
| 4422 __ Jump(ic, RelocInfo::CODE_TARGET); | 4429 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 4423 } | 4430 } |
| 4424 | 4431 |
| 4425 | 4432 |
| 4426 #undef __ | 4433 #undef __ |
| 4427 | 4434 |
| 4428 } } // namespace v8::internal | 4435 } } // namespace v8::internal |
| 4429 | 4436 |
| 4430 #endif // V8_TARGET_ARCH_ARM | 4437 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |