| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_CODE_FACTORY_H_ | 5 #ifndef V8_CODE_FACTORY_H_ |
| 6 #define V8_CODE_FACTORY_H_ | 6 #define V8_CODE_FACTORY_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| 11 #include "src/globals.h" | 11 #include "src/globals.h" |
| 12 #include "src/interface-descriptors.h" | 12 #include "src/interface-descriptors.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 // Associates a body of code with an interface descriptor. | 17 // Associates a body of code with an interface descriptor. |
| 18 class Callable final BASE_EMBEDDED { | 18 class Callable BASE_EMBEDDED { |
| 19 public: | 19 public: |
| 20 Callable(Handle<Code> code, CallInterfaceDescriptor descriptor) | 20 Callable(Handle<Code> code, CallInterfaceDescriptor descriptor) |
| 21 : code_(code), descriptor_(descriptor) {} | 21 : code_(code), descriptor_(descriptor) {} |
| 22 | 22 |
| 23 Handle<Code> code() const { return code_; } | 23 Handle<Code> code() const { return code_; } |
| 24 CallInterfaceDescriptor descriptor() const { return descriptor_; } | 24 CallInterfaceDescriptor descriptor() const { return descriptor_; } |
| 25 | 25 |
| 26 private: | 26 private: |
| 27 const Handle<Code> code_; | 27 const Handle<Code> code_; |
| 28 const CallInterfaceDescriptor descriptor_; | 28 const CallInterfaceDescriptor descriptor_; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 template <typename DescriptorT> |
| 32 class CallableD final : public Callable { |
| 33 public: |
| 34 typedef DescriptorT Descriptor; |
| 35 |
| 36 CallableD(Handle<Code> code, Isolate* isolate) |
| 37 : Callable(code, Descriptor(isolate)) {} |
| 38 }; |
| 31 | 39 |
| 32 class CodeFactory final { | 40 class CodeFactory final { |
| 33 public: | 41 public: |
| 34 // Initial states for ICs. | 42 // Initial states for ICs. |
| 35 static Callable LoadIC(Isolate* isolate); | 43 static Callable LoadIC(Isolate* isolate); |
| 36 static Callable LoadICInOptimizedCode(Isolate* isolate); | 44 static CallableD<LoadWithVectorDescriptor> LoadICInOptimizedCode( |
| 45 Isolate* isolate); |
| 37 static Callable LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode); | 46 static Callable LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode); |
| 38 static Callable LoadGlobalICInOptimizedCode(Isolate* isolate, | 47 static CallableD<LoadGlobalWithVectorDescriptor> LoadGlobalICInOptimizedCode( |
| 39 TypeofMode typeof_mode); | 48 Isolate* isolate, TypeofMode typeof_mode); |
| 40 static Callable KeyedLoadIC(Isolate* isolate); | 49 static Callable KeyedLoadIC(Isolate* isolate); |
| 41 static Callable KeyedLoadICInOptimizedCode(Isolate* isolate); | 50 static CallableD<LoadWithVectorDescriptor> KeyedLoadICInOptimizedCode( |
| 51 Isolate* isolate); |
| 42 static Callable KeyedLoadIC_Megamorphic(Isolate* isolate); | 52 static Callable KeyedLoadIC_Megamorphic(Isolate* isolate); |
| 43 static Callable CallIC(Isolate* isolate, int argc, | 53 static Callable CallIC(Isolate* isolate, int argc, |
| 44 ConvertReceiverMode mode = ConvertReceiverMode::kAny, | 54 ConvertReceiverMode mode = ConvertReceiverMode::kAny, |
| 45 TailCallMode tail_call_mode = TailCallMode::kDisallow); | 55 TailCallMode tail_call_mode = TailCallMode::kDisallow); |
| 46 static Callable CallICInOptimizedCode( | 56 static Callable CallICInOptimizedCode( |
| 47 Isolate* isolate, int argc, | 57 Isolate* isolate, int argc, |
| 48 ConvertReceiverMode mode = ConvertReceiverMode::kAny, | 58 ConvertReceiverMode mode = ConvertReceiverMode::kAny, |
| 49 TailCallMode tail_call_mode = TailCallMode::kDisallow); | 59 TailCallMode tail_call_mode = TailCallMode::kDisallow); |
| 50 static Callable StoreIC(Isolate* isolate, LanguageMode mode); | 60 static Callable StoreIC(Isolate* isolate, LanguageMode mode); |
| 51 static Callable StoreICInOptimizedCode(Isolate* isolate, LanguageMode mode); | 61 static CallableD<StoreWithVectorDescriptor> StoreICInOptimizedCode( |
| 62 Isolate* isolate, LanguageMode mode); |
| 52 static Callable KeyedStoreIC(Isolate* isolate, LanguageMode mode); | 63 static Callable KeyedStoreIC(Isolate* isolate, LanguageMode mode); |
| 53 static Callable KeyedStoreICInOptimizedCode(Isolate* isolate, | 64 static CallableD<StoreWithVectorDescriptor> KeyedStoreICInOptimizedCode( |
| 54 LanguageMode mode); | 65 Isolate* isolate, LanguageMode mode); |
| 55 | 66 |
| 56 static Callable ResumeGenerator(Isolate* isolate); | 67 static Callable ResumeGenerator(Isolate* isolate); |
| 57 | 68 |
| 58 static Callable CompareIC(Isolate* isolate, Token::Value op); | 69 static Callable CompareIC(Isolate* isolate, Token::Value op); |
| 59 static Callable CompareNilIC(Isolate* isolate, NilValue nil_value); | 70 static Callable CompareNilIC(Isolate* isolate, NilValue nil_value); |
| 60 | 71 |
| 61 static Callable BinaryOpIC(Isolate* isolate, Token::Value op); | 72 static Callable BinaryOpIC(Isolate* isolate, Token::Value op); |
| 62 | 73 |
| 63 static Callable ApiGetter(Isolate* isolate); | 74 static Callable ApiGetter(Isolate* isolate); |
| 64 | 75 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 CallableType function_type = CallableType::kAny); | 169 CallableType function_type = CallableType::kAny); |
| 159 static Callable InterpreterPushArgsAndConstruct(Isolate* isolate); | 170 static Callable InterpreterPushArgsAndConstruct(Isolate* isolate); |
| 160 static Callable InterpreterCEntry(Isolate* isolate, int result_size = 1); | 171 static Callable InterpreterCEntry(Isolate* isolate, int result_size = 1); |
| 161 static Callable InterpreterOnStackReplacement(Isolate* isolate); | 172 static Callable InterpreterOnStackReplacement(Isolate* isolate); |
| 162 }; | 173 }; |
| 163 | 174 |
| 164 } // namespace internal | 175 } // namespace internal |
| 165 } // namespace v8 | 176 } // namespace v8 |
| 166 | 177 |
| 167 #endif // V8_CODE_FACTORY_H_ | 178 #endif // V8_CODE_FACTORY_H_ |
| OLD | NEW |