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/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 isolate, result, Execution::Call(isolate, fun, receiver, argc, argv)); | 563 isolate, result, Execution::Call(isolate, fun, receiver, argc, argv)); |
564 return *result; | 564 return *result; |
565 } | 565 } |
566 | 566 |
567 | 567 |
568 RUNTIME_FUNCTION(Runtime_GetOriginalConstructor) { | 568 RUNTIME_FUNCTION(Runtime_GetOriginalConstructor) { |
569 SealHandleScope shs(isolate); | 569 SealHandleScope shs(isolate); |
570 DCHECK(args.length() == 0); | 570 DCHECK(args.length() == 0); |
571 JavaScriptFrameIterator it(isolate); | 571 JavaScriptFrameIterator it(isolate); |
572 JavaScriptFrame* frame = it.frame(); | 572 JavaScriptFrame* frame = it.frame(); |
573 // Currently we don't inline [[Construct]] calls. | 573 // TODO(4544): Currently we never inline any [[Construct]] calls where the |
574 return frame->IsConstructor() && !frame->HasInlinedFrames() | 574 // actual constructor differs from the original constructor. Fix this soon! |
575 ? frame->GetOriginalConstructor() | 575 if (frame->HasInlinedFrames()) { |
576 : isolate->heap()->undefined_value(); | 576 HandleScope scope(isolate); |
| 577 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
| 578 it.frame()->Summarize(&frames); |
| 579 FrameSummary& summary = frames.last(); |
| 580 return summary.is_constructor() ? Object::cast(*summary.function()) |
| 581 : isolate->heap()->undefined_value(); |
| 582 } |
| 583 return frame->IsConstructor() ? frame->GetOriginalConstructor() |
| 584 : isolate->heap()->undefined_value(); |
577 } | 585 } |
578 | 586 |
579 | 587 |
580 // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee. | 588 // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee. |
581 RUNTIME_FUNCTION(Runtime_ConvertReceiver) { | 589 RUNTIME_FUNCTION(Runtime_ConvertReceiver) { |
582 HandleScope scope(isolate); | 590 HandleScope scope(isolate); |
583 DCHECK(args.length() == 1); | 591 DCHECK(args.length() == 1); |
584 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); | 592 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); |
585 if (receiver->IsNull() || receiver->IsUndefined()) { | 593 if (receiver->IsNull() || receiver->IsUndefined()) { |
586 return isolate->global_proxy(); | 594 return isolate->global_proxy(); |
587 } | 595 } |
588 return *Object::ToObject(isolate, receiver).ToHandleChecked(); | 596 return *Object::ToObject(isolate, receiver).ToHandleChecked(); |
589 } | 597 } |
590 | 598 |
591 | 599 |
592 RUNTIME_FUNCTION(Runtime_IsConstructCall) { | 600 RUNTIME_FUNCTION(Runtime_IsConstructCall) { |
593 SealHandleScope shs(isolate); | 601 HandleScope scope(isolate); |
594 DCHECK(args.length() == 0); | 602 DCHECK(args.length() == 0); |
595 JavaScriptFrameIterator it(isolate); | 603 JavaScriptFrameIterator it(isolate); |
596 JavaScriptFrame* frame = it.frame(); | 604 List<FrameSummary> frames(FLAG_max_inlining_levels + 1); |
597 return isolate->heap()->ToBoolean(frame->IsConstructor()); | 605 it.frame()->Summarize(&frames); |
| 606 FrameSummary& summary = frames.last(); |
| 607 return isolate->heap()->ToBoolean(summary.is_constructor()); |
598 } | 608 } |
599 | 609 |
600 | 610 |
601 RUNTIME_FUNCTION(Runtime_IsFunction) { | 611 RUNTIME_FUNCTION(Runtime_IsFunction) { |
602 SealHandleScope shs(isolate); | 612 SealHandleScope shs(isolate); |
603 DCHECK(args.length() == 1); | 613 DCHECK(args.length() == 1); |
604 CONVERT_ARG_CHECKED(Object, obj, 0); | 614 CONVERT_ARG_CHECKED(Object, obj, 0); |
605 return isolate->heap()->ToBoolean(obj->IsJSFunction()); | 615 return isolate->heap()->ToBoolean(obj->IsJSFunction()); |
606 } | 616 } |
607 | 617 |
608 | 618 |
609 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { | 619 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { |
610 HandleScope scope(isolate); | 620 HandleScope scope(isolate); |
611 DCHECK(args.length() == 0); | 621 DCHECK(args.length() == 0); |
612 THROW_NEW_ERROR_RETURN_FAILURE(isolate, | 622 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
613 NewTypeError(MessageTemplate::kStrongArity)); | 623 NewTypeError(MessageTemplate::kStrongArity)); |
614 } | 624 } |
615 | 625 |
616 } // namespace internal | 626 } // namespace internal |
617 } // namespace v8 | 627 } // namespace v8 |
OLD | NEW |