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

Side by Side Diff: runtime/vm/intermediate_language_x64.cc

Issue 627103005: Unrolls array initialization loop for small arrays. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/intermediate_language.h" 8 #include "vm/intermediate_language.h"
9 9
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1902 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 locs->set_out(0, Location::RegisterLocation(RAX)); 1913 locs->set_out(0, Location::RegisterLocation(RAX));
1914 return locs; 1914 return locs;
1915 } 1915 }
1916 1916
1917 1917
1918 // Inlines array allocation for known constant values. 1918 // Inlines array allocation for known constant values.
1919 static void InlineArrayAllocation(FlowGraphCompiler* compiler, 1919 static void InlineArrayAllocation(FlowGraphCompiler* compiler,
1920 intptr_t num_elements, 1920 intptr_t num_elements,
1921 Label* slow_path, 1921 Label* slow_path,
1922 Label* done) { 1922 Label* done) {
1923 const int kInlineArraySize = 12; // Same as kInlineInstanceSize.
1923 const Register kLengthReg = R10; 1924 const Register kLengthReg = R10;
1924 const Register kElemTypeReg = RBX; 1925 const Register kElemTypeReg = RBX;
1925 const intptr_t instance_size = Array::InstanceSize(num_elements); 1926 const intptr_t instance_size = Array::InstanceSize(num_elements);
1926 1927
1927 __ TryAllocateArray(kArrayCid, instance_size, slow_path, Assembler::kFarJump, 1928 __ TryAllocateArray(kArrayCid, instance_size, slow_path, Assembler::kFarJump,
1928 RAX, // instance 1929 RAX, // instance
1929 RCX); // end address 1930 RCX); // end address
1930 1931
1931 // RAX: new object start as a tagged pointer. 1932 // RAX: new object start as a tagged pointer.
1932 // Store the type argument field. 1933 // Store the type argument field.
1933 __ StoreIntoObjectNoBarrier(RAX, 1934 __ StoreIntoObjectNoBarrier(RAX,
1934 FieldAddress(RAX, Array::type_arguments_offset()), 1935 FieldAddress(RAX, Array::type_arguments_offset()),
1935 kElemTypeReg); 1936 kElemTypeReg);
1936 1937
1937 // Set the length field. 1938 // Set the length field.
1938 __ StoreIntoObjectNoBarrier(RAX, 1939 __ StoreIntoObjectNoBarrier(RAX,
1939 FieldAddress(RAX, Array::length_offset()), 1940 FieldAddress(RAX, Array::length_offset()),
1940 kLengthReg); 1941 kLengthReg);
1941 1942
1942 // Initialize all array elements to raw_null. 1943 // Initialize all array elements to raw_null.
1943 // RAX: new object start as a tagged pointer. 1944 // RAX: new object start as a tagged pointer.
1944 // RCX: new object end address. 1945 // RCX: new object end address.
1945 // RDI: iterator which initially points to the start of the variable 1946 // RDI: iterator which initially points to the start of the variable
1946 // data area to be initialized. 1947 // data area to be initialized.
1947 if (num_elements > 0) { 1948 if (num_elements > 0) {
1949 const intptr_t array_size = instance_size - sizeof(RawArray);
1948 __ LoadObject(R12, Object::null_object(), PP); 1950 __ LoadObject(R12, Object::null_object(), PP);
1949 __ leaq(RDI, FieldAddress(RAX, sizeof(RawArray))); 1951 __ leaq(RDI, FieldAddress(RAX, sizeof(RawArray)));
1950 Label init_loop; 1952 if (array_size < (kInlineArraySize * kWordSize)) {
1951 __ Bind(&init_loop); 1953 intptr_t current_offset = 0;
1952 __ movq(Address(RDI, 0), R12); 1954 while (current_offset < array_size) {
1953 __ addq(RDI, Immediate(kWordSize)); 1955 __ movq(Address(RDI, current_offset), R12);
1954 __ cmpq(RDI, RCX); 1956 current_offset += kWordSize;
1955 __ j(BELOW, &init_loop, Assembler::kNearJump); 1957 }
1958 } else {
1959 Label init_loop;
1960 __ Bind(&init_loop);
1961 __ movq(Address(RDI, 0), R12);
1962 __ addq(RDI, Immediate(kWordSize));
1963 __ cmpq(RDI, RCX);
1964 __ j(BELOW, &init_loop, Assembler::kNearJump);
1965 }
1956 } 1966 }
1957 __ jmp(done, Assembler::kNearJump); 1967 __ jmp(done, Assembler::kNearJump);
1958 } 1968 }
1959 1969
1960 1970
1961 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 1971 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
1962 // Allocate the array. R10 = length, RBX = element type. 1972 // Allocate the array. R10 = length, RBX = element type.
1963 const Register kLengthReg = R10; 1973 const Register kLengthReg = R10;
1964 const Register kElemTypeReg = RBX; 1974 const Register kElemTypeReg = RBX;
1965 const Register kResultReg = RAX; 1975 const Register kResultReg = RAX;
(...skipping 3947 matching lines...) Expand 10 before | Expand all | Expand 10 after
5913 __ movq(R10, Immediate(kInvalidObjectPointer)); 5923 __ movq(R10, Immediate(kInvalidObjectPointer));
5914 __ movq(RBX, Immediate(kInvalidObjectPointer)); 5924 __ movq(RBX, Immediate(kInvalidObjectPointer));
5915 #endif 5925 #endif
5916 } 5926 }
5917 5927
5918 } // namespace dart 5928 } // namespace dart
5919 5929
5920 #undef __ 5930 #undef __
5921 5931
5922 #endif // defined TARGET_ARCH_X64 5932 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698