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

Side by Side Diff: src/interpreter/interpreter-assembler.cc

Issue 1923253002: [generators] Create the fixed array holding the registers only once. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 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/interpreter-assembler.h" 5 #include "src/interpreter/interpreter-assembler.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 #endif 708 #endif
709 } 709 }
710 710
711 Node* InterpreterAssembler::RegisterCount() { 711 Node* InterpreterAssembler::RegisterCount() {
712 Node* bytecode_array = LoadRegister(Register::bytecode_array()); 712 Node* bytecode_array = LoadRegister(Register::bytecode_array());
713 Node* frame_size = LoadObjectField( 713 Node* frame_size = LoadObjectField(
714 bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Int32()); 714 bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Int32());
715 return Word32Sar(frame_size, Int32Constant(kPointerSizeLog2)); 715 return Word32Sar(frame_size, Int32Constant(kPointerSizeLog2));
716 } 716 }
717 717
718 Node* InterpreterAssembler::ExportRegisterFile() { 718 Node* InterpreterAssembler::ExportRegisterFile(Node* array) {
719 Node* register_count = RegisterCount();
720 Node* array =
721 AllocateUninitializedFixedArray(ChangeInt32ToIntPtr(register_count));
722
723 Variable var_index(this, MachineRepresentation::kWord32); 719 Variable var_index(this, MachineRepresentation::kWord32);
724 var_index.Bind(Int32Constant(0)); 720 var_index.Bind(Int32Constant(0));
725 721
726 // Iterate over register file and write values into array. 722 // Iterate over register file and write values into array.
727 Label loop(this, &var_index), done_loop(this); 723 Label loop(this, &var_index), done_loop(this);
728 Goto(&loop); 724 Goto(&loop);
729 Bind(&loop); 725 Bind(&loop);
730 { 726 {
731 Node* index = var_index.value(); 727 Node* index = var_index.value();
732 Node* condition = Int32LessThan(index, register_count); 728 Node* condition = Int32LessThan(index, RegisterCount());
733 GotoUnless(condition, &done_loop); 729 GotoUnless(condition, &done_loop);
734 730
735 Node* reg_index = 731 Node* reg_index =
736 Int32Sub(Int32Constant(Register(0).ToOperand()), index); 732 Int32Sub(Int32Constant(Register(0).ToOperand()), index);
737 Node* value = LoadRegister(ChangeInt32ToIntPtr(reg_index)); 733 Node* value = LoadRegister(ChangeInt32ToIntPtr(reg_index));
738 734
739 // No write barrier needed for writing into freshly allocated object. 735 // No write barrier needed for writing into freshly allocated object.
740 StoreFixedArrayElementNoWriteBarrier( 736 StoreFixedArrayElementNoWriteBarrier(
741 array, ChangeInt32ToIntPtr(index), value); 737 array, ChangeInt32ToIntPtr(index), value);
742 738
743 var_index.Bind(Int32Add(index, Int32Constant(1))); 739 var_index.Bind(Int32Add(index, Int32Constant(1)));
744 Goto(&loop); 740 Goto(&loop);
745 } 741 }
746 Bind(&done_loop); 742 Bind(&done_loop);
747 743
748 return array; 744 return array;
749 } 745 }
750 746
751 Node* InterpreterAssembler::ImportRegisterFile(Node* array) { 747 Node* InterpreterAssembler::ImportRegisterFile(Node* array) {
752 Node* register_count = RegisterCount();
753
754 Variable var_index(this, MachineRepresentation::kWord32); 748 Variable var_index(this, MachineRepresentation::kWord32);
755 var_index.Bind(Int32Constant(0)); 749 var_index.Bind(Int32Constant(0));
756 750
757 // Iterate over array and write values into register file. 751 // Iterate over array and write values into register file. Also erase the
752 // array contents to not keep them alive artificially.
758 Label loop(this, &var_index), done_loop(this); 753 Label loop(this, &var_index), done_loop(this);
759 Goto(&loop); 754 Goto(&loop);
760 Bind(&loop); 755 Bind(&loop);
761 { 756 {
762 Node* index = var_index.value(); 757 Node* index = var_index.value();
763 Node* condition = Int32LessThan(index, register_count); 758 Node* condition = Int32LessThan(index, RegisterCount());
764 GotoUnless(condition, &done_loop); 759 GotoUnless(condition, &done_loop);
765 760
766 Node* value = LoadFixedArrayElementInt32Index(array, index); 761 Node* value = LoadFixedArrayElementInt32Index(array, index);
767 762
768 Node* reg_index = 763 Node* reg_index =
769 Int32Sub(Int32Constant(Register(0).ToOperand()), index); 764 Int32Sub(Int32Constant(Register(0).ToOperand()), index);
770 StoreRegister(value, ChangeInt32ToIntPtr(reg_index)); 765 StoreRegister(value, ChangeInt32ToIntPtr(reg_index));
771 766
767 StoreFixedArrayElementInt32Index(array, index, PlaceholderConstant());
rmcilroy 2016/04/27 12:20:04 How about just filling the array with the hole or
Benedikt Meurer 2016/04/27 17:46:02 undefined is a valid JS value, so a bug in reading
rmcilroy 2016/04/28 08:05:49 Makes sense, SGTM with the rename you suggest.
768
772 var_index.Bind(Int32Add(index, Int32Constant(1))); 769 var_index.Bind(Int32Add(index, Int32Constant(1)));
773 Goto(&loop); 770 Goto(&loop);
774 } 771 }
775 Bind(&done_loop); 772 Bind(&done_loop);
776 773
777 return array; 774 return array;
778 } 775 }
779 776
780 } // namespace interpreter 777 } // namespace interpreter
781 } // namespace internal 778 } // namespace internal
782 } // namespace v8 779 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-assembler.h ('k') | src/objects.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698