Chromium Code Reviews

Unified Diff: src/builtins/builtins-utils.h

Issue 2517833005: [cleanup] Refactor builtins-number.cc (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « src/builtins/builtins-number.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-utils.h
diff --git a/src/builtins/builtins-utils.h b/src/builtins/builtins-utils.h
index 6378fdfad5d3413b8d826ae5bb6ccde2e9b05955..b56094a8f3da72124e83acd6235dfbfe33990ed1 100644
--- a/src/builtins/builtins-utils.h
+++ b/src/builtins/builtins-utils.h
@@ -102,6 +102,31 @@ class BuiltinArguments : public Arguments {
Isolate* isolate)
// ----------------------------------------------------------------------------
+// Support macro for defining builtins with Turbofan.
+// ----------------------------------------------------------------------------
+//
+// A builtin function is defined by writing:
+//
+// TF_BUILTIN(name, code_assember_base_class) {
+// ...
+// }
+//
+// In the body of the builtin function the arguments can be accessed
+// through the (inherited) CodeAssembler::Parameter() function.
Igor Sheludko 2016/11/22 18:25:20 I'm sorry, I don't follow.
+#define TF_BUILTIN(Name, AssemblerBase) \
+ class Name##Assembler : public AssemblerBase { \
+ public: \
+ explicit Name##Assembler(compiler::CodeAssemblerState* state) \
+ : AssemblerBase(state) {} \
+ void Generate##Name(); \
+ }; \
+ void Builtins::Generate_##Name(compiler::CodeAssemblerState* state) { \
+ Name##Assembler assembler(state); \
+ assembler.Generate##Name(); \
+ } \
+ void Name##Assembler::Generate##Name()
+
+// ----------------------------------------------------------------------------
#define CHECK_RECEIVER(Type, name, method) \
if (!args.receiver()->Is##Type()) { \
« no previous file with comments | « src/builtins/builtins-number.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine