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

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

Issue 1584223006: Remove signature classes from the VM. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
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_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 "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // Clobbers R10. 267 // Clobbers R10.
268 RawSubtypeTestCache* 268 RawSubtypeTestCache*
269 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( 269 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest(
270 intptr_t token_pos, 270 intptr_t token_pos,
271 const AbstractType& type, 271 const AbstractType& type,
272 Label* is_instance_lbl, 272 Label* is_instance_lbl,
273 Label* is_not_instance_lbl) { 273 Label* is_not_instance_lbl) {
274 __ Comment("InstantiatedTypeWithArgumentsTest"); 274 __ Comment("InstantiatedTypeWithArgumentsTest");
275 ASSERT(type.IsInstantiated()); 275 ASSERT(type.IsInstantiated());
276 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); 276 const Class& type_class = Class::ZoneHandle(zone(), type.type_class());
277 ASSERT((type_class.NumTypeArguments() > 0) || type_class.IsSignatureClass()); 277 ASSERT(type.IsFunctionType() || (type_class.NumTypeArguments() > 0));
278 const Register kInstanceReg = RAX; 278 const Register kInstanceReg = RAX;
279 Error& bound_error = Error::Handle(zone()); 279 Error& bound_error = Error::Handle(zone());
280 const Type& int_type = Type::Handle(zone(), Type::IntType()); 280 const Type& int_type = Type::Handle(zone(), Type::IntType());
281 const bool smi_is_ok = int_type.IsSubtypeOf(type, &bound_error, Heap::kOld); 281 const bool smi_is_ok = int_type.IsSubtypeOf(type, &bound_error, Heap::kOld);
282 // Malformed type should have been handled at graph construction time. 282 // Malformed type should have been handled at graph construction time.
283 ASSERT(smi_is_ok || bound_error.IsNull()); 283 ASSERT(smi_is_ok || bound_error.IsNull());
284 __ testq(kInstanceReg, Immediate(kSmiTagMask)); 284 __ testq(kInstanceReg, Immediate(kSmiTagMask));
285 if (smi_is_ok) { 285 if (smi_is_ok) {
286 __ j(ZERO, is_instance_lbl); 286 __ j(ZERO, is_instance_lbl);
287 } else { 287 } else {
288 __ j(ZERO, is_not_instance_lbl); 288 __ j(ZERO, is_not_instance_lbl);
289 } 289 }
290 const intptr_t num_type_args = type_class.NumTypeArguments(); 290 // A function type test requires checking the function signature.
291 const intptr_t num_type_params = type_class.NumTypeParameters(); 291 if (!type.IsFunctionType()) {
292 const intptr_t from_index = num_type_args - num_type_params; 292 const intptr_t num_type_args = type_class.NumTypeArguments();
293 const TypeArguments& type_arguments = 293 const intptr_t num_type_params = type_class.NumTypeParameters();
294 TypeArguments::ZoneHandle(zone(), type.arguments()); 294 const intptr_t from_index = num_type_args - num_type_params;
295 const bool is_raw_type = type_arguments.IsNull() || 295 const TypeArguments& type_arguments =
296 type_arguments.IsRaw(from_index, num_type_params); 296 TypeArguments::ZoneHandle(zone(), type.arguments());
297 // Signature class is an instantiated parameterized type. 297 const bool is_raw_type = type_arguments.IsNull() ||
298 if (!type_class.IsSignatureClass()) { 298 type_arguments.IsRaw(from_index, num_type_params);
299 if (is_raw_type) { 299 if (is_raw_type) {
300 const Register kClassIdReg = R10; 300 const Register kClassIdReg = R10;
301 // dynamic type argument, check only classes. 301 // dynamic type argument, check only classes.
302 __ LoadClassId(kClassIdReg, kInstanceReg); 302 __ LoadClassId(kClassIdReg, kInstanceReg);
303 __ cmpl(kClassIdReg, Immediate(type_class.id())); 303 __ cmpl(kClassIdReg, Immediate(type_class.id()));
304 __ j(EQUAL, is_instance_lbl); 304 __ j(EQUAL, is_instance_lbl);
305 // List is a very common case. 305 // List is a very common case.
306 if (IsListClass(type_class)) { 306 if (IsListClass(type_class)) {
307 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); 307 GenerateListTypeCheck(kClassIdReg, is_instance_lbl);
308 } 308 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // RAX: instance to test against (preserved). 355 // RAX: instance to test against (preserved).
356 // Clobbers R10, R13. 356 // Clobbers R10, R13.
357 // Returns true if there is a fallthrough. 357 // Returns true if there is a fallthrough.
358 bool FlowGraphCompiler::GenerateInstantiatedTypeNoArgumentsTest( 358 bool FlowGraphCompiler::GenerateInstantiatedTypeNoArgumentsTest(
359 intptr_t token_pos, 359 intptr_t token_pos,
360 const AbstractType& type, 360 const AbstractType& type,
361 Label* is_instance_lbl, 361 Label* is_instance_lbl,
362 Label* is_not_instance_lbl) { 362 Label* is_not_instance_lbl) {
363 __ Comment("InstantiatedTypeNoArgumentsTest"); 363 __ Comment("InstantiatedTypeNoArgumentsTest");
364 ASSERT(type.IsInstantiated()); 364 ASSERT(type.IsInstantiated());
365 if (type.IsFunctionType()) {
366 // Fallthrough.
367 return true;
368 }
365 const Class& type_class = Class::Handle(zone(), type.type_class()); 369 const Class& type_class = Class::Handle(zone(), type.type_class());
366 ASSERT(type_class.NumTypeArguments() == 0); 370 ASSERT(type_class.NumTypeArguments() == 0);
367 371
368 const Register kInstanceReg = RAX; 372 const Register kInstanceReg = RAX;
369 __ testq(kInstanceReg, Immediate(kSmiTagMask)); 373 __ testq(kInstanceReg, Immediate(kSmiTagMask));
370 // If instance is Smi, check directly. 374 // If instance is Smi, check directly.
371 const Class& smi_class = Class::Handle(zone(), Smi::Class()); 375 const Class& smi_class = Class::Handle(zone(), Smi::Class());
372 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), 376 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()),
373 type_class, 377 type_class,
374 TypeArguments::Handle(zone()), 378 TypeArguments::Handle(zone()),
(...skipping 10 matching lines...) Expand all
385 __ j(EQUAL, is_instance_lbl); 389 __ j(EQUAL, is_instance_lbl);
386 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted 390 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted
387 // interfaces. 391 // interfaces.
388 // Bool interface can be implemented only by core class Bool. 392 // Bool interface can be implemented only by core class Bool.
389 if (type.IsBoolType()) { 393 if (type.IsBoolType()) {
390 __ cmpl(kClassIdReg, Immediate(kBoolCid)); 394 __ cmpl(kClassIdReg, Immediate(kBoolCid));
391 __ j(EQUAL, is_instance_lbl); 395 __ j(EQUAL, is_instance_lbl);
392 __ jmp(is_not_instance_lbl); 396 __ jmp(is_not_instance_lbl);
393 return false; 397 return false;
394 } 398 }
395 if (type.IsFunctionType()) { 399 if (type.IsDartFunctionType()) {
396 // Check if instance is a closure. 400 // Check if instance is a closure.
397 __ LoadClassById(R13, kClassIdReg); 401 __ cmpq(kClassIdReg, Immediate(kClosureCid));
398 __ movq(R13, FieldAddress(R13, Class::signature_function_offset())); 402 __ j(EQUAL, is_instance_lbl);
399 __ CompareObject(R13, Object::null_object());
400 __ j(NOT_EQUAL, is_instance_lbl);
401 } 403 }
402 // Custom checking for numbers (Smi, Mint, Bigint and Double). 404 // Custom checking for numbers (Smi, Mint, Bigint and Double).
403 // Note that instance is not Smi (checked above). 405 // Note that instance is not Smi (checked above).
404 if (type.IsSubtypeOf( 406 if (type.IsSubtypeOf(
405 Type::Handle(zone(), Type::Number()), NULL, Heap::kOld)) { 407 Type::Handle(zone(), Type::Number()), NULL, Heap::kOld)) {
406 GenerateNumberTypeCheck( 408 GenerateNumberTypeCheck(
407 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); 409 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl);
408 return false; 410 return false;
409 } 411 }
410 if (type.IsStringType()) { 412 if (type.IsStringType()) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 Label* is_instance_lbl, 544 Label* is_instance_lbl,
543 Label* is_not_instance_lbl) { 545 Label* is_not_instance_lbl) {
544 __ Comment("InlineInstanceof"); 546 __ Comment("InlineInstanceof");
545 if (type.IsVoidType()) { 547 if (type.IsVoidType()) {
546 // A non-null value is returned from a void function, which will result in a 548 // A non-null value is returned from a void function, which will result in a
547 // type error. A null value is handled prior to executing this inline code. 549 // type error. A null value is handled prior to executing this inline code.
548 return SubtypeTestCache::null(); 550 return SubtypeTestCache::null();
549 } 551 }
550 if (type.IsInstantiated()) { 552 if (type.IsInstantiated()) {
551 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); 553 const Class& type_class = Class::ZoneHandle(zone(), type.type_class());
552 // A class equality check is only applicable with a dst type of a 554 // A class equality check is only applicable with a dst type (not a
553 // non-parameterized class, non-signature class, or with a raw dst type of 555 // function type) of a non-parameterized class or with a raw dst type of
554 // a parameterized class. 556 // a parameterized class.
555 if (type_class.IsSignatureClass() || (type_class.NumTypeArguments() > 0)) { 557 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) {
556 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, 558 return GenerateInstantiatedTypeWithArgumentsTest(token_pos,
557 type, 559 type,
558 is_instance_lbl, 560 is_instance_lbl,
559 is_not_instance_lbl); 561 is_not_instance_lbl);
560 // Fall through to runtime call. 562 // Fall through to runtime call.
561 } 563 }
562 const bool has_fall_through = 564 const bool has_fall_through =
563 GenerateInstantiatedTypeNoArgumentsTest(token_pos, 565 GenerateInstantiatedTypeNoArgumentsTest(token_pos,
564 type, 566 type,
565 is_instance_lbl, 567 is_instance_lbl,
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 __ movups(reg, Address(RSP, 0)); 1812 __ movups(reg, Address(RSP, 0));
1811 __ AddImmediate(RSP, Immediate(kFpuRegisterSize)); 1813 __ AddImmediate(RSP, Immediate(kFpuRegisterSize));
1812 } 1814 }
1813 1815
1814 1816
1815 #undef __ 1817 #undef __
1816 1818
1817 } // namespace dart 1819 } // namespace dart
1818 1820
1819 #endif // defined TARGET_ARCH_X64 1821 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698