| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/memory_region.h" | 10 #include "vm/memory_region.h" |
| (...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 void Assembler::EmitGenericShift(int rm, | 1555 void Assembler::EmitGenericShift(int rm, |
| 1556 Register operand, | 1556 Register operand, |
| 1557 Register shifter) { | 1557 Register shifter) { |
| 1558 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1558 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1559 ASSERT(shifter == ECX); | 1559 ASSERT(shifter == ECX); |
| 1560 EmitUint8(0xD3); | 1560 EmitUint8(0xD3); |
| 1561 EmitOperand(rm, Operand(operand)); | 1561 EmitOperand(rm, Operand(operand)); |
| 1562 } | 1562 } |
| 1563 | 1563 |
| 1564 | 1564 |
| 1565 void Assembler::LoadClassOfObject(Register result, | 1565 void Assembler::LoadClassId(Register result, Register object) { |
| 1566 Register object, | 1566 ASSERT(RawObject::kClassTagBit == 16); |
| 1567 Register scratch) { | 1567 ASSERT(RawObject::kClassTagSize == 16); |
| 1568 const intptr_t class_id_offset = Object::tags_offset() + |
| 1569 RawObject::kClassTagBit / kBitsPerByte; |
| 1570 movzxw(result, FieldAddress(object, class_id_offset)); |
| 1571 } |
| 1572 |
| 1573 |
| 1574 void Assembler::LoadClass(Register result, |
| 1575 Register object, |
| 1576 Register scratch) { |
| 1568 ASSERT(scratch != result); | 1577 ASSERT(scratch != result); |
| 1569 LoadClassIndexOfObject(scratch, object); | 1578 LoadClassId(scratch, object); |
| 1570 | 1579 |
| 1571 movl(result, FieldAddress(CTX, Context::isolate_offset())); | 1580 movl(result, FieldAddress(CTX, Context::isolate_offset())); |
| 1572 const intptr_t table_offset_in_isolate = | 1581 const intptr_t table_offset_in_isolate = |
| 1573 Isolate::class_table_offset() + ClassTable::table_offset(); | 1582 Isolate::class_table_offset() + ClassTable::table_offset(); |
| 1574 movl(result, Address(result, table_offset_in_isolate)); | 1583 movl(result, Address(result, table_offset_in_isolate)); |
| 1575 movl(result, Address(result, scratch, TIMES_4, 0)); | 1584 movl(result, Address(result, scratch, TIMES_4, 0)); |
| 1576 } | 1585 } |
| 1577 | 1586 |
| 1578 | 1587 |
| 1579 void Assembler::LoadClassIndexOfObject(Register result, Register object) { | 1588 void Assembler::CompareClassId(Register object, |
| 1580 ASSERT(RawObject::kClassTagBit == 16); | 1589 intptr_t class_id, |
| 1581 ASSERT(RawObject::kClassTagSize == 16); | 1590 Register scratch) { |
| 1582 const intptr_t class_id_offset = Object::tags_offset() + | 1591 LoadClassId(scratch, object); |
| 1583 RawObject::kClassTagBit / kBitsPerByte; | 1592 cmpl(scratch, Immediate(class_id)); |
| 1584 movzxw(result, FieldAddress(object, class_id_offset)); | |
| 1585 } | 1593 } |
| 1586 | 1594 |
| 1587 | 1595 |
| 1588 void Assembler::CompareClassOfObject(Register object, | |
| 1589 const Class& clazz, | |
| 1590 Register scratch) { | |
| 1591 LoadClassIndexOfObject(scratch, object); | |
| 1592 cmpl(scratch, Immediate(clazz.index())); | |
| 1593 } | |
| 1594 | |
| 1595 | |
| 1596 void Assembler::Comment(const char* comment) { | 1596 void Assembler::Comment(const char* comment) { |
| 1597 if (FLAG_code_comments) { | 1597 if (FLAG_code_comments) { |
| 1598 comments_.Add(new CodeComment(buffer_.GetPosition(), | 1598 comments_.Add(new CodeComment(buffer_.GetPosition(), |
| 1599 String::Handle(String::New(comment)))); | 1599 String::Handle(String::New(comment)))); |
| 1600 } | 1600 } |
| 1601 } | 1601 } |
| 1602 | 1602 |
| 1603 | 1603 |
| 1604 const Code::Comments& Assembler::GetCodeComments() const { | 1604 const Code::Comments& Assembler::GetCodeComments() const { |
| 1605 Code::Comments& comments = Code::Comments::New(comments_.length()); | 1605 Code::Comments& comments = Code::Comments::New(comments_.length()); |
| 1606 | 1606 |
| 1607 for (intptr_t i = 0; i < comments_.length(); i++) { | 1607 for (intptr_t i = 0; i < comments_.length(); i++) { |
| 1608 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); | 1608 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); |
| 1609 comments.SetCommentAt(i, comments_[i]->comment()); | 1609 comments.SetCommentAt(i, comments_[i]->comment()); |
| 1610 } | 1610 } |
| 1611 | 1611 |
| 1612 return comments; | 1612 return comments; |
| 1613 } | 1613 } |
| 1614 | 1614 |
| 1615 | 1615 |
| 1616 } // namespace dart | 1616 } // namespace dart |
| 1617 | 1617 |
| 1618 #endif // defined TARGET_ARCH_IA32 | 1618 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |