Chromium Code Reviews| 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-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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 return Arguments::length(); | 75 return Arguments::length(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 template <> | 78 template <> |
| 79 int BuiltinArguments<BuiltinExtraArguments::kTarget>::length() const { | 79 int BuiltinArguments<BuiltinExtraArguments::kTarget>::length() const { |
| 80 return Arguments::length() - 1; | 80 return Arguments::length() - 1; |
| 81 } | 81 } |
| 82 | 82 |
| 83 template <> | 83 template <> |
| 84 Handle<JSFunction> BuiltinArguments<BuiltinExtraArguments::kTarget>::target() { | 84 Handle<JSFunction> BuiltinArguments<BuiltinExtraArguments::kTarget>::target() { |
| 85 return Arguments::at<JSFunction>(Arguments::length() - 1); | 85 return Handle<JSFunction>(reinterpret_cast<JSFunction*>( |
| 86 Arguments::operator[](Arguments::length() - 1))); | |
| 86 } | 87 } |
| 87 | 88 |
| 88 template <> | 89 template <> |
| 89 int BuiltinArguments<BuiltinExtraArguments::kNewTarget>::length() const { | 90 int BuiltinArguments<BuiltinExtraArguments::kNewTarget>::length() const { |
| 90 return Arguments::length() - 1; | 91 return Arguments::length() - 1; |
| 91 } | 92 } |
| 92 | 93 |
| 93 template <> | 94 template <> |
| 94 Handle<HeapObject> | 95 Handle<HeapObject> |
| 95 BuiltinArguments<BuiltinExtraArguments::kNewTarget>::new_target() { | 96 BuiltinArguments<BuiltinExtraArguments::kNewTarget>::new_target() { |
| (...skipping 3301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3397 // ----------------------------------------------------------------------------- | 3398 // ----------------------------------------------------------------------------- |
| 3398 // | 3399 // |
| 3399 | 3400 |
| 3400 | 3401 |
| 3401 namespace { | 3402 namespace { |
| 3402 | 3403 |
| 3403 template <bool is_construct> | 3404 template <bool is_construct> |
| 3404 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper( | 3405 MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper( |
| 3405 Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) { | 3406 Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) { |
| 3406 HandleScope scope(isolate); | 3407 HandleScope scope(isolate); |
| 3407 Handle<JSFunction> function = args.target(); | 3408 Handle<HeapObject> function = args.target(); |
| 3408 DCHECK(args.receiver()->IsJSReceiver()); | 3409 DCHECK(args.receiver()->IsJSReceiver()); |
| 3409 // TODO(ishell): turn this back to a DCHECK. | 3410 // TODO(ishell): turn this back to a DCHECK. |
| 3410 CHECK(function->shared()->IsApiFunction()); | 3411 CHECK(function->IsFunctionTemplateInfo() || |
| 3412 Handle<JSFunction>::cast(function)->shared()->IsApiFunction()); | |
| 3411 | 3413 |
| 3412 Handle<FunctionTemplateInfo> fun_data( | 3414 Handle<FunctionTemplateInfo> fun_data = |
| 3413 function->shared()->get_api_func_data(), isolate); | 3415 function->IsFunctionTemplateInfo() |
| 3416 ? Handle<FunctionTemplateInfo>::cast(function) | |
| 3417 : Handle<FunctionTemplateInfo>(Handle<JSFunction>::cast(function) | |
|
Toon Verwaest
2016/01/22 12:11:36
Shorter: handle(JSFunction::cast(*function)->share
epertoso
2016/01/22 14:36:35
Done.
| |
| 3418 ->shared() | |
| 3419 ->get_api_func_data(), | |
| 3420 isolate); | |
| 3414 if (is_construct) { | 3421 if (is_construct) { |
| 3415 ASSIGN_RETURN_ON_EXCEPTION( | 3422 ASSIGN_RETURN_ON_EXCEPTION( |
| 3416 isolate, fun_data, | 3423 isolate, fun_data, |
| 3417 ApiNatives::ConfigureInstance(isolate, fun_data, | 3424 ApiNatives::ConfigureInstance(isolate, fun_data, |
| 3418 Handle<JSObject>::cast(args.receiver())), | 3425 Handle<JSObject>::cast(args.receiver())), |
| 3419 Object); | 3426 Object); |
| 3420 } | 3427 } |
| 3421 | 3428 |
| 3422 if (!is_construct && !fun_data->accept_any_receiver()) { | 3429 if (!is_construct && !fun_data->accept_any_receiver()) { |
| 3423 Handle<JSReceiver> receiver = args.at<JSReceiver>(0); | 3430 Handle<JSReceiver> receiver = args.at<JSReceiver>(0); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3541 v->VisitPointers(lowest_address(), highest_address() + 1); | 3548 v->VisitPointers(lowest_address(), highest_address() + 1); |
| 3542 } | 3549 } |
| 3543 | 3550 |
| 3544 private: | 3551 private: |
| 3545 DISALLOW_COPY_AND_ASSIGN(RelocatableArguments); | 3552 DISALLOW_COPY_AND_ASSIGN(RelocatableArguments); |
| 3546 }; | 3553 }; |
| 3547 | 3554 |
| 3548 } // namespace | 3555 } // namespace |
| 3549 | 3556 |
| 3550 | 3557 |
| 3551 MaybeHandle<Object> Builtins::InvokeApiFunction(Handle<JSFunction> function, | 3558 MaybeHandle<Object> Builtins::InvokeApiFunction(Handle<HeapObject> function, |
| 3552 Handle<Object> receiver, | 3559 Handle<Object> receiver, |
| 3553 int argc, | 3560 int argc, |
| 3554 Handle<Object> args[]) { | 3561 Handle<Object> args[]) { |
| 3555 // Construct BuiltinArguments object: function, arguments reversed, receiver. | 3562 // Construct BuiltinArguments object: function, arguments reversed, receiver. |
| 3556 const int kBufferSize = 32; | 3563 const int kBufferSize = 32; |
| 3557 Object* small_argv[kBufferSize]; | 3564 Object* small_argv[kBufferSize]; |
| 3558 Object** argv; | 3565 Object** argv; |
| 3559 if (argc + 2 <= kBufferSize) { | 3566 if (argc + 2 <= kBufferSize) { |
| 3560 argv = small_argv; | 3567 argv = small_argv; |
| 3561 } else { | 3568 } else { |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3998 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4005 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 3999 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4006 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4000 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4007 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 4001 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4008 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4002 #undef DEFINE_BUILTIN_ACCESSOR_C | 4009 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 4003 #undef DEFINE_BUILTIN_ACCESSOR_A | 4010 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 4004 | 4011 |
| 4005 | 4012 |
| 4006 } // namespace internal | 4013 } // namespace internal |
| 4007 } // namespace v8 | 4014 } // namespace v8 |
| OLD | NEW |