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

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

Issue 9863043: Inline checks for super class and interfaces (checked mdoe improvements). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « no previous file | runtime/vm/object.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_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/code_generator.h" 8 #include "vm/code_generator.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 } else { 1535 } else {
1536 // Failed assignable type check: call runtime to throw TypeError. 1536 // Failed assignable type check: call runtime to throw TypeError.
1537 __ jmp(&runtime_call, Assembler::kNearJump); 1537 __ jmp(&runtime_call, Assembler::kNearJump);
1538 } 1538 }
1539 // Compare if the classes are equal. 1539 // Compare if the classes are equal.
1540 __ Bind(&compare_classes); 1540 __ Bind(&compare_classes);
1541 // If dst_type is an interface, we can skip the class equality check, 1541 // If dst_type is an interface, we can skip the class equality check,
1542 // because instances cannot be of an interface type. 1542 // because instances cannot be of an interface type.
1543 if (!dst_type_class.is_interface()) { 1543 if (!dst_type_class.is_interface()) {
1544 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); 1544 __ movl(ECX, FieldAddress(EAX, Object::class_offset()));
1545 TestClassAndJump(dst_type_class, &done); 1545 TestClassAndJump(dst_type_class, &done); // Uses ECX.
1546 // Check superclass
1547 __ movl(ECX, FieldAddress(ECX, Class::super_type_offset()));
1548 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset()));
1549 TestClassAndJump(dst_type_class, &done); // Uses ECX.
1546 } else { 1550 } else {
1547 // However, for specific core library interfaces, we can check for 1551 // However, for specific core library interfaces, we can check for
1548 // specific core library classes. 1552 // specific core library classes.
1549 Error& malformed_error = Error::Handle(); 1553 Error& malformed_error = Error::Handle();
1550 if (dst_type.IsBoolInterface()) { 1554 if (dst_type.IsBoolInterface()) {
1551 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); 1555 __ movl(ECX, FieldAddress(EAX, Object::class_offset()));
1552 const Class& bool_class = Class::ZoneHandle( 1556 const Class& bool_class = Class::ZoneHandle(
1553 Isolate::Current()->object_store()->bool_class()); 1557 Isolate::Current()->object_store()->bool_class());
1554 TestClassAndJump(bool_class, &done); 1558 TestClassAndJump(bool_class, &done);
1555 } else if (dst_type.IsSubtypeOf( 1559 } else if (dst_type.IsSubtypeOf(
(...skipping 22 matching lines...) Expand all
1578 Isolate::Current()->object_store()->two_byte_string_class()); 1582 Isolate::Current()->object_store()->two_byte_string_class());
1579 TestClassAndJump(two_byte_string_class, &done); 1583 TestClassAndJump(two_byte_string_class, &done);
1580 const Class& four_byte_string_class = Class::ZoneHandle( 1584 const Class& four_byte_string_class = Class::ZoneHandle(
1581 Isolate::Current()->object_store()->four_byte_string_class()); 1585 Isolate::Current()->object_store()->four_byte_string_class());
1582 TestClassAndJump(four_byte_string_class, &done); 1586 TestClassAndJump(four_byte_string_class, &done);
1583 } else if (dst_type.IsFunctionInterface()) { 1587 } else if (dst_type.IsFunctionInterface()) {
1584 __ movl(ECX, FieldAddress(EAX, Object::class_offset())); 1588 __ movl(ECX, FieldAddress(EAX, Object::class_offset()));
1585 __ movl(ECX, FieldAddress(ECX, Class::signature_function_offset())); 1589 __ movl(ECX, FieldAddress(ECX, Class::signature_function_offset()));
1586 __ cmpl(ECX, raw_null); 1590 __ cmpl(ECX, raw_null);
1587 __ j(NOT_EQUAL, &done, Assembler::kNearJump); 1591 __ j(NOT_EQUAL, &done, Assembler::kNearJump);
1592 } else {
1593 // Check interfaces.
1594 Label fall_through;
1595 // Get interfaces array from class.
1596 __ movl(EBX, FieldAddress(EAX, Object::class_offset()));
1597 __ movl(EBX, FieldAddress(EBX, Class::interfaces_offset()));
1598 __ cmpl(EBX, raw_null);
1599 __ j(EQUAL, &fall_through, Assembler::kNearJump);
1600 // Iterate over interfaces array and check if any of interfaces match.
1601 __ movl(EDI, FieldAddress(EBX, Array::length_offset()));
1602 // EDI: array index
1603 // EBX: array
1604 Label loop;
1605 __ Bind(&loop);
1606 __ subl(EDI, Immediate(Smi::RawValue(1)));
1607 __ cmpl(EDI, Immediate(0));
1608 __ j(LESS, &runtime_call, Assembler::kNearJump);
1609 // EDI is Smi therefore TIMES_2 instead of TIMES_4.
1610 // Get type from array.
1611 __ movl(ECX, FieldAddress(EBX, EDI, TIMES_2, Array::data_offset()));
1612 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset()));
1613 TestClassAndJump(dst_type_class, &done); // Uses ECX.
1614 __ jmp(&loop, Assembler::kNearJump);
1615 // Fall through to runtime code.
1616 __ Bind(&fall_through);
1588 } 1617 }
1589 } 1618 }
1590 } 1619 }
1591 } 1620 }
1592 __ Bind(&runtime_call); 1621 __ Bind(&runtime_call);
1593 __ PushObject(Object::ZoneHandle()); // Make room for the result. 1622 __ PushObject(Object::ZoneHandle()); // Make room for the result.
1594 const Immediate location = 1623 const Immediate location =
1595 Immediate(reinterpret_cast<int32_t>(Smi::New(token_index))); 1624 Immediate(reinterpret_cast<int32_t>(Smi::New(token_index)));
1596 __ pushl(location); // Push the source location. 1625 __ pushl(location); // Push the source location.
1597 __ pushl(EAX); // Push the source object. 1626 __ pushl(EAX); // Push the source object.
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 const Error& error = Error::Handle( 2729 const Error& error = Error::Handle(
2701 Parser::FormatError(script, token_index, "Error", format, args)); 2730 Parser::FormatError(script, token_index, "Error", format, args));
2702 va_end(args); 2731 va_end(args);
2703 Isolate::Current()->long_jump_base()->Jump(1, error); 2732 Isolate::Current()->long_jump_base()->Jump(1, error);
2704 UNREACHABLE(); 2733 UNREACHABLE();
2705 } 2734 }
2706 2735
2707 } // namespace dart 2736 } // namespace dart
2708 2737
2709 #endif // defined TARGET_ARCH_IA32 2738 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698