Line data Source code
1 : // Copyright 2016 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_API_ARGUMENTS_INL_H_
6 : #define V8_API_ARGUMENTS_INL_H_
7 :
8 : #include "src/api-arguments.h"
9 :
10 : #include "src/tracing/trace-event.h"
11 : #include "src/vm-state-inl.h"
12 :
13 : namespace v8 {
14 : namespace internal {
15 :
16 : #define SIDE_EFFECT_CHECK(ISOLATE, F, RETURN_TYPE) \
17 : do { \
18 : if (ISOLATE->needs_side_effect_check() && \
19 : !PerformSideEffectCheck(ISOLATE, FUNCTION_ADDR(F))) { \
20 : return Handle<RETURN_TYPE>(); \
21 : } \
22 : } while (false)
23 :
24 : #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(F) \
25 : F(AccessorNameGetterCallback, "get", v8::Value, Object) \
26 : F(GenericNamedPropertyQueryCallback, "has", v8::Integer, Object) \
27 : F(GenericNamedPropertyDeleterCallback, "delete", v8::Boolean, Object)
28 :
29 : #define WRITE_CALL_1_NAME(Function, type, ApiReturn, InternalReturn) \
30 : Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \
31 : Handle<Name> name) { \
32 : Isolate* isolate = this->isolate(); \
33 : SIDE_EFFECT_CHECK(isolate, f, InternalReturn); \
34 : RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \
35 : VMState<EXTERNAL> state(isolate); \
36 : ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
37 : PropertyCallbackInfo<ApiReturn> info(begin()); \
38 : LOG(isolate, \
39 : ApiNamedPropertyAccess("interceptor-named-" type, holder(), *name)); \
40 : f(v8::Utils::ToLocal(name), info); \
41 : return GetReturnValue<InternalReturn>(isolate); \
42 : }
43 :
44 2581994 : FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(WRITE_CALL_1_NAME)
45 :
46 : #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME
47 : #undef WRITE_CALL_1_NAME
48 :
49 : #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(F) \
50 : F(IndexedPropertyGetterCallback, "get", v8::Value, Object) \
51 : F(IndexedPropertyQueryCallback, "has", v8::Integer, Object) \
52 : F(IndexedPropertyDeleterCallback, "delete", v8::Boolean, Object)
53 :
54 : #define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \
55 : Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \
56 : uint32_t index) { \
57 : Isolate* isolate = this->isolate(); \
58 : SIDE_EFFECT_CHECK(isolate, f, InternalReturn); \
59 : RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \
60 : VMState<EXTERNAL> state(isolate); \
61 : ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \
62 : PropertyCallbackInfo<ApiReturn> info(begin()); \
63 : LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \
64 : holder(), index)); \
65 : f(index, info); \
66 : return GetReturnValue<InternalReturn>(isolate); \
67 : }
68 :
69 735840 : FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(WRITE_CALL_1_INDEX)
70 :
71 : #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX
72 : #undef WRITE_CALL_1_INDEX
73 :
74 1015657 : Handle<Object> PropertyCallbackArguments::Call(
75 : GenericNamedPropertySetterCallback f, Handle<Name> name,
76 : Handle<Object> value) {
77 2031314 : Isolate* isolate = this->isolate();
78 1015657 : SIDE_EFFECT_CHECK(isolate, f, Object);
79 : RuntimeCallTimerScope timer(
80 1015657 : isolate, &RuntimeCallStats::GenericNamedPropertySetterCallback);
81 2031314 : VMState<EXTERNAL> state(isolate);
82 2031314 : ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
83 1015657 : PropertyCallbackInfo<v8::Value> info(begin());
84 1015657 : LOG(isolate,
85 : ApiNamedPropertyAccess("interceptor-named-set", holder(), *name));
86 1015657 : f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info);
87 1015657 : return GetReturnValue<Object>(isolate);
88 : }
89 :
90 59 : Handle<Object> PropertyCallbackArguments::Call(
91 : GenericNamedPropertyDefinerCallback f, Handle<Name> name,
92 : const v8::PropertyDescriptor& desc) {
93 118 : Isolate* isolate = this->isolate();
94 59 : SIDE_EFFECT_CHECK(isolate, f, Object);
95 : RuntimeCallTimerScope timer(
96 59 : isolate, &RuntimeCallStats::GenericNamedPropertyDefinerCallback);
97 118 : VMState<EXTERNAL> state(isolate);
98 118 : ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
99 59 : PropertyCallbackInfo<v8::Value> info(begin());
100 59 : LOG(isolate,
101 : ApiNamedPropertyAccess("interceptor-named-define", holder(), *name));
102 59 : f(v8::Utils::ToLocal(name), desc, info);
103 59 : return GetReturnValue<Object>(isolate);
104 : }
105 :
106 65668 : Handle<Object> PropertyCallbackArguments::Call(IndexedPropertySetterCallback f,
107 : uint32_t index,
108 : Handle<Object> value) {
109 131336 : Isolate* isolate = this->isolate();
110 65668 : SIDE_EFFECT_CHECK(isolate, f, Object);
111 : RuntimeCallTimerScope timer(isolate,
112 65668 : &RuntimeCallStats::IndexedPropertySetterCallback);
113 131336 : VMState<EXTERNAL> state(isolate);
114 131336 : ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
115 65668 : PropertyCallbackInfo<v8::Value> info(begin());
116 65668 : LOG(isolate,
117 : ApiIndexedPropertyAccess("interceptor-indexed-set", holder(), index));
118 65668 : f(index, v8::Utils::ToLocal(value), info);
119 65668 : return GetReturnValue<Object>(isolate);
120 : }
121 :
122 23 : Handle<Object> PropertyCallbackArguments::Call(
123 : IndexedPropertyDefinerCallback f, uint32_t index,
124 : const v8::PropertyDescriptor& desc) {
125 46 : Isolate* isolate = this->isolate();
126 23 : SIDE_EFFECT_CHECK(isolate, f, Object);
127 : RuntimeCallTimerScope timer(
128 23 : isolate, &RuntimeCallStats::IndexedPropertyDefinerCallback);
129 46 : VMState<EXTERNAL> state(isolate);
130 46 : ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
131 23 : PropertyCallbackInfo<v8::Value> info(begin());
132 23 : LOG(isolate,
133 : ApiIndexedPropertyAccess("interceptor-indexed-define", holder(), index));
134 23 : f(index, desc, info);
135 23 : return GetReturnValue<Object>(isolate);
136 : }
137 :
138 634477 : void PropertyCallbackArguments::Call(AccessorNameSetterCallback f,
139 : Handle<Name> name, Handle<Object> value) {
140 1268954 : Isolate* isolate = this->isolate();
141 634477 : if (isolate->needs_side_effect_check() &&
142 0 : !PerformSideEffectCheck(isolate, FUNCTION_ADDR(f))) {
143 0 : return;
144 : }
145 : RuntimeCallTimerScope timer(isolate,
146 634477 : &RuntimeCallStats::AccessorNameSetterCallback);
147 1268954 : VMState<EXTERNAL> state(isolate);
148 1268954 : ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f));
149 634477 : PropertyCallbackInfo<void> info(begin());
150 634477 : LOG(isolate,
151 : ApiNamedPropertyAccess("interceptor-named-set", holder(), *name));
152 634477 : f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info);
153 : }
154 :
155 : #undef SIDE_EFFECT_CHECK
156 :
157 : } // namespace internal
158 : } // namespace v8
159 :
160 : #endif // V8_API_ARGUMENTS_INL_H_
|