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 | |
| 41 | // Define list of builtins implemented in C++. |
| 42 | #define BUILTIN_LIST_C(V) \ |
| 43 | V(Illegal, NO_EXTRA_ARGUMENTS) \ |
| 44 | \ |
| 45 | V(EmptyFunction, NO_EXTRA_ARGUMENTS) \ |
| 46 | \ |
| 47 | V(ArrayCodeGeneric, NO_EXTRA_ARGUMENTS) \ |
| 48 | \ |
| 49 | V(ArrayPush, NO_EXTRA_ARGUMENTS) \ |
| 50 | V(ArrayPop, NO_EXTRA_ARGUMENTS) \ |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 51 | V(ArrayShift, NO_EXTRA_ARGUMENTS) \ |
| 52 | V(ArrayUnshift, NO_EXTRA_ARGUMENTS) \ |
| 53 | V(ArraySlice, NO_EXTRA_ARGUMENTS) \ |
| 54 | V(ArraySplice, NO_EXTRA_ARGUMENTS) \ |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 55 | V(ArrayConcat, NO_EXTRA_ARGUMENTS) \ |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 56 | \ |
| 57 | V(HandleApiCall, NEEDS_CALLED_FUNCTION) \ |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 58 | V(FastHandleApiCall, NO_EXTRA_ARGUMENTS) \ |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 59 | V(HandleApiCallConstruct, NEEDS_CALLED_FUNCTION) \ |
| 60 | V(HandleApiCallAsFunction, NO_EXTRA_ARGUMENTS) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 61 | V(HandleApiCallAsConstructor, NO_EXTRA_ARGUMENTS) \ |
| 62 | \ |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 63 | V(StrictModePoisonPill, NO_EXTRA_ARGUMENTS) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 64 | |
| 65 | // Define list of builtins implemented in assembly. |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 66 | #define BUILTIN_LIST_A(V) \ |
| 67 | V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED, \ |
| 68 | Code::kNoExtraICState) \ |
| 69 | V(JSConstructCall, BUILTIN, UNINITIALIZED, \ |
| 70 | Code::kNoExtraICState) \ |
| 71 | V(JSConstructStubCountdown, BUILTIN, UNINITIALIZED, \ |
| 72 | Code::kNoExtraICState) \ |
| 73 | V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED, \ |
| 74 | Code::kNoExtraICState) \ |
| 75 | V(JSConstructStubApi, BUILTIN, UNINITIALIZED, \ |
| 76 | Code::kNoExtraICState) \ |
| 77 | V(JSEntryTrampoline, BUILTIN, UNINITIALIZED, \ |
| 78 | Code::kNoExtraICState) \ |
| 79 | V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED, \ |
| 80 | Code::kNoExtraICState) \ |
| 81 | V(LazyCompile, BUILTIN, UNINITIALIZED, \ |
| 82 | Code::kNoExtraICState) \ |
| 83 | V(LazyRecompile, BUILTIN, UNINITIALIZED, \ |
| 84 | Code::kNoExtraICState) \ |
| 85 | V(NotifyDeoptimized, BUILTIN, UNINITIALIZED, \ |
| 86 | Code::kNoExtraICState) \ |
| 87 | V(NotifyLazyDeoptimized, BUILTIN, UNINITIALIZED, \ |
| 88 | Code::kNoExtraICState) \ |
| 89 | V(NotifyOSR, BUILTIN, UNINITIALIZED, \ |
| 90 | Code::kNoExtraICState) \ |
| 91 | \ |
| 92 | V(LoadIC_Miss, BUILTIN, UNINITIALIZED, \ |
| 93 | Code::kNoExtraICState) \ |
| 94 | V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED, \ |
| 95 | Code::kNoExtraICState) \ |
| 96 | V(KeyedLoadIC_MissForceGeneric, BUILTIN, UNINITIALIZED, \ |
| 97 | Code::kNoExtraICState) \ |
| 98 | V(KeyedLoadIC_Slow, BUILTIN, UNINITIALIZED, \ |
| 99 | Code::kNoExtraICState) \ |
| 100 | V(StoreIC_Miss, BUILTIN, UNINITIALIZED, \ |
| 101 | Code::kNoExtraICState) \ |
| 102 | V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED, \ |
| 103 | Code::kNoExtraICState) \ |
| 104 | V(KeyedStoreIC_MissForceGeneric, BUILTIN, UNINITIALIZED, \ |
| 105 | Code::kNoExtraICState) \ |
| 106 | V(KeyedStoreIC_Slow, BUILTIN, UNINITIALIZED, \ |
| 107 | Code::kNoExtraICState) \ |
| 108 | V(LoadIC_Initialize, LOAD_IC, UNINITIALIZED, \ |
| 109 | Code::kNoExtraICState) \ |
| 110 | V(LoadIC_PreMonomorphic, LOAD_IC, PREMONOMORPHIC, \ |
| 111 | Code::kNoExtraICState) \ |
| 112 | V(LoadIC_Normal, LOAD_IC, MONOMORPHIC, \ |
| 113 | Code::kNoExtraICState) \ |
| 114 | V(LoadIC_ArrayLength, LOAD_IC, MONOMORPHIC, \ |
| 115 | Code::kNoExtraICState) \ |
| 116 | V(LoadIC_StringLength, LOAD_IC, MONOMORPHIC, \ |
| 117 | Code::kNoExtraICState) \ |
| 118 | V(LoadIC_StringWrapperLength, LOAD_IC, MONOMORPHIC, \ |
| 119 | Code::kNoExtraICState) \ |
| 120 | V(LoadIC_FunctionPrototype, LOAD_IC, MONOMORPHIC, \ |
| 121 | Code::kNoExtraICState) \ |
| 122 | V(LoadIC_Megamorphic, LOAD_IC, MEGAMORPHIC, \ |
| 123 | Code::kNoExtraICState) \ |
| 124 | \ |
| 125 | V(KeyedLoadIC_Initialize, KEYED_LOAD_IC, UNINITIALIZED, \ |
| 126 | Code::kNoExtraICState) \ |
| 127 | V(KeyedLoadIC_PreMonomorphic, KEYED_LOAD_IC, PREMONOMORPHIC, \ |
| 128 | Code::kNoExtraICState) \ |
| 129 | V(KeyedLoadIC_Generic, KEYED_LOAD_IC, MEGAMORPHIC, \ |
| 130 | Code::kNoExtraICState) \ |
| 131 | V(KeyedLoadIC_String, KEYED_LOAD_IC, MEGAMORPHIC, \ |
| 132 | Code::kNoExtraICState) \ |
| 133 | V(KeyedLoadIC_IndexedInterceptor, KEYED_LOAD_IC, MEGAMORPHIC, \ |
| 134 | Code::kNoExtraICState) \ |
| 135 | \ |
| 136 | V(StoreIC_Initialize, STORE_IC, UNINITIALIZED, \ |
| 137 | Code::kNoExtraICState) \ |
| 138 | V(StoreIC_ArrayLength, STORE_IC, MONOMORPHIC, \ |
| 139 | Code::kNoExtraICState) \ |
| 140 | V(StoreIC_Normal, STORE_IC, MONOMORPHIC, \ |
| 141 | Code::kNoExtraICState) \ |
| 142 | V(StoreIC_Megamorphic, STORE_IC, MEGAMORPHIC, \ |
| 143 | Code::kNoExtraICState) \ |
| 144 | V(StoreIC_GlobalProxy, STORE_IC, MEGAMORPHIC, \ |
| 145 | Code::kNoExtraICState) \ |
| 146 | V(StoreIC_Initialize_Strict, STORE_IC, UNINITIALIZED, \ |
| 147 | kStrictMode) \ |
| 148 | V(StoreIC_ArrayLength_Strict, STORE_IC, MONOMORPHIC, \ |
| 149 | kStrictMode) \ |
| 150 | V(StoreIC_Normal_Strict, STORE_IC, MONOMORPHIC, \ |
| 151 | kStrictMode) \ |
| 152 | V(StoreIC_Megamorphic_Strict, STORE_IC, MEGAMORPHIC, \ |
| 153 | kStrictMode) \ |
| 154 | V(StoreIC_GlobalProxy_Strict, STORE_IC, MEGAMORPHIC, \ |
| 155 | kStrictMode) \ |
| 156 | \ |
| 157 | V(KeyedStoreIC_Initialize, KEYED_STORE_IC, UNINITIALIZED, \ |
| 158 | Code::kNoExtraICState) \ |
| 159 | V(KeyedStoreIC_Generic, KEYED_STORE_IC, MEGAMORPHIC, \ |
| 160 | Code::kNoExtraICState) \ |
| 161 | \ |
| 162 | V(KeyedStoreIC_Initialize_Strict, KEYED_STORE_IC, UNINITIALIZED, \ |
| 163 | kStrictMode) \ |
| 164 | V(KeyedStoreIC_Generic_Strict, KEYED_STORE_IC, MEGAMORPHIC, \ |
| 165 | kStrictMode) \ |
| 166 | \ |
| 167 | /* Uses KeyedLoadIC_Initialize; must be after in list. */ \ |
| 168 | V(FunctionCall, BUILTIN, UNINITIALIZED, \ |
| 169 | Code::kNoExtraICState) \ |
| 170 | V(FunctionApply, BUILTIN, UNINITIALIZED, \ |
| 171 | Code::kNoExtraICState) \ |
| 172 | \ |
| 173 | V(ArrayCode, BUILTIN, UNINITIALIZED, \ |
| 174 | Code::kNoExtraICState) \ |
| 175 | V(ArrayConstructCode, BUILTIN, UNINITIALIZED, \ |
| 176 | Code::kNoExtraICState) \ |
| 177 | \ |
| 178 | V(StringConstructCode, BUILTIN, UNINITIALIZED, \ |
| 179 | Code::kNoExtraICState) \ |
| 180 | \ |
| 181 | V(OnStackReplacement, BUILTIN, UNINITIALIZED, \ |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 182 | Code::kNoExtraICState) |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 183 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 184 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 185 | #ifdef ENABLE_DEBUGGER_SUPPORT |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 186 | // Define list of builtins used by the debugger implemented in assembly. |
| 187 | #define BUILTIN_LIST_DEBUG_A(V) \ |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 188 | V(Return_DebugBreak, BUILTIN, DEBUG_BREAK, \ |
| 189 | Code::kNoExtraICState) \ |
| 190 | V(ConstructCall_DebugBreak, BUILTIN, DEBUG_BREAK, \ |
| 191 | Code::kNoExtraICState) \ |
| 192 | V(StubNoRegisters_DebugBreak, BUILTIN, DEBUG_BREAK, \ |
| 193 | Code::kNoExtraICState) \ |
| 194 | V(LoadIC_DebugBreak, LOAD_IC, DEBUG_BREAK, \ |
| 195 | Code::kNoExtraICState) \ |
| 196 | V(KeyedLoadIC_DebugBreak, KEYED_LOAD_IC, DEBUG_BREAK, \ |
| 197 | Code::kNoExtraICState) \ |
| 198 | V(StoreIC_DebugBreak, STORE_IC, DEBUG_BREAK, \ |
| 199 | Code::kNoExtraICState) \ |
| 200 | V(KeyedStoreIC_DebugBreak, KEYED_STORE_IC, DEBUG_BREAK, \ |
| 201 | Code::kNoExtraICState) \ |
| 202 | V(Slot_DebugBreak, BUILTIN, DEBUG_BREAK, \ |
| 203 | Code::kNoExtraICState) \ |
| 204 | V(PlainReturn_LiveEdit, BUILTIN, DEBUG_BREAK, \ |
| 205 | Code::kNoExtraICState) \ |
| 206 | V(FrameDropper_LiveEdit, BUILTIN, DEBUG_BREAK, \ |
| 207 | Code::kNoExtraICState) |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 208 | #else |
| 209 | #define BUILTIN_LIST_DEBUG_A(V) |
| 210 | #endif |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 211 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 212 | // Define list of builtins implemented in JavaScript. |
sgjesse@chromium.org | 05521fc | 2009-05-21 07:37:44 +0000 | [diff] [blame] | 213 | #define BUILTINS_LIST_JS(V) \ |
| 214 | V(EQUALS, 1) \ |
| 215 | V(STRICT_EQUALS, 1) \ |
| 216 | V(COMPARE, 2) \ |
| 217 | V(ADD, 1) \ |
| 218 | V(SUB, 1) \ |
| 219 | V(MUL, 1) \ |
| 220 | V(DIV, 1) \ |
| 221 | V(MOD, 1) \ |
| 222 | V(BIT_OR, 1) \ |
| 223 | V(BIT_AND, 1) \ |
| 224 | V(BIT_XOR, 1) \ |
| 225 | V(UNARY_MINUS, 0) \ |
| 226 | V(BIT_NOT, 0) \ |
| 227 | V(SHL, 1) \ |
| 228 | V(SAR, 1) \ |
| 229 | V(SHR, 1) \ |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 230 | V(DELETE, 2) \ |
sgjesse@chromium.org | 05521fc | 2009-05-21 07:37:44 +0000 | [diff] [blame] | 231 | V(IN, 1) \ |
| 232 | V(INSTANCE_OF, 1) \ |
| 233 | V(GET_KEYS, 0) \ |
| 234 | V(FILTER_KEY, 1) \ |
| 235 | V(CALL_NON_FUNCTION, 0) \ |
| 236 | V(CALL_NON_FUNCTION_AS_CONSTRUCTOR, 0) \ |
| 237 | V(TO_OBJECT, 0) \ |
| 238 | V(TO_NUMBER, 0) \ |
| 239 | V(TO_STRING, 0) \ |
| 240 | V(STRING_ADD_LEFT, 1) \ |
| 241 | V(STRING_ADD_RIGHT, 1) \ |
| 242 | V(APPLY_PREPARE, 1) \ |
ager@chromium.org | ea91cc5 | 2011-05-23 06:06:11 +0000 | [diff] [blame] | 243 | V(APPLY_OVERFLOW, 1) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 244 | |
| 245 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 246 | class BuiltinFunctionTable; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 247 | class ObjectVisitor; |
| 248 | |
| 249 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 250 | class Builtins { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 251 | public: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 252 | ~Builtins(); |
| 253 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 254 | // Generate all builtin code objects. Should be called once during |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 255 | // isolate initialization. |
| 256 | void Setup(bool create_heap_objects); |
| 257 | void TearDown(); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 258 | |
| 259 | // Garbage collection support. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 260 | void IterateBuiltins(ObjectVisitor* v); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 261 | |
| 262 | // Disassembler support. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 263 | const char* Lookup(byte* pc); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 264 | |
| 265 | enum Name { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 266 | #define DEF_ENUM_C(name, ignore) k##name, |
| 267 | #define DEF_ENUM_A(name, kind, state, extra) k##name, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 268 | BUILTIN_LIST_C(DEF_ENUM_C) |
| 269 | BUILTIN_LIST_A(DEF_ENUM_A) |
ager@chromium.org | 8bb6058 | 2008-12-11 12:02:20 +0000 | [diff] [blame] | 270 | BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 271 | #undef DEF_ENUM_C |
| 272 | #undef DEF_ENUM_A |
| 273 | builtin_count |
| 274 | }; |
| 275 | |
| 276 | enum CFunctionId { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 277 | #define DEF_ENUM_C(name, ignore) c_##name, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 278 | BUILTIN_LIST_C(DEF_ENUM_C) |
| 279 | #undef DEF_ENUM_C |
| 280 | cfunction_count |
| 281 | }; |
| 282 | |
| 283 | enum JavaScript { |
| 284 | #define DEF_ENUM(name, ignore) name, |
| 285 | BUILTINS_LIST_JS(DEF_ENUM) |
| 286 | #undef DEF_ENUM |
| 287 | id_count |
| 288 | }; |
| 289 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 290 | #define DECLARE_BUILTIN_ACCESSOR_C(name, ignore) Handle<Code> name(); |
| 291 | #define DECLARE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ |
| 292 | Handle<Code> name(); |
| 293 | BUILTIN_LIST_C(DECLARE_BUILTIN_ACCESSOR_C) |
| 294 | BUILTIN_LIST_A(DECLARE_BUILTIN_ACCESSOR_A) |
| 295 | BUILTIN_LIST_DEBUG_A(DECLARE_BUILTIN_ACCESSOR_A) |
| 296 | #undef DECLARE_BUILTIN_ACCESSOR_C |
| 297 | #undef DECLARE_BUILTIN_ACCESSOR_A |
| 298 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 299 | Code* builtin(Name name) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 300 | // Code::cast cannot be used here since we access builtins |
| 301 | // during the marking phase of mark sweep. See IC::Clear. |
| 302 | return reinterpret_cast<Code*>(builtins_[name]); |
| 303 | } |
| 304 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 305 | Address builtin_address(Name name) { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 306 | return reinterpret_cast<Address>(&builtins_[name]); |
| 307 | } |
| 308 | |
| 309 | static Address c_function_address(CFunctionId id) { |
| 310 | return c_functions_[id]; |
| 311 | } |
| 312 | |
| 313 | static const char* GetName(JavaScript id) { return javascript_names_[id]; } |
| 314 | static int GetArgumentsCount(JavaScript id) { return javascript_argc_[id]; } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 315 | Handle<Code> GetCode(JavaScript id, bool* resolved); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 316 | static int NumberOfJavaScriptBuiltins() { return id_count; } |
| 317 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 318 | bool is_initialized() const { return initialized_; } |
| 319 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 320 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 321 | Builtins(); |
| 322 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 323 | // The external C++ functions called from the code. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 324 | static Address const c_functions_[cfunction_count]; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 325 | |
| 326 | // Note: These are always Code objects, but to conform with |
| 327 | // IterateBuiltins() above which assumes Object**'s for the callback |
| 328 | // function f, we use an Object* array here. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 329 | Object* builtins_[builtin_count]; |
| 330 | const char* names_[builtin_count]; |
| 331 | static const char* const javascript_names_[id_count]; |
| 332 | static int const javascript_argc_[id_count]; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 333 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 334 | static void Generate_Adaptor(MacroAssembler* masm, |
| 335 | CFunctionId id, |
| 336 | BuiltinExtraArguments extra_args); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 337 | static void Generate_JSConstructCall(MacroAssembler* masm); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 338 | static void Generate_JSConstructStubCountdown(MacroAssembler* masm); |
ager@chromium.org | 5aa501c | 2009-06-23 07:57:28 +0000 | [diff] [blame] | 339 | static void Generate_JSConstructStubGeneric(MacroAssembler* masm); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 340 | static void Generate_JSConstructStubApi(MacroAssembler* masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 341 | static void Generate_JSEntryTrampoline(MacroAssembler* masm); |
| 342 | static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 343 | static void Generate_LazyCompile(MacroAssembler* masm); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 344 | static void Generate_LazyRecompile(MacroAssembler* masm); |
| 345 | static void Generate_NotifyDeoptimized(MacroAssembler* masm); |
| 346 | static void Generate_NotifyLazyDeoptimized(MacroAssembler* masm); |
| 347 | static void Generate_NotifyOSR(MacroAssembler* masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 348 | static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm); |
kasperl@chromium.org | b912362 | 2008-09-17 14:05:56 +0000 | [diff] [blame] | 349 | |
| 350 | static void Generate_FunctionCall(MacroAssembler* masm); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 351 | static void Generate_FunctionApply(MacroAssembler* masm); |
christian.plesner.hansen@gmail.com | 2bc58ef | 2009-09-22 10:00:30 +0000 | [diff] [blame] | 352 | |
| 353 | static void Generate_ArrayCode(MacroAssembler* masm); |
| 354 | static void Generate_ArrayConstructCode(MacroAssembler* masm); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 355 | |
| 356 | static void Generate_StringConstructCode(MacroAssembler* masm); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 357 | static void Generate_OnStackReplacement(MacroAssembler* masm); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 358 | |
| 359 | static void InitBuiltinFunctionTable(); |
| 360 | |
| 361 | bool initialized_; |
| 362 | |
| 363 | friend class BuiltinFunctionTable; |
| 364 | friend class Isolate; |
| 365 | |
| 366 | DISALLOW_COPY_AND_ASSIGN(Builtins); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 367 | }; |
| 368 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 369 | } } // namespace v8::internal |
| 370 | |
| 371 | #endif // V8_BUILTINS_H_ |