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

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

Issue 711833002: Support verified heap pointer writes on ia32. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 1 month 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) 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 26 matching lines...) Expand all
37 #include "vm/parser.h" 37 #include "vm/parser.h"
38 #include "vm/report.h" 38 #include "vm/report.h"
39 #include "vm/reusable_handles.h" 39 #include "vm/reusable_handles.h"
40 #include "vm/runtime_entry.h" 40 #include "vm/runtime_entry.h"
41 #include "vm/scopes.h" 41 #include "vm/scopes.h"
42 #include "vm/stack_frame.h" 42 #include "vm/stack_frame.h"
43 #include "vm/symbols.h" 43 #include "vm/symbols.h"
44 #include "vm/tags.h" 44 #include "vm/tags.h"
45 #include "vm/timer.h" 45 #include "vm/timer.h"
46 #include "vm/unicode.h" 46 #include "vm/unicode.h"
47 #include "vm/verified_memory.h"
47 #include "vm/weak_code.h" 48 #include "vm/weak_code.h"
48 49
49 namespace dart { 50 namespace dart {
50 51
51 DEFINE_FLAG(int, huge_method_cutoff_in_code_size, 200000, 52 DEFINE_FLAG(int, huge_method_cutoff_in_code_size, 200000,
52 "Huge method cutoff in unoptimized code size (in bytes)."); 53 "Huge method cutoff in unoptimized code size (in bytes).");
53 DEFINE_FLAG(int, huge_method_cutoff_in_tokens, 20000, 54 DEFINE_FLAG(int, huge_method_cutoff_in_tokens, 20000,
54 "Huge method cutoff in tokens: Disables optimizations for huge methods."); 55 "Huge method cutoff in tokens: Disables optimizations for huge methods.");
55 DEFINE_FLAG(bool, overlap_type_arguments, true, 56 DEFINE_FLAG(bool, overlap_type_arguments, true,
56 "When possible, partially or fully overlap the type arguments of a type " 57 "When possible, partially or fully overlap the type arguments of a type "
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 uword end = address + size; 1692 uword end = address + size;
1692 while (cur < end) { 1693 while (cur < end) {
1693 *reinterpret_cast<uword*>(cur) = initial_value; 1694 *reinterpret_cast<uword*>(cur) = initial_value;
1694 cur += kWordSize; 1695 cur += kWordSize;
1695 } 1696 }
1696 uword tags = 0; 1697 uword tags = 0;
1697 ASSERT(class_id != kIllegalCid); 1698 ASSERT(class_id != kIllegalCid);
1698 tags = RawObject::ClassIdTag::update(class_id, tags); 1699 tags = RawObject::ClassIdTag::update(class_id, tags);
1699 tags = RawObject::SizeTag::update(size, tags); 1700 tags = RawObject::SizeTag::update(size, tags);
1700 reinterpret_cast<RawObject*>(address)->tags_ = tags; 1701 reinterpret_cast<RawObject*>(address)->tags_ = tags;
1702 VerifiedMemory::Accept(address, size);
1701 } 1703 }
1702 1704
1703 1705
1704 void Object::CheckHandle() const { 1706 void Object::CheckHandle() const {
1705 #if defined(DEBUG) 1707 #if defined(DEBUG)
1706 if (raw_ != Object::null()) { 1708 if (raw_ != Object::null()) {
1707 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) { 1709 if ((reinterpret_cast<uword>(raw_) & kSmiTagMask) == kSmiTag) {
1708 ASSERT(vtable() == Smi::handle_vtable_); 1710 ASSERT(vtable() == Smi::handle_vtable_);
1709 return; 1711 return;
1710 } 1712 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 // TODO(koda): This will trip when we start allocating black. 1802 // TODO(koda): This will trip when we start allocating black.
1801 // Revisit code below at that point, to account for the new write barrier. 1803 // Revisit code below at that point, to account for the new write barrier.
1802 ASSERT(!raw_clone->IsMarked()); 1804 ASSERT(!raw_clone->IsMarked());
1803 // Copy the body of the original into the clone. 1805 // Copy the body of the original into the clone.
1804 uword orig_addr = RawObject::ToAddr(orig.raw()); 1806 uword orig_addr = RawObject::ToAddr(orig.raw());
1805 uword clone_addr = RawObject::ToAddr(raw_clone); 1807 uword clone_addr = RawObject::ToAddr(raw_clone);
1806 static const intptr_t kHeaderSizeInBytes = sizeof(RawObject); 1808 static const intptr_t kHeaderSizeInBytes = sizeof(RawObject);
1807 memmove(reinterpret_cast<uint8_t*>(clone_addr + kHeaderSizeInBytes), 1809 memmove(reinterpret_cast<uint8_t*>(clone_addr + kHeaderSizeInBytes),
1808 reinterpret_cast<uint8_t*>(orig_addr + kHeaderSizeInBytes), 1810 reinterpret_cast<uint8_t*>(orig_addr + kHeaderSizeInBytes),
1809 size - kHeaderSizeInBytes); 1811 size - kHeaderSizeInBytes);
1812 VerifiedMemory::Accept(clone_addr, size);
1810 // Add clone to store buffer, if needed. 1813 // Add clone to store buffer, if needed.
1811 if (!raw_clone->IsOldObject()) { 1814 if (!raw_clone->IsOldObject()) {
1812 // No need to remember an object in new space. 1815 // No need to remember an object in new space.
1813 return raw_clone; 1816 return raw_clone;
1814 } else if (orig.raw()->IsOldObject() && !orig.raw()->IsRemembered()) { 1817 } else if (orig.raw()->IsOldObject() && !orig.raw()->IsRemembered()) {
1815 // Old original doesn't need to be remembered, so neither does the clone. 1818 // Old original doesn't need to be remembered, so neither does the clone.
1816 return raw_clone; 1819 return raw_clone;
1817 } 1820 }
1818 StoreBufferUpdateVisitor visitor(Isolate::Current(), raw_clone); 1821 StoreBufferUpdateVisitor visitor(Isolate::Current(), raw_clone);
1819 raw_clone->VisitPointers(&visitor); 1822 raw_clone->VisitPointers(&visitor);
(...skipping 10337 matching lines...) Expand 10 before | Expand all | Expand 10 after
12157 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); 12160 intptr_t pointer_offset_count = assembler->CountPointerOffsets();
12158 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); 12161 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count));
12159 Instructions& instrs = 12162 Instructions& instrs =
12160 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); 12163 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
12161 12164
12162 // Copy the instructions into the instruction area and apply all fixups. 12165 // Copy the instructions into the instruction area and apply all fixups.
12163 // Embedded pointers are still in handles at this point. 12166 // Embedded pointers are still in handles at this point.
12164 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 12167 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
12165 instrs.size()); 12168 instrs.size());
12166 assembler->FinalizeInstructions(region); 12169 assembler->FinalizeInstructions(region);
12170 VerifiedMemory::Accept(region.start(), region.size());
12167 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); 12171 CPU::FlushICache(instrs.EntryPoint(), instrs.size());
12168 12172
12169 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); 12173 code.set_compile_timestamp(OS::GetCurrentTimeMicros());
12170 CodeObservers::NotifyAll(name, 12174 CodeObservers::NotifyAll(name,
12171 instrs.EntryPoint(), 12175 instrs.EntryPoint(),
12172 assembler->prologue_offset(), 12176 assembler->prologue_offset(),
12173 instrs.size(), 12177 instrs.size(),
12174 optimized); 12178 optimized);
12175 12179
12176 { 12180 {
(...skipping 6620 matching lines...) Expand 10 before | Expand all | Expand 10 after
18797 // This should be caught before we reach here. 18801 // This should be caught before we reach here.
18798 FATAL1("Fatal error in Array::New: invalid len %" Pd "\n", len); 18802 FATAL1("Fatal error in Array::New: invalid len %" Pd "\n", len);
18799 } 18803 }
18800 { 18804 {
18801 RawArray* raw = reinterpret_cast<RawArray*>( 18805 RawArray* raw = reinterpret_cast<RawArray*>(
18802 Object::Allocate(class_id, 18806 Object::Allocate(class_id,
18803 Array::InstanceSize(len), 18807 Array::InstanceSize(len),
18804 space)); 18808 space));
18805 NoGCScope no_gc; 18809 NoGCScope no_gc;
18806 raw->StoreSmi(&(raw->ptr()->length_), Smi::New(len)); 18810 raw->StoreSmi(&(raw->ptr()->length_), Smi::New(len));
18811 VerifiedMemory::Accept(reinterpret_cast<uword>(raw->ptr()),
18812 Array::InstanceSize(len));
18807 return raw; 18813 return raw;
18808 } 18814 }
18809 } 18815 }
18810 18816
18811 18817
18812 RawArray* Array::Slice(intptr_t start, 18818 RawArray* Array::Slice(intptr_t start,
18813 intptr_t count, 18819 intptr_t count,
18814 bool with_type_argument) const { 18820 bool with_type_argument) const {
18815 // TODO(vegorov) introduce an array allocation method that fills newly 18821 // TODO(vegorov) introduce an array allocation method that fills newly
18816 // allocated array with values from the given source array instead of 18822 // allocated array with values from the given source array instead of
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after
20410 return tag_label.ToCString(); 20416 return tag_label.ToCString();
20411 } 20417 }
20412 20418
20413 20419
20414 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20420 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20415 Instance::PrintJSONImpl(stream, ref); 20421 Instance::PrintJSONImpl(stream, ref);
20416 } 20422 }
20417 20423
20418 20424
20419 } // namespace dart 20425 } // namespace dart
OLDNEW
« runtime/vm/assembler_ia32.cc ('K') | « runtime/vm/object.h ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698