OLD | NEW |
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-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/api-natives.h" | 9 #include "src/api-natives.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 3890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3901 | 3901 |
3902 | 3902 |
3903 namespace { | 3903 namespace { |
3904 | 3904 |
3905 template <bool is_construct> | 3905 template <bool is_construct> |
3906 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper( | 3906 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper( |
3907 Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) { | 3907 Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) { |
3908 HandleScope scope(isolate); | 3908 HandleScope scope(isolate); |
3909 Handle<HeapObject> function = args.target<HeapObject>(); | 3909 Handle<HeapObject> function = args.target<HeapObject>(); |
3910 Handle<JSReceiver> receiver; | 3910 Handle<JSReceiver> receiver; |
3911 // TODO(ishell): turn this back to a DCHECK. | 3911 |
3912 CHECK(function->IsFunctionTemplateInfo() || | 3912 DCHECK(function->IsFunctionTemplateInfo() || |
3913 Handle<JSFunction>::cast(function)->shared()->IsApiFunction()); | 3913 Handle<JSFunction>::cast(function)->shared()->IsApiFunction()); |
3914 | 3914 |
3915 Handle<FunctionTemplateInfo> fun_data = | 3915 Handle<FunctionTemplateInfo> fun_data = |
3916 function->IsFunctionTemplateInfo() | 3916 function->IsFunctionTemplateInfo() |
3917 ? Handle<FunctionTemplateInfo>::cast(function) | 3917 ? Handle<FunctionTemplateInfo>::cast(function) |
3918 : handle(JSFunction::cast(*function)->shared()->get_api_func_data()); | 3918 : handle(JSFunction::cast(*function)->shared()->get_api_func_data()); |
3919 if (is_construct) { | 3919 if (is_construct) { |
3920 DCHECK(args.receiver()->IsTheHole()); | 3920 DCHECK(args.receiver()->IsTheHole()); |
3921 if (fun_data->instance_template()->IsUndefined()) { | 3921 if (fun_data->instance_template()->IsUndefined()) { |
3922 v8::Local<ObjectTemplate> templ = | 3922 v8::Local<ObjectTemplate> templ = |
3923 ObjectTemplate::New(reinterpret_cast<v8::Isolate*>(isolate), | 3923 ObjectTemplate::New(reinterpret_cast<v8::Isolate*>(isolate), |
(...skipping 25 matching lines...) Expand all Loading... |
3949 Object* raw_holder = fun_data->GetCompatibleReceiver(isolate, *receiver); | 3949 Object* raw_holder = fun_data->GetCompatibleReceiver(isolate, *receiver); |
3950 | 3950 |
3951 if (raw_holder->IsNull()) { | 3951 if (raw_holder->IsNull()) { |
3952 // This function cannot be called with the given receiver. Abort! | 3952 // This function cannot be called with the given receiver. Abort! |
3953 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIllegalInvocation), | 3953 THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIllegalInvocation), |
3954 Object); | 3954 Object); |
3955 } | 3955 } |
3956 | 3956 |
3957 Object* raw_call_data = fun_data->call_code(); | 3957 Object* raw_call_data = fun_data->call_code(); |
3958 if (!raw_call_data->IsUndefined()) { | 3958 if (!raw_call_data->IsUndefined()) { |
3959 // TODO(ishell): remove this debugging code. | 3959 DCHECK(raw_call_data->IsCallHandlerInfo()); |
3960 CHECK(raw_call_data->IsCallHandlerInfo()); | |
3961 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); | 3960 CallHandlerInfo* call_data = CallHandlerInfo::cast(raw_call_data); |
3962 Object* callback_obj = call_data->callback(); | 3961 Object* callback_obj = call_data->callback(); |
3963 v8::FunctionCallback callback = | 3962 v8::FunctionCallback callback = |
3964 v8::ToCData<v8::FunctionCallback>(callback_obj); | 3963 v8::ToCData<v8::FunctionCallback>(callback_obj); |
3965 Object* data_obj = call_data->data(); | 3964 Object* data_obj = call_data->data(); |
3966 | 3965 |
3967 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver()))); | 3966 LOG(isolate, ApiObjectAccess("call", JSObject::cast(*args.receiver()))); |
3968 DCHECK(raw_holder->IsJSObject()); | 3967 DCHECK(raw_holder->IsJSObject()); |
3969 | 3968 |
3970 FunctionCallbackArguments custom(isolate, | 3969 FunctionCallbackArguments custom(isolate, |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4534 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4533 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
4535 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4534 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
4536 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4535 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
4537 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4536 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
4538 #undef DEFINE_BUILTIN_ACCESSOR_C | 4537 #undef DEFINE_BUILTIN_ACCESSOR_C |
4539 #undef DEFINE_BUILTIN_ACCESSOR_A | 4538 #undef DEFINE_BUILTIN_ACCESSOR_A |
4540 | 4539 |
4541 | 4540 |
4542 } // namespace internal | 4541 } // namespace internal |
4543 } // namespace v8 | 4542 } // namespace v8 |
OLD | NEW |