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

Side by Side Diff: src/builtins.cc

Issue 1776913005: Simplify the interface of PropertyCallbackArguments (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
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-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 3952 matching lines...) Expand 10 before | Expand all | Expand 10 after
3963 DCHECK(raw_holder->IsJSObject()); 3963 DCHECK(raw_holder->IsJSObject());
3964 3964
3965 FunctionCallbackArguments custom(isolate, 3965 FunctionCallbackArguments custom(isolate,
3966 data_obj, 3966 data_obj,
3967 *function, 3967 *function,
3968 raw_holder, 3968 raw_holder,
3969 &args[0] - 1, 3969 &args[0] - 1,
3970 args.length() - 1, 3970 args.length() - 1,
3971 is_construct); 3971 is_construct);
3972 3972
3973 v8::Local<v8::Value> value = custom.Call(callback); 3973 Handle<Object> result = custom.Call(callback);
3974 Handle<Object> result; 3974 if (result.is_null()) result = isolate->factory()->undefined_value();
3975 if (value.IsEmpty()) {
3976 result = isolate->factory()->undefined_value();
3977 } else {
3978 result = v8::Utils::OpenHandle(*value);
3979 result->VerifyApiCallResultType();
3980 }
3981 3975
3982 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 3976 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
3983 if (!is_construct || result->IsJSObject()) { 3977 if (!is_construct || result->IsJSObject()) {
3984 return scope.CloseAndEscape(result); 3978 return scope.CloseAndEscape(result);
3985 } 3979 }
3986 } 3980 }
3987 3981
3988 return scope.CloseAndEscape(receiver); 3982 return scope.CloseAndEscape(receiver);
3989 } 3983 }
3990 3984
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
4137 return result; 4131 return result;
4138 } 4132 }
4139 4133
4140 4134
4141 // Helper function to handle calls to non-function objects created through the 4135 // Helper function to handle calls to non-function objects created through the
4142 // API. The object can be called as either a constructor (using new) or just as 4136 // API. The object can be called as either a constructor (using new) or just as
4143 // a function (without new). 4137 // a function (without new).
4144 MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor( 4138 MUST_USE_RESULT static Object* HandleApiCallAsFunctionOrConstructor(
4145 Isolate* isolate, bool is_construct_call, 4139 Isolate* isolate, bool is_construct_call,
4146 BuiltinArguments<BuiltinExtraArguments::kNone> args) { 4140 BuiltinArguments<BuiltinExtraArguments::kNone> args) {
4147 Heap* heap = isolate->heap();
4148
4149 Handle<Object> receiver = args.receiver(); 4141 Handle<Object> receiver = args.receiver();
4150 4142
4151 // Get the object called. 4143 // Get the object called.
4152 JSObject* obj = JSObject::cast(*receiver); 4144 JSObject* obj = JSObject::cast(*receiver);
4153 4145
4154 // Get the invocation callback from the function descriptor that was 4146 // Get the invocation callback from the function descriptor that was
4155 // used to create the called object. 4147 // used to create the called object.
4156 DCHECK(obj->map()->is_callable()); 4148 DCHECK(obj->map()->is_callable());
4157 JSFunction* constructor = JSFunction::cast(obj->map()->GetConstructor()); 4149 JSFunction* constructor = JSFunction::cast(obj->map()->GetConstructor());
4158 // TODO(ishell): turn this back to a DCHECK. 4150 // TODO(ishell): turn this back to a DCHECK.
(...skipping 14 matching lines...) Expand all
4173 HandleScope scope(isolate); 4165 HandleScope scope(isolate);
4174 LOG(isolate, ApiObjectAccess("call non-function", obj)); 4166 LOG(isolate, ApiObjectAccess("call non-function", obj));
4175 4167
4176 FunctionCallbackArguments custom(isolate, 4168 FunctionCallbackArguments custom(isolate,
4177 call_data->data(), 4169 call_data->data(),
4178 constructor, 4170 constructor,
4179 obj, 4171 obj,
4180 &args[0] - 1, 4172 &args[0] - 1,
4181 args.length() - 1, 4173 args.length() - 1,
4182 is_construct_call); 4174 is_construct_call);
4183 v8::Local<v8::Value> value = custom.Call(callback); 4175 Handle<Object> result_handle = custom.Call(callback);
4184 if (value.IsEmpty()) { 4176 if (result_handle.is_null()) {
4185 result = heap->undefined_value(); 4177 result = isolate->heap()->undefined_value();
4186 } else { 4178 } else {
4187 result = *reinterpret_cast<Object**>(*value); 4179 result = *result_handle;
4188 result->VerifyApiCallResultType();
4189 } 4180 }
4190 } 4181 }
4191 // Check for exceptions and return result. 4182 // Check for exceptions and return result.
4192 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); 4183 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate);
4193 return result; 4184 return result;
4194 } 4185 }
4195 4186
4196 4187
4197 // Handle calls to non-function objects created through the API. This delegate 4188 // Handle calls to non-function objects created through the API. This delegate
4198 // function is used when the call is a normal function call. 4189 // function is used when the call is a normal function call.
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
4538 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 4529 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
4539 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 4530 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
4540 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 4531 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
4541 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 4532 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
4542 #undef DEFINE_BUILTIN_ACCESSOR_C 4533 #undef DEFINE_BUILTIN_ACCESSOR_C
4543 #undef DEFINE_BUILTIN_ACCESSOR_A 4534 #undef DEFINE_BUILTIN_ACCESSOR_A
4544 4535
4545 4536
4546 } // namespace internal 4537 } // namespace internal
4547 } // namespace v8 4538 } // namespace v8
OLDNEW
« src/api-arguments.h ('K') | « src/api-arguments.cc ('k') | src/ic/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698