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

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

Issue 1417063011: [runtime] support new Proxy() instead of Proxy.create and install getPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: removing unreachable code Created 5 years, 1 month 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-object.cc ('k') | test/mjsunit/es6/iteration-semantics.js » ('j') | 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) { 14 RUNTIME_FUNCTION(Runtime_CreateJSProxy) {
15 HandleScope scope(isolate); 15 HandleScope scope(isolate);
16 DCHECK(args.length() == 3); 16 DCHECK(args.length() == 3);
17 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); 17 CONVERT_ARG_HANDLE_CHECKED(JSProxy, instance, 0);
18 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 1); 18 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 1);
19 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 2); 19 CONVERT_ARG_HANDLE_CHECKED(Object, handler, 2);
20 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); 20 if (!target->IsSpecObject()) {
21 return *isolate->factory()->NewJSProxy(target, handler, prototype); 21 THROW_NEW_ERROR_RETURN_FAILURE(
22 isolate, NewTypeError(MessageTemplate::kProxyTargetNonObject));
23 }
24 if (target->IsJSProxy() && !JSProxy::cast(*target)->has_handler()) {
25 // TODO(cbruni): Use better error message.
26 THROW_NEW_ERROR_RETURN_FAILURE(
27 isolate, NewTypeError(MessageTemplate::kProxyTargetNonObject));
28 }
29 if (!handler->IsSpecObject()) {
30 THROW_NEW_ERROR_RETURN_FAILURE(
31 isolate, NewTypeError(MessageTemplate::kProxyHandlerNonObject));
32 }
33 if (handler->IsJSProxy() && !JSProxy::cast(*handler)->has_handler()) {
34 // TODO(cbruni): Use better error message.
35 THROW_NEW_ERROR_RETURN_FAILURE(
36 isolate, NewTypeError(MessageTemplate::kProxyHandlerNonObject));
37 }
38 instance->set_target(*target);
39 instance->set_handler(*handler);
40 instance->set_hash(isolate->heap()->undefined_value(), SKIP_WRITE_BARRIER);
41 return *instance;
22 } 42 }
23 43
24 44
25 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) { 45 RUNTIME_FUNCTION(Runtime_CreateJSFunctionProxy) {
26 HandleScope scope(isolate); 46 HandleScope scope(isolate);
27 DCHECK(args.length() == 5); 47 DCHECK(args.length() == 5);
28 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0); 48 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, target, 0);
29 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 1); 49 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 1);
30 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, call_trap, 2); 50 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, call_trap, 2);
31 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); 51 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 91
72 RUNTIME_FUNCTION(Runtime_GetConstructTrap) { 92 RUNTIME_FUNCTION(Runtime_GetConstructTrap) {
73 SealHandleScope shs(isolate); 93 SealHandleScope shs(isolate);
74 DCHECK(args.length() == 1); 94 DCHECK(args.length() == 1);
75 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); 95 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0);
76 return proxy->construct_trap(); 96 return proxy->construct_trap();
77 } 97 }
78 98
79 } // namespace internal 99 } // namespace internal
80 } // namespace v8 100 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | test/mjsunit/es6/iteration-semantics.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698