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

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

Issue 608913002: Track references to allocation stubs via static_calls_table, instead of keeping two referencers ali… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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/object.h ('k') | runtime/vm/raw_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/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 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 3510
3511 void Class::set_allocation_stub(const Code& value) const { 3511 void Class::set_allocation_stub(const Code& value) const {
3512 // Never clear the stub as it may still be a target, but will be GC-d if 3512 // Never clear the stub as it may still be a target, but will be GC-d if
3513 // not referenced. 3513 // not referenced.
3514 ASSERT(!value.IsNull()); 3514 ASSERT(!value.IsNull());
3515 ASSERT(raw_ptr()->allocation_stub_ == Code::null()); 3515 ASSERT(raw_ptr()->allocation_stub_ == Code::null());
3516 StorePointer(&raw_ptr()->allocation_stub_, value.raw()); 3516 StorePointer(&raw_ptr()->allocation_stub_, value.raw());
3517 } 3517 }
3518 3518
3519 3519
3520 void Class::SwitchAllocationStub() const { 3520 void Class::DisableAllocationStub() const {
3521 const Code& alloc_stub = Code::Handle(allocation_stub()); 3521 StorePointer(&raw_ptr()->allocation_stub_, Code::null());
3522 if (!alloc_stub.IsNull()) {
3523 CodePatcher::PatchEntry(alloc_stub);
3524 const Code& spare_alloc_stub = Code::Handle(spare_allocation_stub());
3525 if (spare_alloc_stub.IsNull()) {
3526 StorePointer(&raw_ptr()->allocation_stub_, Code::null());
3527 } else {
3528 ASSERT(CodePatcher::IsEntryPatched(spare_alloc_stub));
3529 CodePatcher::RestoreEntry(spare_alloc_stub);
3530 StorePointer(&raw_ptr()->allocation_stub_, spare_alloc_stub.raw());
3531 }
3532 StorePointer(&raw_ptr()->spare_allocation_stub_, alloc_stub.raw());
3533 }
3534 } 3522 }
3535 3523
3536 3524
3537 bool Class::IsFunctionClass() const { 3525 bool Class::IsFunctionClass() const {
3538 return raw() == Type::Handle(Type::Function()).type_class(); 3526 return raw() == Type::Handle(Type::Function()).type_class();
3539 } 3527 }
3540 3528
3541 3529
3542 bool Class::IsCanonicalSignatureClass() const { 3530 bool Class::IsCanonicalSignatureClass() const {
3543 const Function& function = Function::Handle(signature_function()); 3531 const Function& function = Function::Handle(signature_function());
(...skipping 8446 matching lines...) Expand 10 before | Expand all | Expand 10 after
11990 const intptr_t i = BinarySearchInSCallTable(pc); 11978 const intptr_t i = BinarySearchInSCallTable(pc);
11991 ASSERT(i >= 0); 11979 ASSERT(i >= 0);
11992 const Array& array = 11980 const Array& array =
11993 Array::Handle(raw_ptr()->static_calls_target_table_); 11981 Array::Handle(raw_ptr()->static_calls_target_table_);
11994 ASSERT(code.IsNull() || 11982 ASSERT(code.IsNull() ||
11995 (code.function() == array.At(i + kSCallTableFunctionEntry))); 11983 (code.function() == array.At(i + kSCallTableFunctionEntry)));
11996 array.SetAt(i + kSCallTableCodeEntry, code); 11984 array.SetAt(i + kSCallTableCodeEntry, code);
11997 } 11985 }
11998 11986
11999 11987
11988 void Code::SetStubCallTargetCodeAt(uword pc, const Code& code) const {
11989 const intptr_t i = BinarySearchInSCallTable(pc);
11990 ASSERT(i >= 0);
11991 const Array& array =
11992 Array::Handle(raw_ptr()->static_calls_target_table_);
11993 #if defined(DEBUG)
11994 if (array.At(i + kSCallTableFunctionEntry) == Function::null()) {
11995 ASSERT(!code.IsNull() && Object::Handle(code.owner()).IsClass());
11996 } else {
11997 ASSERT(code.IsNull() ||
11998 (code.function() == array.At(i + kSCallTableFunctionEntry)));
11999 }
12000 #endif
12001 array.SetAt(i + kSCallTableCodeEntry, code);
12002 }
12003
12004
12000 void Code::Disassemble(DisassemblyFormatter* formatter) const { 12005 void Code::Disassemble(DisassemblyFormatter* formatter) const {
12001 const bool fix_patch = CodePatcher::CodeIsPatchable(*this) && 12006 const bool fix_patch = CodePatcher::CodeIsPatchable(*this) &&
12002 CodePatcher::IsEntryPatched(*this); 12007 CodePatcher::IsEntryPatched(*this);
12003 if (fix_patch) { 12008 if (fix_patch) {
12004 // The disassembler may choke on illegal instructions if the code has been 12009 // The disassembler may choke on illegal instructions if the code has been
12005 // patched, un-patch the code before disassembling and re-patch after. 12010 // patched, un-patch the code before disassembling and re-patch after.
12006 CodePatcher::RestoreEntry(*this); 12011 CodePatcher::RestoreEntry(*this);
12007 } 12012 }
12008 const Instructions& instr = Instructions::Handle(instructions()); 12013 const Instructions& instr = Instructions::Handle(instructions());
12009 uword start = instr.EntryPoint(); 12014 uword start = instr.EntryPoint();
(...skipping 8265 matching lines...) Expand 10 before | Expand all | Expand 10 after
20275 return tag_label.ToCString(); 20280 return tag_label.ToCString();
20276 } 20281 }
20277 20282
20278 20283
20279 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20284 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20280 Instance::PrintJSONImpl(stream, ref); 20285 Instance::PrintJSONImpl(stream, ref);
20281 } 20286 }
20282 20287
20283 20288
20284 } // namespace dart 20289 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698