Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1 | // Copyright 2014 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 | #include "src/v8.h" |
| 6 | |
| 7 | #include "src/bootstrapper.h" |
| 8 | #include "src/code-factory.h" |
| 9 | #include "src/ic/ic.h" |
| 10 | |
| 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | |
| 14 | // static |
| 15 | Callable CodeFactory::LoadIC(Isolate* isolate, ContextualMode mode) { |
| 16 | return Callable( |
| 17 | LoadIC::initialize_stub(isolate, LoadICState(mode).GetExtraICState()), |
| 18 | LoadDescriptor(isolate)); |
| 19 | } |
| 20 | |
| 21 | |
| 22 | // static |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 23 | Callable CodeFactory::LoadICInOptimizedCode(Isolate* isolate, |
| 24 | ContextualMode mode) { |
| 25 | if (FLAG_vector_ics) { |
| 26 | return Callable(LoadIC::initialize_stub_in_optimized_code( |
| 27 | isolate, LoadICState(mode).GetExtraICState()), |
| 28 | VectorLoadICDescriptor(isolate)); |
| 29 | } |
| 30 | return CodeFactory::LoadIC(isolate, mode); |
| 31 | } |
| 32 | |
| 33 | |
| 34 | // static |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 35 | Callable CodeFactory::KeyedLoadIC(Isolate* isolate) { |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 36 | return Callable(KeyedLoadIC::initialize_stub(isolate), |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 37 | LoadDescriptor(isolate)); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | // static |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 42 | Callable CodeFactory::KeyedLoadICInOptimizedCode(Isolate* isolate) { |
| 43 | if (FLAG_vector_ics) { |
| 44 | return Callable(KeyedLoadIC::initialize_stub_in_optimized_code(isolate), |
| 45 | VectorLoadICDescriptor(isolate)); |
| 46 | } |
| 47 | return CodeFactory::KeyedLoadIC(isolate); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | // static |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 52 | Callable CodeFactory::StoreIC(Isolate* isolate, StrictMode mode) { |
| 53 | return Callable(StoreIC::initialize_stub(isolate, mode), |
| 54 | StoreDescriptor(isolate)); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | // static |
| 59 | Callable CodeFactory::KeyedStoreIC(Isolate* isolate, StrictMode mode) { |
| 60 | Handle<Code> ic = mode == SLOPPY |
| 61 | ? isolate->builtins()->KeyedStoreIC_Initialize() |
| 62 | : isolate->builtins()->KeyedStoreIC_Initialize_Strict(); |
| 63 | return Callable(ic, StoreDescriptor(isolate)); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | // static |
| 68 | Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) { |
| 69 | Handle<Code> code = CompareIC::GetUninitialized(isolate, op); |
| 70 | return Callable(code, BinaryOpDescriptor(isolate)); |
| 71 | } |
| 72 | |
| 73 | |
| 74 | // static |
| 75 | Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op, |
| 76 | OverwriteMode mode) { |
| 77 | BinaryOpICStub stub(isolate, op, mode); |
| 78 | return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | // static |
| 83 | Callable CodeFactory::ToBoolean(Isolate* isolate, |
| 84 | ToBooleanStub::ResultMode mode, |
| 85 | ToBooleanStub::Types types) { |
| 86 | ToBooleanStub stub(isolate, mode, types); |
| 87 | return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | // static |
| 92 | Callable CodeFactory::ToNumber(Isolate* isolate) { |
| 93 | ToNumberStub stub(isolate); |
| 94 | return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
| 95 | } |
| 96 | |
| 97 | |
| 98 | // static |
| 99 | Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags, |
| 100 | PretenureFlag pretenure_flag) { |
| 101 | StringAddStub stub(isolate, flags, pretenure_flag); |
| 102 | return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
| 103 | } |
| 104 | |
| 105 | |
| 106 | // static |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 107 | Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) { |
| 108 | AllocateHeapNumberStub stub(isolate); |
| 109 | return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
| 110 | } |
| 111 | |
| 112 | |
| 113 | // static |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 114 | Callable CodeFactory::CallFunction(Isolate* isolate, int argc, |
| 115 | CallFunctionFlags flags) { |
| 116 | CallFunctionStub stub(isolate, argc, flags); |
| 117 | return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor()); |
| 118 | } |
| 119 | |
| 120 | } // namespace internal |
| 121 | } // namespace v8 |