OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 Object* CompileStoreField(JSObject* object, | 552 Object* CompileStoreField(JSObject* object, |
553 int index, | 553 int index, |
554 Map* transition, | 554 Map* transition, |
555 String* name); | 555 String* name); |
556 | 556 |
557 private: | 557 private: |
558 Object* GetCode(PropertyType type, String* name); | 558 Object* GetCode(PropertyType type, String* name); |
559 }; | 559 }; |
560 | 560 |
561 | 561 |
| 562 // List of functions with custom constant call IC stubs. |
| 563 // |
| 564 // Installation of custom call generators for the selected builtins is |
| 565 // handled by the bootstrapper. |
| 566 // |
| 567 // Each entry has a name of a global function (lowercased), a name of |
| 568 // a builtin function on its instance prototype (the one the generator |
| 569 // is set for), and a name of a generator itself (used to build ids |
| 570 // and generator function names). |
| 571 #define CUSTOM_CALL_IC_GENERATORS(V) \ |
| 572 V(array, push, ArrayPush) \ |
| 573 V(array, pop, ArrayPop) |
| 574 |
| 575 |
562 class CallStubCompiler: public StubCompiler { | 576 class CallStubCompiler: public StubCompiler { |
563 public: | 577 public: |
| 578 enum { |
| 579 #define DECLARE_CALL_GENERATOR_ID(ignored1, ignored2, name) \ |
| 580 k##name##CallGenerator, |
| 581 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR_ID) |
| 582 #undef DECLARE_CALL_GENERATOR_ID |
| 583 kNumCallGenerators |
| 584 }; |
| 585 |
564 CallStubCompiler(int argc, InLoopFlag in_loop) | 586 CallStubCompiler(int argc, InLoopFlag in_loop) |
565 : arguments_(argc), in_loop_(in_loop) { } | 587 : arguments_(argc), in_loop_(in_loop) { } |
566 | 588 |
567 Object* CompileCallField(JSObject* object, | 589 Object* CompileCallField(JSObject* object, |
568 JSObject* holder, | 590 JSObject* holder, |
569 int index, | 591 int index, |
570 String* name); | 592 String* name); |
571 Object* CompileCallConstant(Object* object, | 593 Object* CompileCallConstant(Object* object, |
572 JSObject* holder, | 594 JSObject* holder, |
573 JSFunction* function, | 595 JSFunction* function, |
574 String* name, | 596 String* name, |
575 CheckType check); | 597 CheckType check); |
576 Object* CompileCallInterceptor(JSObject* object, | 598 Object* CompileCallInterceptor(JSObject* object, |
577 JSObject* holder, | 599 JSObject* holder, |
578 String* name); | 600 String* name); |
579 Object* CompileCallGlobal(JSObject* object, | 601 Object* CompileCallGlobal(JSObject* object, |
580 GlobalObject* holder, | 602 GlobalObject* holder, |
581 JSGlobalPropertyCell* cell, | 603 JSGlobalPropertyCell* cell, |
582 JSFunction* function, | 604 JSFunction* function, |
583 String* name); | 605 String* name); |
584 | 606 |
585 Object* CompileArrayPushCall(Object* object, | 607 // Compiles a custom call constant IC using the generator with given id. |
586 JSObject* holder, | 608 Object* CompileCustomCall(int generator_id, |
587 JSFunction* function, | 609 Object* object, |
588 String* name, | 610 JSObject* holder, |
589 CheckType check); | 611 JSFunction* function, |
| 612 String* name, |
| 613 CheckType check); |
590 | 614 |
591 Object* CompileArrayPopCall(Object* object, | 615 #define DECLARE_CALL_GENERATOR(ignored1, ignored2, name) \ |
592 JSObject* holder, | 616 Object* Compile##name##Call(Object* object, \ |
593 JSFunction* function, | 617 JSObject* holder, \ |
594 String* name, | 618 JSFunction* function, \ |
| 619 String* fname, \ |
595 CheckType check); | 620 CheckType check); |
| 621 CUSTOM_CALL_IC_GENERATORS(DECLARE_CALL_GENERATOR) |
| 622 #undef DECLARE_CALL_GENERATOR |
596 | 623 |
597 private: | 624 private: |
598 const ParameterCount arguments_; | 625 const ParameterCount arguments_; |
599 const InLoopFlag in_loop_; | 626 const InLoopFlag in_loop_; |
600 | 627 |
601 const ParameterCount& arguments() { return arguments_; } | 628 const ParameterCount& arguments() { return arguments_; } |
602 | 629 |
603 Object* GetCode(PropertyType type, String* name); | 630 Object* GetCode(PropertyType type, String* name); |
| 631 |
| 632 // Convenience function. Calls GetCode above passing |
| 633 // CONSTANT_FUNCTION type and the name of the given function. |
| 634 Object* GetCode(JSFunction* function); |
604 }; | 635 }; |
605 | 636 |
606 | 637 |
607 class ConstructStubCompiler: public StubCompiler { | 638 class ConstructStubCompiler: public StubCompiler { |
608 public: | 639 public: |
609 explicit ConstructStubCompiler() {} | 640 explicit ConstructStubCompiler() {} |
610 | 641 |
611 Object* CompileConstructStub(SharedFunctionInfo* shared); | 642 Object* CompileConstructStub(SharedFunctionInfo* shared); |
612 | 643 |
613 private: | 644 private: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 // Determines whether the given function can be called using the | 687 // Determines whether the given function can be called using the |
657 // fast api call builtin. | 688 // fast api call builtin. |
658 void AnalyzePossibleApiFunction(JSFunction* function); | 689 void AnalyzePossibleApiFunction(JSFunction* function); |
659 | 690 |
660 JSFunction* constant_function_; | 691 JSFunction* constant_function_; |
661 bool is_simple_api_call_; | 692 bool is_simple_api_call_; |
662 FunctionTemplateInfo* expected_receiver_type_; | 693 FunctionTemplateInfo* expected_receiver_type_; |
663 CallHandlerInfo* api_call_info_; | 694 CallHandlerInfo* api_call_info_; |
664 }; | 695 }; |
665 | 696 |
666 | |
667 typedef Object* (*CustomCallGenerator)(CallStubCompiler* compiler, | |
668 Object* object, | |
669 JSObject* holder, | |
670 JSFunction* function, | |
671 String* name, | |
672 StubCompiler::CheckType check); | |
673 | |
674 | |
675 Object* CompileArrayPushCall(CallStubCompiler* compiler, | |
676 Object* object, | |
677 JSObject* holder, | |
678 JSFunction* function, | |
679 String* name, | |
680 StubCompiler::CheckType check); | |
681 | |
682 | |
683 Object* CompileArrayPopCall(CallStubCompiler* compiler, | |
684 Object* object, | |
685 JSObject* holder, | |
686 JSFunction* function, | |
687 String* name, | |
688 StubCompiler::CheckType check); | |
689 | |
690 | |
691 } } // namespace v8::internal | 697 } } // namespace v8::internal |
692 | 698 |
693 #endif // V8_STUB_CACHE_H_ | 699 #endif // V8_STUB_CACHE_H_ |
OLD | NEW |