OLD | NEW |
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 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 ASSERT(kStackTraceObjectReg == EDX); | 2025 ASSERT(kStackTraceObjectReg == EDX); |
2026 __ movl(kStackTraceObjectReg, Address(ESP, 5 * kWordSize)); | 2026 __ movl(kStackTraceObjectReg, Address(ESP, 5 * kWordSize)); |
2027 __ movl(kExceptionObjectReg, Address(ESP, 4 * kWordSize)); | 2027 __ movl(kExceptionObjectReg, Address(ESP, 4 * kWordSize)); |
2028 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. | 2028 __ movl(EBP, Address(ESP, 3 * kWordSize)); // Load target frame_pointer. |
2029 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. | 2029 __ movl(EBX, Address(ESP, 1 * kWordSize)); // Load target PC into EBX. |
2030 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. | 2030 __ movl(ESP, Address(ESP, 2 * kWordSize)); // Load target stack_pointer. |
2031 __ jmp(EBX); // Jump to the exception handler code. | 2031 __ jmp(EBX); // Jump to the exception handler code. |
2032 } | 2032 } |
2033 | 2033 |
2034 | 2034 |
2035 // Implements equality operator when one of the arguments is null | |
2036 // (identity check) and updates ICData if necessary. | |
2037 // TOS + 0: return address | |
2038 // TOS + 1: right argument | |
2039 // TOS + 2: left argument | |
2040 // ECX: ICData. | |
2041 // EAX: result. | |
2042 // TODO(srdjan): Move to VM stubs once Boolean objects become VM objects. | |
2043 void StubCode::GenerateEqualityWithNullArgStub(Assembler* assembler) { | |
2044 static const intptr_t kNumArgsTested = 2; | |
2045 #if defined(DEBUG) | |
2046 { Label ok; | |
2047 __ movl(EAX, FieldAddress(ECX, ICData::num_args_tested_offset())); | |
2048 __ cmpl(EAX, Immediate(kNumArgsTested)); | |
2049 __ j(EQUAL, &ok, Assembler::kNearJump); | |
2050 __ Stop("Incorrect ICData for equality"); | |
2051 __ Bind(&ok); | |
2052 } | |
2053 #endif // DEBUG | |
2054 // Check IC data, update if needed. | |
2055 // ECX: IC data object (preserved). | |
2056 __ movl(EBX, FieldAddress(ECX, ICData::ic_data_offset())); | |
2057 // EBX: ic_data_array with check entries: classes and target functions. | |
2058 __ leal(EBX, FieldAddress(EBX, Array::data_offset())); | |
2059 // EBX: points directly to the first ic data array element. | |
2060 | |
2061 Label get_class_id_as_smi, no_match, loop, compute_result, found; | |
2062 __ Bind(&loop); | |
2063 // Check left. | |
2064 __ movl(EAX, Address(ESP, 2 * kWordSize)); | |
2065 __ call(&get_class_id_as_smi); | |
2066 __ movl(EDI, Address(EBX, 0 * kWordSize)); | |
2067 __ cmpl(EAX, EDI); // Class id match? | |
2068 __ j(NOT_EQUAL, &no_match, Assembler::kNearJump); | |
2069 // Check right. | |
2070 __ movl(EAX, Address(ESP, 1 * kWordSize)); | |
2071 __ call(&get_class_id_as_smi); | |
2072 __ movl(EDI, Address(EBX, 1 * kWordSize)); | |
2073 __ cmpl(EAX, EDI); // Class id match? | |
2074 __ j(EQUAL, &found, Assembler::kNearJump); | |
2075 __ Bind(&no_match); | |
2076 // Next check group. | |
2077 __ addl(EBX, Immediate( | |
2078 kWordSize * ICData::TestEntryLengthFor(kNumArgsTested))); | |
2079 __ cmpl(EDI, Immediate(Smi::RawValue(kIllegalCid))); // Done? | |
2080 __ j(NOT_EQUAL, &loop, Assembler::kNearJump); | |
2081 Label update_ic_data; | |
2082 __ jmp(&update_ic_data); | |
2083 | |
2084 __ Bind(&found); | |
2085 const intptr_t count_offset = | |
2086 ICData::CountIndexFor(kNumArgsTested) * kWordSize; | |
2087 __ addl(Address(EBX, count_offset), Immediate(Smi::RawValue(1))); | |
2088 __ j(NO_OVERFLOW, &compute_result); | |
2089 __ movl(Address(EBX, count_offset), | |
2090 Immediate(Smi::RawValue(Smi::kMaxValue))); | |
2091 | |
2092 __ Bind(&compute_result); | |
2093 Label true_label; | |
2094 __ movl(EAX, Address(ESP, 1 * kWordSize)); | |
2095 __ cmpl(EAX, Address(ESP, 2 * kWordSize)); | |
2096 __ j(EQUAL, &true_label, Assembler::kNearJump); | |
2097 __ LoadObject(EAX, Bool::False()); | |
2098 __ ret(); | |
2099 __ Bind(&true_label); | |
2100 __ LoadObject(EAX, Bool::True()); | |
2101 __ ret(); | |
2102 | |
2103 __ Bind(&get_class_id_as_smi); | |
2104 Label not_smi; | |
2105 // Test if Smi -> load Smi class for comparison. | |
2106 __ testl(EAX, Immediate(kSmiTagMask)); | |
2107 __ j(NOT_ZERO, ¬_smi, Assembler::kNearJump); | |
2108 __ movl(EAX, Immediate(Smi::RawValue(kSmiCid))); | |
2109 __ ret(); | |
2110 | |
2111 __ Bind(¬_smi); | |
2112 __ LoadClassId(EAX, EAX); | |
2113 __ SmiTag(EAX); | |
2114 __ ret(); | |
2115 | |
2116 __ Bind(&update_ic_data); | |
2117 | |
2118 // ECX: ICData | |
2119 __ movl(EAX, Address(ESP, 1 * kWordSize)); | |
2120 __ movl(EDI, Address(ESP, 2 * kWordSize)); | |
2121 __ EnterStubFrame(); | |
2122 __ pushl(EDI); // arg 0 | |
2123 __ pushl(EAX); // arg 1 | |
2124 __ PushObject(Symbols::EqualOperator()); // Target's name. | |
2125 __ pushl(ECX); // ICData | |
2126 __ CallRuntime(kUpdateICDataTwoArgsRuntimeEntry, 4); | |
2127 __ Drop(4); | |
2128 __ LeaveFrame(); | |
2129 | |
2130 __ jmp(&compute_result, Assembler::kNearJump); | |
2131 } | |
2132 | |
2133 | |
2134 // Calls to the runtime to optimize the given function. | 2035 // Calls to the runtime to optimize the given function. |
2135 // EDI: function to be reoptimized. | 2036 // EDI: function to be reoptimized. |
2136 // EDX: argument descriptor (preserved). | 2037 // EDX: argument descriptor (preserved). |
2137 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { | 2038 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { |
2138 const Immediate& raw_null = | 2039 const Immediate& raw_null = |
2139 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 2040 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
2140 __ EnterStubFrame(); | 2041 __ EnterStubFrame(); |
2141 __ pushl(EDX); | 2042 __ pushl(EDX); |
2142 __ pushl(raw_null); // Setup space on stack for return value. | 2043 __ pushl(raw_null); // Setup space on stack for return value. |
2143 __ pushl(EDI); | 2044 __ pushl(EDI); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 2173 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
2273 __ popl(temp); | 2174 __ popl(temp); |
2274 __ popl(right); | 2175 __ popl(right); |
2275 __ popl(left); | 2176 __ popl(left); |
2276 __ ret(); | 2177 __ ret(); |
2277 } | 2178 } |
2278 | 2179 |
2279 } // namespace dart | 2180 } // namespace dart |
2280 | 2181 |
2281 #endif // defined TARGET_ARCH_IA32 | 2182 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |