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

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

Issue 10381045: Improve type checking, remove unused stub (removed also in x64 in preparation of porting the better… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « runtime/vm/code_generator_ia32.cc ('k') | runtime/vm/stub_code.h » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 // Compare if the classes are equal. 152 // Compare if the classes are equal.
153 __ Bind(&compare_classes); 153 __ Bind(&compare_classes);
154 // If type is an interface, we can skip the class equality check, 154 // If type is an interface, we can skip the class equality check,
155 // because instances cannot be of an interface type. 155 // because instances cannot be of an interface type.
156 if (!type_class.is_interface()) { 156 if (!type_class.is_interface()) {
157 __ LoadObject(RCX, type_class); 157 __ LoadObject(RCX, type_class);
158 __ movq(R10, FieldAddress(RAX, Object::class_offset())); 158 __ movq(R10, FieldAddress(RAX, Object::class_offset()));
159 __ cmpq(R10, RCX); 159 __ cmpq(R10, RCX);
160 __ j(EQUAL, is_instance); 160 __ j(EQUAL, is_instance);
161 // RAX, RCX, and RDX are preserved in stub, result is in RBX. 161 // TODO(srdjan): Finish implementation.
162 __ call(&StubCode::IsRawSubTypeLabel()); 162 // Otherwise fall through to runtime call.
163 // Result in RBX: 1 is raw subtype.
164 __ cmpq(RBX, Immediate(1));
165 __ j(EQUAL, is_instance);
166 // Otherwise fall through to runtime call.
167 } else { 163 } else {
168 // However, for specific core library interfaces, we can check for 164 // However, for specific core library interfaces, we can check for
169 // specific core library classes. 165 // specific core library classes.
170 Error& malformed_error = Error::Handle(); 166 Error& malformed_error = Error::Handle();
171 if (type.IsBoolInterface()) { 167 if (type.IsBoolInterface()) {
172 __ movq(RCX, FieldAddress(RAX, Object::class_offset())); 168 __ movq(RCX, FieldAddress(RAX, Object::class_offset()));
173 const Class& bool_class = Class::ZoneHandle( 169 const Class& bool_class = Class::ZoneHandle(
174 Isolate::Current()->object_store()->bool_class()); 170 Isolate::Current()->object_store()->bool_class());
175 __ CompareObject(RCX, bool_class); 171 __ CompareObject(RCX, bool_class);
176 __ j(EQUAL, is_instance); 172 __ j(EQUAL, is_instance);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 __ CompareObject(RCX, four_byte_string_class); 205 __ CompareObject(RCX, four_byte_string_class);
210 __ j(EQUAL, is_instance); 206 __ j(EQUAL, is_instance);
211 } else if (type.IsFunctionInterface()) { 207 } else if (type.IsFunctionInterface()) {
212 const Immediate raw_null = 208 const Immediate raw_null =
213 Immediate(reinterpret_cast<intptr_t>(Object::null())); 209 Immediate(reinterpret_cast<intptr_t>(Object::null()));
214 __ movq(RCX, FieldAddress(RAX, Object::class_offset())); 210 __ movq(RCX, FieldAddress(RAX, Object::class_offset()));
215 __ movq(RCX, FieldAddress(RCX, Class::signature_function_offset())); 211 __ movq(RCX, FieldAddress(RCX, Class::signature_function_offset()));
216 __ cmpq(RCX, raw_null); 212 __ cmpq(RCX, raw_null);
217 __ j(NOT_EQUAL, is_instance); 213 __ j(NOT_EQUAL, is_instance);
218 } else { 214 } else {
219 __ LoadObject(RCX, type_class); 215 // TODO(srdjan): Finish implementation.
220 // RAX: Instance (preserved).
221 // RCX: test class (preserved).
222 // RDX: instantiator type arguments (preserved).
223 __ call(&StubCode::IsRawSubTypeLabel());
224 // Result in RBX: 1 is raw subtype.
225 __ cmpq(RBX, Immediate(1));
226 __ j(EQUAL, is_instance);
227 // Otherwise fallthrough to runtime call.
228 } 216 }
229 } 217 }
230 } 218 }
231 } else { 219 } else {
232 ASSERT(!type.IsInstantiated()); 220 ASSERT(!type.IsInstantiated());
233 // Skip check if destination is a dynamic type. 221 // Skip check if destination is a dynamic type.
234 if (type.IsTypeParameter()) { 222 if (type.IsTypeParameter()) {
235 // Check if dynamic. 223 // Check if dynamic.
236 const Immediate raw_null = 224 const Immediate raw_null =
237 Immediate(reinterpret_cast<intptr_t>(Object::null())); 225 Immediate(reinterpret_cast<intptr_t>(Object::null()));
(...skipping 22 matching lines...) Expand all
260 // The instantiated type parameter RCX may not be a Type, but could be an 248 // The instantiated type parameter RCX may not be a Type, but could be an
261 // InstantiatedType. It is therefore necessary to check its class. 249 // InstantiatedType. It is therefore necessary to check its class.
262 __ movq(R10, FieldAddress(RCX, Object::class_offset())); 250 __ movq(R10, FieldAddress(RCX, Object::class_offset()));
263 __ CompareObject(R10, Object::ZoneHandle(Object::type_class())); 251 __ CompareObject(R10, Object::ZoneHandle(Object::type_class()));
264 __ j(NOT_EQUAL, &runtime_call, Assembler::kNearJump); 252 __ j(NOT_EQUAL, &runtime_call, Assembler::kNearJump);
265 __ movq(RCX, FieldAddress(RCX, Type::type_class_offset())); 253 __ movq(RCX, FieldAddress(RCX, Type::type_class_offset()));
266 __ movq(R10, FieldAddress(RCX, Class::type_parameters_offset())); 254 __ movq(R10, FieldAddress(RCX, Class::type_parameters_offset()));
267 // Check that class of type has no type parameters. 255 // Check that class of type has no type parameters.
268 __ cmpq(R10, raw_null); 256 __ cmpq(R10, raw_null);
269 __ j(NOT_EQUAL, &runtime_call, Assembler::kNearJump); 257 __ j(NOT_EQUAL, &runtime_call, Assembler::kNearJump);
270 // We have a non-parameterized class in RCX, compare with class of 258 // TODO(srdjan): Implement subtype test cache.
271 // value in RAX. RAX, RCX, and RDX are preserved in stub.
272 __ call(&StubCode::IsRawSubTypeLabel());
273 // Result in EBX: 1 is raw subtype.
274 __ cmpq(RBX, Immediate(1));
275 __ j(EQUAL, is_instance);
276 // Fall through to runtime call. 259 // Fall through to runtime call.
277 } 260 }
278 } 261 }
279 __ Bind(&runtime_call); 262 __ Bind(&runtime_call);
280 } 263 }
281 264
282 265
283 // Optimize assignable type check by adding inlined tests for: 266 // Optimize assignable type check by adding inlined tests for:
284 // - NULL -> return NULL. 267 // - NULL -> return NULL.
285 // - Smi -> compile time subtype check (only if dst class is not parameterized). 268 // - Smi -> compile time subtype check (only if dst class is not parameterized).
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 ASSERT(exception_handlers_list_ != NULL); 1708 ASSERT(exception_handlers_list_ != NULL);
1726 const ExceptionHandlers& handlers = ExceptionHandlers::Handle( 1709 const ExceptionHandlers& handlers = ExceptionHandlers::Handle(
1727 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint())); 1710 exception_handlers_list_->FinalizeExceptionHandlers(code.EntryPoint()));
1728 code.set_exception_handlers(handlers); 1711 code.set_exception_handlers(handlers);
1729 } 1712 }
1730 1713
1731 1714
1732 } // namespace dart 1715 } // namespace dart
1733 1716
1734 #endif // defined TARGET_ARCH_X64 1717 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_ia32.cc ('k') | runtime/vm/stub_code.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698