| 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/cpu.h" |     10 #include "vm/cpu.h" | 
| (...skipping 12954 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  12965   // larger than the previously added one. |  12965   // larger than the previously added one. | 
|  12966   for (intptr_t i = kSCallTableEntryLength; |  12966   for (intptr_t i = kSCallTableEntryLength; | 
|  12967       i < value.Length(); |  12967       i < value.Length(); | 
|  12968       i += kSCallTableEntryLength) { |  12968       i += kSCallTableEntryLength) { | 
|  12969     ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); |  12969     ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); | 
|  12970   } |  12970   } | 
|  12971 #endif  // DEBUG |  12971 #endif  // DEBUG | 
|  12972 } |  12972 } | 
|  12973  |  12973  | 
|  12974  |  12974  | 
 |  12975 uword Code::EntryPoint() const { | 
 |  12976   RawObject* instr = instructions(); | 
 |  12977   if (!instr->IsHeapObject()) { | 
 |  12978     return active_entry_point(); | 
 |  12979   } else { | 
 |  12980     return Instructions::EntryPoint(instructions()); | 
 |  12981   } | 
 |  12982 } | 
 |  12983  | 
 |  12984  | 
 |  12985 intptr_t Code::Size() const { | 
 |  12986   RawObject* instr = instructions(); | 
 |  12987   if (!instr->IsHeapObject()) { | 
 |  12988     return Smi::Value(raw_ptr()->precompiled_instructions_size_); | 
 |  12989   } else { | 
 |  12990     return instructions()->ptr()->size_; | 
 |  12991   } | 
 |  12992 } | 
 |  12993  | 
 |  12994  | 
|  12975 bool Code::HasBreakpoint() const { |  12995 bool Code::HasBreakpoint() const { | 
|  12976   if (!FLAG_support_debugger) { |  12996   if (!FLAG_support_debugger) { | 
|  12977     return false; |  12997     return false; | 
|  12978   } |  12998   } | 
|  12979   return Isolate::Current()->debugger()->HasBreakpoint(*this); |  12999   return Isolate::Current()->debugger()->HasBreakpoint(*this); | 
|  12980 } |  13000 } | 
|  12981  |  13001  | 
|  12982  |  13002  | 
|  12983 TokenPosition Code::GetTokenPositionAt(intptr_t offset) const { |  13003 TokenPosition Code::GetTokenPositionAt(intptr_t offset) const { | 
|  12984   const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map()); |  13004   const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map()); | 
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  13310     for (intptr_t i = 0; i < pointer_offsets.length(); i++) { |  13330     for (intptr_t i = 0; i < pointer_offsets.length(); i++) { | 
|  13311       intptr_t offset_in_instrs = pointer_offsets[i]; |  13331       intptr_t offset_in_instrs = pointer_offsets[i]; | 
|  13312       code.SetPointerOffsetAt(i, offset_in_instrs); |  13332       code.SetPointerOffsetAt(i, offset_in_instrs); | 
|  13313       uword addr = region.start() + offset_in_instrs; |  13333       uword addr = region.start() + offset_in_instrs; | 
|  13314       const Object* object = *reinterpret_cast<Object**>(addr); |  13334       const Object* object = *reinterpret_cast<Object**>(addr); | 
|  13315       instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), |  13335       instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), | 
|  13316                                  object->raw()); |  13336                                  object->raw()); | 
|  13317     } |  13337     } | 
|  13318  |  13338  | 
|  13319     // Hook up Code and Instructions objects. |  13339     // Hook up Code and Instructions objects. | 
 |  13340     code.set_instructions(instrs.raw()); | 
|  13320     code.SetActiveInstructions(instrs.raw()); |  13341     code.SetActiveInstructions(instrs.raw()); | 
|  13321     code.set_instructions(instrs.raw()); |  | 
|  13322     code.set_is_alive(true); |  13342     code.set_is_alive(true); | 
|  13323  |  13343  | 
 |  13344     ASSERT(code.EntryPoint() == instrs.EntryPoint()); | 
 |  13345     ASSERT(code.Size() == instrs.size()); | 
 |  13346  | 
|  13324     // Set object pool in Instructions object. |  13347     // Set object pool in Instructions object. | 
|  13325     INC_STAT(Thread::Current(), |  13348     INC_STAT(Thread::Current(), | 
|  13326              total_code_size, object_pool.Length() * sizeof(uintptr_t)); |  13349              total_code_size, object_pool.Length() * sizeof(uintptr_t)); | 
|  13327     code.set_object_pool(object_pool.raw()); |  13350     code.set_object_pool(object_pool.raw()); | 
|  13328  |  13351  | 
|  13329     if (FLAG_write_protect_code) { |  13352     if (FLAG_write_protect_code) { | 
|  13330       uword address = RawObject::ToAddr(instrs.raw()); |  13353       uword address = RawObject::ToAddr(instrs.raw()); | 
|  13331       bool status = VirtualMemory::Protect( |  13354       bool status = VirtualMemory::Protect( | 
|  13332           reinterpret_cast<void*>(address), |  13355           reinterpret_cast<void*>(address), | 
|  13333           instrs.raw()->Size(), |  13356           instrs.raw()->Size(), | 
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  13511  |  13534  | 
|  13512 bool Code::IsFunctionCode() const { |  13535 bool Code::IsFunctionCode() const { | 
|  13513   const Object& obj = Object::Handle(owner()); |  13536   const Object& obj = Object::Handle(owner()); | 
|  13514   return obj.IsFunction(); |  13537   return obj.IsFunction(); | 
|  13515 } |  13538 } | 
|  13516  |  13539  | 
|  13517  |  13540  | 
|  13518 void Code::DisableDartCode() const { |  13541 void Code::DisableDartCode() const { | 
|  13519   DEBUG_ASSERT(IsMutatorOrAtSafepoint()); |  13542   DEBUG_ASSERT(IsMutatorOrAtSafepoint()); | 
|  13520   ASSERT(IsFunctionCode()); |  13543   ASSERT(IsFunctionCode()); | 
|  13521   ASSERT(instructions() == active_instructions()); |  13544   ASSERT(!IsDisabled()); | 
|  13522   const Code& new_code = |  13545   const Code& new_code = | 
|  13523       Code::Handle(StubCode::FixCallersTarget_entry()->code()); |  13546       Code::Handle(StubCode::FixCallersTarget_entry()->code()); | 
 |  13547   ASSERT(new_code.instructions()->IsVMHeapObject()); | 
|  13524   SetActiveInstructions(new_code.instructions()); |  13548   SetActiveInstructions(new_code.instructions()); | 
|  13525 } |  13549 } | 
|  13526  |  13550  | 
|  13527  |  13551  | 
|  13528 void Code::DisableStubCode() const { |  13552 void Code::DisableStubCode() const { | 
|  13529   ASSERT(Thread::Current()->IsMutatorThread()); |  13553   ASSERT(Thread::Current()->IsMutatorThread()); | 
|  13530   ASSERT(IsAllocationStubCode()); |  13554   ASSERT(IsAllocationStubCode()); | 
|  13531   ASSERT(instructions() == active_instructions()); |  13555   ASSERT(!IsDisabled()); | 
|  13532   const Code& new_code = |  13556   const Code& new_code = | 
|  13533       Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()); |  13557       Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()); | 
 |  13558   ASSERT(new_code.instructions()->IsVMHeapObject()); | 
|  13534   SetActiveInstructions(new_code.instructions()); |  13559   SetActiveInstructions(new_code.instructions()); | 
|  13535 } |  13560 } | 
|  13536  |  13561  | 
|  13537  |  13562  | 
|  13538 void Code::SetActiveInstructions(RawInstructions* instructions) const { |  13563 void Code::SetActiveInstructions(RawInstructions* instructions) const { | 
|  13539   DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); |  13564   DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); | 
|  13540   // RawInstructions are never allocated in New space and hence a |  13565   // RawInstructions are never allocated in New space and hence a | 
|  13541   // store buffer update is not needed here. |  13566   // store buffer update is not needed here. | 
|  13542   StorePointer(&raw_ptr()->active_instructions_, instructions); |  | 
|  13543   StoreNonPointer(&raw_ptr()->entry_point_, |  13567   StoreNonPointer(&raw_ptr()->entry_point_, | 
|  13544                   reinterpret_cast<uword>(instructions->ptr()) + |  13568                   reinterpret_cast<uword>(instructions->ptr()) + | 
|  13545                   Instructions::HeaderSize()); |  13569                   Instructions::HeaderSize()); | 
|  13546 } |  13570 } | 
|  13547  |  13571  | 
|  13548  |  13572  | 
|  13549 uword Code::GetLazyDeoptPc() const { |  13573 uword Code::GetLazyDeoptPc() const { | 
|  13550   return (lazy_deopt_pc_offset() != kInvalidPc) |  13574   return (lazy_deopt_pc_offset() != kInvalidPc) | 
|  13551       ? EntryPoint() + lazy_deopt_pc_offset() : 0; |  13575       ? EntryPoint() + lazy_deopt_pc_offset() : 0; | 
|  13552 } |  13576 } | 
| (...skipping 8188 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  21741   return UserTag::null(); |  21765   return UserTag::null(); | 
|  21742 } |  21766 } | 
|  21743  |  21767  | 
|  21744  |  21768  | 
|  21745 const char* UserTag::ToCString() const { |  21769 const char* UserTag::ToCString() const { | 
|  21746   const String& tag_label = String::Handle(label()); |  21770   const String& tag_label = String::Handle(label()); | 
|  21747   return tag_label.ToCString(); |  21771   return tag_label.ToCString(); | 
|  21748 } |  21772 } | 
|  21749  |  21773  | 
|  21750 }  // namespace dart |  21774 }  // namespace dart | 
| OLD | NEW |