| OLD | NEW |
| 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/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
| 11 #include "src/deoptimizer.h" | 11 #include "src/deoptimizer.h" |
| 12 #include "src/frames-inl.h" | 12 #include "src/frames-inl.h" |
| 13 #include "src/isolate-inl.h" | 13 #include "src/isolate-inl.h" |
| 14 #include "src/messages.h" | 14 #include "src/messages.h" |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 | 18 |
| 19 RUNTIME_FUNCTION(Runtime_IsSloppyModeFunction) { | 19 RUNTIME_FUNCTION(Runtime_IsSloppyModeFunction) { |
| 20 SealHandleScope shs(isolate); | 20 SealHandleScope shs(isolate); |
| 21 DCHECK(args.length() == 1); | 21 DCHECK(args.length() == 1); |
| 22 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 22 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
| 23 if (!callable->IsJSFunction()) { | 23 if (!callable->IsJSFunction()) { |
| 24 HandleScope scope(isolate); | 24 HandleScope scope(isolate); |
| 25 Handle<Object> delegate; | 25 Handle<JSFunction> delegate; |
| 26 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 26 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 27 isolate, delegate, Execution::TryGetFunctionDelegate( | 27 isolate, delegate, |
| 28 isolate, Handle<JSReceiver>(callable))); | 28 Execution::GetFunctionDelegate(isolate, Handle<JSReceiver>(callable))); |
| 29 callable = JSFunction::cast(*delegate); | 29 callable = JSFunction::cast(*delegate); |
| 30 } | 30 } |
| 31 JSFunction* function = JSFunction::cast(callable); | 31 JSFunction* function = JSFunction::cast(callable); |
| 32 SharedFunctionInfo* shared = function->shared(); | 32 SharedFunctionInfo* shared = function->shared(); |
| 33 return isolate->heap()->ToBoolean(is_sloppy(shared->language_mode())); | 33 return isolate->heap()->ToBoolean(is_sloppy(shared->language_mode())); |
| 34 } | 34 } |
| 35 | 35 |
| 36 | 36 |
| 37 RUNTIME_FUNCTION(Runtime_FunctionGetName) { | 37 RUNTIME_FUNCTION(Runtime_FunctionGetName) { |
| 38 SealHandleScope shs(isolate); | 38 SealHandleScope shs(isolate); |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 base::SmartArrayPointer<Handle<Object> > param_data = | 508 base::SmartArrayPointer<Handle<Object> > param_data = |
| 509 GetCallerArguments(isolate, bound_argc, &total_argc); | 509 GetCallerArguments(isolate, bound_argc, &total_argc); |
| 510 for (int i = 0; i < bound_argc; i++) { | 510 for (int i = 0; i < bound_argc; i++) { |
| 511 param_data[i] = Handle<Object>( | 511 param_data[i] = Handle<Object>( |
| 512 bound_args->get(JSFunction::kBoundArgumentsStartIndex + i), isolate); | 512 bound_args->get(JSFunction::kBoundArgumentsStartIndex + i), isolate); |
| 513 } | 513 } |
| 514 | 514 |
| 515 if (!bound_function->IsJSFunction()) { | 515 if (!bound_function->IsJSFunction()) { |
| 516 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 516 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 517 isolate, bound_function, | 517 isolate, bound_function, |
| 518 Execution::TryGetConstructorDelegate(isolate, bound_function)); | 518 Execution::GetConstructorDelegate(isolate, bound_function)); |
| 519 } | 519 } |
| 520 DCHECK(bound_function->IsJSFunction()); | 520 DCHECK(bound_function->IsJSFunction()); |
| 521 | 521 |
| 522 Handle<Object> result; | 522 Handle<Object> result; |
| 523 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 523 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 524 isolate, result, Execution::New(Handle<JSFunction>::cast(bound_function), | 524 isolate, result, Execution::New(Handle<JSFunction>::cast(bound_function), |
| 525 total_argc, param_data.get())); | 525 total_argc, param_data.get())); |
| 526 return *result; | 526 return *result; |
| 527 } | 527 } |
| 528 | 528 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 Execution::Call(isolate, fun, receiver, argc, argv, true)); | 595 Execution::Call(isolate, fun, receiver, argc, argv, true)); |
| 596 return *result; | 596 return *result; |
| 597 } | 597 } |
| 598 | 598 |
| 599 | 599 |
| 600 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) { | 600 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) { |
| 601 HandleScope scope(isolate); | 601 HandleScope scope(isolate); |
| 602 DCHECK(args.length() == 1); | 602 DCHECK(args.length() == 1); |
| 603 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 603 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 604 RUNTIME_ASSERT(!object->IsJSFunction()); | 604 RUNTIME_ASSERT(!object->IsJSFunction()); |
| 605 return *Execution::GetFunctionDelegate(isolate, object); | 605 Handle<JSFunction> result; |
| 606 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 607 isolate, result, Execution::GetFunctionDelegate(isolate, object)); |
| 608 return *result; |
| 606 } | 609 } |
| 607 | 610 |
| 608 | 611 |
| 609 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { | 612 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { |
| 610 HandleScope scope(isolate); | 613 HandleScope scope(isolate); |
| 611 DCHECK(args.length() == 1); | 614 DCHECK(args.length() == 1); |
| 612 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 615 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
| 613 RUNTIME_ASSERT(!object->IsJSFunction()); | 616 RUNTIME_ASSERT(!object->IsJSFunction()); |
| 614 return *Execution::GetConstructorDelegate(isolate, object); | 617 Handle<JSFunction> result; |
| 618 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 619 isolate, result, Execution::GetConstructorDelegate(isolate, object)); |
| 620 return *result; |
| 615 } | 621 } |
| 616 | 622 |
| 617 | 623 |
| 618 RUNTIME_FUNCTION(Runtime_GetOriginalConstructor) { | 624 RUNTIME_FUNCTION(Runtime_GetOriginalConstructor) { |
| 619 SealHandleScope shs(isolate); | 625 SealHandleScope shs(isolate); |
| 620 DCHECK(args.length() == 0); | 626 DCHECK(args.length() == 0); |
| 621 JavaScriptFrameIterator it(isolate); | 627 JavaScriptFrameIterator it(isolate); |
| 622 JavaScriptFrame* frame = it.frame(); | 628 JavaScriptFrame* frame = it.frame(); |
| 623 return frame->IsConstructor() ? frame->GetOriginalConstructor() | 629 return frame->IsConstructor() ? frame->GetOriginalConstructor() |
| 624 : isolate->heap()->undefined_value(); | 630 : isolate->heap()->undefined_value(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 649 | 655 |
| 650 | 656 |
| 651 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { | 657 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { |
| 652 HandleScope scope(isolate); | 658 HandleScope scope(isolate); |
| 653 DCHECK(args.length() == 0); | 659 DCHECK(args.length() == 0); |
| 654 THROW_NEW_ERROR_RETURN_FAILURE(isolate, | 660 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
| 655 NewTypeError(MessageTemplate::kStrongArity)); | 661 NewTypeError(MessageTemplate::kStrongArity)); |
| 656 } | 662 } |
| 657 } // namespace internal | 663 } // namespace internal |
| 658 } // namespace v8 | 664 } // namespace v8 |
| OLD | NEW |