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

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

Issue 1377583005: Restore back pointer from Instructions to Code (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
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 13031 matching lines...) Expand 10 before | Expand all | Expand 10 after
13042 intptr_t pointer_offset_count = assembler->CountPointerOffsets(); 13042 intptr_t pointer_offset_count = assembler->CountPointerOffsets();
13043 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count)); 13043 Code& code = Code::ZoneHandle(Code::New(pointer_offset_count));
13044 #ifdef TARGET_ARCH_IA32 13044 #ifdef TARGET_ARCH_IA32
13045 assembler->set_code_object(code); 13045 assembler->set_code_object(code);
13046 #endif 13046 #endif
13047 Instructions& instrs = 13047 Instructions& instrs =
13048 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize())); 13048 Instructions::ZoneHandle(Instructions::New(assembler->CodeSize()));
13049 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize()); 13049 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize());
13050 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize()); 13050 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize());
13051 13051
13052 // TODO(johnmccutchan): Protect this behind precompilation flag.
rmacnak 2015/09/29 16:50:12 This is safe. Reading is the problem.
13053 instrs.set_code(code.raw());
13052 // Copy the instructions into the instruction area and apply all fixups. 13054 // Copy the instructions into the instruction area and apply all fixups.
13053 // Embedded pointers are still in handles at this point. 13055 // Embedded pointers are still in handles at this point.
13054 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()), 13056 MemoryRegion region(reinterpret_cast<void*>(instrs.EntryPoint()),
13055 instrs.size()); 13057 instrs.size());
13056 assembler->FinalizeInstructions(region); 13058 assembler->FinalizeInstructions(region);
13057 VerifiedMemory::Accept(region.start(), region.size()); 13059 VerifiedMemory::Accept(region.start(), region.size());
13058 CPU::FlushICache(instrs.EntryPoint(), instrs.size()); 13060 CPU::FlushICache(instrs.EntryPoint(), instrs.size());
13059 13061
13060 code.set_compile_timestamp(OS::GetCurrentTimeMicros()); 13062 code.set_compile_timestamp(OS::GetCurrentTimeMicros());
13061 CodeObservers::NotifyAll(name, 13063 CodeObservers::NotifyAll(name,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
13123 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(), 13125 return FinalizeCode(function.ToLibNamePrefixedQualifiedCString(),
13124 assembler, 13126 assembler,
13125 optimized); 13127 optimized);
13126 } else { 13128 } else {
13127 return FinalizeCode("", assembler); 13129 return FinalizeCode("", assembler);
13128 } 13130 }
13129 } 13131 }
13130 13132
13131 13133
13132 // Check if object matches find condition. 13134 // Check if object matches find condition.
13133 bool Code::FindRawCodeVisitor::FindObject(RawObject* obj) const { 13135 bool Code::FindRawCodeVisitor::FindObject(RawObject* raw_obj) const {
13134 return RawCode::ContainsPC(obj, pc_); 13136 uword tags = raw_obj->ptr()->tags_;
13137 if (RawObject::ClassIdTag::decode(tags) == kInstructionsCid) {
13138 RawInstructions* raw_insts = reinterpret_cast<RawInstructions*>(raw_obj);
13139 return RawInstructions::ContainsPC(raw_insts, pc_);
13140 }
13141 return false;
13135 } 13142 }
13136 13143
13137 13144
13138 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) { 13145 RawCode* Code::LookupCodeInIsolate(Isolate* isolate, uword pc) {
13139 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate())); 13146 ASSERT((isolate == Isolate::Current()) || (isolate == Dart::vm_isolate()));
rmacnak 2015/09/29 16:50:12 if (Dart::IsRunningPrecompiledCode()) { // Fall
Cutch 2015/09/29 23:24:29 Done.
13140 NoSafepointScope no_safepoint; 13147 NoSafepointScope no_safepoint;
13141 FindRawCodeVisitor visitor(pc); 13148 FindRawCodeVisitor visitor(pc);
13142 RawObject* instr; 13149 RawInstructions* instr;
13143 if (isolate->heap() == NULL) { 13150 if (isolate->heap() == NULL) {
13144 return Code::null(); 13151 return Code::null();
13145 } 13152 }
13146 instr = isolate->heap()->FindOldObject(&visitor); 13153 instr = isolate->heap()->FindObjectInCodeSpace(&visitor);
13147 if (instr != Code::null()) { 13154 if (instr != Instructions::null()) {
13148 return static_cast<RawCode*>(instr); 13155 return instr->ptr()->code_;
rmacnak 2015/09/29 16:50:12 instr->code() for ASSERT
Cutch 2015/09/29 23:24:29 Done.
13149 } 13156 }
13150 return Code::null(); 13157 return Code::null();
13151 } 13158 }
13152 13159
13153 13160
13154 RawCode* Code::LookupCode(uword pc) { 13161 RawCode* Code::LookupCode(uword pc) {
13155 return LookupCodeInIsolate(Isolate::Current(), pc); 13162 return LookupCodeInIsolate(Isolate::Current(), pc);
13156 } 13163 }
13157 13164
13158 13165
(...skipping 8305 matching lines...) Expand 10 before | Expand all | Expand 10 after
21464 return tag_label.ToCString(); 21471 return tag_label.ToCString();
21465 } 21472 }
21466 21473
21467 21474
21468 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21475 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21469 Instance::PrintJSONImpl(stream, ref); 21476 Instance::PrintJSONImpl(stream, ref);
21470 } 21477 }
21471 21478
21472 21479
21473 } // namespace dart 21480 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698