| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 if (object->IsGlobalObject()) { | 384 if (object->IsGlobalObject()) { |
| 385 __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); | 385 __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); |
| 386 __ str(r3, MemOperand(sp, arguments.immediate() * kPointerSize)); | 386 __ str(r3, MemOperand(sp, arguments.immediate() * kPointerSize)); |
| 387 } | 387 } |
| 388 | 388 |
| 389 // Invoke the function. | 389 // Invoke the function. |
| 390 __ InvokeFunction(r1, arguments, JUMP_FUNCTION); | 390 __ InvokeFunction(r1, arguments, JUMP_FUNCTION); |
| 391 } | 391 } |
| 392 | 392 |
| 393 | 393 |
| 394 static void GenerateCallConstFunction(MacroAssembler* masm, | |
| 395 JSFunction* function, | |
| 396 const ParameterCount& arguments) { | |
| 397 ASSERT(function->is_compiled()); | |
| 398 | |
| 399 // Get the function and setup the context. | |
| 400 __ mov(r1, Operand(Handle<JSFunction>(function))); | |
| 401 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | |
| 402 | |
| 403 // Jump to the cached code (tail call). | |
| 404 Handle<Code> code(function->code()); | |
| 405 ParameterCount expected(function->shared()->formal_parameter_count()); | |
| 406 __ InvokeCode(code, expected, arguments, | |
| 407 RelocInfo::CODE_TARGET, JUMP_FUNCTION); | |
| 408 } | |
| 409 | |
| 410 | |
| 411 template <class Compiler> | 394 template <class Compiler> |
| 412 static void CompileLoadInterceptor(Compiler* compiler, | 395 static void CompileLoadInterceptor(Compiler* compiler, |
| 413 StubCompiler* stub_compiler, | 396 StubCompiler* stub_compiler, |
| 414 MacroAssembler* masm, | 397 MacroAssembler* masm, |
| 415 JSObject* object, | 398 JSObject* object, |
| 416 JSObject* holder, | 399 JSObject* holder, |
| 417 String* name, | 400 String* name, |
| 418 LookupResult* lookup, | 401 LookupResult* lookup, |
| 419 Register receiver, | 402 Register receiver, |
| 420 Register scratch1, | 403 Register scratch1, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 void CompileCacheable(MacroAssembler* masm, | 479 void CompileCacheable(MacroAssembler* masm, |
| 497 StubCompiler* stub_compiler, | 480 StubCompiler* stub_compiler, |
| 498 Register receiver, | 481 Register receiver, |
| 499 Register holder, | 482 Register holder, |
| 500 Register scratch1, | 483 Register scratch1, |
| 501 Register scratch2, | 484 Register scratch2, |
| 502 JSObject* holder_obj, | 485 JSObject* holder_obj, |
| 503 LookupResult* lookup, | 486 LookupResult* lookup, |
| 504 String* name, | 487 String* name, |
| 505 Label* miss_label) { | 488 Label* miss_label) { |
| 506 AccessorInfo* callback = 0; | 489 AccessorInfo* callback = NULL; |
| 507 bool optimize = false; | 490 bool optimize = false; |
| 508 // So far the most popular follow ups for interceptor loads are FIELD | 491 // So far the most popular follow ups for interceptor loads are FIELD |
| 509 // and CALLBACKS, so inline only them, other cases may be added | 492 // and CALLBACKS, so inline only them, other cases may be added |
| 510 // later. | 493 // later. |
| 511 if (lookup->type() == FIELD) { | 494 if (lookup->type() == FIELD) { |
| 512 optimize = true; | 495 optimize = true; |
| 513 } else if (lookup->type() == CALLBACKS) { | 496 } else if (lookup->type() == CALLBACKS) { |
| 514 Object* callback_object = lookup->GetCallbackObject(); | 497 Object* callback_object = lookup->GetCallbackObject(); |
| 515 if (callback_object->IsAccessorInfo()) { | 498 if (callback_object->IsAccessorInfo()) { |
| 516 callback = AccessorInfo::cast(callback_object); | 499 callback = AccessorInfo::cast(callback_object); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 598 } |
| 616 | 599 |
| 617 private: | 600 private: |
| 618 Register name_; | 601 Register name_; |
| 619 }; | 602 }; |
| 620 | 603 |
| 621 | 604 |
| 622 class CallInterceptorCompiler BASE_EMBEDDED { | 605 class CallInterceptorCompiler BASE_EMBEDDED { |
| 623 public: | 606 public: |
| 624 CallInterceptorCompiler(const ParameterCount& arguments, Register name) | 607 CallInterceptorCompiler(const ParameterCount& arguments, Register name) |
| 625 : arguments_(arguments), argc_(arguments.immediate()), name_(name) {} | 608 : arguments_(arguments), name_(name) {} |
| 626 | 609 |
| 627 void CompileCacheable(MacroAssembler* masm, | 610 void CompileCacheable(MacroAssembler* masm, |
| 628 StubCompiler* stub_compiler, | 611 StubCompiler* stub_compiler, |
| 629 Register receiver, | 612 Register receiver, |
| 630 Register holder, | 613 Register holder, |
| 631 Register scratch1, | 614 Register scratch1, |
| 632 Register scratch2, | 615 Register scratch2, |
| 633 JSObject* holder_obj, | 616 JSObject* holder_obj, |
| 634 LookupResult* lookup, | 617 LookupResult* lookup, |
| 635 String* name, | 618 String* name, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 __ LoadRoot(scratch2, Heap::kNoInterceptorResultSentinelRootIndex); | 658 __ LoadRoot(scratch2, Heap::kNoInterceptorResultSentinelRootIndex); |
| 676 __ cmp(r0, scratch2); | 659 __ cmp(r0, scratch2); |
| 677 Label invoke; | 660 Label invoke; |
| 678 __ b(ne, &invoke); | 661 __ b(ne, &invoke); |
| 679 | 662 |
| 680 stub_compiler->CheckPrototypes(holder_obj, scratch1, | 663 stub_compiler->CheckPrototypes(holder_obj, scratch1, |
| 681 lookup->holder(), scratch1, | 664 lookup->holder(), scratch1, |
| 682 scratch2, | 665 scratch2, |
| 683 name, | 666 name, |
| 684 miss_label); | 667 miss_label); |
| 685 GenerateCallConstFunction(masm, function, arguments_); | 668 __ InvokeFunction(function, arguments_); |
| 686 | 669 |
| 687 __ bind(&invoke); | 670 __ bind(&invoke); |
| 688 } | 671 } |
| 689 | 672 |
| 690 void CompileRegular(MacroAssembler* masm, | 673 void CompileRegular(MacroAssembler* masm, |
| 691 Register receiver, | 674 Register receiver, |
| 692 Register holder, | 675 Register holder, |
| 693 Register scratch, | 676 Register scratch, |
| 694 JSObject* holder_obj, | 677 JSObject* holder_obj, |
| 695 Label* miss_label) { | 678 Label* miss_label) { |
| 696 __ EnterInternalFrame(); | 679 __ EnterInternalFrame(); |
| 697 // Save the name_ register across the call. | 680 // Save the name_ register across the call. |
| 698 __ push(name_); | 681 __ push(name_); |
| 699 | 682 |
| 700 PushInterceptorArguments(masm, | 683 PushInterceptorArguments(masm, |
| 701 receiver, | 684 receiver, |
| 702 holder, | 685 holder, |
| 703 name_, | 686 name_, |
| 704 holder_obj); | 687 holder_obj); |
| 705 | 688 |
| 706 ExternalReference ref = ExternalReference( | 689 __ CallExternalReference( |
| 707 IC_Utility(IC::kLoadPropertyWithInterceptorForCall)); | 690 ExternalReference(IC_Utility(IC::kLoadPropertyWithInterceptorForCall)), |
| 708 __ mov(r0, Operand(5)); | 691 5); |
| 709 __ mov(r1, Operand(ref)); | |
| 710 | |
| 711 CEntryStub stub(1); | |
| 712 __ CallStub(&stub); | |
| 713 | 692 |
| 714 // Restore the name_ register. | 693 // Restore the name_ register. |
| 715 __ pop(name_); | 694 __ pop(name_); |
| 716 __ LeaveInternalFrame(); | 695 __ LeaveInternalFrame(); |
| 717 } | 696 } |
| 718 | 697 |
| 719 private: | 698 private: |
| 720 const ParameterCount& arguments_; | 699 const ParameterCount& arguments_; |
| 721 int argc_; | |
| 722 Register name_; | 700 Register name_; |
| 723 }; | 701 }; |
| 724 | 702 |
| 725 | 703 |
| 726 #undef __ | 704 #undef __ |
| 727 #define __ ACCESS_MASM(masm()) | 705 #define __ ACCESS_MASM(masm()) |
| 728 | 706 |
| 729 | 707 |
| 730 Register StubCompiler::CheckPrototypes(JSObject* object, | 708 Register StubCompiler::CheckPrototypes(JSObject* object, |
| 731 Register object_reg, | 709 Register object_reg, |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); | 1024 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); |
| 1047 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); | 1025 __ LoadRoot(ip, Heap::kFixedArrayMapRootIndex); |
| 1048 __ cmp(r2, ip); | 1026 __ cmp(r2, ip); |
| 1049 __ b(ne, &miss); | 1027 __ b(ne, &miss); |
| 1050 break; | 1028 break; |
| 1051 | 1029 |
| 1052 default: | 1030 default: |
| 1053 UNREACHABLE(); | 1031 UNREACHABLE(); |
| 1054 } | 1032 } |
| 1055 | 1033 |
| 1056 GenerateCallConstFunction(masm(), function, arguments()); | 1034 __ InvokeFunction(function, arguments()); |
| 1057 | 1035 |
| 1058 // Handle call cache miss. | 1036 // Handle call cache miss. |
| 1059 __ bind(&miss); | 1037 __ bind(&miss); |
| 1060 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); | 1038 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); |
| 1061 __ Jump(ic, RelocInfo::CODE_TARGET); | 1039 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 1062 | 1040 |
| 1063 // Return the generated code. | 1041 // Return the generated code. |
| 1064 String* function_name = NULL; | 1042 String* function_name = NULL; |
| 1065 if (function->shared()->name()->IsString()) { | 1043 if (function->shared()->name()->IsString()) { |
| 1066 function_name = String::cast(function->shared()->name()); | 1044 function_name = String::cast(function->shared()->name()); |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1860 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); | 1838 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 1861 | 1839 |
| 1862 // Return the generated code. | 1840 // Return the generated code. |
| 1863 return GetCode(); | 1841 return GetCode(); |
| 1864 } | 1842 } |
| 1865 | 1843 |
| 1866 | 1844 |
| 1867 #undef __ | 1845 #undef __ |
| 1868 | 1846 |
| 1869 } } // namespace v8::internal | 1847 } } // namespace v8::internal |
| OLD | NEW |