| 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_RUNTIME_CALL(#Function); \ |
| 23 VMState<EXTERNAL> state(isolate); \ | 24 VMState<EXTERNAL> state(isolate); \ |
| 24 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ | 25 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ |
| 25 PropertyCallbackInfo<ApiReturn> info(begin()); \ | 26 PropertyCallbackInfo<ApiReturn> info(begin()); \ |
| 26 LOG(isolate, \ | 27 LOG(isolate, \ |
| 27 ApiNamedPropertyAccess("interceptor-named-" type, holder(), *name)); \ | 28 ApiNamedPropertyAccess("interceptor-named-" type, holder(), *name)); \ |
| 28 f(v8::Utils::ToLocal(name), info); \ | 29 f(v8::Utils::ToLocal(name), info); \ |
| 29 return GetReturnValue<InternalReturn>(isolate); \ | 30 return GetReturnValue<InternalReturn>(isolate); \ |
| 30 } | 31 } |
| 31 | 32 |
| 32 FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(WRITE_CALL_1_NAME) | 33 FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME(WRITE_CALL_1_NAME) |
| 33 | 34 |
| 34 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME | 35 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_NAME |
| 35 #undef WRITE_CALL_1_NAME | 36 #undef WRITE_CALL_1_NAME |
| 36 | 37 |
| 37 #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(F) \ | 38 #define FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(F) \ |
| 38 F(IndexedPropertyGetterCallback, "get", v8::Value, Object) \ | 39 F(IndexedPropertyGetterCallback, "get", v8::Value, Object) \ |
| 39 F(IndexedPropertyQueryCallback, "has", v8::Integer, Object) \ | 40 F(IndexedPropertyQueryCallback, "has", v8::Integer, Object) \ |
| 40 F(IndexedPropertyDeleterCallback, "delete", v8::Boolean, Object) | 41 F(IndexedPropertyDeleterCallback, "delete", v8::Boolean, Object) |
| 41 | 42 |
| 42 #define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \ | 43 #define WRITE_CALL_1_INDEX(Function, type, ApiReturn, InternalReturn) \ |
| 43 Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \ | 44 Handle<InternalReturn> PropertyCallbackArguments::Call(Function f, \ |
| 44 uint32_t index) { \ | 45 uint32_t index) { \ |
| 45 Isolate* isolate = this->isolate(); \ | 46 Isolate* isolate = this->isolate(); \ |
| 46 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \ | 47 RuntimeCallTimerScope timer(isolate, &RuntimeCallStats::Function); \ |
| 48 TRACE_RUNTIME_CALL(#Function); \ |
| 47 VMState<EXTERNAL> state(isolate); \ | 49 VMState<EXTERNAL> state(isolate); \ |
| 48 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ | 50 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); \ |
| 49 PropertyCallbackInfo<ApiReturn> info(begin()); \ | 51 PropertyCallbackInfo<ApiReturn> info(begin()); \ |
| 50 LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \ | 52 LOG(isolate, ApiIndexedPropertyAccess("interceptor-indexed-" type, \ |
| 51 holder(), index)); \ | 53 holder(), index)); \ |
| 52 f(index, info); \ | 54 f(index, info); \ |
| 53 return GetReturnValue<InternalReturn>(isolate); \ | 55 return GetReturnValue<InternalReturn>(isolate); \ |
| 54 } | 56 } |
| 55 | 57 |
| 56 FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(WRITE_CALL_1_INDEX) | 58 FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX(WRITE_CALL_1_INDEX) |
| 57 | 59 |
| 58 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX | 60 #undef FOR_EACH_CALLBACK_TABLE_MAPPING_1_INDEX |
| 59 #undef WRITE_CALL_1_INDEX | 61 #undef WRITE_CALL_1_INDEX |
| 60 | 62 |
| 61 Handle<Object> PropertyCallbackArguments::Call( | 63 Handle<Object> PropertyCallbackArguments::Call( |
| 62 GenericNamedPropertySetterCallback f, Handle<Name> name, | 64 GenericNamedPropertySetterCallback f, Handle<Name> name, |
| 63 Handle<Object> value) { | 65 Handle<Object> value) { |
| 64 Isolate* isolate = this->isolate(); | 66 Isolate* isolate = this->isolate(); |
| 65 RuntimeCallTimerScope timer( | 67 RuntimeCallTimerScope timer( |
| 66 isolate, &RuntimeCallStats::GenericNamedPropertySetterCallback); | 68 isolate, &RuntimeCallStats::GenericNamedPropertySetterCallback); |
| 69 TRACE_RUNTIME_CALL("GenericNamedPropertySetterCallback"); |
| 67 VMState<EXTERNAL> state(isolate); | 70 VMState<EXTERNAL> state(isolate); |
| 68 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 71 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
| 69 PropertyCallbackInfo<v8::Value> info(begin()); | 72 PropertyCallbackInfo<v8::Value> info(begin()); |
| 70 LOG(isolate, | 73 LOG(isolate, |
| 71 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); | 74 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); |
| 72 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); | 75 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
| 73 return GetReturnValue<Object>(isolate); | 76 return GetReturnValue<Object>(isolate); |
| 74 } | 77 } |
| 75 | 78 |
| 76 Handle<Object> PropertyCallbackArguments::Call(IndexedPropertySetterCallback f, | 79 Handle<Object> PropertyCallbackArguments::Call(IndexedPropertySetterCallback f, |
| 77 uint32_t index, | 80 uint32_t index, |
| 78 Handle<Object> value) { | 81 Handle<Object> value) { |
| 79 Isolate* isolate = this->isolate(); | 82 Isolate* isolate = this->isolate(); |
| 80 RuntimeCallTimerScope timer(isolate, | 83 RuntimeCallTimerScope timer(isolate, |
| 81 &RuntimeCallStats::IndexedPropertySetterCallback); | 84 &RuntimeCallStats::IndexedPropertySetterCallback); |
| 85 TRACE_RUNTIME_CALL("IndexedPropertySetterCallback"); |
| 82 VMState<EXTERNAL> state(isolate); | 86 VMState<EXTERNAL> state(isolate); |
| 83 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 87 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
| 84 PropertyCallbackInfo<v8::Value> info(begin()); | 88 PropertyCallbackInfo<v8::Value> info(begin()); |
| 85 LOG(isolate, | 89 LOG(isolate, |
| 86 ApiIndexedPropertyAccess("interceptor-indexed-set", holder(), index)); | 90 ApiIndexedPropertyAccess("interceptor-indexed-set", holder(), index)); |
| 87 f(index, v8::Utils::ToLocal(value), info); | 91 f(index, v8::Utils::ToLocal(value), info); |
| 88 return GetReturnValue<Object>(isolate); | 92 return GetReturnValue<Object>(isolate); |
| 89 } | 93 } |
| 90 | 94 |
| 91 void PropertyCallbackArguments::Call(AccessorNameSetterCallback f, | 95 void PropertyCallbackArguments::Call(AccessorNameSetterCallback f, |
| 92 Handle<Name> name, Handle<Object> value) { | 96 Handle<Name> name, Handle<Object> value) { |
| 93 Isolate* isolate = this->isolate(); | 97 Isolate* isolate = this->isolate(); |
| 94 RuntimeCallTimerScope timer(isolate, | 98 RuntimeCallTimerScope timer(isolate, |
| 95 &RuntimeCallStats::AccessorNameSetterCallback); | 99 &RuntimeCallStats::AccessorNameSetterCallback); |
| 100 TRACE_RUNTIME_CALL("AccessorNameSetterCallback"); |
| 96 VMState<EXTERNAL> state(isolate); | 101 VMState<EXTERNAL> state(isolate); |
| 97 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); | 102 ExternalCallbackScope call_scope(isolate, FUNCTION_ADDR(f)); |
| 98 PropertyCallbackInfo<void> info(begin()); | 103 PropertyCallbackInfo<void> info(begin()); |
| 99 LOG(isolate, | 104 LOG(isolate, |
| 100 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); | 105 ApiNamedPropertyAccess("interceptor-named-set", holder(), *name)); |
| 101 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); | 106 f(v8::Utils::ToLocal(name), v8::Utils::ToLocal(value), info); |
| 102 } | 107 } |
| 103 | 108 |
| 104 } // namespace internal | 109 } // namespace internal |
| 105 } // namespace v8 | 110 } // namespace v8 |
| OLD | NEW |