OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 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 #include "src/api-arguments.h" | 5 #include "src/api-arguments.h" |
6 | 6 |
7 #include "src/tracing/trace-event.h" | 7 #include "src/tracing/trace-event.h" |
8 #include "src/vm-state-inl.h" | 8 #include "src/vm-state-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(F) \ | 13 #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(F) \ |
14 F(AccessorNameGetterCallback, "get", v8::Value, Object) \ | 14 F(AccessorNameGetterCallback, "get", v8::Value, Object) \ |
15 F(GenericNamedPropertyQueryCallback, "has", v8::Integer, Object) \ | 15 F(GenericNamedPropertyQueryCallback, "has", v8::Integer, Object) \ |
16 F(GenericNamedPropertyDeleterCallback, "delete", v8::Boolean, Object) | 16 F(GenericNamedPropertyDeleterCallback, "delete", v8::Boolean, Object) |
17 | 17 |
18 #define WRITE_CALL_1_NAME(Function, type, ApiReturn, InternalReturn) \ | 18 #define WRITE_CALL_1_NAME(Function, type, ApiReturn, InternalReturn) \ |
19 Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \ | 19 Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \ |
20 Handle<Name> name) { \ | 20 Handle<Name> name) { \ |
21 Isolate* isolate = this->isolate(); \ | 21 Isolate* isolate = this->isolate(); \ |
22 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \ | 22 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \ |
23 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( \ | |
24 isolate, &tracing::TraceEventStatsTable::Function); \ | |
25 VMState<EXTERNAL> state(isolate); \ | 23 VMState<EXTERNAL> state(isolate); \ |
26 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ | 24 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ |
27 PropertyCallbackInfo<ApiReturn> info(begin()); \ | 25 PropertyCallbackInfo<ApiReturn> info(begin()); \ |
28 LOG(isolate, \ | 26 LOG(isolate, \ |
29 ApiNamedPropertyAccess("interceptor-named-" type, holder(), *name)); \ | 27 ApiNamedPropertyAccess("interceptor-named-" type, holder(), *name)); \ |
30 f(v8::Utils::ToLocal(name), info); \ | 28 f(v8::Utils::ToLocal(name), info); \ |
31 return GetReturnValue<InternalReturn>(isolate); \ | 29 return GetReturnValue<InternalReturn>(isolate); \ |
32 } | 30 } |
33 | 31 |
34 FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(WRITE_CALL_1_NAME) | 32 FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(WRITE_CALL_1_NAME) |
35 | 33 |
36 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME | 34 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME |
37 #undef WRITE_CALL_1_NAME | 35 #undef WRITE_CALL_1_NAME |
38 | 36 |
39 #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(F) \ | 37 #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(F) \ |
40 F(IndexedPropertyGetterCallback, "get", v8::Value, Object) \ | 38 F(IndexedPropertyGetterCallback, "get", v8::Value, Object) \ |
41 F(IndexedPropertyQueryCallback, "has", v8::Integer, Object) \ | 39 F(IndexedPropertyQueryCallback, "has", v8::Integer, Object) \ |
42 F(IndexedPropertyDeleterCallback, "delete", v8::Boolean, Object) | 40 F(IndexedPropertyDeleterCallback, "delete", v8::Boolean, Object) |
43 | 41 |
44 #define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \ | 42 #define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \ |
45 Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \ | 43 Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \ |
46 uint32_t index) { \ | 44 uint32_t index) { \ |
47 Isolate* isolate = this->isolate(); \ | 45 Isolate* isolate = this->isolate(); \ |
48 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \ | 46 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \ |
49 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( \ | |
50 isolate, &tracing::TraceEventStatsTable::Function); \ | |
51 VMState<EXTERNAL> state(isolate); \ | 47 VMState<EXTERNAL> state(isolate); \ |
52 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ | 48 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ |
53 PropertyCallbackInfo<ApiReturn> info(begin()); \ | 49 PropertyCallbackInfo<ApiReturn> info(begin()); \ |
54 LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \ | 50 LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \ |
55 holder(), index)); \ | 51 holder(), index)); \ |
56 f(index, info); \ | 52 f(index, info); \ |
57 return GetReturnValue<InternalReturn>(isolate); \ | 53 return GetReturnValue<InternalReturn>(isolate); \ |
58 } | 54 } |
59 | 55 |
60 FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(WRITE_CALL_1_INDEX) | 56 FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(WRITE_CALL_1_INDEX) |
61 | 57 |
62 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX | 58 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX |
63 #undef WRITE_CALL_1_INDEX | 59 #undef WRITE_CALL_1_INDEX |
64 | 60 |
65 Handle<Object> PropertyCallbackArguments::Call( | 61 Handle<Object> PropertyCallbackArguments::Call( |
66 GenericNamedPropertySetterCallback f, Handle<Name> name, | 62 GenericNamedPropertySetterCallback f, Handle<Name> name, |
67 Handle<Object> value) { | 63 Handle<Object> value) { |
68 Isolate* isolate = this->isolate(); | 64 Isolate* isolate = this->isolate(); |
69 RuntimeCallTimerScope timer( | 65 RuntimeCallTimerScope timer( |
70 isolate, &RuntimeCallStats::GenericNamedPropertySetterCallback); | 66 isolate, &RuntimeCallStats::GenericNamedPropertySetterCallback); |
71 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
72 isolate, | |
73 &tracing::TraceEventStatsTable::GenericNamedPropertySetterCallback); | |
74 VMState<EXTERNAL> state(isolate); | 67 VMState<EXTERNAL> state(isolate); |
75 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 68 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
76 PropertyCallbackInfo<v8::Value> info(begin()); | 69 PropertyCallbackInfo<v8::Value> info(begin()); |
77 LOG(isolate, | 70 LOG(isolate, |
78 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); | 71 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); |
79 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); | 72 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
80 return GetReturnValue<Object>(isolate); | 73 return GetReturnValue<Object>(isolate); |
81 } | 74 } |
82 | 75 |
83 Handle<Object> PropertyCallbackArguments::Call(IndexedPropertySetterCallback f, | 76 Handle<Object> PropertyCallbackArguments::Call(IndexedPropertySetterCallback f, |
84 uint32_t index, | 77 uint32_t index, |
85 Handle<Object> value) { | 78 Handle<Object> value) { |
86 Isolate* isolate = this->isolate(); | 79 Isolate* isolate = this->isolate(); |
87 RuntimeCallTimerScope timer(isolate, | 80 RuntimeCallTimerScope timer(isolate, |
88 &RuntimeCallStats::IndexedPropertySetterCallback); | 81 &RuntimeCallStats::IndexedPropertySetterCallback); |
89 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
90 isolate, &tracing::TraceEventStatsTable::IndexedPropertySetterCallback); | |
91 VMState<EXTERNAL> state(isolate); | 82 VMState<EXTERNAL> state(isolate); |
92 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 83 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
93 PropertyCallbackInfo<v8::Value> info(begin()); | 84 PropertyCallbackInfo<v8::Value> info(begin()); |
94 LOG(isolate, | 85 LOG(isolate, |
95 ApiIndexedPropertyAccess("interceptor-indexed-set", holder(), index)); | 86 ApiIndexedPropertyAccess("interceptor-indexed-set", holder(), index)); |
96 f(index, v8::Utils::ToLocal(value), info); | 87 f(index, v8::Utils::ToLocal(value), info); |
97 return GetReturnValue<Object>(isolate); | 88 return GetReturnValue<Object>(isolate); |
98 } | 89 } |
99 | 90 |
100 void PropertyCallbackArguments::Call(AccessorNameSetterCallback f, | 91 void PropertyCallbackArguments::Call(AccessorNameSetterCallback f, |
101 Handle<Name> name, Handle<Object> value) { | 92 Handle<Name> name, Handle<Object> value) { |
102 Isolate* isolate = this->isolate(); | 93 Isolate* isolate = this->isolate(); |
103 RuntimeCallTimerScope timer(isolate, | 94 RuntimeCallTimerScope timer(isolate, |
104 &RuntimeCallStats::AccessorNameSetterCallback); | 95 &RuntimeCallStats::AccessorNameSetterCallback); |
105 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( | |
106 isolate, &tracing::TraceEventStatsTable::AccessorNameSetterCallback); | |
107 VMState<EXTERNAL> state(isolate); | 96 VMState<EXTERNAL> state(isolate); |
108 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 97 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
109 PropertyCallbackInfo<void> info(begin()); | 98 PropertyCallbackInfo<void> info(begin()); |
110 LOG(isolate, | 99 LOG(isolate, |
111 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); | 100 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); |
112 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); | 101 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
113 } | 102 } |
114 | 103 |
115 } // namespace internal | 104 } // namespace internal |
116 } // namespace v8 | 105 } // namespace v8 |
OLD | NEW |