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

Side by Side Diff: runtime/vm/intermediate_language_ia32.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_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | 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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 locs->set_out(0, Location::RegisterLocation(EAX)); 2055 locs->set_out(0, Location::RegisterLocation(EAX));
2056 return locs; 2056 return locs;
2057 } 2057 }
2058 2058
2059 2059
2060 // Inlines array allocation for known constant values. 2060 // Inlines array allocation for known constant values.
2061 static void InlineArrayAllocation(FlowGraphCompiler* compiler, 2061 static void InlineArrayAllocation(FlowGraphCompiler* compiler,
2062 intptr_t num_elements, 2062 intptr_t num_elements,
2063 Label* slow_path, 2063 Label* slow_path,
2064 Label* done) { 2064 Label* done) {
2065 const int kInlineArraySize = 12; // Same as kInlineInstanceSize.
2065 const Register kLengthReg = EDX; 2066 const Register kLengthReg = EDX;
2066 const Register kElemTypeReg = ECX; 2067 const Register kElemTypeReg = ECX;
2067 const intptr_t instance_size = Array::InstanceSize(num_elements); 2068 const intptr_t instance_size = Array::InstanceSize(num_elements);
2068 2069
2069 // Instance in EAX. 2070 // Instance in EAX.
2070 // Object end address in EBX. 2071 // Object end address in EBX.
2071 __ TryAllocateArray(kArrayCid, instance_size, slow_path, Assembler::kFarJump, 2072 __ TryAllocateArray(kArrayCid, instance_size, slow_path, Assembler::kFarJump,
2072 EAX, // instance 2073 EAX, // instance
2073 EBX); // end address 2074 EBX); // end address
2074 2075
2075 // Store the type argument field. 2076 // Store the type argument field.
2076 __ StoreIntoObjectNoBarrier(EAX, 2077 __ StoreIntoObjectNoBarrier(EAX,
2077 FieldAddress(EAX, Array::type_arguments_offset()), 2078 FieldAddress(EAX, Array::type_arguments_offset()),
2078 kElemTypeReg); 2079 kElemTypeReg);
2079 2080
2080 // Set the length field. 2081 // Set the length field.
2081 __ StoreIntoObjectNoBarrier(EAX, 2082 __ StoreIntoObjectNoBarrier(EAX,
2082 FieldAddress(EAX, Array::length_offset()), 2083 FieldAddress(EAX, Array::length_offset()),
2083 kLengthReg); 2084 kLengthReg);
2084 2085
2085 // Initialize all array elements to raw_null. 2086 // Initialize all array elements to raw_null.
2086 // EAX: new object start as a tagged pointer. 2087 // EAX: new object start as a tagged pointer.
2087 // EBX: new object end address. 2088 // EBX: new object end address.
2088 // EDI: iterator which initially points to the start of the variable 2089 // EDI: iterator which initially points to the start of the variable
2089 // data area to be initialized. 2090 // data area to be initialized.
2090 if (num_elements > 0) { 2091 if (num_elements > 0) {
2092 const intptr_t array_size = instance_size - sizeof(RawArray);
2091 const Immediate& raw_null = 2093 const Immediate& raw_null =
2092 Immediate(reinterpret_cast<intptr_t>(Object::null())); 2094 Immediate(reinterpret_cast<intptr_t>(Object::null()));
2093 __ leal(EDI, FieldAddress(EAX, sizeof(RawArray))); 2095 __ leal(EDI, FieldAddress(EAX, sizeof(RawArray)));
2094 Label init_loop; 2096 if (array_size < (kInlineArraySize * kWordSize)) {
2095 __ Bind(&init_loop); 2097 intptr_t current_offset = 0;
2096 __ movl(Address(EDI, 0), raw_null); 2098 __ movl(EBX, raw_null);
2097 __ addl(EDI, Immediate(kWordSize)); 2099 while (current_offset < array_size) {
2098 __ cmpl(EDI, EBX); 2100 __ movl(Address(EDI, current_offset), EBX);
2099 __ j(BELOW, &init_loop, Assembler::kNearJump); 2101 current_offset += kWordSize;
2102 }
2103 } else {
2104 Label init_loop;
2105 __ Bind(&init_loop);
2106 __ movl(Address(EDI, 0), raw_null);
2107 __ addl(EDI, Immediate(kWordSize));
2108 __ cmpl(EDI, EBX);
2109 __ j(BELOW, &init_loop, Assembler::kNearJump);
2110 }
2100 } 2111 }
2101 __ jmp(done, Assembler::kNearJump); 2112 __ jmp(done, Assembler::kNearJump);
2102 } 2113 }
2103 2114
2104 2115
2105 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 2116 void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
2106 // Allocate the array. EDX = length, ECX = element type. 2117 // Allocate the array. EDX = length, ECX = element type.
2107 const Register kLengthReg = EDX; 2118 const Register kLengthReg = EDX;
2108 const Register kElemTypeReg = ECX; 2119 const Register kElemTypeReg = ECX;
2109 const Register kResultReg = EAX; 2120 const Register kResultReg = EAX;
(...skipping 4661 matching lines...) Expand 10 before | Expand all | Expand 10 after
6771 __ movl(EDX, Immediate(kInvalidObjectPointer)); 6782 __ movl(EDX, Immediate(kInvalidObjectPointer));
6772 __ movl(EDX, Immediate(kInvalidObjectPointer)); 6783 __ movl(EDX, Immediate(kInvalidObjectPointer));
6773 #endif 6784 #endif
6774 } 6785 }
6775 6786
6776 } // namespace dart 6787 } // namespace dart
6777 6788
6778 #undef __ 6789 #undef __
6779 6790
6780 #endif // defined TARGET_ARCH_IA32 6791 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language_arm64.cc ('k') | runtime/vm/intermediate_language_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698