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 namespace v8 {
9 namespace internal {
10 
11 // ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Call]] case.
BUILTIN(ProxyConstructor)12 BUILTIN(ProxyConstructor) {
13   HandleScope scope(isolate);
14   THROW_NEW_ERROR_RETURN_FAILURE(
15       isolate,
16       NewTypeError(MessageTemplate::kConstructorNotFunction,
17                    isolate->factory()->NewStringFromAsciiChecked("Proxy")));
18 }
19 
20 // ES6 section 26.2.1.1 Proxy ( target, handler ) for the [[Construct]] case.
BUILTIN(ProxyConstructor_ConstructStub)21 BUILTIN(ProxyConstructor_ConstructStub) {
22   HandleScope scope(isolate);
23   DCHECK(isolate->proxy_function()->IsConstructor());
24   Handle<Object> target = args.atOrUndefined(isolate, 1);
25   Handle<Object> handler = args.atOrUndefined(isolate, 2);
26   RETURN_RESULT_OR_FAILURE(isolate, JSProxy::New(isolate, target, handler));
27 }
28 
29 }  // namespace internal
30 }  // namespace v8
31