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

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

Issue 10536067: Generate code for store buffer updates in open-coded object field stores. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: correct handling of null Created 8 years, 6 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 | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/code_generator.cc » ('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) 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"
11 #include "vm/runtime_entry.h" 11 #include "vm/runtime_entry.h"
12 #include "vm/stub_code.h" 12 #include "vm/stub_code.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 DECLARE_RUNTIME_ENTRY(StoreBuffer);
17
16 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); 18 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message.");
17 DEFINE_FLAG(bool, code_comments, false, 19 DEFINE_FLAG(bool, code_comments, false,
18 "Include comments into code and disassembly"); 20 "Include comments into code and disassembly");
19 21
20 22
21 class DirectCallRelocation : public AssemblerFixup { 23 class DirectCallRelocation : public AssemblerFixup {
22 public: 24 public:
23 void Process(const MemoryRegion& region, int position) { 25 void Process(const MemoryRegion& region, int position) {
24 // Direct calls are relative to the following instruction on x86. 26 // Direct calls are relative to the following instruction on x86.
25 int32_t pointer = region.Load<int32_t>(position); 27 int32_t pointer = region.Load<int32_t>(position);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 94 }
93 95
94 96
95 void Assembler::popl(const Address& address) { 97 void Assembler::popl(const Address& address) {
96 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 98 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
97 EmitUint8(0x8F); 99 EmitUint8(0x8F);
98 EmitOperand(0, address); 100 EmitOperand(0, address);
99 } 101 }
100 102
101 103
104 void Assembler::pushal() {
105 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
106 EmitUint8(0x60);
107 }
108
109
110 void Assembler::popal() {
111 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
112 EmitUint8(0x61);
113 }
114
115
102 void Assembler::movl(Register dst, const Immediate& imm) { 116 void Assembler::movl(Register dst, const Immediate& imm) {
103 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 117 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
104 EmitUint8(0xB8 + dst); 118 EmitUint8(0xB8 + dst);
105 EmitImmediate(imm); 119 EmitImmediate(imm);
106 } 120 }
107 121
108 122
109 void Assembler::movl(Register dst, Register src) { 123 void Assembler::movl(Register dst, Register src) {
110 AssemblerBuffer::EnsureCapacity ensured(&buffer_); 124 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
111 EmitUint8(0x89); 125 EmitUint8(0x89);
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 EmitOperand(7, Operand(reg)); 1372 EmitOperand(7, Operand(reg));
1359 buffer_.EmitObject(object); 1373 buffer_.EmitObject(object);
1360 } 1374 }
1361 } 1375 }
1362 } 1376 }
1363 1377
1364 1378
1365 void Assembler::StoreIntoObject(Register object, 1379 void Assembler::StoreIntoObject(Register object,
1366 const FieldAddress& dest, 1380 const FieldAddress& dest,
1367 Register value) { 1381 Register value) {
1368 // TODO(iposva): Add write barrier.
1369 movl(dest, value); 1382 movl(dest, value);
1383 Label done;
1384 // Check that 'value' is a new object. Store buffer updates are not
1385 // required when storing a smi or an old object.
1386 testl(value, Immediate(kNewObjectAlignmentOffset | kHeapObjectTag));
1387 j(NOT_EQUAL, &done, Assembler::kNearJump);
1388 // Check that 'object' is an old object. A store buffer update is
1389 // not required when storing into a new object.
1390 testl(object, Immediate(kOldObjectAlignmentOffset | kHeapObjectTag));
1391 j(NOT_EQUAL, &done, Assembler::kNearJump);
1392 // A store buffer update is required.
1393 pushal();
1394 pushl(dest); // Push argument
1395 CallRuntime(kStoreBufferRuntimeEntry);
1396 popl(value); // Pop argument
1397 popal();
1398 Bind(&done);
1370 } 1399 }
1371 1400
1372 1401
1402 void Assembler::StoreIntoObjectNoBarrier(Register object,
1403 const FieldAddress& dest,
1404 Register value) {
1405 movl(dest, value);
1406 #if defined(DEBUG)
1407 Label done;
1408 testl(value, Immediate(kNewObjectAlignmentOffset | kHeapObjectTag));
1409 j(NOT_EQUAL, &done, Assembler::kNearJump);
1410 testl(object, Immediate(kOldObjectAlignmentOffset | kHeapObjectTag));
1411 j(NOT_EQUAL, &done, Assembler::kNearJump);
1412 Stop("Store buffer update is required");
1413 Bind(&done);
1414 #endif
1415 // No store buffer update.
1416 }
1417
1418
1419 void Assembler::StoreIntoObjectNoBarrier(Register object,
1420 const FieldAddress& dest,
1421 const Object& value) {
1422 if (value.IsSmi()) {
1423 movl(dest, Immediate(reinterpret_cast<int32_t>(value.raw())));
1424 } else {
1425 ASSERT(value.IsOld());
1426 AssemblerBuffer::EnsureCapacity ensured(&buffer_);
1427 EmitUint8(0xC7);
1428 EmitOperand(0, dest);
1429 buffer_.EmitObject(value);
1430 }
1431 // No store buffer update.
1432 }
1433
1434
1373 void Assembler::LoadDoubleConstant(XmmRegister dst, double value) { 1435 void Assembler::LoadDoubleConstant(XmmRegister dst, double value) {
1374 // TODO(5410843): Need to have a code constants table. 1436 // TODO(5410843): Need to have a code constants table.
1375 int64_t constant = bit_cast<int64_t, double>(value); 1437 int64_t constant = bit_cast<int64_t, double>(value);
1376 pushl(Immediate(Utils::High32Bits(constant))); 1438 pushl(Immediate(Utils::High32Bits(constant)));
1377 pushl(Immediate(Utils::Low32Bits(constant))); 1439 pushl(Immediate(Utils::Low32Bits(constant)));
1378 movsd(dst, Address(ESP, 0)); 1440 movsd(dst, Address(ESP, 0));
1379 addl(ESP, Immediate(2 * kWordSize)); 1441 addl(ESP, Immediate(2 * kWordSize));
1380 } 1442 }
1381 1443
1382 1444
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 comments.SetCommentAt(i, comments_[i]->comment()); 1708 comments.SetCommentAt(i, comments_[i]->comment());
1647 } 1709 }
1648 1710
1649 return comments; 1711 return comments;
1650 } 1712 }
1651 1713
1652 1714
1653 } // namespace dart 1715 } // namespace dart
1654 1716
1655 #endif // defined TARGET_ARCH_IA32 1717 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/code_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698