OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 | 8 |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 DCHECK(arg.index() - i == receiver.index() + 1); | 707 DCHECK(arg.index() - i == receiver.index() + 1); |
708 builder()->StoreAccumulatorInRegister(arg); | 708 builder()->StoreAccumulatorInRegister(arg); |
709 } | 709 } |
710 | 710 |
711 // TODO(rmcilroy): Deal with possible direct eval here? | 711 // TODO(rmcilroy): Deal with possible direct eval here? |
712 // TODO(rmcilroy): Use CallIC to allow call type feedback. | 712 // TODO(rmcilroy): Use CallIC to allow call type feedback. |
713 builder()->Call(callee, receiver, args->length()); | 713 builder()->Call(callee, receiver, args->length()); |
714 } | 714 } |
715 | 715 |
716 | 716 |
717 void BytecodeGenerator::VisitCallNew(CallNew* expr) { UNIMPLEMENTED(); } | 717 void BytecodeGenerator::VisitCallNew(CallNew* expr) { |
718 TemporaryRegisterScope temporary_register_scope(builder()); | |
719 Register constructor = temporary_register_scope.NewRegister(); | |
720 Visit(expr->expression()); | |
721 builder()->StoreAccumulatorInRegister(constructor); | |
722 | |
723 ZoneList<Expression*>* args = expr->arguments(); | |
724 if (args->length() > 0) { | |
725 Register first_arg = temporary_register_scope.NewRegister(); | |
726 | |
727 for (int i = 0; i < args->length(); ++i) { | |
728 Visit(args->at(i)); | |
729 Register arg = | |
730 (i == 0) ? first_arg : temporary_register_scope.NewRegister(); | |
731 DCHECK_EQ(arg.index() - i, first_arg.index()); | |
732 builder()->StoreAccumulatorInRegister(arg); | |
733 } | |
rmcilroy
2015/10/13 14:07:30
nit - would it be possible to pull out this code i
oth
2015/10/14 08:40:09
Done.
| |
734 builder()->New(constructor, first_arg, args->length()); | |
735 } else { | |
736 builder()->New(constructor, constructor, 0); | |
737 } | |
738 } | |
718 | 739 |
719 | 740 |
720 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 741 void BytecodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
721 if (expr->is_jsruntime()) { | 742 if (expr->is_jsruntime()) { |
722 UNIMPLEMENTED(); | 743 UNIMPLEMENTED(); |
723 } | 744 } |
724 | 745 |
725 // Evaluate all arguments to the runtime call. | 746 // Evaluate all arguments to the runtime call. |
726 ZoneList<Expression*>* args = expr->arguments(); | 747 ZoneList<Expression*>* args = expr->arguments(); |
727 TemporaryRegisterScope temporary_register_scope(&builder_); | 748 TemporaryRegisterScope temporary_register_scope(&builder_); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
867 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 888 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
868 return info()->feedback_vector()->GetIndex(slot); | 889 return info()->feedback_vector()->GetIndex(slot); |
869 } | 890 } |
870 | 891 |
871 | 892 |
872 Register BytecodeGenerator::current_context() const { return current_context_; } | 893 Register BytecodeGenerator::current_context() const { return current_context_; } |
873 | 894 |
874 } // namespace interpreter | 895 } // namespace interpreter |
875 } // namespace internal | 896 } // namespace internal |
876 } // namespace v8 | 897 } // namespace v8 |
OLD | NEW |