ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_BUILTINS_H_ |
| 29 | #define V8_BUILTINS_H_ |
| 30 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 31 | namespace v8 { |
| 32 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 33 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 34 | // Specifies extra arguments required by a C++ builtin. |
| 35 | enum BuiltinExtraArguments { |
| 36 | NO_EXTRA_ARGUMENTS = 0, |
| 37 | NEEDS_CALLED_FUNCTION = 1 |
| 38 | }; |
| 39 | |
| 40 | |
mvstanton@chromium.org | e4ac3ef | 2012-11-12 14:53:34 +0000 | [diff] [blame] | 41 | #define CODE_AGE_LIST_WITH_ARG(V, A) \ |
| 42 | V(Quadragenarian, A) \ |
| 43 | V(Quinquagenarian, A) \ |
| 44 | V(Sexagenarian, A) \ |
| 45 | V(Septuagenarian, A) \ |
| 46 | V(Octogenarian, A) |
| 47 | |
| 48 | #define CODE_AGE_LIST_IGNORE_ARG(X, V) V(X) |
| 49 | |
| 50 | #define CODE_AGE_LIST(V) \ |
| 51 | CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V) |
| 52 | |
| 53 | #define DECLARE_CODE_AGE_BUILTIN(C, V) \ |
| 54 | V(Make##C##CodeYoungAgainOddMarking, BUILTIN, \ |
| 55 | UNINITIALIZED, Code::kNoExtraICState) \ |
| 56 | V(Make##C##CodeYoungAgainEvenMarking, BUILTIN, \ |
| 57 | UNINITIALIZED, Code::kNoExtraICState) |
| 58 | |
| 59 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 60 | // Define list of builtins implemented in C++. |
| 61 | #define BUILTIN_LIST_C(V) \ |
| 62 | V(Illegal, NO_EXTRA_ARGUMENTS) \ |
| 63 | \ |
| 64 | V(EmptyFunction, NO_EXTRA_ARGUMENTS) \ |
| 65 | \ |
svenpanne@chromium.org | 3c93e77 | 2012-01-02 09:26:59 +0000 | [diff] [blame] | 66 | V(InternalArrayCodeGeneric, NO_EXTRA_ARGUMENTS) \ |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 67 | V(ArrayCodeGeneric, NO_EXTRA_ARGUMENTS) \ |
| 68 | \ |
| 69 | V(ArrayPush, NO_EXTRA_ARGUMENTS) \ |
| 70 | V(ArrayPop, NO_EXTRA_ARGUMENTS) \ |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 71 | V(ArrayShift, NO_EXTRA_ARGUMENTS) \ |
| 72 | V(ArrayUnshift, NO_EXTRA_ARGUMENTS) \ |
| 73 | V(ArraySlice, NO_EXTRA_ARGUMENTS) \ |
| 74 | V(ArraySplice, NO_EXTRA_ARGUMENTS) \ |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 75 | V(ArrayConcat, NO_EXTRA_ARGUMENTS) \ |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 76 | \ |
| 77 | V(HandleApiCall, NEEDS_CALLED_FUNCTION) \ |
| 78 | V(HandleApiCallConstruct, NEEDS_CALLED_FUNCTION) \ |
| 79 | V(HandleApiCallAsFunction, NO_EXTRA_ARGUMENTS) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 80 | V(HandleApiCallAsConstructor, NO_EXTRA_ARGUMENTS) \ |
| 81 | \ |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 82 | V(StrictModePoisonPill, NO_EXTRA_ARGUMENTS) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 83 | |
| 84 | // Define list of builtins implemented in assembly. |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 85 | #define BUILTIN_LIST_A(V) \ |
| 86 | V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED, \ |
| 87 | Code::kNoExtraICState) \ |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 88 | V(InRecompileQueue, BUILTIN, UNINITIALIZED, \ |
| 89 | Code::kNoExtraICState) \ |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 90 | V(InstallRecompiledCode, BUILTIN, UNINITIALIZED, \ |
| 91 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 92 | V(JSConstructStubCountdown, BUILTIN, UNINITIALIZED, \ |
| 93 | Code::kNoExtraICState) \ |
| 94 | V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED, \ |
| 95 | Code::kNoExtraICState) \ |
| 96 | V(JSConstructStubApi, BUILTIN, UNINITIALIZED, \ |
| 97 | Code::kNoExtraICState) \ |
| 98 | V(JSEntryTrampoline, BUILTIN, UNINITIALIZED, \ |
| 99 | Code::kNoExtraICState) \ |
| 100 | V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED, \ |
| 101 | Code::kNoExtraICState) \ |
| 102 | V(LazyCompile, BUILTIN, UNINITIALIZED, \ |
| 103 | Code::kNoExtraICState) \ |
| 104 | V(LazyRecompile, BUILTIN, UNINITIALIZED, \ |
| 105 | Code::kNoExtraICState) \ |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 106 | V(ParallelRecompile, BUILTIN, UNINITIALIZED, \ |
| 107 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 108 | V(NotifyDeoptimized, BUILTIN, UNINITIALIZED, \ |
| 109 | Code::kNoExtraICState) \ |
| 110 | V(NotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, \ |
| 111 | Code::kNoExtraICState) \ |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 112 | V(NotifyStubFailure, BUILTIN, UNINITIALIZED, \ |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 113 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 114 | V(NotifyOSR, BUILTIN, UNINITIALIZED, \ |
| 115 | Code::kNoExtraICState) \ |
| 116 | \ |
| 117 | V(LoadIC_Miss, BUILTIN, UNINITIALIZED, \ |
| 118 | Code::kNoExtraICState) \ |
| 119 | V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED, \ |
| 120 | Code::kNoExtraICState) \ |
| 121 | V(KeyedLoadIC_MissForceGeneric, BUILTIN, UNINITIALIZED, \ |
| 122 | Code::kNoExtraICState) \ |
| 123 | V(KeyedLoadIC_Slow, BUILTIN, UNINITIALIZED, \ |
| 124 | Code::kNoExtraICState) \ |
| 125 | V(StoreIC_Miss, BUILTIN, UNINITIALIZED, \ |
| 126 | Code::kNoExtraICState) \ |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame^] | 127 | V(StoreIC_Slow, BUILTIN, UNINITIALIZED, \ |
| 128 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 129 | V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED, \ |
| 130 | Code::kNoExtraICState) \ |
| 131 | V(KeyedStoreIC_MissForceGeneric, BUILTIN, UNINITIALIZED, \ |
| 132 | Code::kNoExtraICState) \ |
| 133 | V(KeyedStoreIC_Slow, BUILTIN, UNINITIALIZED, \ |
| 134 | Code::kNoExtraICState) \ |
| 135 | V(LoadIC_Initialize, LOAD_IC, UNINITIALIZED, \ |
| 136 | Code::kNoExtraICState) \ |
| 137 | V(LoadIC_PreMonomorphic, LOAD_IC, PREMONOMORPHIC, \ |
| 138 | Code::kNoExtraICState) \ |
| 139 | V(LoadIC_Normal, LOAD_IC, MONOMORPHIC, \ |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 140 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 141 | V(LoadIC_Megamorphic, LOAD_IC, MEGAMORPHIC, \ |
| 142 | Code::kNoExtraICState) \ |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 143 | V(LoadIC_Getter_ForDeopt, LOAD_IC, MONOMORPHIC, \ |
| 144 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 145 | \ |
| 146 | V(KeyedLoadIC_Initialize, KEYED_LOAD_IC, UNINITIALIZED, \ |
| 147 | Code::kNoExtraICState) \ |
| 148 | V(KeyedLoadIC_PreMonomorphic, KEYED_LOAD_IC, PREMONOMORPHIC, \ |
| 149 | Code::kNoExtraICState) \ |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 150 | V(KeyedLoadIC_Generic, KEYED_LOAD_IC, GENERIC, \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 151 | Code::kNoExtraICState) \ |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 152 | V(KeyedLoadIC_String, KEYED_LOAD_IC, MEGAMORPHIC, \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 153 | Code::kNoExtraICState) \ |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 154 | V(KeyedLoadIC_IndexedInterceptor, KEYED_LOAD_IC, MONOMORPHIC, \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 155 | Code::kNoExtraICState) \ |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 156 | V(KeyedLoadIC_NonStrictArguments, KEYED_LOAD_IC, MONOMORPHIC, \ |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 157 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 158 | \ |
| 159 | V(StoreIC_Initialize, STORE_IC, UNINITIALIZED, \ |
| 160 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 161 | V(StoreIC_Normal, STORE_IC, MONOMORPHIC, \ |
| 162 | Code::kNoExtraICState) \ |
| 163 | V(StoreIC_Megamorphic, STORE_IC, MEGAMORPHIC, \ |
| 164 | Code::kNoExtraICState) \ |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 165 | V(StoreIC_GlobalProxy, STORE_IC, GENERIC, \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 166 | Code::kNoExtraICState) \ |
| 167 | V(StoreIC_Initialize_Strict, STORE_IC, UNINITIALIZED, \ |
| 168 | kStrictMode) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 169 | V(StoreIC_Normal_Strict, STORE_IC, MONOMORPHIC, \ |
| 170 | kStrictMode) \ |
| 171 | V(StoreIC_Megamorphic_Strict, STORE_IC, MEGAMORPHIC, \ |
| 172 | kStrictMode) \ |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 173 | V(StoreIC_GlobalProxy_Strict, STORE_IC, GENERIC, \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 174 | kStrictMode) \ |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 175 | V(StoreIC_Setter_ForDeopt, STORE_IC, MONOMORPHIC, \ |
| 176 | kStrictMode) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 177 | \ |
| 178 | V(KeyedStoreIC_Initialize, KEYED_STORE_IC, UNINITIALIZED, \ |
| 179 | Code::kNoExtraICState) \ |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 180 | V(KeyedStoreIC_Generic, KEYED_STORE_IC, GENERIC, \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 181 | Code::kNoExtraICState) \ |
| 182 | \ |
| 183 | V(KeyedStoreIC_Initialize_Strict, KEYED_STORE_IC, UNINITIALIZED, \ |
| 184 | kStrictMode) \ |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 185 | V(KeyedStoreIC_Generic_Strict, KEYED_STORE_IC, GENERIC, \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 186 | kStrictMode) \ |
mstarzinger@chromium.org | 068ea0a | 2013-01-30 09:39:44 +0000 | [diff] [blame] | 187 | V(KeyedStoreIC_NonStrictArguments, KEYED_STORE_IC, MONOMORPHIC, \ |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 188 | Code::kNoExtraICState) \ |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 189 | V(TransitionElementsSmiToDouble, BUILTIN, UNINITIALIZED, \ |
| 190 | Code::kNoExtraICState) \ |
| 191 | V(TransitionElementsDoubleToObject, BUILTIN, UNINITIALIZED, \ |
| 192 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 193 | \ |
| 194 | /* Uses KeyedLoadIC_Initialize; must be after in list. */ \ |
| 195 | V(FunctionCall, BUILTIN, UNINITIALIZED, \ |
| 196 | Code::kNoExtraICState) \ |
| 197 | V(FunctionApply, BUILTIN, UNINITIALIZED, \ |
| 198 | Code::kNoExtraICState) \ |
| 199 | \ |
svenpanne@chromium.org | 3c93e77 | 2012-01-02 09:26:59 +0000 | [diff] [blame] | 200 | V(InternalArrayCode, BUILTIN, UNINITIALIZED, \ |
| 201 | Code::kNoExtraICState) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 202 | V(ArrayCode, BUILTIN, UNINITIALIZED, \ |
| 203 | Code::kNoExtraICState) \ |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 204 | V(CommonArrayConstructCode, BUILTIN, UNINITIALIZED, \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 205 | Code::kNoExtraICState) \ |
| 206 | \ |
| 207 | V(StringConstructCode, BUILTIN, UNINITIALIZED, \ |
| 208 | Code::kNoExtraICState) \ |
| 209 | \ |
| 210 | V(OnStackReplacement, BUILTIN, UNINITIALIZED, \ |
mvstanton@chromium.org | e4ac3ef | 2012-11-12 14:53:34 +0000 | [diff] [blame] | 211 | Code::kNoExtraICState) \ |
| 212 | CODE_AGE_LIST_WITH_ARG(DECLARE_CODE_AGE_BUILTIN, V) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 213 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 214 | #ifdef ENABLE_DEBUGGER_SUPPORT |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 215 | // Define list of builtins used by the debugger implemented in assembly. |
yangguo@chromium.org | 9768bf1 | 2013-01-11 14:51:07 +0000 | [diff] [blame] | 216 | #define BUILTIN_LIST_DEBUG_A(V) \ |
| 217 | V(Return_DebugBreak, BUILTIN, DEBUG_STUB, \ |
| 218 | DEBUG_BREAK) \ |
| 219 | V(CallFunctionStub_DebugBreak, BUILTIN, DEBUG_STUB, \ |
| 220 | DEBUG_BREAK) \ |
| 221 | V(CallFunctionStub_Recording_DebugBreak, BUILTIN, DEBUG_STUB, \ |
| 222 | DEBUG_BREAK) \ |
| 223 | V(CallConstructStub_DebugBreak, BUILTIN, DEBUG_STUB, \ |
| 224 | DEBUG_BREAK) \ |
| 225 | V(CallConstructStub_Recording_DebugBreak, BUILTIN, DEBUG_STUB, \ |
| 226 | DEBUG_BREAK) \ |
| 227 | V(LoadIC_DebugBreak, LOAD_IC, DEBUG_STUB, \ |
| 228 | DEBUG_BREAK) \ |
| 229 | V(KeyedLoadIC_DebugBreak, KEYED_LOAD_IC, DEBUG_STUB, \ |
| 230 | DEBUG_BREAK) \ |
| 231 | V(StoreIC_DebugBreak, STORE_IC, DEBUG_STUB, \ |
| 232 | DEBUG_BREAK) \ |
| 233 | V(KeyedStoreIC_DebugBreak, KEYED_STORE_IC, DEBUG_STUB, \ |
| 234 | DEBUG_BREAK) \ |
danno@chromium.org | f005df6 | 2013-04-30 16:36:45 +0000 | [diff] [blame] | 235 | V(CompareNilIC_DebugBreak, COMPARE_NIL_IC, DEBUG_STUB, \ |
| 236 | DEBUG_BREAK) \ |
yangguo@chromium.org | 9768bf1 | 2013-01-11 14:51:07 +0000 | [diff] [blame] | 237 | V(Slot_DebugBreak, BUILTIN, DEBUG_STUB, \ |
| 238 | DEBUG_BREAK) \ |
| 239 | V(PlainReturn_LiveEdit, BUILTIN, DEBUG_STUB, \ |
| 240 | DEBUG_BREAK) \ |
| 241 | V(FrameDropper_LiveEdit, BUILTIN, DEBUG_STUB, \ |
| 242 | DEBUG_BREAK) |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 243 | #else |
| 244 | #define BUILTIN_LIST_DEBUG_A(V) |
| 245 | #endif |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 246 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 247 | // Define list of builtins implemented in JavaScript. |
sgjesse@chromium.org | 05521fc | 2009-05-21 07:37:44 +0000 | [diff] [blame] | 248 | #define BUILTINS_LIST_JS(V) \ |
| 249 | V(EQUALS, 1) \ |
| 250 | V(STRICT_EQUALS, 1) \ |
| 251 | V(COMPARE, 2) \ |
| 252 | V(ADD, 1) \ |
| 253 | V(SUB, 1) \ |
| 254 | V(MUL, 1) \ |
| 255 | V(DIV, 1) \ |
| 256 | V(MOD, 1) \ |
| 257 | V(BIT_OR, 1) \ |
| 258 | V(BIT_AND, 1) \ |
| 259 | V(BIT_XOR, 1) \ |
| 260 | V(UNARY_MINUS, 0) \ |
| 261 | V(BIT_NOT, 0) \ |
| 262 | V(SHL, 1) \ |
| 263 | V(SAR, 1) \ |
| 264 | V(SHR, 1) \ |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 265 | V(DELETE, 2) \ |
sgjesse@chromium.org | 05521fc | 2009-05-21 07:37:44 +0000 | [diff] [blame] | 266 | V(IN, 1) \ |
| 267 | V(INSTANCE_OF, 1) \ |
sgjesse@chromium.org | 05521fc | 2009-05-21 07:37:44 +0000 | [diff] [blame] | 268 | V(FILTER_KEY, 1) \ |
| 269 | V(CALL_NON_FUNCTION, 0) \ |
| 270 | V(CALL_NON_FUNCTION_AS_CONSTRUCTOR, 0) \ |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 271 | V(CALL_FUNCTION_PROXY, 1) \ |
| 272 | V(CALL_FUNCTION_PROXY_AS_CONSTRUCTOR, 1) \ |
sgjesse@chromium.org | 05521fc | 2009-05-21 07:37:44 +0000 | [diff] [blame] | 273 | V(TO_OBJECT, 0) \ |
| 274 | V(TO_NUMBER, 0) \ |
| 275 | V(TO_STRING, 0) \ |
| 276 | V(STRING_ADD_LEFT, 1) \ |
| 277 | V(STRING_ADD_RIGHT, 1) \ |
| 278 | V(APPLY_PREPARE, 1) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 279 | V(APPLY_OVERFLOW, 1) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 280 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 281 | class BuiltinFunctionTable; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 282 | class ObjectVisitor; |
| 283 | |
| 284 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 285 | class Builtins { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 286 | public: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 287 | ~Builtins(); |
| 288 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 289 | // Generate all builtin code objects. Should be called once during |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 290 | // isolate initialization. |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 291 | void SetUp(bool create_heap_objects); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 292 | void TearDown(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 293 | |
| 294 | // Garbage collection support. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 295 | void IterateBuiltins(ObjectVisitor* v); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 296 | |
| 297 | // Disassembler support. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 298 | const char* Lookup(byte* pc); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 299 | |
| 300 | enum Name { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 301 | #define DEF_ENUM_C(name, ignore) k##name, |
| 302 | #define DEF_ENUM_A(name, kind, state, extra) k##name, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 303 | BUILTIN_LIST_C(DEF_ENUM_C) |
| 304 | BUILTIN_LIST_A(DEF_ENUM_A) |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 305 | BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 306 | #undef DEF_ENUM_C |
| 307 | #undef DEF_ENUM_A |
| 308 | builtin_count |
| 309 | }; |
| 310 | |
| 311 | enum CFunctionId { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 312 | #define DEF_ENUM_C(name, ignore) c_##name, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 313 | BUILTIN_LIST_C(DEF_ENUM_C) |
| 314 | #undef DEF_ENUM_C |
| 315 | cfunction_count |
| 316 | }; |
| 317 | |
| 318 | enum JavaScript { |
| 319 | #define DEF_ENUM(name, ignore) name, |
| 320 | BUILTINS_LIST_JS(DEF_ENUM) |
| 321 | #undef DEF_ENUM |
| 322 | id_count |
| 323 | }; |
| 324 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 325 | #define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name(); |
| 326 | #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ |
| 327 | Handle<Code> name(); |
| 328 | BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C) |
| 329 | BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A) |
| 330 | BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A) |
| 331 | #undef DECLARE_BUILTIN_ACCESSOR_C |
| 332 | #undef DECLARE_BUILTIN_ACCESSOR_A |
| 333 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 334 | Code* builtin(Name name) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 335 | // Code::cast cannot be used here since we access builtins |
| 336 | // during the marking phase of mark sweep. See IC::Clear. |
| 337 | return reinterpret_cast<Code*>(builtins_[name]); |
| 338 | } |
| 339 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 340 | Address builtin_address(Name name) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 341 | return reinterpret_cast<Address>(&builtins_[name]); |
| 342 | } |
| 343 | |
| 344 | static Address c_function_address(CFunctionId id) { |
| 345 | return c_functions_[id]; |
| 346 | } |
| 347 | |
| 348 | static const char* GetName(JavaScript id) { return javascript_names_[id]; } |
| 349 | static int GetArgumentsCount(JavaScript id) { return javascript_argc_[id]; } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 350 | Handle<Code> GetCode(JavaScript id, bool* resolved); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 351 | static int NumberOfJavaScriptBuiltins() { return id_count; } |
| 352 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 353 | bool is_initialized() const { return initialized_; } |
| 354 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 355 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 356 | Builtins(); |
| 357 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 358 | // The external C++ functions called from the code. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 359 | static Address const c_functions_[cfunction_count]; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 360 | |
| 361 | // Note: These are always Code objects, but to conform with |
| 362 | // IterateBuiltins() above which assumes Object**'s for the callback |
| 363 | // function f, we use an Object* array here. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 364 | Object* builtins_[builtin_count]; |
| 365 | const char* names_[builtin_count]; |
| 366 | static const char* const javascript_names_[id_count]; |
| 367 | static int const javascript_argc_[id_count]; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 368 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 369 | static void Generate_Adaptor(MacroAssembler* masm, |
| 370 | CFunctionId id, |
| 371 | BuiltinExtraArguments extra_args); |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 372 | static void Generate_InRecompileQueue(MacroAssembler* masm); |
ulan@chromium.org | 6e196bf | 2013-03-13 09:38:22 +0000 | [diff] [blame] | 373 | static void Generate_InstallRecompiledCode(MacroAssembler* masm); |
yangguo@chromium.org | 304cc33 | 2012-07-24 07:59:48 +0000 | [diff] [blame] | 374 | static void Generate_ParallelRecompile(MacroAssembler* masm); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 375 | static void Generate_JSConstructStubCountdown(MacroAssembler* masm); |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 376 | static void Generate_JSConstructStubGeneric(MacroAssembler* masm); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 377 | static void Generate_JSConstructStubApi(MacroAssembler* masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 378 | static void Generate_JSEntryTrampoline(MacroAssembler* masm); |
| 379 | static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 380 | static void Generate_LazyCompile(MacroAssembler* masm); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 381 | static void Generate_LazyRecompile(MacroAssembler* masm); |
| 382 | static void Generate_NotifyDeoptimized(MacroAssembler* masm); |
| 383 | static void Generate_NotifyLazyDeoptimized(MacroAssembler* masm); |
| 384 | static void Generate_NotifyOSR(MacroAssembler* masm); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 385 | static void Generate_NotifyStubFailure(MacroAssembler* masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 386 | static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 387 | |
| 388 | static void Generate_FunctionCall(MacroAssembler* masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 389 | static void Generate_FunctionApply(MacroAssembler* masm); |
christian.plesner.hansen@gmail.com | 2bc58ef | 2009-09-22 10:00:30 +0000 | [diff] [blame] | 390 | |
svenpanne@chromium.org | 3c93e77 | 2012-01-02 09:26:59 +0000 | [diff] [blame] | 391 | static void Generate_InternalArrayCode(MacroAssembler* masm); |
christian.plesner.hansen@gmail.com | 2bc58ef | 2009-09-22 10:00:30 +0000 | [diff] [blame] | 392 | static void Generate_ArrayCode(MacroAssembler* masm); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 393 | static void Generate_CommonArrayConstructCode(MacroAssembler* masm); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 394 | |
| 395 | static void Generate_StringConstructCode(MacroAssembler* masm); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 396 | static void Generate_OnStackReplacement(MacroAssembler* masm); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 397 | |
mvstanton@chromium.org | e4ac3ef | 2012-11-12 14:53:34 +0000 | [diff] [blame] | 398 | #define DECLARE_CODE_AGE_BUILTIN_GENERATOR(C) \ |
| 399 | static void Generate_Make##C##CodeYoungAgainEvenMarking( \ |
| 400 | MacroAssembler* masm); \ |
| 401 | static void Generate_Make##C##CodeYoungAgainOddMarking( \ |
| 402 | MacroAssembler* masm); |
| 403 | CODE_AGE_LIST(DECLARE_CODE_AGE_BUILTIN_GENERATOR) |
| 404 | #undef DECLARE_CODE_AGE_BUILTIN_GENERATOR |
| 405 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 406 | static void InitBuiltinFunctionTable(); |
| 407 | |
| 408 | bool initialized_; |
| 409 | |
| 410 | friend class BuiltinFunctionTable; |
| 411 | friend class Isolate; |
| 412 | |
| 413 | DISALLOW_COPY_AND_ASSIGN(Builtins); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 414 | }; |
| 415 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 416 | } } // namespace v8::internal |
| 417 | |
| 418 | #endif // V8_BUILTINS_H_ |