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

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

Issue 167683002: Simplify type argument instantiation cache lookup by introducing an array (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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
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 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 const Immediate& raw_null = 2179 const Immediate& raw_null =
2180 Immediate(reinterpret_cast<intptr_t>(Object::null())); 2180 Immediate(reinterpret_cast<intptr_t>(Object::null()));
2181 __ cmpl(instantiator_reg, raw_null); 2181 __ cmpl(instantiator_reg, raw_null);
2182 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump); 2182 __ j(EQUAL, &type_arguments_instantiated, Assembler::kNearJump);
2183 } 2183 }
2184 // Lookup cache before calling runtime. 2184 // Lookup cache before calling runtime.
2185 // TODO(fschneider): Consider moving this into a shared stub to reduce 2185 // TODO(fschneider): Consider moving this into a shared stub to reduce
2186 // generated code size. 2186 // generated code size.
2187 __ LoadObject(EDI, type_arguments()); 2187 __ LoadObject(EDI, type_arguments());
2188 __ movl(EDI, FieldAddress(EDI, TypeArguments::instantiations_offset())); 2188 __ movl(EDI, FieldAddress(EDI, TypeArguments::instantiations_offset()));
2189 __ movl(EBX, FieldAddress(EDI, Array::length_offset()));
2190 __ leal(EDI, FieldAddress(EDI, Array::data_offset())); 2189 __ leal(EDI, FieldAddress(EDI, Array::data_offset()));
2191 __ leal(EBX, Address(EDI, EBX, TIMES_2, 0)); // EBX is smi. 2190 // The instantiations cache is initialized with Object::zero_array() and is
2191 // therefore guaranteed to contain kNoInstantiator. No length check needed.
2192 Label loop, found, slow_case; 2192 Label loop, found, slow_case;
2193 __ Bind(&loop); 2193 __ Bind(&loop);
2194 __ cmpl(EDI, EBX);
2195 __ j(ABOVE_EQUAL, &slow_case);
2196 __ movl(EDX, Address(EDI, 0 * kWordSize)); // Cached instantiator. 2194 __ movl(EDX, Address(EDI, 0 * kWordSize)); // Cached instantiator.
2197 __ cmpl(EDX, EAX); 2195 __ cmpl(EDX, EAX);
2198 __ j(EQUAL, &found, Assembler::kNearJump); 2196 __ j(EQUAL, &found, Assembler::kNearJump);
2199 __ cmpl(EDX, Immediate(Smi::RawValue(StubCode::kNoInstantiator))); 2197 __ cmpl(EDX, Immediate(Smi::RawValue(StubCode::kNoInstantiator)));
2200 __ j(EQUAL, &slow_case); 2198 __ j(EQUAL, &slow_case);
2201 __ addl(EDI, Immediate(2 * kWordSize)); 2199 __ addl(EDI, Immediate(2 * kWordSize));
Florian Schneider 2014/02/17 10:09:59 You could save one branch instruction by reorderin
regis 2014/02/18 19:29:29 Done on all platforms.
2202 __ jmp(&loop, Assembler::kNearJump); 2200 __ jmp(&loop, Assembler::kNearJump);
2203 __ Bind(&found); 2201 __ Bind(&found);
2204 __ movl(EAX, Address(EDI, 1 * kWordSize)); // Cached instantiated args. 2202 __ movl(EAX, Address(EDI, 1 * kWordSize)); // Cached instantiated args.
2205 __ jmp(&type_arguments_instantiated); 2203 __ jmp(&type_arguments_instantiated);
2206 2204
2207 __ Bind(&slow_case); 2205 __ Bind(&slow_case);
2208 // Instantiate non-null type arguments. 2206 // Instantiate non-null type arguments.
2209 // A runtime call to instantiate the type arguments is required. 2207 // A runtime call to instantiate the type arguments is required.
2210 __ PushObject(Object::ZoneHandle()); // Make room for the result. 2208 __ PushObject(Object::ZoneHandle()); // Make room for the result.
2211 __ PushObject(type_arguments()); 2209 __ PushObject(type_arguments());
(...skipping 3065 matching lines...) Expand 10 before | Expand all | Expand 10 after
5277 PcDescriptors::kOther, 5275 PcDescriptors::kOther,
5278 locs()); 5276 locs());
5279 __ Drop(2); // Discard type arguments and receiver. 5277 __ Drop(2); // Discard type arguments and receiver.
5280 } 5278 }
5281 5279
5282 } // namespace dart 5280 } // namespace dart
5283 5281
5284 #undef __ 5282 #undef __
5285 5283
5286 #endif // defined TARGET_ARCH_IA32 5284 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698