Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: src/builtins/builtins-definitions.h

Issue 2784793002: [builtins] Extract builtin definitions (Closed)
Patch Set: Fixes Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins.h ('k') | src/counters.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_BUILTINS_BUILTINS_H_ 5 #ifndef V8_BUILTINS_BUILTINS_DEFINITIONS_H_
6 #define V8_BUILTINS_BUILTINS_H_ 6 #define V8_BUILTINS_BUILTINS_DEFINITIONS_H_
7
8 #include "src/base/flags.h"
9 #include "src/globals.h"
10 7
11 namespace v8 { 8 namespace v8 {
12 namespace internal { 9 namespace internal {
13 10
14 class Callable;
15 template <typename T>
16 class Handle;
17 class Isolate;
18
19 #define CODE_AGE_LIST_WITH_ARG(V, A) \ 11 #define CODE_AGE_LIST_WITH_ARG(V, A) \
20 V(Quadragenarian, A) \ 12 V(Quadragenarian, A) \
21 V(Quinquagenarian, A) \ 13 V(Quinquagenarian, A) \
22 V(Sexagenarian, A) \ 14 V(Sexagenarian, A) \
23 V(Septuagenarian, A) \ 15 V(Septuagenarian, A) \
24 V(Octogenarian, A) 16 V(Octogenarian, A)
25 17
26 #define CODE_AGE_LIST_IGNORE_ARG(X, V) V(X) 18 #define CODE_AGE_LIST_IGNORE_ARG(X, V) V(X)
27 19
28 #define CODE_AGE_LIST(V) CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V) 20 #define CODE_AGE_LIST(V) CODE_AGE_LIST_WITH_ARG(CODE_AGE_LIST_IGNORE_ARG, V)
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 #define BUILTIN_LIST_A(V) \ 953 #define BUILTIN_LIST_A(V) \
962 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ 954 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \
963 IGNORE_BUILTIN, V, V) 955 IGNORE_BUILTIN, V, V)
964 956
965 #define BUILTIN_LIST_DBG(V) \ 957 #define BUILTIN_LIST_DBG(V) \
966 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \ 958 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, IGNORE_BUILTIN, \
967 IGNORE_BUILTIN, IGNORE_BUILTIN, V) 959 IGNORE_BUILTIN, IGNORE_BUILTIN, V)
968 960
969 #define BUILTINS_WITH_UNTAGGED_PARAMS(V) V(WasmCompileLazy) 961 #define BUILTINS_WITH_UNTAGGED_PARAMS(V) V(WasmCompileLazy)
970 962
971 // Forward declarations.
972 class ObjectVisitor;
973 enum class InterpreterPushArgsMode : unsigned;
974 namespace compiler {
975 class CodeAssemblerState;
976 }
977
978 class Builtins {
979 public:
980 ~Builtins();
981
982 // Generate all builtin code objects. Should be called once during
983 // isolate initialization.
984 void SetUp(Isolate* isolate, bool create_heap_objects);
985 void TearDown();
986
987 // Garbage collection support.
988 void IterateBuiltins(ObjectVisitor* v);
989
990 // Disassembler support.
991 const char* Lookup(byte* pc);
992
993 enum Name : int32_t {
994 #define DEF_ENUM(Name, ...) k##Name,
995 BUILTIN_LIST_ALL(DEF_ENUM)
996 #undef DEF_ENUM
997 builtin_count
998 };
999
1000 #define DECLARE_BUILTIN_ACCESSOR(Name, ...) \
1001 V8_EXPORT_PRIVATE Handle<Code> Name();
1002 BUILTIN_LIST_ALL(DECLARE_BUILTIN_ACCESSOR)
1003 #undef DECLARE_BUILTIN_ACCESSOR
1004
1005 // Convenience wrappers.
1006 Handle<Code> CallFunction(
1007 ConvertReceiverMode = ConvertReceiverMode::kAny,
1008 TailCallMode tail_call_mode = TailCallMode::kDisallow);
1009 Handle<Code> Call(ConvertReceiverMode = ConvertReceiverMode::kAny,
1010 TailCallMode tail_call_mode = TailCallMode::kDisallow);
1011 Handle<Code> CallBoundFunction(TailCallMode tail_call_mode);
1012 Handle<Code> NonPrimitiveToPrimitive(
1013 ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
1014 Handle<Code> OrdinaryToPrimitive(OrdinaryToPrimitiveHint hint);
1015 Handle<Code> InterpreterPushArgsAndCall(TailCallMode tail_call_mode,
1016 InterpreterPushArgsMode mode);
1017 Handle<Code> InterpreterPushArgsAndConstruct(InterpreterPushArgsMode mode);
1018 Handle<Code> NewFunctionContext(ScopeType scope_type);
1019 Handle<Code> NewCloneShallowArray(AllocationSiteMode allocation_mode);
1020 Handle<Code> NewCloneShallowObject(int length);
1021
1022 Code* builtin(Name name) {
1023 // Code::cast cannot be used here since we access builtins
1024 // during the marking phase of mark sweep. See IC::Clear.
1025 return reinterpret_cast<Code*>(builtins_[name]);
1026 }
1027
1028 Address builtin_address(Name name) {
1029 return reinterpret_cast<Address>(&builtins_[name]);
1030 }
1031
1032 static Callable CallableFor(Isolate* isolate, Name name);
1033
1034 static const char* name(int index);
1035
1036 // Returns the C++ entry point for builtins implemented in C++, and the null
1037 // Address otherwise.
1038 static Address CppEntryOf(int index);
1039
1040 static bool IsCpp(int index);
1041 static bool IsApi(int index);
1042 static bool HasCppImplementation(int index);
1043
1044 bool is_initialized() const { return initialized_; }
1045
1046 MUST_USE_RESULT static MaybeHandle<Object> InvokeApiFunction(
1047 Isolate* isolate, bool is_construct, Handle<HeapObject> function,
1048 Handle<Object> receiver, int argc, Handle<Object> args[],
1049 Handle<HeapObject> new_target);
1050
1051 enum ExitFrameType { EXIT, BUILTIN_EXIT };
1052
1053 static void Generate_Adaptor(MacroAssembler* masm, Address builtin_address,
1054 ExitFrameType exit_frame_type);
1055
1056 static bool AllowDynamicFunction(Isolate* isolate, Handle<JSFunction> target,
1057 Handle<JSObject> target_global_proxy);
1058
1059 private:
1060 Builtins();
1061
1062 static void Generate_CallFunction(MacroAssembler* masm,
1063 ConvertReceiverMode mode,
1064 TailCallMode tail_call_mode);
1065
1066 static void Generate_CallBoundFunctionImpl(MacroAssembler* masm,
1067 TailCallMode tail_call_mode);
1068
1069 static void Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode,
1070 TailCallMode tail_call_mode);
1071 static void Generate_CallForwardVarargs(MacroAssembler* masm,
1072 Handle<Code> code);
1073
1074 static void Generate_InterpreterPushArgsAndCallImpl(
1075 MacroAssembler* masm, TailCallMode tail_call_mode,
1076 InterpreterPushArgsMode mode);
1077
1078 static void Generate_InterpreterPushArgsAndConstructImpl(
1079 MacroAssembler* masm, InterpreterPushArgsMode mode);
1080
1081 #define DECLARE_ASM(Name, ...) \
1082 static void Generate_##Name(MacroAssembler* masm);
1083 #define DECLARE_TF(Name, ...) \
1084 static void Generate_##Name(compiler::CodeAssemblerState* state);
1085
1086 BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TF, DECLARE_TF,
1087 DECLARE_TF, DECLARE_ASM, DECLARE_ASM)
1088
1089 #undef DECLARE_ASM
1090 #undef DECLARE_TF
1091
1092 // Note: These are always Code objects, but to conform with
1093 // IterateBuiltins() above which assumes Object**'s for the callback
1094 // function f, we use an Object* array here.
1095 Object* builtins_[builtin_count];
1096 bool initialized_;
1097
1098 friend class Isolate;
1099
1100 DISALLOW_COPY_AND_ASSIGN(Builtins);
1101 };
1102
1103 } // namespace internal 963 } // namespace internal
1104 } // namespace v8 964 } // namespace v8
1105 965
1106 #endif // V8_BUILTINS_BUILTINS_H_ 966 #endif // V8_BUILTINS_BUILTINS_DEFINITIONS_H_
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698