Chromium Code Reviews

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

Issue 104663004: Preview of a first step towards unification of hydrogen calls (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 34 matching lines...)
45 V(AddI) \ 45 V(AddI) \
46 V(Allocate) \ 46 V(Allocate) \
47 V(ApplyArguments) \ 47 V(ApplyArguments) \
48 V(ArgumentsElements) \ 48 V(ArgumentsElements) \
49 V(ArgumentsLength) \ 49 V(ArgumentsLength) \
50 V(ArithmeticD) \ 50 V(ArithmeticD) \
51 V(ArithmeticT) \ 51 V(ArithmeticT) \
52 V(BitI) \ 52 V(BitI) \
53 V(BoundsCheck) \ 53 V(BoundsCheck) \
54 V(Branch) \ 54 V(Branch) \
55 V(CallConstantFunction) \ 55 V(CallJSFunction) \
56 V(CallWithDescriptor) \
56 V(CallFunction) \ 57 V(CallFunction) \
57 V(CallGlobal) \ 58 V(CallGlobal) \
58 V(CallKeyed) \
59 V(CallKnownGlobal) \
60 V(CallNamed) \
61 V(CallNew) \ 59 V(CallNew) \
62 V(CallNewArray) \ 60 V(CallNewArray) \
63 V(CallRuntime) \ 61 V(CallRuntime) \
64 V(CallStub) \ 62 V(CallStub) \
65 V(CheckInstanceType) \ 63 V(CheckInstanceType) \
66 V(CheckMaps) \ 64 V(CheckMaps) \
67 V(CheckMapValue) \ 65 V(CheckMapValue) \
68 V(CheckNonSmi) \ 66 V(CheckNonSmi) \
69 V(CheckSmi) \ 67 V(CheckSmi) \
70 V(CheckValue) \ 68 V(CheckValue) \
(...skipping 222 matching lines...)
293 class IsCallBits: public BitField<bool, 0, 1> {}; 291 class IsCallBits: public BitField<bool, 0, 1> {};
294 292
295 LEnvironment* environment_; 293 LEnvironment* environment_;
296 SetOncePointer<LPointerMap> pointer_map_; 294 SetOncePointer<LPointerMap> pointer_map_;
297 HValue* hydrogen_value_; 295 HValue* hydrogen_value_;
298 int bit_field_; 296 int bit_field_;
299 }; 297 };
300 298
301 299
302 // R = number of result operands (0 or 1). 300 // R = number of result operands (0 or 1).
303 // I = number of input operands. 301 template<int R>
304 // T = number of temporary operands. 302 class LTemplateResultInstruction : public LInstruction {
305 template<int R, int I, int T>
306 class LTemplateInstruction : public LInstruction {
307 public: 303 public:
308 // Allow 0 or 1 output operands. 304 // Allow 0 or 1 output operands.
309 STATIC_ASSERT(R == 0 || R == 1); 305 STATIC_ASSERT(R == 0 || R == 1);
310 virtual bool HasResult() const V8_FINAL V8_OVERRIDE { 306 virtual bool HasResult() const V8_FINAL V8_OVERRIDE {
311 return R != 0 && result() != NULL; 307 return R != 0 && result() != NULL;
312 } 308 }
313 void set_result(LOperand* operand) { results_[0] = operand; } 309 void set_result(LOperand* operand) { results_[0] = operand; }
314 LOperand* result() const { return results_[0]; } 310 LOperand* result() const { return results_[0]; }
315 311
316 protected: 312 protected:
317 EmbeddedContainer<LOperand*, R> results_; 313 EmbeddedContainer<LOperand*, R> results_;
314 };
315
316
317 // R = number of result operands (0 or 1).
318 // I = number of input operands.
319 // T = number of temporary operands.
320 template<int R, int I, int T>
321 class LTemplateInstruction : public LTemplateResultInstruction<R> {
322 protected:
318 EmbeddedContainer<LOperand*, I> inputs_; 323 EmbeddedContainer<LOperand*, I> inputs_;
319 EmbeddedContainer<LOperand*, T> temps_; 324 EmbeddedContainer<LOperand*, T> temps_;
320 325
321 private: 326 private:
322 // Iterator support. 327 // Iterator support.
323 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; } 328 virtual int InputCount() V8_FINAL V8_OVERRIDE { return I; }
324 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; } 329 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
325 330
326 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; } 331 virtual int TempCount() V8_FINAL V8_OVERRIDE { return T; }
327 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; } 332 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return temps_[i]; }
(...skipping 1451 matching lines...)
1779 explicit LGlobalReceiver(LOperand* global_object) { 1784 explicit LGlobalReceiver(LOperand* global_object) {
1780 inputs_[0] = global_object; 1785 inputs_[0] = global_object;
1781 } 1786 }
1782 1787
1783 LOperand* global() { return inputs_[0]; } 1788 LOperand* global() { return inputs_[0]; }
1784 1789
1785 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver") 1790 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver")
1786 }; 1791 };
1787 1792
1788 1793
1789 class LCallConstantFunction V8_FINAL : public LTemplateInstruction<1, 0, 0> { 1794 class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1790 public: 1795 public:
1791 DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function") 1796 LCallJSFunction(LOperand* function, LOperand* call_kind) {
1792 DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction) 1797 inputs_[0] = function;
1798 inputs_[1] = call_kind;
1799 }
1793 1800
1794 virtual void PrintDataTo(StringStream* stream); 1801 LOperand* function() { return inputs_[0]; }
1802 LOperand* call_kind() { return inputs_[1]; }
1795 1803
1796 Handle<JSFunction> function() { return hydrogen()->function(); } 1804 DECLARE_CONCRETE_INSTRUCTION(CallJSFunction, "call-js-function")
1805 DECLARE_HYDROGEN_ACCESSOR(CallJSFunction)
1806
1807 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1808
1797 int arity() const { return hydrogen()->argument_count() - 1; } 1809 int arity() const { return hydrogen()->argument_count() - 1; }
1798 }; 1810 };
1799 1811
1800 1812
1813 class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> {
1814 public:
1815 LCallWithDescriptor(const CodeStubInterfaceDescriptor* descriptor,
1816 ZoneList<LOperand*>& operands,
1817 Zone* zone)
1818 : descriptor_(descriptor),
1819 inputs_(descriptor->environment_length() + 1, zone) {
1820 ASSERT(descriptor->environment_length() + 1 == operands.length());
1821 inputs_.AddAll(operands, zone);
1822 }
1823
1824 LOperand* target() const { return inputs_[0]; }
1825
1826
1827 private:
1828 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor")
1829 DECLARE_HYDROGEN_ACCESSOR(CallWithDescriptor)
1830
1831 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1832
1833 int arity() const { return hydrogen()->argument_count() - 1; }
1834
1835 const CodeStubInterfaceDescriptor* descriptor_;
1836 ZoneList<LOperand*> inputs_;
1837
1838 virtual void InternalSetOperandAt(int index,
1839 LOperand* value) V8_FINAL V8_OVERRIDE {
1840 inputs_[index] = value;
1841 }
1842
1843 // Iterator support.
1844 virtual int InputCount() V8_FINAL V8_OVERRIDE { return inputs_.length(); }
1845 virtual LOperand* InputAt(int i) V8_FINAL V8_OVERRIDE { return inputs_[i]; }
1846
1847 virtual int TempCount() V8_FINAL V8_OVERRIDE { return 0; }
1848 virtual LOperand* TempAt(int i) V8_FINAL V8_OVERRIDE { return NULL; }
1849 };
1850
1851
1801 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> { 1852 class LInvokeFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1802 public: 1853 public:
1803 LInvokeFunction(LOperand* context, LOperand* function) { 1854 LInvokeFunction(LOperand* context, LOperand* function) {
1804 inputs_[0] = context; 1855 inputs_[0] = context;
1805 inputs_[1] = function; 1856 inputs_[1] = function;
1806 } 1857 }
1807 1858
1808 LOperand* context() { return inputs_[0]; } 1859 LOperand* context() { return inputs_[0]; }
1809 LOperand* function() { return inputs_[1]; } 1860 LOperand* function() { return inputs_[1]; }
1810 1861
1811 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function") 1862 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function")
1812 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction) 1863 DECLARE_HYDROGEN_ACCESSOR(InvokeFunction)
1813 1864
1814 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 1865 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1815 1866
1816 int arity() const { return hydrogen()->argument_count() - 1; } 1867 int arity() const { return hydrogen()->argument_count() - 1; }
1817 }; 1868 };
1818 1869
1819
1820 class LCallKeyed V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1821 public:
1822 LCallKeyed(LOperand* context, LOperand* key) {
1823 inputs_[0] = context;
1824 inputs_[1] = key;
1825 }
1826
1827 DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed")
1828 DECLARE_HYDROGEN_ACCESSOR(CallKeyed)
1829
1830 LOperand* context() { return inputs_[0]; }
1831 LOperand* key() { return inputs_[1]; }
1832
1833 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1834
1835 int arity() const { return hydrogen()->argument_count() - 1; }
1836 };
1837
1838
1839 class LCallNamed V8_FINAL : public LTemplateInstruction<1, 1, 0> {
1840 public:
1841 explicit LCallNamed(LOperand* context) {
1842 inputs_[0] = context;
1843 }
1844
1845 LOperand* context() { return inputs_[0]; }
1846
1847 DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named")
1848 DECLARE_HYDROGEN_ACCESSOR(CallNamed)
1849
1850 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1851
1852 Handle<String> name() const { return hydrogen()->name(); }
1853 int arity() const { return hydrogen()->argument_count() - 1; }
1854 };
1855
1856 1870
1857 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> { 1871 class LCallFunction V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1858 public: 1872 public:
1859 LCallFunction(LOperand* context, LOperand* function) { 1873 LCallFunction(LOperand* context, LOperand* function) {
1860 inputs_[0] = context; 1874 inputs_[0] = context;
1861 inputs_[1] = function; 1875 inputs_[1] = function;
1862 } 1876 }
1863 1877
1864 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function") 1878 DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function")
1865 DECLARE_HYDROGEN_ACCESSOR(CallFunction) 1879 DECLARE_HYDROGEN_ACCESSOR(CallFunction)
(...skipping 15 matching lines...)
1881 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global") 1895 DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global")
1882 DECLARE_HYDROGEN_ACCESSOR(CallGlobal) 1896 DECLARE_HYDROGEN_ACCESSOR(CallGlobal)
1883 1897
1884 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; 1898 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1885 1899
1886 Handle<String> name() const {return hydrogen()->name(); } 1900 Handle<String> name() const {return hydrogen()->name(); }
1887 int arity() const { return hydrogen()->argument_count() - 1; } 1901 int arity() const { return hydrogen()->argument_count() - 1; }
1888 }; 1902 };
1889 1903
1890 1904
1891 class LCallKnownGlobal V8_FINAL : public LTemplateInstruction<1, 0, 0> {
1892 public:
1893 DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global")
1894 DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal)
1895
1896 virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE;
1897
1898 int arity() const { return hydrogen()->argument_count() - 1; }
1899 };
1900
1901
1902 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> { 1905 class LCallNew V8_FINAL : public LTemplateInstruction<1, 2, 0> {
1903 public: 1906 public:
1904 LCallNew(LOperand* context, LOperand* constructor) { 1907 LCallNew(LOperand* context, LOperand* constructor) {
1905 inputs_[0] = context; 1908 inputs_[0] = context;
1906 inputs_[1] = constructor; 1909 inputs_[1] = constructor;
1907 } 1910 }
1908 1911
1909 LOperand* context() { return inputs_[0]; } 1912 LOperand* context() { return inputs_[0]; }
1910 LOperand* constructor() { return inputs_[1]; } 1913 LOperand* constructor() { return inputs_[1]; }
1911 1914
(...skipping 821 matching lines...)
2733 // Will not be moved to a register even if one is freely available. 2736 // Will not be moved to a register even if one is freely available.
2734 MUST_USE_RESULT LOperand* UseAny(HValue* value); 2737 MUST_USE_RESULT LOperand* UseAny(HValue* value);
2735 2738
2736 // Temporary operand that must be in a register. 2739 // Temporary operand that must be in a register.
2737 MUST_USE_RESULT LUnallocated* TempRegister(); 2740 MUST_USE_RESULT LUnallocated* TempRegister();
2738 MUST_USE_RESULT LOperand* FixedTemp(Register reg); 2741 MUST_USE_RESULT LOperand* FixedTemp(Register reg);
2739 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg); 2742 MUST_USE_RESULT LOperand* FixedTemp(XMMRegister reg);
2740 2743
2741 // Methods for setting up define-use relationships. 2744 // Methods for setting up define-use relationships.
2742 // Return the same instruction that they are passed. 2745 // Return the same instruction that they are passed.
2743 template<int I, int T> 2746 LInstruction* Define(LTemplateResultInstruction<1>* instr,
2744 LInstruction* Define(LTemplateInstruction<1, I, T>* instr, 2747 LUnallocated* result);
2745 LUnallocated* result); 2748 LInstruction* DefineAsRegister(LTemplateResultInstruction<1>* instr);
2746 template<int I, int T> 2749 LInstruction* DefineAsSpilled(LTemplateResultInstruction<1>* instr,
2747 LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr); 2750 int index);
2748 template<int I, int T> 2751 LInstruction* DefineSameAsFirst(LTemplateResultInstruction<1>* instr);
2749 LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr, 2752 LInstruction* DefineFixed(LTemplateResultInstruction<1>* instr,
2750 int index); 2753 Register reg);
2751 template<int I, int T> 2754 LInstruction* DefineFixedDouble(LTemplateResultInstruction<1>* instr,
2752 LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr); 2755 XMMRegister reg);
2753 template<int I, int T>
2754 LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr,
2755 Register reg);
2756 template<int I, int T>
2757 LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr,
2758 XMMRegister reg);
2759 // Assigns an environment to an instruction. An instruction which can 2756 // Assigns an environment to an instruction. An instruction which can
2760 // deoptimize must have an environment. 2757 // deoptimize must have an environment.
2761 LInstruction* AssignEnvironment(LInstruction* instr); 2758 LInstruction* AssignEnvironment(LInstruction* instr);
2762 // Assigns a pointer map to an instruction. An instruction which can 2759 // Assigns a pointer map to an instruction. An instruction which can
2763 // trigger a GC or a lazy deoptimization must have a pointer map. 2760 // trigger a GC or a lazy deoptimization must have a pointer map.
2764 LInstruction* AssignPointerMap(LInstruction* instr); 2761 LInstruction* AssignPointerMap(LInstruction* instr);
2765 2762
2766 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY }; 2763 enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY };
2767 2764
2768 // Marks a call for the register allocator. Assigns a pointer map to 2765 // Marks a call for the register allocator. Assigns a pointer map to
(...skipping 32 matching lines...)
2801 2798
2802 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); 2799 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2803 }; 2800 };
2804 2801
2805 #undef DECLARE_HYDROGEN_ACCESSOR 2802 #undef DECLARE_HYDROGEN_ACCESSOR
2806 #undef DECLARE_CONCRETE_INSTRUCTION 2803 #undef DECLARE_CONCRETE_INSTRUCTION
2807 2804
2808 } } // namespace v8::int 2805 } } // namespace v8::int
2809 2806
2810 #endif // V8_X64_LITHIUM_X64_H_ 2807 #endif // V8_X64_LITHIUM_X64_H_
OLDNEW

Powered by Google App Engine