OLD | NEW |
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 // Gets the major key from a code object that is a code stub or binary op IC. | 155 // Gets the major key from a code object that is a code stub or binary op IC. |
156 static Major GetMajorKey(Code* code_stub) { | 156 static Major GetMajorKey(Code* code_stub) { |
157 return static_cast<Major>(code_stub->major_key()); | 157 return static_cast<Major>(code_stub->major_key()); |
158 } | 158 } |
159 | 159 |
160 static const char* MajorName(Major major_key, bool allow_unknown_keys); | 160 static const char* MajorName(Major major_key, bool allow_unknown_keys); |
161 | 161 |
162 virtual ~CodeStub() {} | 162 virtual ~CodeStub() {} |
163 | 163 |
164 bool CompilingCallsToThisStubIsGCSafe(Isolate* isolate) { | |
165 bool is_pregenerated = IsPregenerated(isolate); | |
166 Code* code = NULL; | |
167 CHECK(!is_pregenerated || FindCodeInCache(&code, isolate)); | |
168 return is_pregenerated; | |
169 } | |
170 | |
171 // See comment above, where Instanceof is defined. | |
172 virtual bool IsPregenerated(Isolate* isolate) { return false; } | |
173 | |
174 static void GenerateStubsAheadOfTime(Isolate* isolate); | 164 static void GenerateStubsAheadOfTime(Isolate* isolate); |
175 static void GenerateStubsRequiringBuiltinsAheadOfTime(Isolate* isolate); | 165 static void GenerateStubsRequiringBuiltinsAheadOfTime(Isolate* isolate); |
176 static void GenerateFPStubs(Isolate* isolate); | 166 static void GenerateFPStubs(Isolate* isolate); |
177 | 167 |
178 // Some stubs put untagged junk on the stack that cannot be scanned by the | 168 // Some stubs put untagged junk on the stack that cannot be scanned by the |
179 // GC. This means that we must be statically sure that no GC can occur while | 169 // GC. This means that we must be statically sure that no GC can occur while |
180 // they are running. If that is the case they should override this to return | 170 // they are running. If that is the case they should override this to return |
181 // true, which will cause an assertion if we try to call something that can | 171 // true, which will cause an assertion if we try to call something that can |
182 // GC or if we try to put a stack frame on top of the junk, which would not | 172 // GC or if we try to put a stack frame on top of the junk, which would not |
183 // result in a traversable stack. | 173 // result in a traversable stack. |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 DISALLOW_COPY_AND_ASSIGN(FastCloneShallowObjectStub); | 666 DISALLOW_COPY_AND_ASSIGN(FastCloneShallowObjectStub); |
677 }; | 667 }; |
678 | 668 |
679 | 669 |
680 class CreateAllocationSiteStub : public HydrogenCodeStub { | 670 class CreateAllocationSiteStub : public HydrogenCodeStub { |
681 public: | 671 public: |
682 explicit CreateAllocationSiteStub() { } | 672 explicit CreateAllocationSiteStub() { } |
683 | 673 |
684 virtual Handle<Code> GenerateCode(Isolate* isolate); | 674 virtual Handle<Code> GenerateCode(Isolate* isolate); |
685 | 675 |
686 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { return true; } | |
687 | |
688 static void GenerateAheadOfTime(Isolate* isolate); | 676 static void GenerateAheadOfTime(Isolate* isolate); |
689 | 677 |
690 virtual void InitializeInterfaceDescriptor( | 678 virtual void InitializeInterfaceDescriptor( |
691 Isolate* isolate, | 679 Isolate* isolate, |
692 CodeStubInterfaceDescriptor* descriptor); | 680 CodeStubInterfaceDescriptor* descriptor); |
693 | 681 |
694 private: | 682 private: |
695 Major MajorKey() { return CreateAllocationSite; } | 683 Major MajorKey() { return CreateAllocationSite; } |
696 int NotMissMinorKey() { return 0; } | 684 int NotMissMinorKey() { return 0; } |
697 | 685 |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 explicit CEntryStub(int result_size, | 1448 explicit CEntryStub(int result_size, |
1461 SaveFPRegsMode save_doubles = kDontSaveFPRegs) | 1449 SaveFPRegsMode save_doubles = kDontSaveFPRegs) |
1462 : result_size_(result_size), save_doubles_(save_doubles) { } | 1450 : result_size_(result_size), save_doubles_(save_doubles) { } |
1463 | 1451 |
1464 void Generate(MacroAssembler* masm); | 1452 void Generate(MacroAssembler* masm); |
1465 | 1453 |
1466 // The version of this stub that doesn't save doubles is generated ahead of | 1454 // The version of this stub that doesn't save doubles is generated ahead of |
1467 // time, so it's OK to call it from other stubs that can't cope with GC during | 1455 // time, so it's OK to call it from other stubs that can't cope with GC during |
1468 // their code generation. On machines that always have gp registers (x64) we | 1456 // their code generation. On machines that always have gp registers (x64) we |
1469 // can generate both variants ahead of time. | 1457 // can generate both variants ahead of time. |
1470 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE; | |
1471 static void GenerateAheadOfTime(Isolate* isolate); | 1458 static void GenerateAheadOfTime(Isolate* isolate); |
1472 | 1459 |
1473 protected: | 1460 protected: |
1474 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { | 1461 virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE { |
1475 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); | 1462 ASSERT(CpuFeatures::VerifyCrossCompiling(SSE2)); |
1476 }; | 1463 }; |
1477 | 1464 |
1478 private: | 1465 private: |
1479 void GenerateCore(MacroAssembler* masm, | 1466 void GenerateCore(MacroAssembler* masm, |
1480 Label* throw_normal_exception, | 1467 Label* throw_normal_exception, |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 } | 1799 } |
1813 | 1800 |
1814 private: | 1801 private: |
1815 StringCharCodeAtGenerator char_code_at_generator_; | 1802 StringCharCodeAtGenerator char_code_at_generator_; |
1816 StringCharFromCodeGenerator char_from_code_generator_; | 1803 StringCharFromCodeGenerator char_from_code_generator_; |
1817 | 1804 |
1818 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); | 1805 DISALLOW_COPY_AND_ASSIGN(StringCharAtGenerator); |
1819 }; | 1806 }; |
1820 | 1807 |
1821 | 1808 |
1822 class AllowStubCallsScope { | |
1823 public: | |
1824 AllowStubCallsScope(MacroAssembler* masm, bool allow) | |
1825 : masm_(masm), previous_allow_(masm->allow_stub_calls()) { | |
1826 masm_->set_allow_stub_calls(allow); | |
1827 } | |
1828 ~AllowStubCallsScope() { | |
1829 masm_->set_allow_stub_calls(previous_allow_); | |
1830 } | |
1831 | |
1832 private: | |
1833 MacroAssembler* masm_; | |
1834 bool previous_allow_; | |
1835 | |
1836 DISALLOW_COPY_AND_ASSIGN(AllowStubCallsScope); | |
1837 }; | |
1838 | |
1839 | |
1840 class KeyedLoadDictionaryElementStub : public HydrogenCodeStub { | 1809 class KeyedLoadDictionaryElementStub : public HydrogenCodeStub { |
1841 public: | 1810 public: |
1842 KeyedLoadDictionaryElementStub() {} | 1811 KeyedLoadDictionaryElementStub() {} |
1843 | 1812 |
1844 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; | 1813 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE; |
1845 | 1814 |
1846 virtual void InitializeInterfaceDescriptor( | 1815 virtual void InitializeInterfaceDescriptor( |
1847 Isolate* isolate, | 1816 Isolate* isolate, |
1848 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 1817 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
1849 | 1818 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2077 } | 2046 } |
2078 | 2047 |
2079 AllocationSiteOverrideMode override_mode() const { | 2048 AllocationSiteOverrideMode override_mode() const { |
2080 return AllocationSiteOverrideModeBits::decode(bit_field_); | 2049 return AllocationSiteOverrideModeBits::decode(bit_field_); |
2081 } | 2050 } |
2082 | 2051 |
2083 ContextCheckMode context_mode() const { | 2052 ContextCheckMode context_mode() const { |
2084 return ContextCheckModeBits::decode(bit_field_); | 2053 return ContextCheckModeBits::decode(bit_field_); |
2085 } | 2054 } |
2086 | 2055 |
2087 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { | |
2088 // We only pre-generate stubs that verify correct context | |
2089 return context_mode() == CONTEXT_CHECK_REQUIRED; | |
2090 } | |
2091 | |
2092 static void GenerateStubsAheadOfTime(Isolate* isolate); | 2056 static void GenerateStubsAheadOfTime(Isolate* isolate); |
2093 static void InstallDescriptors(Isolate* isolate); | 2057 static void InstallDescriptors(Isolate* isolate); |
2094 | 2058 |
2095 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 2059 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
2096 static const int kConstructor = 0; | 2060 static const int kConstructor = 0; |
2097 static const int kPropertyCell = 1; | 2061 static const int kPropertyCell = 1; |
2098 | 2062 |
2099 private: | 2063 private: |
2100 int NotMissMinorKey() { return bit_field_; } | 2064 int NotMissMinorKey() { return bit_field_; } |
2101 | 2065 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); | 2142 DISALLOW_COPY_AND_ASSIGN(ArrayNArgumentsConstructorStub); |
2179 }; | 2143 }; |
2180 | 2144 |
2181 | 2145 |
2182 class InternalArrayConstructorStubBase : public HydrogenCodeStub { | 2146 class InternalArrayConstructorStubBase : public HydrogenCodeStub { |
2183 public: | 2147 public: |
2184 explicit InternalArrayConstructorStubBase(ElementsKind kind) { | 2148 explicit InternalArrayConstructorStubBase(ElementsKind kind) { |
2185 kind_ = kind; | 2149 kind_ = kind; |
2186 } | 2150 } |
2187 | 2151 |
2188 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { return true; } | |
2189 static void GenerateStubsAheadOfTime(Isolate* isolate); | 2152 static void GenerateStubsAheadOfTime(Isolate* isolate); |
2190 static void InstallDescriptors(Isolate* isolate); | 2153 static void InstallDescriptors(Isolate* isolate); |
2191 | 2154 |
2192 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 2155 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
2193 static const int kConstructor = 0; | 2156 static const int kConstructor = 0; |
2194 | 2157 |
2195 ElementsKind elements_kind() const { return kind_; } | 2158 ElementsKind elements_kind() const { return kind_; } |
2196 | 2159 |
2197 private: | 2160 private: |
2198 int NotMissMinorKey() { return kind_; } | 2161 int NotMissMinorKey() { return kind_; } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2442 | 2405 |
2443 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); | 2406 DISALLOW_COPY_AND_ASSIGN(StoreArrayLiteralElementStub); |
2444 }; | 2407 }; |
2445 | 2408 |
2446 | 2409 |
2447 class StubFailureTrampolineStub : public PlatformCodeStub { | 2410 class StubFailureTrampolineStub : public PlatformCodeStub { |
2448 public: | 2411 public: |
2449 explicit StubFailureTrampolineStub(StubFunctionMode function_mode) | 2412 explicit StubFailureTrampolineStub(StubFunctionMode function_mode) |
2450 : fp_registers_(CanUseFPRegisters()), function_mode_(function_mode) {} | 2413 : fp_registers_(CanUseFPRegisters()), function_mode_(function_mode) {} |
2451 | 2414 |
2452 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { return true; } | |
2453 | |
2454 static void GenerateAheadOfTime(Isolate* isolate); | 2415 static void GenerateAheadOfTime(Isolate* isolate); |
2455 | 2416 |
2456 private: | 2417 private: |
2457 class FPRegisters: public BitField<bool, 0, 1> {}; | 2418 class FPRegisters: public BitField<bool, 0, 1> {}; |
2458 class FunctionModeField: public BitField<StubFunctionMode, 1, 1> {}; | 2419 class FunctionModeField: public BitField<StubFunctionMode, 1, 1> {}; |
2459 | 2420 |
2460 Major MajorKey() { return StubFailureTrampoline; } | 2421 Major MajorKey() { return StubFailureTrampoline; } |
2461 int MinorKey() { | 2422 int MinorKey() { |
2462 return FPRegisters::encode(fp_registers_) | | 2423 return FPRegisters::encode(fp_registers_) | |
2463 FunctionModeField::encode(function_mode_); | 2424 FunctionModeField::encode(function_mode_); |
2464 } | 2425 } |
2465 | 2426 |
2466 void Generate(MacroAssembler* masm); | 2427 void Generate(MacroAssembler* masm); |
2467 | 2428 |
2468 bool fp_registers_; | 2429 bool fp_registers_; |
2469 StubFunctionMode function_mode_; | 2430 StubFunctionMode function_mode_; |
2470 | 2431 |
2471 DISALLOW_COPY_AND_ASSIGN(StubFailureTrampolineStub); | 2432 DISALLOW_COPY_AND_ASSIGN(StubFailureTrampolineStub); |
2472 }; | 2433 }; |
2473 | 2434 |
2474 | 2435 |
2475 class StubFailureTailCallTrampolineStub : public PlatformCodeStub { | 2436 class StubFailureTailCallTrampolineStub : public PlatformCodeStub { |
2476 public: | 2437 public: |
2477 StubFailureTailCallTrampolineStub() : fp_registers_(CanUseFPRegisters()) {} | 2438 StubFailureTailCallTrampolineStub() : fp_registers_(CanUseFPRegisters()) {} |
2478 | 2439 |
2479 virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE { return true; } | |
2480 | |
2481 static void GenerateAheadOfTime(Isolate* isolate); | 2440 static void GenerateAheadOfTime(Isolate* isolate); |
2482 | 2441 |
2483 private: | 2442 private: |
2484 class FPRegisters: public BitField<bool, 0, 1> {}; | 2443 class FPRegisters: public BitField<bool, 0, 1> {}; |
2485 Major MajorKey() { return StubFailureTailCallTrampoline; } | 2444 Major MajorKey() { return StubFailureTailCallTrampoline; } |
2486 int MinorKey() { return FPRegisters::encode(fp_registers_); } | 2445 int MinorKey() { return FPRegisters::encode(fp_registers_); } |
2487 | 2446 |
2488 void Generate(MacroAssembler* masm); | 2447 void Generate(MacroAssembler* masm); |
2489 | 2448 |
2490 bool fp_registers_; | 2449 bool fp_registers_; |
(...skipping 21 matching lines...) Expand all Loading... |
2512 int MinorKey() { return 0; } | 2471 int MinorKey() { return 0; } |
2513 | 2472 |
2514 void Generate(MacroAssembler* masm); | 2473 void Generate(MacroAssembler* masm); |
2515 | 2474 |
2516 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2475 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
2517 }; | 2476 }; |
2518 | 2477 |
2519 } } // namespace v8::internal | 2478 } } // namespace v8::internal |
2520 | 2479 |
2521 #endif // V8_CODE_STUBS_H_ | 2480 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |