Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef V8_CODE_FACTORY_H_ |
| 6 | #define V8_CODE_FACTORY_H_ |
| 7 | |
| 8 | #include "src/allocation.h" |
| 9 | #include "src/assembler.h" |
| 10 | #include "src/codegen.h" |
| 11 | #include "src/globals.h" |
| 12 | #include "src/interface-descriptors.h" |
| 13 | |
| 14 | namespace v8 { |
| 15 | namespace internal { |
| 16 | |
| 17 | // Associates a body of code with an interface descriptor. |
| 18 | class Callable FINAL BASE_EMBEDDED { |
| 19 | public: |
| 20 | Callable(Handle<Code> code, CallInterfaceDescriptor descriptor) |
| 21 | : code_(code), descriptor_(descriptor) {} |
| 22 | |
| 23 | Handle<Code> code() const { return code_; } |
| 24 | CallInterfaceDescriptor descriptor() const { return descriptor_; } |
| 25 | |
| 26 | private: |
| 27 | const Handle<Code> code_; |
| 28 | const CallInterfaceDescriptor descriptor_; |
| 29 | }; |
| 30 | |
| 31 | |
| 32 | class CodeFactory FINAL { |
| 33 | public: |
| 34 | // Initial states for ICs. |
| 35 | static Callable LoadIC(Isolate* isolate, ContextualMode mode); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 36 | static Callable LoadICInOptimizedCode(Isolate* isolate, ContextualMode mode); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 37 | static Callable KeyedLoadIC(Isolate* isolate); |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 38 | static Callable KeyedLoadICInOptimizedCode(Isolate* isolate); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 39 | static Callable StoreIC(Isolate* isolate, StrictMode mode); |
| 40 | static Callable KeyedStoreIC(Isolate* isolate, StrictMode mode); |
| 41 | |
| 42 | static Callable CompareIC(Isolate* isolate, Token::Value op); |
| 43 | |
| 44 | static Callable BinaryOpIC(Isolate* isolate, Token::Value op, |
| 45 | OverwriteMode mode = NO_OVERWRITE); |
| 46 | |
| 47 | // Code stubs. Add methods here as needed to reduce dependency on |
| 48 | // code-stubs.h. |
| 49 | static Callable ToBoolean( |
| 50 | Isolate* isolate, ToBooleanStub::ResultMode mode, |
| 51 | ToBooleanStub::Types types = ToBooleanStub::Types()); |
| 52 | |
| 53 | static Callable ToNumber(Isolate* isolate); |
| 54 | |
| 55 | static Callable StringAdd(Isolate* isolate, StringAddFlags flags, |
| 56 | PretenureFlag pretenure_flag); |
| 57 | |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 58 | static Callable AllocateHeapNumber(Isolate* isolate); |
| 59 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 60 | static Callable CallFunction(Isolate* isolate, int argc, |
| 61 | CallFunctionFlags flags); |
| 62 | }; |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 63 | |
| 64 | } // namespace internal |
| 65 | } // namespace v8 |
| 66 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 67 | #endif // V8_CODE_FACTORY_H_ |