| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 Handle<Code> ComputeCallArguments(int argc, Code::Kind kind); | 223 Handle<Code> ComputeCallArguments(int argc, Code::Kind kind); |
| 224 | 224 |
| 225 Handle<Code> ComputeCallMegamorphic(int argc, | 225 Handle<Code> ComputeCallMegamorphic(int argc, |
| 226 Code::Kind kind, | 226 Code::Kind kind, |
| 227 Code::ExtraICState state); | 227 Code::ExtraICState state); |
| 228 | 228 |
| 229 Handle<Code> ComputeCallMiss(int argc, | 229 Handle<Code> ComputeCallMiss(int argc, |
| 230 Code::Kind kind, | 230 Code::Kind kind, |
| 231 Code::ExtraICState state); | 231 Code::ExtraICState state); |
| 232 | 232 |
| 233 MUST_USE_RESULT MaybeObject* TryComputeCallMiss(int argc, | |
| 234 Code::Kind kind, | |
| 235 Code::ExtraICState state); | |
| 236 | |
| 237 // Finds the Code object stored in the Heap::non_monomorphic_cache(). | 233 // Finds the Code object stored in the Heap::non_monomorphic_cache(). |
| 238 Code* FindCallInitialize(int argc, RelocInfo::Mode mode, Code::Kind kind); | 234 Code* FindCallInitialize(int argc, RelocInfo::Mode mode, Code::Kind kind); |
| 239 | 235 |
| 240 #ifdef ENABLE_DEBUGGER_SUPPORT | 236 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 241 Handle<Code> ComputeCallDebugBreak(int argc, Code::Kind kind); | 237 Handle<Code> ComputeCallDebugBreak(int argc, Code::Kind kind); |
| 242 | 238 |
| 243 Handle<Code> ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind); | 239 Handle<Code> ComputeCallDebugPrepareStepIn(int argc, Code::Kind kind); |
| 244 #endif | 240 #endif |
| 245 | 241 |
| 246 // Update cache for entry hash(name, map). | 242 // Update cache for entry hash(name, map). |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 381 |
| 386 // Functions to compile either CallIC or KeyedCallIC. The specific kind | 382 // Functions to compile either CallIC or KeyedCallIC. The specific kind |
| 387 // is extracted from the code flags. | 383 // is extracted from the code flags. |
| 388 Handle<Code> CompileCallInitialize(Code::Flags flags); | 384 Handle<Code> CompileCallInitialize(Code::Flags flags); |
| 389 Handle<Code> CompileCallPreMonomorphic(Code::Flags flags); | 385 Handle<Code> CompileCallPreMonomorphic(Code::Flags flags); |
| 390 Handle<Code> CompileCallNormal(Code::Flags flags); | 386 Handle<Code> CompileCallNormal(Code::Flags flags); |
| 391 Handle<Code> CompileCallMegamorphic(Code::Flags flags); | 387 Handle<Code> CompileCallMegamorphic(Code::Flags flags); |
| 392 Handle<Code> CompileCallArguments(Code::Flags flags); | 388 Handle<Code> CompileCallArguments(Code::Flags flags); |
| 393 Handle<Code> CompileCallMiss(Code::Flags flags); | 389 Handle<Code> CompileCallMiss(Code::Flags flags); |
| 394 | 390 |
| 395 MUST_USE_RESULT MaybeObject* TryCompileCallMiss(Code::Flags flags); | |
| 396 | |
| 397 #ifdef ENABLE_DEBUGGER_SUPPORT | 391 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 398 Handle<Code> CompileCallDebugBreak(Code::Flags flags); | 392 Handle<Code> CompileCallDebugBreak(Code::Flags flags); |
| 399 Handle<Code> CompileCallDebugPrepareStepIn(Code::Flags flags); | 393 Handle<Code> CompileCallDebugPrepareStepIn(Code::Flags flags); |
| 400 #endif | 394 #endif |
| 401 | 395 |
| 402 // Static functions for generating parts of stubs. | 396 // Static functions for generating parts of stubs. |
| 403 static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, | 397 static void GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, |
| 404 int index, | 398 int index, |
| 405 Register prototype); | 399 Register prototype); |
| 406 | 400 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 Register CheckPrototypes(Handle<JSObject> object, | 477 Register CheckPrototypes(Handle<JSObject> object, |
| 484 Register object_reg, | 478 Register object_reg, |
| 485 Handle<JSObject> holder, | 479 Handle<JSObject> holder, |
| 486 Register holder_reg, | 480 Register holder_reg, |
| 487 Register scratch1, | 481 Register scratch1, |
| 488 Register scratch2, | 482 Register scratch2, |
| 489 Handle<String> name, | 483 Handle<String> name, |
| 490 int save_at_depth, | 484 int save_at_depth, |
| 491 Label* miss); | 485 Label* miss); |
| 492 | 486 |
| 493 // TODO(kmillikin): Eliminate this function when the stub cache is fully | |
| 494 // handlified. | |
| 495 Register CheckPrototypes(JSObject* object, | |
| 496 Register object_reg, | |
| 497 JSObject* holder, | |
| 498 Register holder_reg, | |
| 499 Register scratch1, | |
| 500 Register scratch2, | |
| 501 String* name, | |
| 502 Label* miss) { | |
| 503 return CheckPrototypes(object, object_reg, holder, holder_reg, scratch1, | |
| 504 scratch2, name, kInvalidProtoDepth, miss); | |
| 505 } | |
| 506 | |
| 507 // TODO(kmillikin): Eliminate this function when the stub cache is fully | |
| 508 // handlified. | |
| 509 Register CheckPrototypes(JSObject* object, | |
| 510 Register object_reg, | |
| 511 JSObject* holder, | |
| 512 Register holder_reg, | |
| 513 Register scratch1, | |
| 514 Register scratch2, | |
| 515 String* name, | |
| 516 int save_at_depth, | |
| 517 Label* miss); | |
| 518 | |
| 519 protected: | 487 protected: |
| 520 Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name); | 488 Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name); |
| 521 Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<String> name); | 489 Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<String> name); |
| 522 | 490 |
| 491 // TODO(kmillikin): Remove these functions once the ConstructStubCompiler |
| 492 // is handlified. |
| 523 MUST_USE_RESULT MaybeObject* TryGetCodeWithFlags(Code::Flags flags, | 493 MUST_USE_RESULT MaybeObject* TryGetCodeWithFlags(Code::Flags flags, |
| 524 const char* name); | 494 const char* name); |
| 525 MUST_USE_RESULT MaybeObject* TryGetCodeWithFlags(Code::Flags flags, | 495 MUST_USE_RESULT MaybeObject* TryGetCodeWithFlags(Code::Flags flags, |
| 526 String* name); | 496 String* name); |
| 527 | 497 |
| 528 MacroAssembler* masm() { return &masm_; } | 498 MacroAssembler* masm() { return &masm_; } |
| 529 void set_failure(Failure* failure) { failure_ = failure; } | 499 void set_failure(Failure* failure) { failure_ = failure; } |
| 530 | 500 |
| 531 void GenerateLoadField(Handle<JSObject> object, | 501 void GenerateLoadField(Handle<JSObject> object, |
| 532 Handle<JSObject> holder, | 502 Handle<JSObject> holder, |
| 533 Register receiver, | 503 Register receiver, |
| 534 Register scratch1, | 504 Register scratch1, |
| 535 Register scratch2, | 505 Register scratch2, |
| 536 Register scratch3, | 506 Register scratch3, |
| 537 int index, | 507 int index, |
| 538 Handle<String> name, | 508 Handle<String> name, |
| 539 Label* miss); | 509 Label* miss); |
| 540 | 510 |
| 541 MaybeObject* GenerateLoadCallback(JSObject* object, | 511 void GenerateLoadCallback(Handle<JSObject> object, |
| 542 JSObject* holder, | 512 Handle<JSObject> holder, |
| 543 Register receiver, | 513 Register receiver, |
| 544 Register name_reg, | 514 Register name_reg, |
| 545 Register scratch1, | 515 Register scratch1, |
| 546 Register scratch2, | 516 Register scratch2, |
| 547 Register scratch3, | 517 Register scratch3, |
| 548 AccessorInfo* callback, | 518 Handle<AccessorInfo> callback, |
| 549 String* name, | 519 Handle<String> name, |
| 550 Label* miss); | 520 Label* miss); |
| 551 | 521 |
| 552 void GenerateLoadConstant(Handle<JSObject> object, | 522 void GenerateLoadConstant(Handle<JSObject> object, |
| 553 Handle<JSObject> holder, | 523 Handle<JSObject> holder, |
| 554 Register receiver, | 524 Register receiver, |
| 555 Register scratch1, | 525 Register scratch1, |
| 556 Register scratch2, | 526 Register scratch2, |
| 557 Register scratch3, | 527 Register scratch3, |
| 558 Handle<Object> value, | 528 Handle<Object> value, |
| 559 Handle<String> name, | 529 Handle<String> name, |
| 560 Label* miss); | 530 Label* miss); |
| 561 | 531 |
| 562 void GenerateLoadInterceptor(JSObject* object, | 532 void GenerateLoadInterceptor(Handle<JSObject> object, |
| 563 JSObject* holder, | 533 Handle<JSObject> holder, |
| 564 LookupResult* lookup, | 534 LookupResult* lookup, |
| 565 Register receiver, | 535 Register receiver, |
| 566 Register name_reg, | 536 Register name_reg, |
| 567 Register scratch1, | 537 Register scratch1, |
| 568 Register scratch2, | 538 Register scratch2, |
| 569 Register scratch3, | 539 Register scratch3, |
| 570 String* name, | 540 Handle<String> name, |
| 571 Label* miss); | 541 Label* miss); |
| 572 | 542 |
| 573 static void LookupPostInterceptor(JSObject* holder, | 543 static void LookupPostInterceptor(Handle<JSObject> holder, |
| 574 String* name, | 544 Handle<String> name, |
| 575 LookupResult* lookup); | 545 LookupResult* lookup); |
| 576 | 546 |
| 577 Isolate* isolate() { return isolate_; } | 547 Isolate* isolate() { return isolate_; } |
| 578 Heap* heap() { return isolate()->heap(); } | 548 Heap* heap() { return isolate()->heap(); } |
| 579 Factory* factory() { return isolate()->factory(); } | 549 Factory* factory() { return isolate()->factory(); } |
| 580 | 550 |
| 581 private: | 551 private: |
| 582 Isolate* isolate_; | 552 Isolate* isolate_; |
| 583 MacroAssembler masm_; | 553 MacroAssembler masm_; |
| 584 Failure* failure_; | 554 Failure* failure_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 596 Handle<Code> CompileLoadField(Handle<JSObject> object, | 566 Handle<Code> CompileLoadField(Handle<JSObject> object, |
| 597 Handle<JSObject> holder, | 567 Handle<JSObject> holder, |
| 598 int index, | 568 int index, |
| 599 Handle<String> name); | 569 Handle<String> name); |
| 600 | 570 |
| 601 Handle<Code> CompileLoadCallback(Handle<String> name, | 571 Handle<Code> CompileLoadCallback(Handle<String> name, |
| 602 Handle<JSObject> object, | 572 Handle<JSObject> object, |
| 603 Handle<JSObject> holder, | 573 Handle<JSObject> holder, |
| 604 Handle<AccessorInfo> callback); | 574 Handle<AccessorInfo> callback); |
| 605 | 575 |
| 606 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name, | |
| 607 JSObject* object, | |
| 608 JSObject* holder, | |
| 609 AccessorInfo* callback); | |
| 610 | |
| 611 Handle<Code> CompileLoadConstant(Handle<JSObject> object, | 576 Handle<Code> CompileLoadConstant(Handle<JSObject> object, |
| 612 Handle<JSObject> holder, | 577 Handle<JSObject> holder, |
| 613 Handle<Object> value, | 578 Handle<Object> value, |
| 614 Handle<String> name); | 579 Handle<String> name); |
| 615 | 580 |
| 616 Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, | 581 Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, |
| 617 Handle<JSObject> holder, | 582 Handle<JSObject> holder, |
| 618 Handle<String> name); | 583 Handle<String> name); |
| 619 | 584 |
| 620 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, | |
| 621 JSObject* holder, | |
| 622 String* name); | |
| 623 | |
| 624 Handle<Code> CompileLoadGlobal(Handle<JSObject> object, | 585 Handle<Code> CompileLoadGlobal(Handle<JSObject> object, |
| 625 Handle<GlobalObject> holder, | 586 Handle<GlobalObject> holder, |
| 626 Handle<JSGlobalPropertyCell> cell, | 587 Handle<JSGlobalPropertyCell> cell, |
| 627 Handle<String> name, | 588 Handle<String> name, |
| 628 bool is_dont_delete); | 589 bool is_dont_delete); |
| 629 | 590 |
| 630 private: | 591 private: |
| 631 MUST_USE_RESULT MaybeObject* TryGetCode(PropertyType type, String* name); | |
| 632 | |
| 633 Handle<Code> GetCode(PropertyType type, Handle<String> name); | 592 Handle<Code> GetCode(PropertyType type, Handle<String> name); |
| 634 }; | 593 }; |
| 635 | 594 |
| 636 | 595 |
| 637 class KeyedLoadStubCompiler: public StubCompiler { | 596 class KeyedLoadStubCompiler: public StubCompiler { |
| 638 public: | 597 public: |
| 639 explicit KeyedLoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } | 598 explicit KeyedLoadStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } |
| 640 | 599 |
| 641 Handle<Code> CompileLoadField(Handle<String> name, | 600 Handle<Code> CompileLoadField(Handle<String> name, |
| 642 Handle<JSObject> object, | 601 Handle<JSObject> object, |
| 643 Handle<JSObject> holder, | 602 Handle<JSObject> holder, |
| 644 int index); | 603 int index); |
| 645 | 604 |
| 646 Handle<Code> CompileLoadCallback(Handle<String> name, | 605 Handle<Code> CompileLoadCallback(Handle<String> name, |
| 647 Handle<JSObject> object, | 606 Handle<JSObject> object, |
| 648 Handle<JSObject> holder, | 607 Handle<JSObject> holder, |
| 649 Handle<AccessorInfo> callback); | 608 Handle<AccessorInfo> callback); |
| 650 | 609 |
| 651 MUST_USE_RESULT MaybeObject* CompileLoadCallback(String* name, | |
| 652 JSObject* object, | |
| 653 JSObject* holder, | |
| 654 AccessorInfo* callback); | |
| 655 | |
| 656 Handle<Code> CompileLoadConstant(Handle<String> name, | 610 Handle<Code> CompileLoadConstant(Handle<String> name, |
| 657 Handle<JSObject> object, | 611 Handle<JSObject> object, |
| 658 Handle<JSObject> holder, | 612 Handle<JSObject> holder, |
| 659 Handle<Object> value); | 613 Handle<Object> value); |
| 660 | 614 |
| 661 Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, | 615 Handle<Code> CompileLoadInterceptor(Handle<JSObject> object, |
| 662 Handle<JSObject> holder, | 616 Handle<JSObject> holder, |
| 663 Handle<String> name); | 617 Handle<String> name); |
| 664 | 618 |
| 665 MUST_USE_RESULT MaybeObject* CompileLoadInterceptor(JSObject* object, | |
| 666 JSObject* holder, | |
| 667 String* name); | |
| 668 | |
| 669 Handle<Code> CompileLoadArrayLength(Handle<String> name); | 619 Handle<Code> CompileLoadArrayLength(Handle<String> name); |
| 670 | 620 |
| 671 Handle<Code> CompileLoadStringLength(Handle<String> name); | 621 Handle<Code> CompileLoadStringLength(Handle<String> name); |
| 672 | 622 |
| 673 Handle<Code> CompileLoadFunctionPrototype(Handle<String> name); | 623 Handle<Code> CompileLoadFunctionPrototype(Handle<String> name); |
| 674 | 624 |
| 675 Handle<Code> CompileLoadElement(Handle<Map> receiver_map); | 625 Handle<Code> CompileLoadElement(Handle<Map> receiver_map); |
| 676 | 626 |
| 677 Handle<Code> CompileLoadPolymorphic(MapHandleList* receiver_maps, | 627 Handle<Code> CompileLoadPolymorphic(MapHandleList* receiver_maps, |
| 678 CodeHandleList* handler_ics); | 628 CodeHandleList* handler_ics); |
| 679 | 629 |
| 680 static void GenerateLoadExternalArray(MacroAssembler* masm, | 630 static void GenerateLoadExternalArray(MacroAssembler* masm, |
| 681 ElementsKind elements_kind); | 631 ElementsKind elements_kind); |
| 682 | 632 |
| 683 static void GenerateLoadFastElement(MacroAssembler* masm); | 633 static void GenerateLoadFastElement(MacroAssembler* masm); |
| 684 | 634 |
| 685 static void GenerateLoadFastDoubleElement(MacroAssembler* masm); | 635 static void GenerateLoadFastDoubleElement(MacroAssembler* masm); |
| 686 | 636 |
| 687 static void GenerateLoadDictionaryElement(MacroAssembler* masm); | 637 static void GenerateLoadDictionaryElement(MacroAssembler* masm); |
| 688 | 638 |
| 689 private: | 639 private: |
| 690 MaybeObject* TryGetCode(PropertyType type, | |
| 691 String* name, | |
| 692 InlineCacheState state = MONOMORPHIC); | |
| 693 | |
| 694 Handle<Code> GetCode(PropertyType type, | 640 Handle<Code> GetCode(PropertyType type, |
| 695 Handle<String> name, | 641 Handle<String> name, |
| 696 InlineCacheState state = MONOMORPHIC); | 642 InlineCacheState state = MONOMORPHIC); |
| 697 }; | 643 }; |
| 698 | 644 |
| 699 | 645 |
| 700 class StoreStubCompiler: public StubCompiler { | 646 class StoreStubCompiler: public StubCompiler { |
| 701 public: | 647 public: |
| 702 StoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode) | 648 StoreStubCompiler(Isolate* isolate, StrictModeFlag strict_mode) |
| 703 : StubCompiler(isolate), strict_mode_(strict_mode) { } | 649 : StubCompiler(isolate), strict_mode_(strict_mode) { } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 Handle<JSObject> holder, | 735 Handle<JSObject> holder, |
| 790 int index, | 736 int index, |
| 791 Handle<String> name); | 737 Handle<String> name); |
| 792 | 738 |
| 793 Handle<Code> CompileCallConstant(Handle<Object> object, | 739 Handle<Code> CompileCallConstant(Handle<Object> object, |
| 794 Handle<JSObject> holder, | 740 Handle<JSObject> holder, |
| 795 Handle<JSFunction> function, | 741 Handle<JSFunction> function, |
| 796 Handle<String> name, | 742 Handle<String> name, |
| 797 CheckType check); | 743 CheckType check); |
| 798 | 744 |
| 799 MUST_USE_RESULT MaybeObject* CompileCallConstant(Object* object, | |
| 800 JSObject* holder, | |
| 801 JSFunction* function, | |
| 802 String* name, | |
| 803 CheckType check); | |
| 804 | |
| 805 Handle<Code> CompileCallInterceptor(Handle<JSObject> object, | 745 Handle<Code> CompileCallInterceptor(Handle<JSObject> object, |
| 806 Handle<JSObject> holder, | 746 Handle<JSObject> holder, |
| 807 Handle<String> name); | 747 Handle<String> name); |
| 808 | 748 |
| 809 MUST_USE_RESULT MaybeObject* CompileCallInterceptor(JSObject* object, | |
| 810 JSObject* holder, | |
| 811 String* name); | |
| 812 | |
| 813 Handle<Code> CompileCallGlobal(Handle<JSObject> object, | 749 Handle<Code> CompileCallGlobal(Handle<JSObject> object, |
| 814 Handle<GlobalObject> holder, | 750 Handle<GlobalObject> holder, |
| 815 Handle<JSGlobalPropertyCell> cell, | 751 Handle<JSGlobalPropertyCell> cell, |
| 816 Handle<JSFunction> function, | 752 Handle<JSFunction> function, |
| 817 Handle<String> name); | 753 Handle<String> name); |
| 818 | 754 |
| 819 MUST_USE_RESULT MaybeObject* CompileCallGlobal(JSObject* object, | 755 static bool HasCustomCallGenerator(Handle<JSFunction> function); |
| 820 GlobalObject* holder, | |
| 821 JSGlobalPropertyCell* cell, | |
| 822 JSFunction* function, | |
| 823 String* name); | |
| 824 | |
| 825 static bool HasCustomCallGenerator(JSFunction* function); | |
| 826 | 756 |
| 827 private: | 757 private: |
| 828 // Compiles a custom call constant/global IC. For constant calls | 758 // Compiles a custom call constant/global IC. For constant calls cell is |
| 829 // cell is NULL. Returns undefined if there is no custom call code | 759 // NULL. Returns an empty handle if there is no custom call code for the |
| 830 // for the given function or it can't be generated. | 760 // given function. |
| 831 MUST_USE_RESULT MaybeObject* CompileCustomCall(Object* object, | 761 Handle<Code> CompileCustomCall(Handle<Object> object, |
| 832 JSObject* holder, | 762 Handle<JSObject> holder, |
| 833 JSGlobalPropertyCell* cell, | 763 Handle<JSGlobalPropertyCell> cell, |
| 834 JSFunction* function, | 764 Handle<JSFunction> function, |
| 835 String* name); | 765 Handle<String> name); |
| 836 | 766 |
| 837 #define DECLARE_CALL_GENERATOR(name) \ | 767 #define DECLARE_CALL_GENERATOR(name) \ |
| 838 MUST_USE_RESULT MaybeObject* Compile##name##Call(Object* object, \ | 768 Handle<Code> Compile##name##Call(Handle<Object> object, \ |
| 839 JSObject* holder, \ | 769 Handle<JSObject> holder, \ |
| 840 JSGlobalPropertyCell* cell, \ | 770 Handle<JSGlobalPropertyCell> cell, \ |
| 841 JSFunction* function, \ | 771 Handle<JSFunction> function, \ |
| 842 String* fname); | 772 Handle<String> fname); |
| 843 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR) | 773 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR) |
| 844 #undef DECLARE_CALL_GENERATOR | 774 #undef DECLARE_CALL_GENERATOR |
| 845 | 775 |
| 846 MUST_USE_RESULT MaybeObject* CompileFastApiCall( | 776 Handle<Code> CompileFastApiCall(const CallOptimization& optimization, |
| 847 const CallOptimization& optimization, | 777 Handle<Object> object, |
| 848 Object* object, | 778 Handle<JSObject> holder, |
| 849 JSObject* holder, | 779 Handle<JSGlobalPropertyCell> cell, |
| 850 JSGlobalPropertyCell* cell, | 780 Handle<JSFunction> function, |
| 851 JSFunction* function, | 781 Handle<String> name); |
| 852 String* name); | 782 |
| 783 Handle<Code> GetCode(PropertyType type, Handle<String> name); |
| 784 Handle<Code> GetCode(Handle<JSFunction> function); |
| 785 |
| 786 const ParameterCount& arguments() { return arguments_; } |
| 787 |
| 788 void GenerateNameCheck(Handle<String> name, Label* miss); |
| 789 |
| 790 void GenerateGlobalReceiverCheck(Handle<JSObject> object, |
| 791 Handle<JSObject> holder, |
| 792 Handle<String> name, |
| 793 Label* miss); |
| 794 |
| 795 // Generates code to load the function from the cell checking that |
| 796 // it still contains the same function. |
| 797 void GenerateLoadFunctionFromCell(Handle<JSGlobalPropertyCell> cell, |
| 798 Handle<JSFunction> function, |
| 799 Label* miss); |
| 800 |
| 801 // Generates a jump to CallIC miss stub. |
| 802 void GenerateMissBranch(); |
| 853 | 803 |
| 854 const ParameterCount arguments_; | 804 const ParameterCount arguments_; |
| 855 const Code::Kind kind_; | 805 const Code::Kind kind_; |
| 856 const Code::ExtraICState extra_state_; | 806 const Code::ExtraICState extra_state_; |
| 857 const InlineCacheHolderFlag cache_holder_; | 807 const InlineCacheHolderFlag cache_holder_; |
| 858 | |
| 859 const ParameterCount& arguments() { return arguments_; } | |
| 860 | |
| 861 Handle<Code> GetCode(PropertyType type, Handle<String> name); | |
| 862 Handle<Code> GetCode(Handle<JSFunction> function); | |
| 863 | |
| 864 // TODO(kmillikin): Eliminate these functions when the stub cache is fully | |
| 865 // handlified. | |
| 866 MUST_USE_RESULT MaybeObject* TryGetCode(PropertyType type, String* name); | |
| 867 MUST_USE_RESULT MaybeObject* TryGetCode(JSFunction* function); | |
| 868 | |
| 869 void GenerateNameCheck(Handle<String> name, Label* miss); | |
| 870 | |
| 871 void GenerateGlobalReceiverCheck(JSObject* object, | |
| 872 JSObject* holder, | |
| 873 String* name, | |
| 874 Label* miss); | |
| 875 | |
| 876 // Generates code to load the function from the cell checking that | |
| 877 // it still contains the same function. | |
| 878 void GenerateLoadFunctionFromCell(JSGlobalPropertyCell* cell, | |
| 879 JSFunction* function, | |
| 880 Label* miss); | |
| 881 | |
| 882 // Generates a jump to CallIC miss stub. | |
| 883 void GenerateMissBranch(); | |
| 884 | |
| 885 // TODO(kmillikin): Eliminate this function when the stub cache is fully | |
| 886 // handlified. | |
| 887 MUST_USE_RESULT MaybeObject* TryGenerateMissBranch(); | |
| 888 }; | 808 }; |
| 889 | 809 |
| 890 | 810 |
| 891 class ConstructStubCompiler: public StubCompiler { | 811 class ConstructStubCompiler: public StubCompiler { |
| 892 public: | 812 public: |
| 893 explicit ConstructStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } | 813 explicit ConstructStubCompiler(Isolate* isolate) : StubCompiler(isolate) { } |
| 894 | 814 |
| 895 MUST_USE_RESULT MaybeObject* CompileConstructStub(JSFunction* function); | 815 MUST_USE_RESULT MaybeObject* CompileConstructStub(JSFunction* function); |
| 896 | 816 |
| 897 private: | 817 private: |
| 898 MaybeObject* GetCode(); | 818 MaybeObject* GetCode(); |
| 899 }; | 819 }; |
| 900 | 820 |
| 901 | 821 |
| 902 // Holds information about possible function call optimizations. | 822 // Holds information about possible function call optimizations. |
| 903 class CallOptimization BASE_EMBEDDED { | 823 class CallOptimization BASE_EMBEDDED { |
| 904 public: | 824 public: |
| 905 explicit CallOptimization(LookupResult* lookup); | 825 explicit CallOptimization(LookupResult* lookup); |
| 906 | 826 |
| 907 explicit CallOptimization(JSFunction* function); | 827 explicit CallOptimization(Handle<JSFunction> function); |
| 908 | 828 |
| 909 bool is_constant_call() const { | 829 bool is_constant_call() const { |
| 910 return constant_function_ != NULL; | 830 return !constant_function_.is_null(); |
| 911 } | 831 } |
| 912 | 832 |
| 913 JSFunction* constant_function() const { | 833 Handle<JSFunction> constant_function() const { |
| 914 ASSERT(constant_function_ != NULL); | 834 ASSERT(is_constant_call()); |
| 915 return constant_function_; | 835 return constant_function_; |
| 916 } | 836 } |
| 917 | 837 |
| 918 bool is_simple_api_call() const { | 838 bool is_simple_api_call() const { |
| 919 return is_simple_api_call_; | 839 return is_simple_api_call_; |
| 920 } | 840 } |
| 921 | 841 |
| 922 FunctionTemplateInfo* expected_receiver_type() const { | 842 Handle<FunctionTemplateInfo> expected_receiver_type() const { |
| 923 ASSERT(is_simple_api_call_); | 843 ASSERT(is_simple_api_call()); |
| 924 return expected_receiver_type_; | 844 return expected_receiver_type_; |
| 925 } | 845 } |
| 926 | 846 |
| 927 CallHandlerInfo* api_call_info() const { | 847 Handle<CallHandlerInfo> api_call_info() const { |
| 928 ASSERT(is_simple_api_call_); | 848 ASSERT(is_simple_api_call()); |
| 929 return api_call_info_; | 849 return api_call_info_; |
| 930 } | 850 } |
| 931 | 851 |
| 932 // Returns the depth of the object having the expected type in the | 852 // Returns the depth of the object having the expected type in the |
| 933 // prototype chain between the two arguments. | 853 // prototype chain between the two arguments. |
| 934 int GetPrototypeDepthOfExpectedType(JSObject* object, | 854 int GetPrototypeDepthOfExpectedType(Handle<JSObject> object, |
| 935 JSObject* holder) const; | 855 Handle<JSObject> holder) const; |
| 936 | 856 |
| 937 private: | 857 private: |
| 938 void Initialize(JSFunction* function); | 858 void Initialize(Handle<JSFunction> function); |
| 939 | 859 |
| 940 // Determines whether the given function can be called using the | 860 // Determines whether the given function can be called using the |
| 941 // fast api call builtin. | 861 // fast api call builtin. |
| 942 void AnalyzePossibleApiFunction(JSFunction* function); | 862 void AnalyzePossibleApiFunction(Handle<JSFunction> function); |
| 943 | 863 |
| 944 JSFunction* constant_function_; | 864 Handle<JSFunction> constant_function_; |
| 945 bool is_simple_api_call_; | 865 bool is_simple_api_call_; |
| 946 FunctionTemplateInfo* expected_receiver_type_; | 866 Handle<FunctionTemplateInfo> expected_receiver_type_; |
| 947 CallHandlerInfo* api_call_info_; | 867 Handle<CallHandlerInfo> api_call_info_; |
| 948 }; | 868 }; |
| 949 | 869 |
| 950 | 870 |
| 951 } } // namespace v8::internal | 871 } } // namespace v8::internal |
| 952 | 872 |
| 953 #endif // V8_STUB_CACHE_H_ | 873 #endif // V8_STUB_CACHE_H_ |
| OLD | NEW |