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
3// found in the LICENSE file.
4
5#include "src/builtins/builtins.h"
6#include "src/builtins/builtins-utils.h"
7
8#include "src/counters.h"
9#include "src/objects-inl.h"
10
11namespace v8 {
12namespace internal {
13
14// ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Call]] case.
15BUILTIN(ProxyConstructor) {
16  HandleScope scope(isolate);
17  THROW_NEW_ERROR_RETURN_FAILURE(
18      isolate,
19      NewTypeError(MessageTemplate::kConstructorNotFunction,
20                   isolate->factory()->NewStringFromAsciiChecked("Proxy")));
21}
22
23// ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Construct]] case.
24BUILTIN(ProxyConstructor_ConstructStub) {
25  HandleScope scope(isolate);
26  DCHECK(isolate->proxy_function()->IsConstructor());
27  Handle<Object> target = args.atOrUndefined(isolate, 1);
28  Handle<Object> handler = args.atOrUndefined(isolate, 2);
29  RETURN_RESULT_OR_FAILURE(isolate, JSProxy::New(isolate, target, handler));
30}
31
32}  // namespace internal
33}  // namespace v8
34