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

Side by Side Diff: src/runtime/runtime-function.cc

Issue 1316933002: [es6] Initial steps towards a correct implementation of IsCallable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: ia32, arm and arm64 ports. Misc cleanups. Created 5 years, 3 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 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/messages.h" 13 #include "src/messages.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 RUNTIME_FUNCTION(Runtime_IsSloppyModeFunction) { 18 RUNTIME_FUNCTION(Runtime_IsSloppyModeFunction) {
19 SealHandleScope shs(isolate); 19 SealHandleScope shs(isolate);
20 DCHECK(args.length() == 1); 20 DCHECK(args.length() == 1);
21 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 21 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
22 if (!callable->IsJSFunction()) { 22 if (!callable->IsJSFunction()) {
23 HandleScope scope(isolate); 23 HandleScope scope(isolate);
24 Handle<Object> delegate; 24 Handle<JSFunction> delegate;
25 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 25 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
26 isolate, delegate, Execution::TryGetFunctionDelegate( 26 isolate, delegate,
27 isolate, Handle<JSReceiver>(callable))); 27 Execution::GetFunctionDelegate(isolate, Handle<JSReceiver>(callable)));
28 callable = JSFunction::cast(*delegate); 28 callable = JSFunction::cast(*delegate);
29 } 29 }
30 JSFunction* function = JSFunction::cast(callable); 30 JSFunction* function = JSFunction::cast(callable);
31 SharedFunctionInfo* shared = function->shared(); 31 SharedFunctionInfo* shared = function->shared();
32 return isolate->heap()->ToBoolean(is_sloppy(shared->language_mode())); 32 return isolate->heap()->ToBoolean(is_sloppy(shared->language_mode()));
33 } 33 }
34 34
35 35
36 RUNTIME_FUNCTION(Runtime_FunctionGetName) { 36 RUNTIME_FUNCTION(Runtime_FunctionGetName) {
37 SealHandleScope shs(isolate); 37 SealHandleScope shs(isolate);
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 base::SmartArrayPointer<Handle<Object> > param_data = 507 base::SmartArrayPointer<Handle<Object> > param_data =
508 GetCallerArguments(isolate, bound_argc, &total_argc); 508 GetCallerArguments(isolate, bound_argc, &total_argc);
509 for (int i = 0; i < bound_argc; i++) { 509 for (int i = 0; i < bound_argc; i++) {
510 param_data[i] = Handle<Object>( 510 param_data[i] = Handle<Object>(
511 bound_args->get(JSFunction::kBoundArgumentsStartIndex + i), isolate); 511 bound_args->get(JSFunction::kBoundArgumentsStartIndex + i), isolate);
512 } 512 }
513 513
514 if (!bound_function->IsJSFunction()) { 514 if (!bound_function->IsJSFunction()) {
515 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 515 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
516 isolate, bound_function, 516 isolate, bound_function,
517 Execution::TryGetConstructorDelegate(isolate, bound_function)); 517 Execution::GetConstructorDelegate(isolate, bound_function));
518 } 518 }
519 DCHECK(bound_function->IsJSFunction()); 519 DCHECK(bound_function->IsJSFunction());
520 520
521 Handle<Object> result; 521 Handle<Object> result;
522 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 522 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
523 isolate, result, Execution::New(Handle<JSFunction>::cast(bound_function), 523 isolate, result, Execution::New(Handle<JSFunction>::cast(bound_function),
524 total_argc, param_data.get())); 524 total_argc, param_data.get()));
525 return *result; 525 return *result;
526 } 526 }
527 527
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 Execution::Call(isolate, fun, receiver, argc, argv, true)); 594 Execution::Call(isolate, fun, receiver, argc, argv, true));
595 return *result; 595 return *result;
596 } 596 }
597 597
598 598
599 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) { 599 RUNTIME_FUNCTION(Runtime_GetFunctionDelegate) {
600 HandleScope scope(isolate); 600 HandleScope scope(isolate);
601 DCHECK(args.length() == 1); 601 DCHECK(args.length() == 1);
602 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 602 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
603 RUNTIME_ASSERT(!object->IsJSFunction()); 603 RUNTIME_ASSERT(!object->IsJSFunction());
604 return *Execution::GetFunctionDelegate(isolate, object); 604 Handle<JSFunction> result;
605 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
606 isolate, result, Execution::GetFunctionDelegate(isolate, object));
607 return *result;
605 } 608 }
606 609
607 610
608 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) { 611 RUNTIME_FUNCTION(Runtime_GetConstructorDelegate) {
609 HandleScope scope(isolate); 612 HandleScope scope(isolate);
610 DCHECK(args.length() == 1); 613 DCHECK(args.length() == 1);
611 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 614 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
612 RUNTIME_ASSERT(!object->IsJSFunction()); 615 RUNTIME_ASSERT(!object->IsJSFunction());
613 return *Execution::GetConstructorDelegate(isolate, object); 616 Handle<JSFunction> result;
617 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
618 isolate, result, Execution::GetConstructorDelegate(isolate, object));
619 return *result;
614 } 620 }
615 621
616 622
617 RUNTIME_FUNCTION(Runtime_GetOriginalConstructor) { 623 RUNTIME_FUNCTION(Runtime_GetOriginalConstructor) {
618 SealHandleScope shs(isolate); 624 SealHandleScope shs(isolate);
619 DCHECK(args.length() == 0); 625 DCHECK(args.length() == 0);
620 JavaScriptFrameIterator it(isolate); 626 JavaScriptFrameIterator it(isolate);
621 JavaScriptFrame* frame = it.frame(); 627 JavaScriptFrame* frame = it.frame();
622 return frame->IsConstructor() ? frame->GetOriginalConstructor() 628 return frame->IsConstructor() ? frame->GetOriginalConstructor()
623 : isolate->heap()->undefined_value(); 629 : isolate->heap()->undefined_value();
(...skipping 24 matching lines...) Expand all
648 654
649 655
650 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { 656 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) {
651 HandleScope scope(isolate); 657 HandleScope scope(isolate);
652 DCHECK(args.length() == 0); 658 DCHECK(args.length() == 0);
653 THROW_NEW_ERROR_RETURN_FAILURE(isolate, 659 THROW_NEW_ERROR_RETURN_FAILURE(isolate,
654 NewTypeError(MessageTemplate::kStrongArity)); 660 NewTypeError(MessageTemplate::kStrongArity));
655 } 661 }
656 } // namespace internal 662 } // namespace internal
657 } // namespace v8 663 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698