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

Side by Side Diff: src/builtins.cc

Issue 1642223003: [api] Make ObjectTemplate::SetNativeDataProperty() work even if the ObjectTemplate does not have a … (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed asserts preventing JSReceiver properties in ObjectTemplate Created 4 years, 10 months 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/bootstrapper.cc ('k') | src/contexts.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/builtins.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 3505 matching lines...) Expand 10 before | Expand all | Expand 10 after
3516 // 3516 //
3517 3517
3518 3518
3519 namespace { 3519 namespace {
3520 3520
3521 template <bool is_construct> 3521 template <bool is_construct>
3522 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper( 3522 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper(
3523 Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) { 3523 Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) {
3524 HandleScope scope(isolate); 3524 HandleScope scope(isolate);
3525 Handle<JSFunction> function = args.target(); 3525 Handle<JSFunction> function = args.target();
3526 DCHECK(args.receiver()->IsJSReceiver()); 3526 Handle<JSReceiver> receiver;
3527 // TODO(ishell): turn this back to a DCHECK. 3527 // TODO(ishell): turn this back to a DCHECK.
3528 CHECK(function->shared()->IsApiFunction()); 3528 CHECK(function->shared()->IsApiFunction());
3529 3529
3530 Handle<FunctionTemplateInfo> fun_data( 3530 Handle<FunctionTemplateInfo> fun_data(
3531 function->shared()->get_api_func_data(), isolate); 3531 function->shared()->get_api_func_data(), isolate);
3532 if (is_construct) { 3532 if (is_construct) {
3533 ASSIGN_RETURN_ON_EXCEPTION( 3533 DCHECK(args.receiver()->IsTheHole());
3534 isolate, fun_data, 3534 if (fun_data->instance_template()->IsUndefined()) {
3535 ApiNatives::ConfigureInstance(isolate, fun_data, 3535 v8::Local<ObjectTemplate> templ =
3536 Handle<JSObject>::cast(args.receiver())), 3536 ObjectTemplate::New(reinterpret_cast<v8::Isolate*>(isolate),
3537 Object); 3537 ToApiHandle<v8::FunctionTemplate>(fun_data));
3538 fun_data->set_instance_template(*Utils::OpenHandle(*templ));
3539 }
3540 Handle<ObjectTemplateInfo> instance_template(
3541 ObjectTemplateInfo::cast(fun_data->instance_template()), isolate);
3542 ASSIGN_RETURN_ON_EXCEPTION(isolate, receiver,
3543 ApiNatives::InstantiateObject(instance_template),
3544 Object);
3545 args[0] = *receiver;
3546 DCHECK_EQ(*receiver, *args.receiver());
3547 } else {
3548 DCHECK(args.receiver()->IsJSReceiver());
3549 receiver = args.at<JSReceiver>(0);
3538 } 3550 }
3539 3551
3540 if (!is_construct && !fun_data->accept_any_receiver()) { 3552 if (!is_construct && !fun_data->accept_any_receiver()) {
3541 Handle<JSReceiver> receiver = args.at<JSReceiver>(0);
3542 if (receiver->IsJSObject() && receiver->IsAccessCheckNeeded()) { 3553 if (receiver->IsJSObject() && receiver->IsAccessCheckNeeded()) {
3543 Handle<JSObject> js_receiver = Handle<JSObject>::cast(receiver); 3554 Handle<JSObject> js_receiver = Handle<JSObject>::cast(receiver);
3544 if (!isolate->MayAccess(handle(isolate->context()), js_receiver)) { 3555 if (!isolate->MayAccess(handle(isolate->context()), js_receiver)) {
3545 isolate->ReportFailedAccessCheck(js_receiver); 3556 isolate->ReportFailedAccessCheck(js_receiver);
3546 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 3557 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
3547 } 3558 }
3548 } 3559 }
3549 } 3560 }
3550 3561
3551 Object* raw_holder = fun_data->GetCompatibleReceiver(isolate, args[0]); 3562 Object* raw_holder = fun_data->GetCompatibleReceiver(isolate, *receiver);
3552 3563
3553 if (raw_holder->IsNull()) { 3564 if (raw_holder->IsNull()) {
3554 // This function cannot be called with the given receiver. Abort! 3565 // This function cannot be called with the given receiver. Abort!
3555 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIllegalInvocation), 3566 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIllegalInvocation),
3556 Object); 3567 Object);
3557 } 3568 }
3558 3569
3559 Object* raw_call_data = fun_data->call_code(); 3570 Object* raw_call_data = fun_data->call_code();
3560 if (!raw_call_data->IsUndefined()) { 3571 if (!raw_call_data->IsUndefined()) {
3561 // TODO(ishell): remove this debugging code. 3572 // TODO(ishell): remove this debugging code.
(...skipping 23 matching lines...) Expand all
3585 result = v8::Utils::OpenHandle(*value); 3596 result = v8::Utils::OpenHandle(*value);
3586 result->VerifyApiCallResultType(); 3597 result->VerifyApiCallResultType();
3587 } 3598 }
3588 3599
3589 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 3600 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
3590 if (!is_construct || result->IsJSObject()) { 3601 if (!is_construct || result->IsJSObject()) {
3591 return scope.CloseAndEscape(result); 3602 return scope.CloseAndEscape(result);
3592 } 3603 }
3593 } 3604 }
3594 3605
3595 return scope.CloseAndEscape(args.receiver()); 3606 return scope.CloseAndEscape(receiver);
3596 } 3607 }
3597 3608
3598 } // namespace 3609 } // namespace
3599 3610
3600 3611
3601 BUILTIN(HandleApiCall) { 3612 BUILTIN(HandleApiCall) {
3602 HandleScope scope(isolate); 3613 HandleScope scope(isolate);
3603 Handle<Object> result; 3614 Handle<Object> result;
3604 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 3615 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
3605 HandleApiCallHelper<false>(isolate, args)); 3616 HandleApiCallHelper<false>(isolate, args));
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
4155 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 4166 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
4156 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 4167 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
4157 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 4168 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
4158 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 4169 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
4159 #undef DEFINE_BUILTIN_ACCESSOR_C 4170 #undef DEFINE_BUILTIN_ACCESSOR_C
4160 #undef DEFINE_BUILTIN_ACCESSOR_A 4171 #undef DEFINE_BUILTIN_ACCESSOR_A
4161 4172
4162 4173
4163 } // namespace internal 4174 } // namespace internal
4164 } // namespace v8 4175 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698