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

Side by Side Diff: runtime/vm/flow_graph_compiler_ia32.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_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // Clobbers ECX, EDI. 270 // Clobbers ECX, EDI.
271 RawSubtypeTestCache* 271 RawSubtypeTestCache*
272 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest( 272 FlowGraphCompiler::GenerateInstantiatedTypeWithArgumentsTest(
273 intptr_t token_pos, 273 intptr_t token_pos,
274 const AbstractType& type, 274 const AbstractType& type,
275 Label* is_instance_lbl, 275 Label* is_instance_lbl,
276 Label* is_not_instance_lbl) { 276 Label* is_not_instance_lbl) {
277 __ Comment("InstantiatedTypeWithArgumentsTest"); 277 __ Comment("InstantiatedTypeWithArgumentsTest");
278 ASSERT(type.IsInstantiated()); 278 ASSERT(type.IsInstantiated());
279 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); 279 const Class& type_class = Class::ZoneHandle(zone(), type.type_class());
280 ASSERT((type_class.NumTypeArguments() > 0) || type_class.IsSignatureClass()); 280 ASSERT(type.IsFunctionType() || (type_class.NumTypeArguments() > 0));
281 const Register kInstanceReg = EAX; 281 const Register kInstanceReg = EAX;
282 Error& bound_error = Error::Handle(zone()); 282 Error& bound_error = Error::Handle(zone());
283 const Type& int_type = Type::Handle(zone(), Type::IntType()); 283 const Type& int_type = Type::Handle(zone(), Type::IntType());
284 const bool smi_is_ok = int_type.IsSubtypeOf(type, &bound_error, Heap::kOld); 284 const bool smi_is_ok = int_type.IsSubtypeOf(type, &bound_error, Heap::kOld);
285 // Malformed type should have been handled at graph construction time. 285 // Malformed type should have been handled at graph construction time.
286 ASSERT(smi_is_ok || bound_error.IsNull()); 286 ASSERT(smi_is_ok || bound_error.IsNull());
287 __ testl(kInstanceReg, Immediate(kSmiTagMask)); 287 __ testl(kInstanceReg, Immediate(kSmiTagMask));
288 if (smi_is_ok) { 288 if (smi_is_ok) {
289 __ j(ZERO, is_instance_lbl); 289 __ j(ZERO, is_instance_lbl);
290 } else { 290 } else {
291 __ j(ZERO, is_not_instance_lbl); 291 __ j(ZERO, is_not_instance_lbl);
292 } 292 }
293 const intptr_t num_type_args = type_class.NumTypeArguments(); 293 // A function type test requires checking the function signature.
294 const intptr_t num_type_params = type_class.NumTypeParameters(); 294 if (!type.IsFunctionType()) {
295 const intptr_t from_index = num_type_args - num_type_params; 295 const intptr_t num_type_args = type_class.NumTypeArguments();
296 const TypeArguments& type_arguments = 296 const intptr_t num_type_params = type_class.NumTypeParameters();
297 TypeArguments::ZoneHandle(zone(), type.arguments()); 297 const intptr_t from_index = num_type_args - num_type_params;
298 const bool is_raw_type = type_arguments.IsNull() || 298 const TypeArguments& type_arguments =
299 type_arguments.IsRaw(from_index, num_type_params); 299 TypeArguments::ZoneHandle(zone(), type.arguments());
300 // Signature class is an instantiated parameterized type. 300 const bool is_raw_type = type_arguments.IsNull() ||
301 if (!type_class.IsSignatureClass()) { 301 type_arguments.IsRaw(from_index, num_type_params);
302 if (is_raw_type) { 302 if (is_raw_type) {
303 const Register kClassIdReg = ECX; 303 const Register kClassIdReg = ECX;
304 // dynamic type argument, check only classes. 304 // dynamic type argument, check only classes.
305 __ LoadClassId(kClassIdReg, kInstanceReg); 305 __ LoadClassId(kClassIdReg, kInstanceReg);
306 __ cmpl(kClassIdReg, Immediate(type_class.id())); 306 __ cmpl(kClassIdReg, Immediate(type_class.id()));
307 __ j(EQUAL, is_instance_lbl); 307 __ j(EQUAL, is_instance_lbl);
308 // List is a very common case. 308 // List is a very common case.
309 if (IsListClass(type_class)) { 309 if (IsListClass(type_class)) {
310 GenerateListTypeCheck(kClassIdReg, is_instance_lbl); 310 GenerateListTypeCheck(kClassIdReg, is_instance_lbl);
311 } 311 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 // EAX: instance to test against (preserved). 358 // EAX: instance to test against (preserved).
359 // Clobbers ECX, EDI. 359 // Clobbers ECX, EDI.
360 // Returns true if there is a fallthrough. 360 // Returns true if there is a fallthrough.
361 bool FlowGraphCompiler::GenerateInstantiatedTypeNoArgumentsTest( 361 bool FlowGraphCompiler::GenerateInstantiatedTypeNoArgumentsTest(
362 intptr_t token_pos, 362 intptr_t token_pos,
363 const AbstractType& type, 363 const AbstractType& type,
364 Label* is_instance_lbl, 364 Label* is_instance_lbl,
365 Label* is_not_instance_lbl) { 365 Label* is_not_instance_lbl) {
366 __ Comment("InstantiatedTypeNoArgumentsTest"); 366 __ Comment("InstantiatedTypeNoArgumentsTest");
367 ASSERT(type.IsInstantiated()); 367 ASSERT(type.IsInstantiated());
368 if (type.IsFunctionType()) {
369 // Fallthrough.
370 return true;
371 }
368 const Class& type_class = Class::Handle(zone(), type.type_class()); 372 const Class& type_class = Class::Handle(zone(), type.type_class());
369 ASSERT(type_class.NumTypeArguments() == 0); 373 ASSERT(type_class.NumTypeArguments() == 0);
370 374
371 const Register kInstanceReg = EAX; 375 const Register kInstanceReg = EAX;
372 __ testl(kInstanceReg, Immediate(kSmiTagMask)); 376 __ testl(kInstanceReg, Immediate(kSmiTagMask));
373 // If instance is Smi, check directly. 377 // If instance is Smi, check directly.
374 const Class& smi_class = Class::Handle(zone(), Smi::Class()); 378 const Class& smi_class = Class::Handle(zone(), Smi::Class());
375 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()), 379 if (smi_class.IsSubtypeOf(TypeArguments::Handle(zone()),
376 type_class, 380 type_class,
377 TypeArguments::Handle(zone()), 381 TypeArguments::Handle(zone()),
(...skipping 10 matching lines...) Expand all
388 __ j(EQUAL, is_instance_lbl); 392 __ j(EQUAL, is_instance_lbl);
389 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted 393 // See ClassFinalizer::ResolveSuperTypeAndInterfaces for list of restricted
390 // interfaces. 394 // interfaces.
391 // Bool interface can be implemented only by core class Bool. 395 // Bool interface can be implemented only by core class Bool.
392 if (type.IsBoolType()) { 396 if (type.IsBoolType()) {
393 __ cmpl(kClassIdReg, Immediate(kBoolCid)); 397 __ cmpl(kClassIdReg, Immediate(kBoolCid));
394 __ j(EQUAL, is_instance_lbl); 398 __ j(EQUAL, is_instance_lbl);
395 __ jmp(is_not_instance_lbl); 399 __ jmp(is_not_instance_lbl);
396 return false; 400 return false;
397 } 401 }
398 if (type.IsFunctionType()) { 402 if (type.IsDartFunctionType()) {
399 // Check if instance is a closure. 403 // Check if instance is a closure.
400 const Immediate& raw_null = 404 __ cmpl(kClassIdReg, Immediate(kClosureCid));
401 Immediate(reinterpret_cast<intptr_t>(Object::null())); 405 __ j(EQUAL, is_instance_lbl);
402 __ LoadClassById(EDI, kClassIdReg);
403 __ movl(EDI, FieldAddress(EDI, Class::signature_function_offset()));
404 __ cmpl(EDI, raw_null);
405 __ j(NOT_EQUAL, is_instance_lbl);
406 } 406 }
407 // Custom checking for numbers (Smi, Mint, Bigint and Double). 407 // Custom checking for numbers (Smi, Mint, Bigint and Double).
408 // Note that instance is not Smi (checked above). 408 // Note that instance is not Smi (checked above).
409 if (type.IsSubtypeOf( 409 if (type.IsSubtypeOf(
410 Type::Handle(zone(), Type::Number()), NULL, Heap::kOld)) { 410 Type::Handle(zone(), Type::Number()), NULL, Heap::kOld)) {
411 GenerateNumberTypeCheck( 411 GenerateNumberTypeCheck(
412 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl); 412 kClassIdReg, type, is_instance_lbl, is_not_instance_lbl);
413 return false; 413 return false;
414 } 414 }
415 if (type.IsStringType()) { 415 if (type.IsStringType()) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 Label* is_instance_lbl, 548 Label* is_instance_lbl,
549 Label* is_not_instance_lbl) { 549 Label* is_not_instance_lbl) {
550 __ Comment("InlineInstanceof"); 550 __ Comment("InlineInstanceof");
551 if (type.IsVoidType()) { 551 if (type.IsVoidType()) {
552 // A non-null value is returned from a void function, which will result in a 552 // A non-null value is returned from a void function, which will result in a
553 // type error. A null value is handled prior to executing this inline code. 553 // type error. A null value is handled prior to executing this inline code.
554 return SubtypeTestCache::null(); 554 return SubtypeTestCache::null();
555 } 555 }
556 if (type.IsInstantiated()) { 556 if (type.IsInstantiated()) {
557 const Class& type_class = Class::ZoneHandle(zone(), type.type_class()); 557 const Class& type_class = Class::ZoneHandle(zone(), type.type_class());
558 // A class equality check is only applicable with a dst type of a 558 // A class equality check is only applicable with a dst type (not a
559 // non-parameterized class, non-signature class, or with a raw dst type of 559 // function type) of a non-parameterized class or with a raw dst type of
560 // a parameterized class. 560 // a parameterized class.
561 if (type_class.IsSignatureClass() || (type_class.NumTypeArguments() > 0)) { 561 if (type.IsFunctionType() || (type_class.NumTypeArguments() > 0)) {
562 return GenerateInstantiatedTypeWithArgumentsTest(token_pos, 562 return GenerateInstantiatedTypeWithArgumentsTest(token_pos,
563 type, 563 type,
564 is_instance_lbl, 564 is_instance_lbl,
565 is_not_instance_lbl); 565 is_not_instance_lbl);
566 // Fall through to runtime call. 566 // Fall through to runtime call.
567 } 567 }
568 const bool has_fall_through = 568 const bool has_fall_through =
569 GenerateInstantiatedTypeNoArgumentsTest(token_pos, 569 GenerateInstantiatedTypeNoArgumentsTest(token_pos,
570 type, 570 type,
571 is_instance_lbl, 571 is_instance_lbl,
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 __ movups(reg, Address(ESP, 0)); 1838 __ movups(reg, Address(ESP, 0));
1839 __ addl(ESP, Immediate(kFpuRegisterSize)); 1839 __ addl(ESP, Immediate(kFpuRegisterSize));
1840 } 1840 }
1841 1841
1842 1842
1843 #undef __ 1843 #undef __
1844 1844
1845 } // namespace dart 1845 } // namespace dart
1846 1846
1847 #endif // defined TARGET_ARCH_IA32 1847 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698