Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/x64/codegen-x64.h

Issue 1148007: Merge bleeding_edge from version 2.1.3 up to revision 4205... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_X64_CODEGEN_X64_H_ 28 #ifndef V8_X64_CODEGEN_X64_H_
29 #define V8_X64_CODEGEN_X64_H_ 29 #define V8_X64_CODEGEN_X64_H_
30 30
31 #include "ic-inl.h"
32
31 namespace v8 { 33 namespace v8 {
32 namespace internal { 34 namespace internal {
33 35
34 // Forward declarations 36 // Forward declarations
35 class CompilationInfo; 37 class CompilationInfo;
36 class DeferredCode; 38 class DeferredCode;
37 class RegisterAllocator; 39 class RegisterAllocator;
38 class RegisterFile; 40 class RegisterFile;
39 41
40 enum InitState { CONST_INIT, NOT_CONST_INIT }; 42 enum InitState { CONST_INIT, NOT_CONST_INIT };
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 RegisterAllocator* allocator() const { return allocator_; } 332 RegisterAllocator* allocator() const { return allocator_; }
331 333
332 CodeGenState* state() { return state_; } 334 CodeGenState* state() { return state_; }
333 void set_state(CodeGenState* state) { state_ = state; } 335 void set_state(CodeGenState* state) { state_ = state; }
334 336
335 void AddDeferred(DeferredCode* code) { deferred_.Add(code); } 337 void AddDeferred(DeferredCode* code) { deferred_.Add(code); }
336 338
337 bool in_spilled_code() const { return in_spilled_code_; } 339 bool in_spilled_code() const { return in_spilled_code_; }
338 void set_in_spilled_code(bool flag) { in_spilled_code_ = flag; } 340 void set_in_spilled_code(bool flag) { in_spilled_code_ = flag; }
339 341
342 // If the name is an inline runtime function call return the number of
343 // expected arguments. Otherwise return -1.
344 static int InlineRuntimeCallArgumentsCount(Handle<String> name);
345
340 private: 346 private:
341 // Construction/Destruction 347 // Construction/Destruction
342 explicit CodeGenerator(MacroAssembler* masm); 348 explicit CodeGenerator(MacroAssembler* masm);
343 349
344 // Accessors 350 // Accessors
345 inline bool is_eval(); 351 inline bool is_eval();
346 inline Scope* scope(); 352 inline Scope* scope();
347 353
348 // Generating deferred code. 354 // Generating deferred code.
349 void ProcessDeferred(); 355 void ProcessDeferred();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 void CallApplyLazy(Expression* applicand, 505 void CallApplyLazy(Expression* applicand,
500 Expression* receiver, 506 Expression* receiver,
501 VariableProxy* arguments, 507 VariableProxy* arguments,
502 int position); 508 int position);
503 509
504 void CheckStack(); 510 void CheckStack();
505 511
506 struct InlineRuntimeLUT { 512 struct InlineRuntimeLUT {
507 void (CodeGenerator::*method)(ZoneList<Expression*>*); 513 void (CodeGenerator::*method)(ZoneList<Expression*>*);
508 const char* name; 514 const char* name;
515 int nargs;
509 }; 516 };
510 static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name); 517 static InlineRuntimeLUT* FindInlineRuntimeLUT(Handle<String> name);
511 bool CheckForInlineRuntimeCall(CallRuntime* node); 518 bool CheckForInlineRuntimeCall(CallRuntime* node);
512 static bool PatchInlineRuntimeEntry(Handle<String> name, 519 static bool PatchInlineRuntimeEntry(Handle<String> name,
513 const InlineRuntimeLUT& new_entry, 520 const InlineRuntimeLUT& new_entry,
514 InlineRuntimeLUT* old_entry); 521 InlineRuntimeLUT* old_entry);
515 void ProcessDeclarations(ZoneList<Declaration*>* declarations); 522 void ProcessDeclarations(ZoneList<Declaration*>* declarations);
516 523
517 static Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop); 524 static Handle<Code> ComputeCallInitialize(int argc, InLoopFlag in_loop);
518 525
(...skipping 11 matching lines...) Expand all
530 void GenerateIsRegExp(ZoneList<Expression*>* args); 537 void GenerateIsRegExp(ZoneList<Expression*>* args);
531 void GenerateIsObject(ZoneList<Expression*>* args); 538 void GenerateIsObject(ZoneList<Expression*>* args);
532 void GenerateIsFunction(ZoneList<Expression*>* args); 539 void GenerateIsFunction(ZoneList<Expression*>* args);
533 void GenerateIsUndetectableObject(ZoneList<Expression*>* args); 540 void GenerateIsUndetectableObject(ZoneList<Expression*>* args);
534 541
535 // Support for construct call checks. 542 // Support for construct call checks.
536 void GenerateIsConstructCall(ZoneList<Expression*>* args); 543 void GenerateIsConstructCall(ZoneList<Expression*>* args);
537 544
538 // Support for arguments.length and arguments[?]. 545 // Support for arguments.length and arguments[?].
539 void GenerateArgumentsLength(ZoneList<Expression*>* args); 546 void GenerateArgumentsLength(ZoneList<Expression*>* args);
540 void GenerateArgumentsAccess(ZoneList<Expression*>* args); 547 void GenerateArguments(ZoneList<Expression*>* args);
541 548
542 // Support for accessing the class and value fields of an object. 549 // Support for accessing the class and value fields of an object.
543 void GenerateClassOf(ZoneList<Expression*>* args); 550 void GenerateClassOf(ZoneList<Expression*>* args);
544 void GenerateValueOf(ZoneList<Expression*>* args); 551 void GenerateValueOf(ZoneList<Expression*>* args);
545 void GenerateSetValueOf(ZoneList<Expression*>* args); 552 void GenerateSetValueOf(ZoneList<Expression*>* args);
546 553
547 // Fast support for charCodeAt(n). 554 // Fast support for charCodeAt(n).
548 void GenerateFastCharCodeAt(ZoneList<Expression*>* args); 555 void GenerateFastCharCodeAt(ZoneList<Expression*>* args);
549 556
550 // Fast support for string.charAt(n) and string[n]. 557 // Fast support for string.charAt(n) and string[n].
(...skipping 17 matching lines...) Expand all
568 575
569 // Fast support for StringCompare. 576 // Fast support for StringCompare.
570 void GenerateStringCompare(ZoneList<Expression*>* args); 577 void GenerateStringCompare(ZoneList<Expression*>* args);
571 578
572 // Support for direct calls from JavaScript to native RegExp code. 579 // Support for direct calls from JavaScript to native RegExp code.
573 void GenerateRegExpExec(ZoneList<Expression*>* args); 580 void GenerateRegExpExec(ZoneList<Expression*>* args);
574 581
575 // Fast support for number to string. 582 // Fast support for number to string.
576 void GenerateNumberToString(ZoneList<Expression*>* args); 583 void GenerateNumberToString(ZoneList<Expression*>* args);
577 584
578 // Fast support for Math.pow(). 585 // Fast call to math functions.
579 void GenerateMathPow(ZoneList<Expression*>* args); 586 void GenerateMathPow(ZoneList<Expression*>* args);
580
581 // Fast call to math functions.
582 void GenerateMathSin(ZoneList<Expression*>* args); 587 void GenerateMathSin(ZoneList<Expression*>* args);
583 void GenerateMathCos(ZoneList<Expression*>* args); 588 void GenerateMathCos(ZoneList<Expression*>* args);
584
585 // Fast case for sqrt
586 void GenerateMathSqrt(ZoneList<Expression*>* args); 589 void GenerateMathSqrt(ZoneList<Expression*>* args);
587 590
588 // Simple condition analysis. 591 // Simple condition analysis.
589 enum ConditionAnalysis { 592 enum ConditionAnalysis {
590 ALWAYS_TRUE, 593 ALWAYS_TRUE,
591 ALWAYS_FALSE, 594 ALWAYS_FALSE,
592 DONT_KNOW 595 DONT_KNOW
593 }; 596 };
594 ConditionAnalysis AnalyzeCondition(Expression* cond); 597 ConditionAnalysis AnalyzeCondition(Expression* cond);
595 598
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 public: 666 public:
664 GenericBinaryOpStub(Token::Value op, 667 GenericBinaryOpStub(Token::Value op,
665 OverwriteMode mode, 668 OverwriteMode mode,
666 GenericBinaryFlags flags, 669 GenericBinaryFlags flags,
667 NumberInfo operands_type = NumberInfo::Unknown()) 670 NumberInfo operands_type = NumberInfo::Unknown())
668 : op_(op), 671 : op_(op),
669 mode_(mode), 672 mode_(mode),
670 flags_(flags), 673 flags_(flags),
671 args_in_registers_(false), 674 args_in_registers_(false),
672 args_reversed_(false), 675 args_reversed_(false),
673 name_(NULL), 676 static_operands_type_(operands_type),
674 operands_type_(operands_type) { 677 runtime_operands_type_(BinaryOpIC::DEFAULT),
678 name_(NULL) {
675 use_sse3_ = CpuFeatures::IsSupported(SSE3); 679 use_sse3_ = CpuFeatures::IsSupported(SSE3);
676 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); 680 ASSERT(OpBits::is_valid(Token::NUM_TOKENS));
677 } 681 }
678 682
683 GenericBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info)
684 : op_(OpBits::decode(key)),
685 mode_(ModeBits::decode(key)),
686 flags_(FlagBits::decode(key)),
687 args_in_registers_(ArgsInRegistersBits::decode(key)),
688 args_reversed_(ArgsReversedBits::decode(key)),
689 use_sse3_(SSE3Bits::decode(key)),
690 static_operands_type_(NumberInfo::ExpandedRepresentation(
691 StaticTypeInfoBits::decode(key))),
692 runtime_operands_type_(type_info),
693 name_(NULL) {
694 }
695
679 // Generate code to call the stub with the supplied arguments. This will add 696 // Generate code to call the stub with the supplied arguments. This will add
680 // code at the call site to prepare arguments either in registers or on the 697 // code at the call site to prepare arguments either in registers or on the
681 // stack together with the actual call. 698 // stack together with the actual call.
682 void GenerateCall(MacroAssembler* masm, Register left, Register right); 699 void GenerateCall(MacroAssembler* masm, Register left, Register right);
683 void GenerateCall(MacroAssembler* masm, Register left, Smi* right); 700 void GenerateCall(MacroAssembler* masm, Register left, Smi* right);
684 void GenerateCall(MacroAssembler* masm, Smi* left, Register right); 701 void GenerateCall(MacroAssembler* masm, Smi* left, Register right);
685 702
686 Result GenerateCall(MacroAssembler* masm, 703 Result GenerateCall(MacroAssembler* masm,
687 VirtualFrame* frame, 704 VirtualFrame* frame,
688 Result* left, 705 Result* left,
689 Result* right); 706 Result* right);
690 707
691 private: 708 private:
692 Token::Value op_; 709 Token::Value op_;
693 OverwriteMode mode_; 710 OverwriteMode mode_;
694 GenericBinaryFlags flags_; 711 GenericBinaryFlags flags_;
695 bool args_in_registers_; // Arguments passed in registers not on the stack. 712 bool args_in_registers_; // Arguments passed in registers not on the stack.
696 bool args_reversed_; // Left and right argument are swapped. 713 bool args_reversed_; // Left and right argument are swapped.
697 bool use_sse3_; 714 bool use_sse3_;
715
716 // Number type information of operands, determined by code generator.
717 NumberInfo static_operands_type_;
718
719 // Operand type information determined at runtime.
720 BinaryOpIC::TypeInfo runtime_operands_type_;
721
698 char* name_; 722 char* name_;
699 NumberInfo operands_type_;
700 723
701 const char* GetName(); 724 const char* GetName();
702 725
703 #ifdef DEBUG 726 #ifdef DEBUG
704 void Print() { 727 void Print() {
705 PrintF("GenericBinaryOpStub %d (op %s), " 728 PrintF("GenericBinaryOpStub %d (op %s), "
706 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %s)\n", 729 "(mode %d, flags %d, registers %d, reversed %d, only_numbers %s)\n",
707 MinorKey(), 730 MinorKey(),
708 Token::String(op_), 731 Token::String(op_),
709 static_cast<int>(mode_), 732 static_cast<int>(mode_),
710 static_cast<int>(flags_), 733 static_cast<int>(flags_),
711 static_cast<int>(args_in_registers_), 734 static_cast<int>(args_in_registers_),
712 static_cast<int>(args_reversed_), 735 static_cast<int>(args_reversed_),
713 operands_type_.ToString()); 736 static_operands_type_.ToString());
714 } 737 }
715 #endif 738 #endif
716 739
717 // Minor key encoding in 16 bits NNNFRASOOOOOOOMM. 740 // Minor key encoding in 18 bits TTNNNFRASOOOOOOOMM.
718 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; 741 class ModeBits: public BitField<OverwriteMode, 0, 2> {};
719 class OpBits: public BitField<Token::Value, 2, 7> {}; 742 class OpBits: public BitField<Token::Value, 2, 7> {};
720 class SSE3Bits: public BitField<bool, 9, 1> {}; 743 class SSE3Bits: public BitField<bool, 9, 1> {};
721 class ArgsInRegistersBits: public BitField<bool, 10, 1> {}; 744 class ArgsInRegistersBits: public BitField<bool, 10, 1> {};
722 class ArgsReversedBits: public BitField<bool, 11, 1> {}; 745 class ArgsReversedBits: public BitField<bool, 11, 1> {};
723 class FlagBits: public BitField<GenericBinaryFlags, 12, 1> {}; 746 class FlagBits: public BitField<GenericBinaryFlags, 12, 1> {};
724 class NumberInfoBits: public BitField<int, 13, 3> {}; 747 class StaticTypeInfoBits: public BitField<int, 13, 3> {};
748 class RuntimeTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 16, 2> {};
725 749
726 Major MajorKey() { return GenericBinaryOp; } 750 Major MajorKey() { return GenericBinaryOp; }
727 int MinorKey() { 751 int MinorKey() {
728 // Encode the parameters in a unique 16 bit value. 752 // Encode the parameters in a unique 18 bit value.
729 return OpBits::encode(op_) 753 return OpBits::encode(op_)
730 | ModeBits::encode(mode_) 754 | ModeBits::encode(mode_)
731 | FlagBits::encode(flags_) 755 | FlagBits::encode(flags_)
732 | SSE3Bits::encode(use_sse3_) 756 | SSE3Bits::encode(use_sse3_)
733 | ArgsInRegistersBits::encode(args_in_registers_) 757 | ArgsInRegistersBits::encode(args_in_registers_)
734 | ArgsReversedBits::encode(args_reversed_) 758 | ArgsReversedBits::encode(args_reversed_)
735 | NumberInfoBits::encode(operands_type_.ThreeBitRepresentation()); 759 | StaticTypeInfoBits::encode(
760 static_operands_type_.ThreeBitRepresentation())
761 | RuntimeTypeInfoBits::encode(runtime_operands_type_);
736 } 762 }
737 763
738 void Generate(MacroAssembler* masm); 764 void Generate(MacroAssembler* masm);
739 void GenerateSmiCode(MacroAssembler* masm, Label* slow); 765 void GenerateSmiCode(MacroAssembler* masm, Label* slow);
740 void GenerateLoadArguments(MacroAssembler* masm); 766 void GenerateLoadArguments(MacroAssembler* masm);
741 void GenerateReturn(MacroAssembler* masm); 767 void GenerateReturn(MacroAssembler* masm);
768 void GenerateRegisterArgsPush(MacroAssembler* masm);
769 void GenerateTypeTransition(MacroAssembler* masm);
742 770
743 bool ArgsInRegistersSupported() { 771 bool ArgsInRegistersSupported() {
744 return (op_ == Token::ADD) || (op_ == Token::SUB) 772 return (op_ == Token::ADD) || (op_ == Token::SUB)
745 || (op_ == Token::MUL) || (op_ == Token::DIV); 773 || (op_ == Token::MUL) || (op_ == Token::DIV);
746 } 774 }
747 bool IsOperationCommutative() { 775 bool IsOperationCommutative() {
748 return (op_ == Token::ADD) || (op_ == Token::MUL); 776 return (op_ == Token::ADD) || (op_ == Token::MUL);
749 } 777 }
750 778
751 void SetArgsInRegisters() { args_in_registers_ = true; } 779 void SetArgsInRegisters() { args_in_registers_ = true; }
752 void SetArgsReversed() { args_reversed_ = true; } 780 void SetArgsReversed() { args_reversed_ = true; }
753 bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; } 781 bool HasSmiCodeInStub() { return (flags_ & NO_SMI_CODE_IN_STUB) == 0; }
754 bool HasArgsInRegisters() { return args_in_registers_; } 782 bool HasArgsInRegisters() { return args_in_registers_; }
755 bool HasArgsReversed() { return args_reversed_; } 783 bool HasArgsReversed() { return args_reversed_; }
784
785 bool ShouldGenerateSmiCode() {
786 return HasSmiCodeInStub() &&
787 runtime_operands_type_ != BinaryOpIC::HEAP_NUMBERS &&
788 runtime_operands_type_ != BinaryOpIC::STRINGS;
789 }
790
791 bool ShouldGenerateFPCode() {
792 return runtime_operands_type_ != BinaryOpIC::STRINGS;
793 }
794
795 virtual int GetCodeKind() { return Code::BINARY_OP_IC; }
796
797 virtual InlineCacheState GetICState() {
798 return BinaryOpIC::ToState(runtime_operands_type_);
799 }
756 }; 800 };
757 801
758 802
759 class StringStubBase: public CodeStub { 803 class StringStubBase: public CodeStub {
760 public: 804 public:
761 // Generate code for copying characters using a simple loop. This should only 805 // Generate code for copying characters using a simple loop. This should only
762 // be used in places where the number of characters is small and the 806 // be used in places where the number of characters is small and the
763 // additional setup and checking in GenerateCopyCharactersREP adds too much 807 // additional setup and checking in GenerateCopyCharactersREP adds too much
764 // overhead. Copying of overlapping regions is not supported. 808 // overhead. Copying of overlapping regions is not supported.
765 void GenerateCopyCharacters(MacroAssembler* masm, 809 void GenerateCopyCharacters(MacroAssembler* masm,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 Register scratch4); 901 Register scratch4);
858 902
859 private: 903 private:
860 Major MajorKey() { return StringCompare; } 904 Major MajorKey() { return StringCompare; }
861 int MinorKey() { return 0; } 905 int MinorKey() { return 0; }
862 906
863 void Generate(MacroAssembler* masm); 907 void Generate(MacroAssembler* masm);
864 }; 908 };
865 909
866 910
911 class NumberToStringStub: public CodeStub {
912 public:
913 NumberToStringStub() { }
914
915 // Generate code to do a lookup in the number string cache. If the number in
916 // the register object is found in the cache the generated code falls through
917 // with the result in the result register. The object and the result register
918 // can be the same. If the number is not found in the cache the code jumps to
919 // the label not_found with only the content of register object unchanged.
920 static void GenerateLookupNumberStringCache(MacroAssembler* masm,
921 Register object,
922 Register result,
923 Register scratch1,
924 Register scratch2,
925 bool object_is_smi,
926 Label* not_found);
927
928 private:
929 Major MajorKey() { return NumberToString; }
930 int MinorKey() { return 0; }
931
932 void Generate(MacroAssembler* masm);
933
934 const char* GetName() { return "NumberToStringStub"; }
935
936 #ifdef DEBUG
937 void Print() {
938 PrintF("NumberToStringStub\n");
939 }
940 #endif
941 };
942
943
867 } } // namespace v8::internal 944 } } // namespace v8::internal
868 945
869 #endif // V8_X64_CODEGEN_X64_H_ 946 #endif // V8_X64_CODEGEN_X64_H_
OLDNEW
« src/runtime.cc ('K') | « src/x64/assembler-x64.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698