| OLD | NEW |
| 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/become.h" | 10 #include "vm/become.h" |
| (...skipping 11366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11377 // This should be caught before we reach here. | 11377 // This should be caught before we reach here. |
| 11378 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size); | 11378 FATAL1("Fatal error in Instructions::New: invalid size %" Pd "\n", size); |
| 11379 } | 11379 } |
| 11380 Instructions& result = Instructions::Handle(); | 11380 Instructions& result = Instructions::Handle(); |
| 11381 { | 11381 { |
| 11382 uword aligned_size = Instructions::InstanceSize(size); | 11382 uword aligned_size = Instructions::InstanceSize(size); |
| 11383 RawObject* raw = | 11383 RawObject* raw = |
| 11384 Object::Allocate(Instructions::kClassId, aligned_size, Heap::kCode); | 11384 Object::Allocate(Instructions::kClassId, aligned_size, Heap::kCode); |
| 11385 NoSafepointScope no_safepoint; | 11385 NoSafepointScope no_safepoint; |
| 11386 result ^= raw; | 11386 result ^= raw; |
| 11387 result.set_size(has_single_entry_point ? size : -size); | 11387 result.SetSize(size); |
| 11388 result.SetHasSingleEntryPoint(has_single_entry_point); |
| 11388 } | 11389 } |
| 11389 return result.raw(); | 11390 return result.raw(); |
| 11390 } | 11391 } |
| 11391 | 11392 |
| 11392 | 11393 |
| 11393 const char* Instructions::ToCString() const { | 11394 const char* Instructions::ToCString() const { |
| 11394 return "Instructions"; | 11395 return "Instructions"; |
| 11395 } | 11396 } |
| 11396 | 11397 |
| 11397 | 11398 |
| (...skipping 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13757 | 13758 |
| 13758 | 13759 |
| 13759 void Code::Disassemble(DisassemblyFormatter* formatter) const { | 13760 void Code::Disassemble(DisassemblyFormatter* formatter) const { |
| 13760 #ifndef PRODUCT | 13761 #ifndef PRODUCT |
| 13761 if (!FLAG_support_disassembler) { | 13762 if (!FLAG_support_disassembler) { |
| 13762 return; | 13763 return; |
| 13763 } | 13764 } |
| 13764 const Instructions& instr = Instructions::Handle(instructions()); | 13765 const Instructions& instr = Instructions::Handle(instructions()); |
| 13765 uword start = instr.PayloadStart(); | 13766 uword start = instr.PayloadStart(); |
| 13766 if (formatter == NULL) { | 13767 if (formatter == NULL) { |
| 13767 Disassembler::Disassemble(start, start + instr.size(), *this); | 13768 Disassembler::Disassemble(start, start + instr.Size(), *this); |
| 13768 } else { | 13769 } else { |
| 13769 Disassembler::Disassemble(start, start + instr.size(), formatter, *this); | 13770 Disassembler::Disassemble(start, start + instr.Size(), formatter, *this); |
| 13770 } | 13771 } |
| 13771 #endif | 13772 #endif |
| 13772 } | 13773 } |
| 13773 | 13774 |
| 13774 | 13775 |
| 13775 const Code::Comments& Code::comments() const { | 13776 const Code::Comments& Code::comments() const { |
| 13776 #if defined(DART_PRECOMPILED_RUNTIME) | 13777 #if defined(DART_PRECOMPILED_RUNTIME) |
| 13777 Comments* comments = new Code::Comments(Array::Handle()); | 13778 Comments* comments = new Code::Comments(Array::Handle()); |
| 13778 #else | 13779 #else |
| 13779 Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_)); | 13780 Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_)); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13988 assembler->set_code_object(code); | 13989 assembler->set_code_object(code); |
| 13989 #endif | 13990 #endif |
| 13990 Instructions& instrs = Instructions::ZoneHandle(Instructions::New( | 13991 Instructions& instrs = Instructions::ZoneHandle(Instructions::New( |
| 13991 assembler->CodeSize(), assembler->has_single_entry_point())); | 13992 assembler->CodeSize(), assembler->has_single_entry_point())); |
| 13992 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize()); | 13993 INC_STAT(Thread::Current(), total_instr_size, assembler->CodeSize()); |
| 13993 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize()); | 13994 INC_STAT(Thread::Current(), total_code_size, assembler->CodeSize()); |
| 13994 | 13995 |
| 13995 // Copy the instructions into the instruction area and apply all fixups. | 13996 // Copy the instructions into the instruction area and apply all fixups. |
| 13996 // Embedded pointers are still in handles at this point. | 13997 // Embedded pointers are still in handles at this point. |
| 13997 MemoryRegion region(reinterpret_cast<void*>(instrs.PayloadStart()), | 13998 MemoryRegion region(reinterpret_cast<void*>(instrs.PayloadStart()), |
| 13998 instrs.size()); | 13999 instrs.Size()); |
| 13999 assembler->FinalizeInstructions(region); | 14000 assembler->FinalizeInstructions(region); |
| 14000 CPU::FlushICache(instrs.PayloadStart(), instrs.size()); | 14001 CPU::FlushICache(instrs.PayloadStart(), instrs.Size()); |
| 14001 | 14002 |
| 14002 code.set_compile_timestamp(OS::GetCurrentMonotonicMicros()); | 14003 code.set_compile_timestamp(OS::GetCurrentMonotonicMicros()); |
| 14003 #ifndef PRODUCT | 14004 #ifndef PRODUCT |
| 14004 CodeObservers::NotifyAll(name, instrs.PayloadStart(), | 14005 CodeObservers::NotifyAll(name, instrs.PayloadStart(), |
| 14005 assembler->prologue_offset(), instrs.size(), | 14006 assembler->prologue_offset(), instrs.Size(), |
| 14006 optimized); | 14007 optimized); |
| 14007 #endif | 14008 #endif |
| 14008 { | 14009 { |
| 14009 NoSafepointScope no_safepoint; | 14010 NoSafepointScope no_safepoint; |
| 14010 const ZoneGrowableArray<intptr_t>& pointer_offsets = | 14011 const ZoneGrowableArray<intptr_t>& pointer_offsets = |
| 14011 assembler->GetPointerOffsets(); | 14012 assembler->GetPointerOffsets(); |
| 14012 ASSERT(pointer_offsets.length() == pointer_offset_count); | 14013 ASSERT(pointer_offsets.length() == pointer_offset_count); |
| 14013 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); | 14014 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); |
| 14014 | 14015 |
| 14015 // Set pointer offsets list in Code object and resolve all handles in | 14016 // Set pointer offsets list in Code object and resolve all handles in |
| (...skipping 8612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22628 return UserTag::null(); | 22629 return UserTag::null(); |
| 22629 } | 22630 } |
| 22630 | 22631 |
| 22631 | 22632 |
| 22632 const char* UserTag::ToCString() const { | 22633 const char* UserTag::ToCString() const { |
| 22633 const String& tag_label = String::Handle(label()); | 22634 const String& tag_label = String::Handle(label()); |
| 22634 return tag_label.ToCString(); | 22635 return tag_label.ToCString(); |
| 22635 } | 22636 } |
| 22636 | 22637 |
| 22637 } // namespace dart | 22638 } // namespace dart |
| OLD | NEW |