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

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

Issue 2132803002: Megamorphic code cleanup. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | runtime/vm/stub_code_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" 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 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 const Register left = EAX; 2014 const Register left = EAX;
2015 const Register right = EDX; 2015 const Register right = EDX;
2016 const Register temp = ECX; 2016 const Register temp = ECX;
2017 __ movl(left, Address(ESP, 2 * kWordSize)); 2017 __ movl(left, Address(ESP, 2 * kWordSize));
2018 __ movl(right, Address(ESP, 1 * kWordSize)); 2018 __ movl(right, Address(ESP, 1 * kWordSize));
2019 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2019 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
2020 __ ret(); 2020 __ ret();
2021 } 2021 }
2022 2022
2023 2023
2024 void StubCode::EmitMegamorphicLookup(Assembler* assembler) {
2025 __ LoadTaggedClassIdMayBeSmi(EAX, EBX);
2026 // EAX: class ID of the receiver (smi).
2027 __ movl(EDI, FieldAddress(ECX, MegamorphicCache::buckets_offset()));
2028 __ movl(EBX, FieldAddress(ECX, MegamorphicCache::mask_offset()));
2029 // EDI: cache buckets array.
2030 // EBX: mask.
2031 __ pushl(ECX); // Spill MegamorphicCache.
2032
2033 // Compute the table index.
2034 ASSERT(MegamorphicCache::kSpreadFactor == 7);
2035 // Use leal and subl multiply with 7 == 8 - 1.
2036 __ leal(ECX, Address(EAX, TIMES_8, 0));
2037 __ subl(ECX, EAX);
2038 // ECX: probe.
2039
2040 Label loop, update, load_target_function;
2041 __ jmp(&loop);
2042
2043 __ Bind(&update);
2044 __ addl(ECX, Immediate(Smi::RawValue(1)));
2045 __ Bind(&loop);
2046 __ andl(ECX, EBX);
2047 const intptr_t base = Array::data_offset();
2048 // ECX is smi tagged, but table entries are two words, so TIMES_4.
2049 __ movl(EDX, FieldAddress(EDI, ECX, TIMES_4, base));
2050
2051 ASSERT(kIllegalCid == 0);
2052 __ testl(EDX, EDX);
2053 __ j(ZERO, &load_target_function, Assembler::kNearJump);
2054 __ cmpl(EDX, EAX);
2055 __ j(NOT_EQUAL, &update, Assembler::kNearJump);
2056
2057 __ Bind(&load_target_function);
2058 // Call the target found in the cache. For a class id match, this is a
2059 // proper target for the given name and arguments descriptor. If the
2060 // illegal class id was found, the target is a cache miss handler that can
2061 // be invoked as a normal Dart function.
2062 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
2063 __ popl(ECX); // Restore MegamorphicCache.
2064 __ movl(EDX,
2065 FieldAddress(ECX, MegamorphicCache::arguments_descriptor_offset()));
2066 __ movl(EBX, FieldAddress(EAX, Function::entry_point_offset()));
2067 }
2068
2069
2070 // Called from megamorphic calls. 2024 // Called from megamorphic calls.
2071 // EBX: receiver 2025 // EBX: receiver
2072 // ECX: MegamorphicCache (preserved) 2026 // ECX: MegamorphicCache (preserved)
2073 // Result: 2027 // Result:
2074 // EBX: target entry point 2028 // EBX: target entry point
2075 // EDX: argument descriptor 2029 // EDX: argument descriptor
2076 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2030 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2077 // Jump if receiver is a smi. 2031 // Jump if receiver is a smi.
2078 Label smi_case; 2032 Label smi_case;
2079 // Check if object (in tmp) is a Smi. 2033 // Check if object (in tmp) is a Smi.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 2108
2155 2109
2156 2110
2157 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) { 2111 void StubCode::GenerateFrameAwaitingMaterializationStub(Assembler* assembler) {
2158 __ int3(); 2112 __ int3();
2159 } 2113 }
2160 2114
2161 } // namespace dart 2115 } // namespace dart
2162 2116
2163 #endif // defined TARGET_ARCH_IA32 2117 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm64.cc ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698