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