1 // Copyright 2017 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 #ifndef V8_BUILTINS_BUILTINS_PROXY_GEN_H_
6 #define V8_BUILTINS_BUILTINS_PROXY_GEN_H_
7 
8 #include "src/codegen/code-stub-assembler.h"
9 #include "src/objects/js-proxy.h"
10 
11 namespace v8 {
12 namespace internal {
13 using compiler::Node;
14 
15 class ProxiesCodeStubAssembler : public CodeStubAssembler {
16  public:
ProxiesCodeStubAssembler(compiler::CodeAssemblerState * state)17   explicit ProxiesCodeStubAssembler(compiler::CodeAssemblerState* state)
18       : CodeStubAssembler(state) {}
19 
20   TNode<JSProxy> AllocateProxy(TNode<Context> context, TNode<JSReceiver> target,
21                                TNode<JSReceiver> handler);
22   TNode<JSFunction> AllocateProxyRevokeFunction(TNode<Context> context,
23                                                 TNode<JSProxy> proxy);
24 
25   void CheckGetSetTrapResult(TNode<Context> context, TNode<JSReceiver> target,
26                              TNode<JSProxy> proxy, TNode<Name> name,
27                              TNode<Object> trap_result,
28                              JSProxy::AccessKind access_kind);
29 
30   void CheckHasTrapResult(TNode<Context> context, TNode<JSReceiver> target,
31                           TNode<JSProxy> proxy, TNode<Name> name);
32 
33   void CheckDeleteTrapResult(TNode<Context> context, TNode<JSReceiver> target,
34                              TNode<JSProxy> proxy, TNode<Name> name);
35 
36   enum ProxyRevokeFunctionContextSlot {
37     kProxySlot = Context::MIN_CONTEXT_SLOTS,
38     kProxyContextLength,
39   };
40 
41  private:
42   TNode<Context> CreateProxyRevokeFunctionContext(
43       TNode<JSProxy> proxy, TNode<NativeContext> native_context);
44 };
45 
46 }  // namespace internal
47 }  // namespace v8
48 
49 #endif  // V8_BUILTINS_BUILTINS_PROXY_GEN_H_
50