1
1
#include " env-inl.h"
2
2
#include " node.h"
3
+ #include " node_debug.h"
3
4
#include " node_external_reference.h"
4
5
6
+ using v8::CFunction;
5
7
using v8::Context;
6
8
using v8::FunctionCallbackInfo;
7
9
using v8::Local;
@@ -36,22 +38,35 @@ namespace {
36
38
V (DataView) \
37
39
V (SharedArrayBuffer) \
38
40
V (Proxy) \
39
- V (ModuleNamespaceObject) \
41
+ V (ModuleNamespaceObject)
40
42
43
+ #define V (type ) \
44
+ static void Is##type(const FunctionCallbackInfo<Value>& args) { \
45
+ args.GetReturnValue ().Set (args[0 ]->Is ##type ()); \
46
+ } \
47
+ static bool Is##type##FastApi(Local<Value> unused, Local<Value> receiver) { \
48
+ TRACK_V8_FAST_API_CALL (" types.isMethod.macro" ); \
49
+ return receiver->Is ##type (); \
50
+ } \
51
+ static CFunction fast_is_##type##_ = CFunction::Make(Is##type##FastApi);
41
52
42
- #define V (type ) \
43
- static void Is##type(const FunctionCallbackInfo<Value>& args) { \
44
- args.GetReturnValue ().Set (args[0 ]->Is ##type ()); \
45
- }
46
-
47
- VALUE_METHOD_MAP (V)
53
+ VALUE_METHOD_MAP (V)
48
54
#undef V
49
55
50
56
static void IsAnyArrayBuffer (const FunctionCallbackInfo<Value>& args) {
51
57
args.GetReturnValue ().Set (
52
58
args[0 ]->IsArrayBuffer () || args[0 ]->IsSharedArrayBuffer ());
53
59
}
54
60
61
+ static bool IsAnyArrayBufferFastApi (Local<Value> unused,
62
+ Local<Value> receiver) {
63
+ TRACK_V8_FAST_API_CALL (" types.isAnyArrayBuffer" );
64
+ return receiver->IsArrayBuffer () || receiver->IsSharedArrayBuffer ();
65
+ }
66
+
67
+ static CFunction fast_is_any_array_buffer_ =
68
+ CFunction::Make (IsAnyArrayBufferFastApi);
69
+
55
70
static void IsBoxedPrimitive (const FunctionCallbackInfo<Value>& args) {
56
71
args.GetReturnValue ().Set (
57
72
args[0 ]->IsNumberObject () ||
@@ -61,27 +76,57 @@ static void IsBoxedPrimitive(const FunctionCallbackInfo<Value>& args) {
61
76
args[0 ]->IsSymbolObject ());
62
77
}
63
78
79
+ static bool IsBoxedPrimitiveFastApi (Local<Value> unused,
80
+ Local<Value> receiver) {
81
+ TRACK_V8_FAST_API_CALL (" types.isBoxedPrimitive" );
82
+ return receiver->IsNumberObject () || receiver->IsStringObject () ||
83
+ receiver->IsBooleanObject () || receiver->IsBigIntObject () ||
84
+ receiver->IsSymbolObject ();
85
+ }
86
+
87
+ static CFunction fast_is_boxed_primitive_ =
88
+ CFunction::Make (IsBoxedPrimitiveFastApi);
89
+
64
90
void InitializeTypes (Local<Object> target,
65
91
Local<Value> unused,
66
92
Local<Context> context,
67
93
void * priv) {
68
- #define V (type ) SetMethodNoSideEffect(context, target, " is" #type, Is##type);
94
+ #define V (type ) \
95
+ SetFastMethodNoSideEffect ( \
96
+ context, target, " is" #type, Is##type, &fast_is_##type##_);
97
+
69
98
VALUE_METHOD_MAP (V)
70
99
#undef V
71
100
72
- SetMethodNoSideEffect (context, target, " isAnyArrayBuffer" , IsAnyArrayBuffer);
73
- SetMethodNoSideEffect (context, target, " isBoxedPrimitive" , IsBoxedPrimitive);
101
+ SetFastMethodNoSideEffect (context,
102
+ target,
103
+ " isAnyArrayBuffer" ,
104
+ IsAnyArrayBuffer,
105
+ &fast_is_any_array_buffer_);
106
+ SetFastMethodNoSideEffect (context,
107
+ target,
108
+ " isBoxedPrimitive" ,
109
+ IsBoxedPrimitive,
110
+ &fast_is_boxed_primitive_);
74
111
}
75
112
76
113
} // anonymous namespace
77
114
78
115
void RegisterTypesExternalReferences (ExternalReferenceRegistry* registry) {
79
- #define V (type ) registry->Register (Is##type);
116
+ #define V (type ) \
117
+ registry->Register (Is##type); \
118
+ registry->Register (Is##type##FastApi); \
119
+ registry->Register (fast_is_##type##_.GetTypeInfo ());
120
+
80
121
VALUE_METHOD_MAP (V)
81
122
#undef V
82
123
83
124
registry->Register (IsAnyArrayBuffer);
125
+ registry->Register (IsAnyArrayBufferFastApi);
126
+ registry->Register (fast_is_any_array_buffer_.GetTypeInfo ());
84
127
registry->Register (IsBoxedPrimitive);
128
+ registry->Register (IsBoxedPrimitiveFastApi);
129
+ registry->Register (fast_is_boxed_primitive_.GetTypeInfo ());
85
130
}
86
131
} // namespace node
87
132
0 commit comments