Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/runtime/runtime-proxy.cc

Issue 1491893002: [proxies] Implement the Proxy constructor in C++ fully. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@BuiltinsExtraArguments
Patch Set: Address feedback. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 RUNTIME_FUNCTION(Runtime_CreateJSProxy) {
15 HandleScope scope(isolate);
16 DCHECK(args.length() == 2);
17 CONVERT_ARG_HANDLE_CHECKED(Object, target, 0);
18 CONVERT_ARG_HANDLE_CHECKED(Object, handler, 1);
19 if (!target->IsJSReceiver()) {
20 THROW_NEW_ERROR_RETURN_FAILURE(
21 isolate, NewTypeError(MessageTemplate::kProxyTargetNonObject));
22 }
23 if (!handler->IsJSReceiver()) {
24 THROW_NEW_ERROR_RETURN_FAILURE(
25 isolate, NewTypeError(MessageTemplate::kProxyHandlerNonObject));
26 }
27 if ((target->IsJSProxy() && JSProxy::cast(*target)->IsRevoked()) ||
28 (handler->IsJSProxy() && JSProxy::cast(*handler)->IsRevoked())) {
29 THROW_NEW_ERROR_RETURN_FAILURE(
30 isolate, NewTypeError(MessageTemplate::kProxyHandlerOrTargetRevoked));
31 }
32 return *isolate->factory()->NewJSProxy(Handle<JSReceiver>::cast(target),
33 Handle<JSReceiver>::cast(handler));
34 }
35
36
37 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) { 14 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) {
38 HandleScope scope(isolate); 15 HandleScope scope(isolate);
39 DCHECK(args.length() == 5); 16 DCHECK(args.length() == 5);
40 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); 17 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0);
41 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 1); 18 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 1);
42 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, call_trap, 2); 19 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, call_trap, 2);
43 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); 20 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
44 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 3); 21 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 3);
45 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 4); 22 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 4);
46 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); 23 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 60
84 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { 61 RUNTIME_FUNCTION(Runtime_GetConstructTrap) {
85 SealHandleScope shs(isolate); 62 SealHandleScope shs(isolate);
86 DCHECK(args.length() == 1); 63 DCHECK(args.length() == 1);
87 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); 64 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
88 return proxy->construct_trap(); 65 return proxy->construct_trap();
89 } 66 }
90 67
91 } // namespace internal 68 } // namespace internal
92 } // namespace v8 69 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698