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

Side by Side Diff: runtime/vm/assembler_mips.h

Issue 886173003: VM: Align implementations of assembler constant pools. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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
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 #ifndef VM_ASSEMBLER_MIPS_H_ 5 #ifndef VM_ASSEMBLER_MIPS_H_
6 #define VM_ASSEMBLER_MIPS_H_ 6 #define VM_ASSEMBLER_MIPS_H_
7 7
8 #ifndef VM_ASSEMBLER_H_ 8 #ifndef VM_ASSEMBLER_H_
9 #error Do not include assembler_mips.h directly; use assembler.h instead. 9 #error Do not include assembler_mips.h directly; use assembler.h instead.
10 #endif 10 #endif
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 } 229 }
230 230
231 uword bits_; 231 uword bits_;
232 }; 232 };
233 233
234 234
235 class Assembler : public ValueObject { 235 class Assembler : public ValueObject {
236 public: 236 public:
237 explicit Assembler(bool use_far_branches = false) 237 explicit Assembler(bool use_far_branches = false)
238 : buffer_(), 238 : buffer_(),
239 object_pool_(GrowableObjectArray::Handle()),
240 prologue_offset_(-1), 239 prologue_offset_(-1),
241 use_far_branches_(use_far_branches), 240 use_far_branches_(use_far_branches),
242 delay_slot_available_(false), 241 delay_slot_available_(false),
243 in_delay_slot_(false), 242 in_delay_slot_(false),
244 comments_(), 243 comments_(),
245 allow_constant_pool_(true) { } 244 allow_constant_pool_(true) { }
246 ~Assembler() { } 245 ~Assembler() { }
247 246
248 void PopRegister(Register r) { Pop(r); } 247 void PopRegister(Register r) { Pop(r); }
249 248
250 void Bind(Label* label); 249 void Bind(Label* label);
251 void Jump(Label* label) { b(label); } 250 void Jump(Label* label) { b(label); }
252 251
253 // Misc. functionality 252 // Misc. functionality
254 intptr_t CodeSize() const { return buffer_.Size(); } 253 intptr_t CodeSize() const { return buffer_.Size(); }
255 intptr_t prologue_offset() const { return prologue_offset_; } 254 intptr_t prologue_offset() const { return prologue_offset_; }
256 255
257 // Count the fixups that produce a pointer offset, without processing 256 // Count the fixups that produce a pointer offset, without processing
258 // the fixups. 257 // the fixups.
259 intptr_t CountPointerOffsets() const { 258 intptr_t CountPointerOffsets() const {
260 return buffer_.CountPointerOffsets(); 259 return buffer_.CountPointerOffsets();
261 } 260 }
262 261
263 const ZoneGrowableArray<intptr_t>& GetPointerOffsets() const { 262 const ZoneGrowableArray<intptr_t>& GetPointerOffsets() const {
264 return buffer_.pointer_offsets(); 263 return buffer_.pointer_offsets();
265 } 264 }
266 const GrowableObjectArray& object_pool() const { return object_pool_; } 265 const GrowableObjectArray& object_pool() const { return object_pool_.data(); }
267 void FinalizeInstructions(const MemoryRegion& region) { 266 void FinalizeInstructions(const MemoryRegion& region) {
268 buffer_.FinalizeInstructions(region); 267 buffer_.FinalizeInstructions(region);
269 } 268 }
270 269
271 bool use_far_branches() const { 270 bool use_far_branches() const {
272 return FLAG_use_far_branches || use_far_branches_; 271 return FLAG_use_far_branches || use_far_branches_;
273 } 272 }
274 273
275 void set_use_far_branches(bool b) { 274 void set_use_far_branches(bool b) {
276 ASSERT(buffer_.Size() == 0); 275 ASSERT(buffer_.Size() == 0);
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 } 919 }
921 920
922 void BranchLink(const ExternalLabel* label) { 921 void BranchLink(const ExternalLabel* label) {
923 ASSERT(!in_delay_slot_); 922 ASSERT(!in_delay_slot_);
924 LoadImmediate(T9, label->address()); 923 LoadImmediate(T9, label->address());
925 jalr(T9); 924 jalr(T9);
926 } 925 }
927 926
928 void BranchLinkPatchable(const ExternalLabel* label) { 927 void BranchLinkPatchable(const ExternalLabel* label) {
929 ASSERT(!in_delay_slot_); 928 ASSERT(!in_delay_slot_);
930 const int32_t offset = 929 const int32_t offset = Array::element_offset(
931 Array::data_offset() + 4*AddExternalLabel(label) - kHeapObjectTag; 930 object_pool_.FindExternalLabel(label, kPatchable));
932 LoadWordFromPoolOffset(T9, offset); 931 LoadWordFromPoolOffset(T9, offset - kHeapObjectTag);
933 jalr(T9); 932 jalr(T9);
934 delay_slot_available_ = false; // CodePatcher expects a nop. 933 delay_slot_available_ = false; // CodePatcher expects a nop.
935 } 934 }
936 935
937 void Drop(intptr_t stack_elements) { 936 void Drop(intptr_t stack_elements) {
938 ASSERT(stack_elements >= 0); 937 ASSERT(stack_elements >= 0);
939 if (stack_elements > 0) { 938 if (stack_elements > 0) {
940 addiu(SP, SP, Immediate(stack_elements * kWordSize)); 939 addiu(SP, SP, Immediate(stack_elements * kWordSize));
941 } 940 }
942 } 941 }
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 1605
1607 bool allow_constant_pool() const { 1606 bool allow_constant_pool() const {
1608 return allow_constant_pool_; 1607 return allow_constant_pool_;
1609 } 1608 }
1610 void set_allow_constant_pool(bool b) { 1609 void set_allow_constant_pool(bool b) {
1611 allow_constant_pool_ = b; 1610 allow_constant_pool_ = b;
1612 } 1611 }
1613 1612
1614 private: 1613 private:
1615 AssemblerBuffer buffer_; 1614 AssemblerBuffer buffer_;
1616 GrowableObjectArray& object_pool_; // Objects and patchable jump targets. 1615 ObjectPool object_pool_; // Objects and patchable jump targets.
1617
1618 // Hashmap for fast lookup in object pool.
1619 DirectChainedHashMap<ObjIndexPair> object_pool_index_table_;
1620 1616
1621 intptr_t prologue_offset_; 1617 intptr_t prologue_offset_;
1622 1618
1623 bool use_far_branches_; 1619 bool use_far_branches_;
1624 bool delay_slot_available_; 1620 bool delay_slot_available_;
1625 bool in_delay_slot_; 1621 bool in_delay_slot_;
1626 1622
1627 int32_t AddObject(const Object& obj);
1628 int32_t AddExternalLabel(const ExternalLabel* label);
1629
1630 class CodeComment : public ZoneAllocated { 1623 class CodeComment : public ZoneAllocated {
1631 public: 1624 public:
1632 CodeComment(intptr_t pc_offset, const String& comment) 1625 CodeComment(intptr_t pc_offset, const String& comment)
1633 : pc_offset_(pc_offset), comment_(comment) { } 1626 : pc_offset_(pc_offset), comment_(comment) { }
1634 1627
1635 intptr_t pc_offset() const { return pc_offset_; } 1628 intptr_t pc_offset() const { return pc_offset_; }
1636 const String& comment() const { return comment_; } 1629 const String& comment() const { return comment_; }
1637 1630
1638 private: 1631 private:
1639 intptr_t pc_offset_; 1632 intptr_t pc_offset_;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 Register value, 1738 Register value,
1746 Label* no_update); 1739 Label* no_update);
1747 1740
1748 DISALLOW_ALLOCATION(); 1741 DISALLOW_ALLOCATION();
1749 DISALLOW_COPY_AND_ASSIGN(Assembler); 1742 DISALLOW_COPY_AND_ASSIGN(Assembler);
1750 }; 1743 };
1751 1744
1752 } // namespace dart 1745 } // namespace dart
1753 1746
1754 #endif // VM_ASSEMBLER_MIPS_H_ 1747 #endif // VM_ASSEMBLER_MIPS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698