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