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

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

Issue 1125623003: Move megamorphic lookup code to stub instead of inlining. Preformance loss < 5%, instruction size r… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 | 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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 Assembler* assembler) { 2047 Assembler* assembler) {
2048 const Register left = EAX; 2048 const Register left = EAX;
2049 const Register right = EDX; 2049 const Register right = EDX;
2050 const Register temp = ECX; 2050 const Register temp = ECX;
2051 __ movl(left, Address(ESP, 2 * kWordSize)); 2051 __ movl(left, Address(ESP, 2 * kWordSize));
2052 __ movl(right, Address(ESP, 1 * kWordSize)); 2052 __ movl(right, Address(ESP, 1 * kWordSize));
2053 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2053 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
2054 __ ret(); 2054 __ ret();
2055 } 2055 }
2056 2056
2057
2058 // Called from megamorphic calls.
2059 // EDI: receiver.
2060 // EBX: lookup cache.
2061 // Result:
2062 // EBX: entry point.
2063 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2064 __ LoadTaggedClassIdMayBeSmi(EAX, EDI);
2065
2066 // EAX: class ID of the receiver (smi).
2067 __ movl(EDI, FieldAddress(EBX, MegamorphicCache::buckets_offset()));
2068 __ movl(EBX, FieldAddress(EBX, MegamorphicCache::mask_offset()));
2069 // EDI: cache buckets array.
2070 // EBX: mask.
2071 __ movl(ECX, EAX);
2072
2073 Label loop, update, call_target_function;
2074 __ jmp(&loop);
2075
2076 __ Bind(&update);
2077 __ addl(ECX, Immediate(Smi::RawValue(1)));
2078 __ Bind(&loop);
2079 __ andl(ECX, EBX);
2080 const intptr_t base = Array::data_offset();
2081 // ECX is smi tagged, but table entries are two words, so TIMES_4.
2082 __ movl(EDX, FieldAddress(EDI, ECX, TIMES_4, base));
2083
2084 ASSERT(kIllegalCid == 0);
2085 __ testl(EDX, EDX);
2086 __ j(ZERO, &call_target_function, Assembler::kNearJump);
2087 __ cmpl(EDX, EAX);
2088 __ j(NOT_EQUAL, &update, Assembler::kNearJump);
2089
2090 __ Bind(&call_target_function);
2091 // Call the target found in the cache. For a class id match, this is a
2092 // proper target for the given name and arguments descriptor. If the
2093 // illegal class id was found, the target is a cache miss handler that can
2094 // be invoked as a normal Dart function.
2095 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
2096 __ movl(EBX, FieldAddress(EAX, Function::instructions_offset()));
2097 // TODO(srdjan): Evaluate performance impact of moving the instruction below
2098 // to the call site, instead of having it here.
2099 __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
2100 __ ret();
2101 }
2102
2103
2057 } // namespace dart 2104 } // namespace dart
2058 2105
2059 #endif // defined TARGET_ARCH_IA32 2106 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698