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

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

Issue 1925153003: Undo "Don't include an object header for instructions in the text section." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« 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 13500 matching lines...) Expand 10 before | Expand all | Expand 10 after
13511 // larger than the previously added one. 13511 // larger than the previously added one.
13512 for (intptr_t i = kSCallTableEntryLength; 13512 for (intptr_t i = kSCallTableEntryLength;
13513 i < value.Length(); 13513 i < value.Length();
13514 i += kSCallTableEntryLength) { 13514 i += kSCallTableEntryLength) {
13515 ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); 13515 ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i));
13516 } 13516 }
13517 #endif // DEBUG 13517 #endif // DEBUG
13518 } 13518 }
13519 13519
13520 13520
13521 uword Code::EntryPoint() const {
13522 RawObject* instr = instructions();
13523 if (!instr->IsHeapObject()) {
13524 return active_entry_point();
13525 } else {
13526 return Instructions::EntryPoint(instructions());
13527 }
13528 }
13529
13530
13531 intptr_t Code::Size() const {
13532 RawObject* instr = instructions();
13533 if (!instr->IsHeapObject()) {
13534 return Smi::Value(raw_ptr()->precompiled_instructions_size_);
13535 } else {
13536 return instructions()->ptr()->size_;
13537 }
13538 }
13539
13540
13541 bool Code::HasBreakpoint() const { 13521 bool Code::HasBreakpoint() const {
13542 if (!FLAG_support_debugger) { 13522 if (!FLAG_support_debugger) {
13543 return false; 13523 return false;
13544 } 13524 }
13545 return Isolate::Current()->debugger()->HasBreakpoint(*this); 13525 return Isolate::Current()->debugger()->HasBreakpoint(*this);
13546 } 13526 }
13547 13527
13548 13528
13549 TokenPosition Code::GetTokenPositionAt(intptr_t offset) const { 13529 TokenPosition Code::GetTokenPositionAt(intptr_t offset) const {
13550 const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map()); 13530 const CodeSourceMap& map = CodeSourceMap::Handle(code_source_map());
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
13876 for (intptr_t i = 0; i < pointer_offsets.length(); i++) { 13856 for (intptr_t i = 0; i < pointer_offsets.length(); i++) {
13877 intptr_t offset_in_instrs = pointer_offsets[i]; 13857 intptr_t offset_in_instrs = pointer_offsets[i];
13878 code.SetPointerOffsetAt(i, offset_in_instrs); 13858 code.SetPointerOffsetAt(i, offset_in_instrs);
13879 uword addr = region.start() + offset_in_instrs; 13859 uword addr = region.start() + offset_in_instrs;
13880 const Object* object = *reinterpret_cast<Object**>(addr); 13860 const Object* object = *reinterpret_cast<Object**>(addr);
13881 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), 13861 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr),
13882 object->raw()); 13862 object->raw());
13883 } 13863 }
13884 13864
13885 // Hook up Code and Instructions objects. 13865 // Hook up Code and Instructions objects.
13866 code.SetActiveInstructions(instrs.raw());
13886 code.set_instructions(instrs.raw()); 13867 code.set_instructions(instrs.raw());
13887 code.SetActiveInstructions(instrs.raw());
13888 code.set_is_alive(true); 13868 code.set_is_alive(true);
13889 13869
13890 ASSERT(code.EntryPoint() == instrs.EntryPoint());
13891 ASSERT(code.Size() == instrs.size());
13892
13893 // Set object pool in Instructions object. 13870 // Set object pool in Instructions object.
13894 INC_STAT(Thread::Current(), 13871 INC_STAT(Thread::Current(),
13895 total_code_size, object_pool.Length() * sizeof(uintptr_t)); 13872 total_code_size, object_pool.Length() * sizeof(uintptr_t));
13896 code.set_object_pool(object_pool.raw()); 13873 code.set_object_pool(object_pool.raw());
13897 13874
13898 if (FLAG_write_protect_code) { 13875 if (FLAG_write_protect_code) {
13899 uword address = RawObject::ToAddr(instrs.raw()); 13876 uword address = RawObject::ToAddr(instrs.raw());
13900 bool status = VirtualMemory::Protect( 13877 bool status = VirtualMemory::Protect(
13901 reinterpret_cast<void*>(address), 13878 reinterpret_cast<void*>(address),
13902 instrs.raw()->Size(), 13879 instrs.raw()->Size(),
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
14085 14062
14086 bool Code::IsFunctionCode() const { 14063 bool Code::IsFunctionCode() const {
14087 const Object& obj = Object::Handle(owner()); 14064 const Object& obj = Object::Handle(owner());
14088 return obj.IsFunction(); 14065 return obj.IsFunction();
14089 } 14066 }
14090 14067
14091 14068
14092 void Code::DisableDartCode() const { 14069 void Code::DisableDartCode() const {
14093 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); 14070 DEBUG_ASSERT(IsMutatorOrAtSafepoint());
14094 ASSERT(IsFunctionCode()); 14071 ASSERT(IsFunctionCode());
14095 ASSERT(!IsDisabled()); 14072 ASSERT(instructions() == active_instructions());
14096 const Code& new_code = 14073 const Code& new_code =
14097 Code::Handle(StubCode::FixCallersTarget_entry()->code()); 14074 Code::Handle(StubCode::FixCallersTarget_entry()->code());
14098 ASSERT(new_code.instructions()->IsVMHeapObject());
14099 SetActiveInstructions(new_code.instructions()); 14075 SetActiveInstructions(new_code.instructions());
14100 } 14076 }
14101 14077
14102 14078
14103 void Code::DisableStubCode() const { 14079 void Code::DisableStubCode() const {
14104 #if !defined(TARGET_ARCH_DBC) 14080 #if !defined(TARGET_ARCH_DBC)
14105 ASSERT(Thread::Current()->IsMutatorThread()); 14081 ASSERT(Thread::Current()->IsMutatorThread());
14106 ASSERT(IsAllocationStubCode()); 14082 ASSERT(IsAllocationStubCode());
14107 ASSERT(!IsDisabled()); 14083 ASSERT(instructions() == active_instructions());
14108 const Code& new_code = 14084 const Code& new_code =
14109 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()); 14085 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code());
14110 ASSERT(new_code.instructions()->IsVMHeapObject());
14111 SetActiveInstructions(new_code.instructions()); 14086 SetActiveInstructions(new_code.instructions());
14112 #else 14087 #else
14113 // DBC does not use allocation stubs. 14088 // DBC does not use allocation stubs.
14114 UNIMPLEMENTED(); 14089 UNIMPLEMENTED();
14115 #endif // !defined(TARGET_ARCH_DBC) 14090 #endif // !defined(TARGET_ARCH_DBC)
14116 } 14091 }
14117 14092
14118 14093
14119 void Code::SetActiveInstructions(RawInstructions* instructions) const { 14094 void Code::SetActiveInstructions(RawInstructions* instructions) const {
14120 DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); 14095 DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive());
14121 // RawInstructions are never allocated in New space and hence a 14096 // RawInstructions are never allocated in New space and hence a
14122 // store buffer update is not needed here. 14097 // store buffer update is not needed here.
14098 StorePointer(&raw_ptr()->active_instructions_, instructions);
14123 StoreNonPointer(&raw_ptr()->entry_point_, 14099 StoreNonPointer(&raw_ptr()->entry_point_,
14124 reinterpret_cast<uword>(instructions->ptr()) + 14100 reinterpret_cast<uword>(instructions->ptr()) +
14125 Instructions::HeaderSize()); 14101 Instructions::HeaderSize());
14126 } 14102 }
14127 14103
14128 14104
14129 uword Code::GetLazyDeoptPc() const { 14105 uword Code::GetLazyDeoptPc() const {
14130 return (lazy_deopt_pc_offset() != kInvalidPc) 14106 return (lazy_deopt_pc_offset() != kInvalidPc)
14131 ? EntryPoint() + lazy_deopt_pc_offset() : 0; 14107 ? EntryPoint() + lazy_deopt_pc_offset() : 0;
14132 } 14108 }
(...skipping 8264 matching lines...) Expand 10 before | Expand all | Expand 10 after
22397 return UserTag::null(); 22373 return UserTag::null();
22398 } 22374 }
22399 22375
22400 22376
22401 const char* UserTag::ToCString() const { 22377 const char* UserTag::ToCString() const {
22402 const String& tag_label = String::Handle(label()); 22378 const String& tag_label = String::Handle(label());
22403 return tag_label.ToCString(); 22379 return tag_label.ToCString();
22404 } 22380 }
22405 22381
22406 } // namespace dart 22382 } // 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