| 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); \ |
| 23 VMState<EXTERNAL> state(isolate); \ | 25 VMState<EXTERNAL> state(isolate); \ |
| 24 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ | 26 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ |
| 25 PropertyCallbackInfo<ApiReturn> info(begin()); \ | 27 PropertyCallbackInfo<ApiReturn> info(begin()); \ |
| 26 LOG(isolate, \ | 28 LOG(isolate, \ |
| 27 ApiNamedPropertyAccess("interceptor-named-" type, holder(), *name)); \ | 29 ApiNamedPropertyAccess("interceptor-named-" type, holder(), *name)); \ |
| 28 f(v8::Utils::ToLocal(name), info); \ | 30 f(v8::Utils::ToLocal(name), info); \ |
| 29 return GetReturnValue<InternalReturn>(isolate); \ | 31 return GetReturnValue<InternalReturn>(isolate); \ |
| 30 } | 32 } |
| 31 | 33 |
| 32 FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(WRITE_CALL_1_NAME) | 34 FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(WRITE_CALL_1_NAME) |
| 33 | 35 |
| 34 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME | 36 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME |
| 35 #undef WRITE_CALL_1_NAME | 37 #undef WRITE_CALL_1_NAME |
| 36 | 38 |
| 37 #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(F) \ | 39 #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(F) \ |
| 38 F(IndexedPropertyGetterCallback, "get", v8::Value, Object) \ | 40 F(IndexedPropertyGetterCallback, "get", v8::Value, Object) \ |
| 39 F(IndexedPropertyQueryCallback, "has", v8::Integer, Object) \ | 41 F(IndexedPropertyQueryCallback, "has", v8::Integer, Object) \ |
| 40 F(IndexedPropertyDeleterCallback, "delete", v8::Boolean, Object) | 42 F(IndexedPropertyDeleterCallback, "delete", v8::Boolean, Object) |
| 41 | 43 |
| 42 #define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \ | 44 #define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \ |
| 43 Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \ | 45 Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \ |
| 44 uint32_t index) { \ | 46 uint32_t index) { \ |
| 45 Isolate* isolate = this->isolate(); \ | 47 Isolate* isolate = this->isolate(); \ |
| 46 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \ | 48 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \ |
| 49 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( \ |
| 50 isolate, &tracing::TraceEventStatsTable::Function); \ |
| 47 VMState<EXTERNAL> state(isolate); \ | 51 VMState<EXTERNAL> state(isolate); \ |
| 48 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ | 52 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ |
| 49 PropertyCallbackInfo<ApiReturn> info(begin()); \ | 53 PropertyCallbackInfo<ApiReturn> info(begin()); \ |
| 50 LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \ | 54 LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \ |
| 51 holder(), index)); \ | 55 holder(), index)); \ |
| 52 f(index, info); \ | 56 f(index, info); \ |
| 53 return GetReturnValue<InternalReturn>(isolate); \ | 57 return GetReturnValue<InternalReturn>(isolate); \ |
| 54 } | 58 } |
| 55 | 59 |
| 56 FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(WRITE_CALL_1_INDEX) | 60 FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(WRITE_CALL_1_INDEX) |
| 57 | 61 |
| 58 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX | 62 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX |
| 59 #undef WRITE_CALL_1_INDEX | 63 #undef WRITE_CALL_1_INDEX |
| 60 | 64 |
| 61 Handle<Object> PropertyCallbackArguments::Call( | 65 Handle<Object> PropertyCallbackArguments::Call( |
| 62 GenericNamedPropertySetterCallback f, Handle<Name> name, | 66 GenericNamedPropertySetterCallback f, Handle<Name> name, |
| 63 Handle<Object> value) { | 67 Handle<Object> value) { |
| 64 Isolate* isolate = this->isolate(); | 68 Isolate* isolate = this->isolate(); |
| 65 RuntimeCallTimerScope timer( | 69 RuntimeCallTimerScope timer( |
| 66 isolate, &RuntimeCallStats::GenericNamedPropertySetterCallback); | 70 isolate, &RuntimeCallStats::GenericNamedPropertySetterCallback); |
| 71 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 72 isolate, |
| 73 &tracing::TraceEventStatsTable::GenericNamedPropertySetterCallback); |
| 67 VMState<EXTERNAL> state(isolate); | 74 VMState<EXTERNAL> state(isolate); |
| 68 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 75 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
| 69 PropertyCallbackInfo<v8::Value> info(begin()); | 76 PropertyCallbackInfo<v8::Value> info(begin()); |
| 70 LOG(isolate, | 77 LOG(isolate, |
| 71 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); | 78 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); |
| 72 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); | 79 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
| 73 return GetReturnValue<Object>(isolate); | 80 return GetReturnValue<Object>(isolate); |
| 74 } | 81 } |
| 75 | 82 |
| 76 Handle<Object> PropertyCallbackArguments::Call( | 83 Handle<Object> PropertyCallbackArguments::Call( |
| 77 GenericNamedPropertyDefinerCallback f, Handle<Name> name, | 84 GenericNamedPropertyDefinerCallback f, Handle<Name> name, |
| 78 const v8::PropertyDescriptor& desc) { | 85 const v8::PropertyDescriptor& desc) { |
| 79 Isolate* isolate = this->isolate(); | 86 Isolate* isolate = this->isolate(); |
| 80 RuntimeCallTimerScope timer( | 87 RuntimeCallTimerScope timer( |
| 81 isolate, &RuntimeCallStats::GenericNamedPropertyDefinerCallback); | 88 isolate, &RuntimeCallStats::GenericNamedPropertyDefinerCallback); |
| 89 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 90 isolate, |
| 91 &tracing::TraceEventStatsTable::GenericNamedPropertyDefinerCallback); |
| 82 VMState<EXTERNAL> state(isolate); | 92 VMState<EXTERNAL> state(isolate); |
| 83 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 93 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
| 84 PropertyCallbackInfo<v8::Value> info(begin()); | 94 PropertyCallbackInfo<v8::Value> info(begin()); |
| 85 LOG(isolate, | 95 LOG(isolate, |
| 86 ApiNamedPropertyAccess("interceptor-named-define", holder(), *name)); | 96 ApiNamedPropertyAccess("interceptor-named-define", holder(), *name)); |
| 87 f(v8::Utils::ToLocal(name), desc, info); | 97 f(v8::Utils::ToLocal(name), desc, info); |
| 88 return GetReturnValue<Object>(isolate); | 98 return GetReturnValue<Object>(isolate); |
| 89 } | 99 } |
| 90 | 100 |
| 91 Handle<Object> PropertyCallbackArguments::Call(IndexedPropertySetterCallback f, | 101 Handle<Object> PropertyCallbackArguments::Call(IndexedPropertySetterCallback f, |
| 92 uint32_t index, | 102 uint32_t index, |
| 93 Handle<Object> value) { | 103 Handle<Object> value) { |
| 94 Isolate* isolate = this->isolate(); | 104 Isolate* isolate = this->isolate(); |
| 95 RuntimeCallTimerScope timer(isolate, | 105 RuntimeCallTimerScope timer(isolate, |
| 96 &RuntimeCallStats::IndexedPropertySetterCallback); | 106 &RuntimeCallStats::IndexedPropertySetterCallback); |
| 107 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 108 isolate, &tracing::TraceEventStatsTable::IndexedPropertySetterCallback); |
| 97 VMState<EXTERNAL> state(isolate); | 109 VMState<EXTERNAL> state(isolate); |
| 98 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 110 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
| 99 PropertyCallbackInfo<v8::Value> info(begin()); | 111 PropertyCallbackInfo<v8::Value> info(begin()); |
| 100 LOG(isolate, | 112 LOG(isolate, |
| 101 ApiIndexedPropertyAccess("interceptor-indexed-set", holder(), index)); | 113 ApiIndexedPropertyAccess("interceptor-indexed-set", holder(), index)); |
| 102 f(index, v8::Utils::ToLocal(value), info); | 114 f(index, v8::Utils::ToLocal(value), info); |
| 103 return GetReturnValue<Object>(isolate); | 115 return GetReturnValue<Object>(isolate); |
| 104 } | 116 } |
| 105 | 117 |
| 106 Handle<Object> PropertyCallbackArguments::Call( | 118 Handle<Object> PropertyCallbackArguments::Call( |
| 107 IndexedPropertyDefinerCallback f, uint32_t index, | 119 IndexedPropertyDefinerCallback f, uint32_t index, |
| 108 const v8::PropertyDescriptor& desc) { | 120 const v8::PropertyDescriptor& desc) { |
| 109 Isolate* isolate = this->isolate(); | 121 Isolate* isolate = this->isolate(); |
| 110 RuntimeCallTimerScope timer( | 122 RuntimeCallTimerScope timer( |
| 111 isolate, &RuntimeCallStats::IndexedPropertyDefinerCallback); | 123 isolate, &RuntimeCallStats::IndexedPropertyDefinerCallback); |
| 124 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 125 isolate, &tracing::TraceEventStatsTable::IndexedPropertyDefinerCallback); |
| 112 VMState<EXTERNAL> state(isolate); | 126 VMState<EXTERNAL> state(isolate); |
| 113 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 127 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
| 114 PropertyCallbackInfo<v8::Value> info(begin()); | 128 PropertyCallbackInfo<v8::Value> info(begin()); |
| 115 LOG(isolate, | 129 LOG(isolate, |
| 116 ApiIndexedPropertyAccess("interceptor-indexed-define", holder(), index)); | 130 ApiIndexedPropertyAccess("interceptor-indexed-define", holder(), index)); |
| 117 f(index, desc, info); | 131 f(index, desc, info); |
| 118 return GetReturnValue<Object>(isolate); | 132 return GetReturnValue<Object>(isolate); |
| 119 } | 133 } |
| 120 | 134 |
| 121 void PropertyCallbackArguments::Call(AccessorNameSetterCallback f, | 135 void PropertyCallbackArguments::Call(AccessorNameSetterCallback f, |
| 122 Handle<Name> name, Handle<Object> value) { | 136 Handle<Name> name, Handle<Object> value) { |
| 123 Isolate* isolate = this->isolate(); | 137 Isolate* isolate = this->isolate(); |
| 124 RuntimeCallTimerScope timer(isolate, | 138 RuntimeCallTimerScope timer(isolate, |
| 125 &RuntimeCallStats::AccessorNameSetterCallback); | 139 &RuntimeCallStats::AccessorNameSetterCallback); |
| 140 TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED( |
| 141 isolate, &tracing::TraceEventStatsTable::AccessorNameSetterCallback); |
| 126 VMState<EXTERNAL> state(isolate); | 142 VMState<EXTERNAL> state(isolate); |
| 127 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 143 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
| 128 PropertyCallbackInfo<void> info(begin()); | 144 PropertyCallbackInfo<void> info(begin()); |
| 129 LOG(isolate, | 145 LOG(isolate, |
| 130 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); | 146 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); |
| 131 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); | 147 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
| 132 } | 148 } |
| 133 | 149 |
| 134 } // namespace internal | 150 } // namespace internal |
| 135 } // namespace v8 | 151 } // namespace v8 |
| OLD | NEW |