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

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

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
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 5106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5117 StorePointer(&raw_ptr()->source_class_, value.raw()); 5117 StorePointer(&raw_ptr()->source_class_, value.raw());
5118 } 5118 }
5119 5119
5120 5120
5121 bool Function::HasBreakpoint() const { 5121 bool Function::HasBreakpoint() const {
5122 return Isolate::Current()->debugger()->HasBreakpoint(*this); 5122 return Isolate::Current()->debugger()->HasBreakpoint(*this);
5123 } 5123 }
5124 5124
5125 5125
5126 void Function::SetInstructions(const Code& value) const { 5126 void Function::SetInstructions(const Code& value) const {
5127 StorePointer(&raw_ptr()->instructions_, value.instructions()); 5127 StorePointer(&raw_ptr()->code_, value.raw());
5128 } 5128 }
5129 5129
5130 void Function::AttachCode(const Code& value) const { 5130 void Function::AttachCode(const Code& value) const {
5131 SetInstructions(value); 5131 SetInstructions(value);
5132 ASSERT(Function::Handle(value.function()).IsNull() || 5132 ASSERT(Function::Handle(value.function()).IsNull() ||
5133 (value.function() == this->raw())); 5133 (value.function() == this->raw()));
5134 value.set_owner(*this); 5134 value.set_owner(*this);
5135 } 5135 }
5136 5136
5137 5137
5138 bool Function::HasCode() const { 5138 bool Function::HasCode() const {
5139 ASSERT(raw_ptr()->instructions_ != Instructions::null()); 5139 ASSERT(raw_ptr()->code_ != Code::null());
5140 StubCode* stub_code = Isolate::Current()->stub_code(); 5140 StubCode* stub_code = Isolate::Current()->stub_code();
5141 return raw_ptr()->instructions_ != 5141 return raw_ptr()->code_ != stub_code->LazyCompile_entry()->code();
5142 stub_code->LazyCompile_entry()->code()->ptr()->instructions_;
5143 } 5142 }
5144 5143
5145 5144
5146 void Function::ClearCode() const { 5145 void Function::ClearCode() const {
5147 ASSERT(ic_data_array() == Array::null()); 5146 ASSERT(ic_data_array() == Array::null());
5148 StorePointer(&raw_ptr()->unoptimized_code_, Code::null()); 5147 StorePointer(&raw_ptr()->unoptimized_code_, Code::null());
5149 StubCode* stub_code = Isolate::Current()->stub_code(); 5148 StubCode* stub_code = Isolate::Current()->stub_code();
5150 StorePointer(&raw_ptr()->instructions_, 5149 StorePointer(&raw_ptr()->code_,
5151 Code::Handle(stub_code->LazyCompile_entry()->code()).instructions()); 5150 stub_code->LazyCompile_entry()->code());
5152 } 5151 }
5153 5152
5154 5153
5155 void Function::SwitchToUnoptimizedCode() const { 5154 void Function::SwitchToUnoptimizedCode() const {
5156 ASSERT(HasOptimizedCode()); 5155 ASSERT(HasOptimizedCode());
5157 Thread* thread = Thread::Current(); 5156 Thread* thread = Thread::Current();
5158 Isolate* isolate = thread->isolate(); 5157 Isolate* isolate = thread->isolate();
5159 Zone* zone = thread->zone(); 5158 Zone* zone = thread->zone();
5160 const Code& current_code = Code::Handle(zone, CurrentCode()); 5159 const Code& current_code = Code::Handle(zone, CurrentCode());
5161 5160
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after
6586 const Object& obj = Object::Handle(raw_ptr()->owner_); 6585 const Object& obj = Object::Handle(raw_ptr()->owner_);
6587 if (obj.IsClass()) { 6586 if (obj.IsClass()) {
6588 return Class::Cast(obj).script(); 6587 return Class::Cast(obj).script();
6589 } 6588 }
6590 ASSERT(obj.IsPatchClass()); 6589 ASSERT(obj.IsPatchClass());
6591 return PatchClass::Cast(obj).Script(); 6590 return PatchClass::Cast(obj).Script();
6592 } 6591 }
6593 6592
6594 6593
6595 bool Function::HasOptimizedCode() const { 6594 bool Function::HasOptimizedCode() const {
6596 return HasCode() && Code::Handle(Instructions::Handle( 6595 return HasCode() && Code::Handle(CurrentCode()).is_optimized();
6597 raw_ptr()->instructions_).code()).is_optimized();
6598 } 6596 }
6599 6597
6600 6598
6601 RawString* Function::PrettyName() const { 6599 RawString* Function::PrettyName() const {
6602 const String& str = String::Handle(name()); 6600 const String& str = String::Handle(name());
6603 return String::IdentifierPrettyName(str); 6601 return String::IdentifierPrettyName(str);
6604 } 6602 }
6605 6603
6606 6604
6607 const char* Function::QualifiedUserVisibleNameCString() const { 6605 const char* Function::QualifiedUserVisibleNameCString() const {
(...skipping 6023 matching lines...) Expand 10 before | Expand all | Expand 10 after
12631 for (intptr_t i = 0; i < pointer_offsets.length(); i++) { 12629 for (intptr_t i = 0; i < pointer_offsets.length(); i++) {
12632 intptr_t offset_in_instrs = pointer_offsets[i]; 12630 intptr_t offset_in_instrs = pointer_offsets[i];
12633 code.SetPointerOffsetAt(i, offset_in_instrs); 12631 code.SetPointerOffsetAt(i, offset_in_instrs);
12634 uword addr = region.start() + offset_in_instrs; 12632 uword addr = region.start() + offset_in_instrs;
12635 const Object* object = *reinterpret_cast<Object**>(addr); 12633 const Object* object = *reinterpret_cast<Object**>(addr);
12636 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), 12634 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr),
12637 object->raw()); 12635 object->raw());
12638 } 12636 }
12639 12637
12640 // Hook up Code and Instructions objects. 12638 // Hook up Code and Instructions objects.
12641 instrs.set_code(code.raw());
12642 code.set_instructions(instrs.raw()); 12639 code.set_instructions(instrs.raw());
12643 code.set_is_alive(true); 12640 code.set_is_alive(true);
12644 12641
12645 // Set object pool in Instructions object. 12642 // Set object pool in Instructions object.
12646 INC_STAT(Isolate::Current(), 12643 INC_STAT(Isolate::Current(),
12647 total_code_size, object_pool.Length() * sizeof(uintptr_t)); 12644 total_code_size, object_pool.Length() * sizeof(uintptr_t));
12648 instrs.set_object_pool(object_pool.raw()); 12645 code.set_object_pool(object_pool.raw());
12649 12646
12650 if (FLAG_write_protect_code) { 12647 if (FLAG_write_protect_code) {
12651 uword address = RawObject::ToAddr(instrs.raw()); 12648 uword address = RawObject::ToAddr(instrs.raw());
12652 bool status = VirtualMemory::Protect( 12649 bool status = VirtualMemory::Protect(
12653 reinterpret_cast<void*>(address), 12650 reinterpret_cast<void*>(address),
12654 instrs.raw()->Size(), 12651 instrs.raw()->Size(),
12655 VirtualMemory::kReadExecute); 12652 VirtualMemory::kReadExecute);
12656 ASSERT(status); 12653 ASSERT(status);
12657 } 12654 }
12658 } 12655 }
(...skipping 21 matching lines...) Expand all
12680 assembler, 12677 assembler,
12681 optimized); 12678 optimized);
12682 } else { 12679 } else {
12683 return FinalizeCode("", assembler); 12680 return FinalizeCode("", assembler);
12684 } 12681 }
12685 } 12682 }
12686 12683
12687 12684
12688 // Check if object matches find condition. 12685 // Check if object matches find condition.
12689 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { 12686 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const {
12690 return RawInstructions::ContainsPC(obj, pc_); 12687 return RawCode::ContainsPC(obj, pc_);
12691 } 12688 }
12692 12689
12693 12690
12694 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { 12691 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) {
12695 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); 12692 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate()));
12696 NoSafepointScope no_safepoint; 12693 NoSafepointScope no_safepoint;
12697 FindRawCodeVisitor visitor(pc); 12694 FindRawCodeVisitor visitor(pc);
12698 RawInstructions* instr; 12695 RawObject* instr;
12699 if (isolate->heap() == NULL) { 12696 if (isolate->heap() == NULL) {
12700 return Code::null(); 12697 return Code::null();
12701 } 12698 }
12702 instr = isolate->heap()->FindObjectInCodeSpace(&visitor); 12699 instr = isolate->heap()->FindOldObject(&visitor);
12703 if (instr != Instructions::null()) { 12700 if (instr != Code::null()) {
12704 return instr->ptr()->code_; 12701 return static_cast<RawCode*>(instr);
12705 } 12702 }
12706 return Code::null(); 12703 return Code::null();
12707 } 12704 }
12708 12705
12709 12706
12710 RawCode* Code::LookupCode(uword pc) { 12707 RawCode* Code::LookupCode(uword pc) {
12711 return LookupCodeInIsolate(Isolate::Current(), pc); 12708 return LookupCodeInIsolate(Isolate::Current(), pc);
12712 } 12709 }
12713 12710
12714 12711
(...skipping 8259 matching lines...) Expand 10 before | Expand all | Expand 10 after
20974 return tag_label.ToCString(); 20971 return tag_label.ToCString();
20975 } 20972 }
20976 20973
20977 20974
20978 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20975 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20979 Instance::PrintJSONImpl(stream, ref); 20976 Instance::PrintJSONImpl(stream, ref);
20980 } 20977 }
20981 20978
20982 20979
20983 } // namespace dart 20980 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698