| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_BUILTINS_H_ | 28 #ifndef V8_BUILTINS_H_ |
| 29 #define V8_BUILTINS_H_ | 29 #define V8_BUILTINS_H_ |
| 30 | 30 |
| 31 namespace v8 { | 31 namespace v8 { |
| 32 namespace internal { | 32 namespace internal { |
| 33 | 33 |
| 34 // Define list of builtins implemented in C. | 34 // Specifies extra arguments required by a C++ builtin. |
| 35 #define BUILTIN_LIST_C(V) \ | 35 enum BuiltinExtraArguments { |
| 36 V(Illegal) \ | 36 NO_EXTRA_ARGUMENTS = 0, |
| 37 \ | 37 NEEDS_CALLED_FUNCTION = 1 |
| 38 V(EmptyFunction) \ | 38 }; |
| 39 \ | 39 |
| 40 V(ArrayCodeGeneric) \ | 40 |
| 41 \ | 41 // Define list of builtins implemented in C++. |
| 42 V(ArrayPush) \ | 42 #define BUILTIN_LIST_C(V) \ |
| 43 V(ArrayPop) \ | 43 V(Illegal, NO_EXTRA_ARGUMENTS) \ |
| 44 \ | 44 \ |
| 45 V(HandleApiCall) \ | 45 V(EmptyFunction, NO_EXTRA_ARGUMENTS) \ |
| 46 V(HandleApiCallAsFunction) \ | 46 \ |
| 47 V(HandleApiCallAsConstructor) | 47 V(ArrayCodeGeneric, NO_EXTRA_ARGUMENTS) \ |
| 48 \ |
| 49 V(ArrayPush, NO_EXTRA_ARGUMENTS) \ |
| 50 V(ArrayPop, NO_EXTRA_ARGUMENTS) \ |
| 51 \ |
| 52 V(HandleApiCall, NEEDS_CALLED_FUNCTION) \ |
| 53 V(HandleApiCallConstruct, NEEDS_CALLED_FUNCTION) \ |
| 54 V(HandleApiCallAsFunction, NO_EXTRA_ARGUMENTS) \ |
| 55 V(HandleApiCallAsConstructor, NO_EXTRA_ARGUMENTS) |
| 48 | 56 |
| 49 | 57 |
| 50 // Define list of builtins implemented in assembly. | 58 // Define list of builtins implemented in assembly. |
| 51 #define BUILTIN_LIST_A(V) \ | 59 #define BUILTIN_LIST_A(V) \ |
| 52 V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED) \ | 60 V(ArgumentsAdaptorTrampoline, BUILTIN, UNINITIALIZED) \ |
| 53 V(JSConstructCall, BUILTIN, UNINITIALIZED) \ | 61 V(JSConstructCall, BUILTIN, UNINITIALIZED) \ |
| 54 V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED) \ | 62 V(JSConstructStubGeneric, BUILTIN, UNINITIALIZED) \ |
| 63 V(JSConstructStubApi, BUILTIN, UNINITIALIZED) \ |
| 55 V(JSEntryTrampoline, BUILTIN, UNINITIALIZED) \ | 64 V(JSEntryTrampoline, BUILTIN, UNINITIALIZED) \ |
| 56 V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED) \ | 65 V(JSConstructEntryTrampoline, BUILTIN, UNINITIALIZED) \ |
| 57 \ | 66 \ |
| 58 V(LoadIC_Miss, BUILTIN, UNINITIALIZED) \ | 67 V(LoadIC_Miss, BUILTIN, UNINITIALIZED) \ |
| 59 V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED) \ | 68 V(KeyedLoadIC_Miss, BUILTIN, UNINITIALIZED) \ |
| 60 V(StoreIC_Miss, BUILTIN, UNINITIALIZED) \ | 69 V(StoreIC_Miss, BUILTIN, UNINITIALIZED) \ |
| 61 V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED) \ | 70 V(KeyedStoreIC_Miss, BUILTIN, UNINITIALIZED) \ |
| 62 \ | 71 \ |
| 63 V(StoreIC_ExtendStorage, BUILTIN, UNINITIALIZED) \ | 72 V(StoreIC_ExtendStorage, BUILTIN, UNINITIALIZED) \ |
| 64 V(KeyedStoreIC_ExtendStorage, BUILTIN, UNINITIALIZED) \ | 73 V(KeyedStoreIC_ExtendStorage, BUILTIN, UNINITIALIZED) \ |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 static void Setup(bool create_heap_objects); | 171 static void Setup(bool create_heap_objects); |
| 163 static void TearDown(); | 172 static void TearDown(); |
| 164 | 173 |
| 165 // Garbage collection support. | 174 // Garbage collection support. |
| 166 static void IterateBuiltins(ObjectVisitor* v); | 175 static void IterateBuiltins(ObjectVisitor* v); |
| 167 | 176 |
| 168 // Disassembler support. | 177 // Disassembler support. |
| 169 static const char* Lookup(byte* pc); | 178 static const char* Lookup(byte* pc); |
| 170 | 179 |
| 171 enum Name { | 180 enum Name { |
| 172 #define DEF_ENUM_C(name) name, | 181 #define DEF_ENUM_C(name, ignore) name, |
| 173 #define DEF_ENUM_A(name, kind, state) name, | 182 #define DEF_ENUM_A(name, kind, state) name, |
| 174 BUILTIN_LIST_C(DEF_ENUM_C) | 183 BUILTIN_LIST_C(DEF_ENUM_C) |
| 175 BUILTIN_LIST_A(DEF_ENUM_A) | 184 BUILTIN_LIST_A(DEF_ENUM_A) |
| 176 BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) | 185 BUILTIN_LIST_DEBUG_A(DEF_ENUM_A) |
| 177 #undef DEF_ENUM_C | 186 #undef DEF_ENUM_C |
| 178 #undef DEF_ENUM_A | 187 #undef DEF_ENUM_A |
| 179 builtin_count | 188 builtin_count |
| 180 }; | 189 }; |
| 181 | 190 |
| 182 enum CFunctionId { | 191 enum CFunctionId { |
| 183 #define DEF_ENUM_C(name) c_##name, | 192 #define DEF_ENUM_C(name, ignore) c_##name, |
| 184 BUILTIN_LIST_C(DEF_ENUM_C) | 193 BUILTIN_LIST_C(DEF_ENUM_C) |
| 185 #undef DEF_ENUM_C | 194 #undef DEF_ENUM_C |
| 186 cfunction_count | 195 cfunction_count |
| 187 }; | 196 }; |
| 188 | 197 |
| 189 enum JavaScript { | 198 enum JavaScript { |
| 190 #define DEF_ENUM(name, ignore) name, | 199 #define DEF_ENUM(name, ignore) name, |
| 191 BUILTINS_LIST_JS(DEF_ENUM) | 200 BUILTINS_LIST_JS(DEF_ENUM) |
| 192 #undef DEF_ENUM | 201 #undef DEF_ENUM |
| 193 id_count | 202 id_count |
| (...skipping 11 matching lines...) Expand all Loading... |
| 205 | 214 |
| 206 static Address c_function_address(CFunctionId id) { | 215 static Address c_function_address(CFunctionId id) { |
| 207 return c_functions_[id]; | 216 return c_functions_[id]; |
| 208 } | 217 } |
| 209 | 218 |
| 210 static const char* GetName(JavaScript id) { return javascript_names_[id]; } | 219 static const char* GetName(JavaScript id) { return javascript_names_[id]; } |
| 211 static int GetArgumentsCount(JavaScript id) { return javascript_argc_[id]; } | 220 static int GetArgumentsCount(JavaScript id) { return javascript_argc_[id]; } |
| 212 static Handle<Code> GetCode(JavaScript id, bool* resolved); | 221 static Handle<Code> GetCode(JavaScript id, bool* resolved); |
| 213 static int NumberOfJavaScriptBuiltins() { return id_count; } | 222 static int NumberOfJavaScriptBuiltins() { return id_count; } |
| 214 | 223 |
| 215 static Object* builtin_passed_function; | |
| 216 | |
| 217 private: | 224 private: |
| 218 // The external C++ functions called from the code. | 225 // The external C++ functions called from the code. |
| 219 static Address c_functions_[cfunction_count]; | 226 static Address c_functions_[cfunction_count]; |
| 220 | 227 |
| 221 // Note: These are always Code objects, but to conform with | 228 // Note: These are always Code objects, but to conform with |
| 222 // IterateBuiltins() above which assumes Object**'s for the callback | 229 // IterateBuiltins() above which assumes Object**'s for the callback |
| 223 // function f, we use an Object* array here. | 230 // function f, we use an Object* array here. |
| 224 static Object* builtins_[builtin_count]; | 231 static Object* builtins_[builtin_count]; |
| 225 static const char* names_[builtin_count]; | 232 static const char* names_[builtin_count]; |
| 226 static const char* javascript_names_[id_count]; | 233 static const char* javascript_names_[id_count]; |
| 227 static int javascript_argc_[id_count]; | 234 static int javascript_argc_[id_count]; |
| 228 | 235 |
| 229 static void Generate_Adaptor(MacroAssembler* masm, CFunctionId id); | 236 static void Generate_Adaptor(MacroAssembler* masm, |
| 237 CFunctionId id, |
| 238 BuiltinExtraArguments extra_args); |
| 230 static void Generate_JSConstructCall(MacroAssembler* masm); | 239 static void Generate_JSConstructCall(MacroAssembler* masm); |
| 231 static void Generate_JSConstructStubGeneric(MacroAssembler* masm); | 240 static void Generate_JSConstructStubGeneric(MacroAssembler* masm); |
| 241 static void Generate_JSConstructStubApi(MacroAssembler* masm); |
| 232 static void Generate_JSEntryTrampoline(MacroAssembler* masm); | 242 static void Generate_JSEntryTrampoline(MacroAssembler* masm); |
| 233 static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm); | 243 static void Generate_JSConstructEntryTrampoline(MacroAssembler* masm); |
| 234 static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm); | 244 static void Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm); |
| 235 | 245 |
| 236 static void Generate_FunctionCall(MacroAssembler* masm); | 246 static void Generate_FunctionCall(MacroAssembler* masm); |
| 237 static void Generate_FunctionApply(MacroAssembler* masm); | 247 static void Generate_FunctionApply(MacroAssembler* masm); |
| 238 | 248 |
| 239 static void Generate_ArrayCode(MacroAssembler* masm); | 249 static void Generate_ArrayCode(MacroAssembler* masm); |
| 240 static void Generate_ArrayConstructCode(MacroAssembler* masm); | 250 static void Generate_ArrayConstructCode(MacroAssembler* masm); |
| 241 }; | 251 }; |
| 242 | 252 |
| 243 } } // namespace v8::internal | 253 } } // namespace v8::internal |
| 244 | 254 |
| 245 #endif // V8_BUILTINS_H_ | 255 #endif // V8_BUILTINS_H_ |
| OLD | NEW |