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