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

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

Issue 2416963009: Minor cleanup: use handle when setting instructions in code object. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/precompiler.cc » ('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/become.h" 10 #include "vm/become.h"
(...skipping 14275 matching lines...) Expand 10 before | Expand all | Expand 10 after
14286 for (intptr_t i = 0; i < pointer_offsets.length(); i++) { 14286 for (intptr_t i = 0; i < pointer_offsets.length(); i++) {
14287 intptr_t offset_in_instrs = pointer_offsets[i]; 14287 intptr_t offset_in_instrs = pointer_offsets[i];
14288 code.SetPointerOffsetAt(i, offset_in_instrs); 14288 code.SetPointerOffsetAt(i, offset_in_instrs);
14289 uword addr = region.start() + offset_in_instrs; 14289 uword addr = region.start() + offset_in_instrs;
14290 const Object* object = *reinterpret_cast<Object**>(addr); 14290 const Object* object = *reinterpret_cast<Object**>(addr);
14291 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr), 14291 instrs.raw()->StorePointer(reinterpret_cast<RawObject**>(addr),
14292 object->raw()); 14292 object->raw());
14293 } 14293 }
14294 14294
14295 // Hook up Code and Instructions objects. 14295 // Hook up Code and Instructions objects.
14296 code.SetActiveInstructions(instrs.raw()); 14296 code.SetActiveInstructions(instrs);
14297 code.set_instructions(instrs.raw()); 14297 code.set_instructions(instrs);
14298 code.set_is_alive(true); 14298 code.set_is_alive(true);
14299 14299
14300 // Set object pool in Instructions object. 14300 // Set object pool in Instructions object.
14301 INC_STAT(Thread::Current(), 14301 INC_STAT(Thread::Current(),
14302 total_code_size, object_pool.Length() * sizeof(uintptr_t)); 14302 total_code_size, object_pool.Length() * sizeof(uintptr_t));
14303 code.set_object_pool(object_pool.raw()); 14303 code.set_object_pool(object_pool.raw());
14304 14304
14305 if (FLAG_write_protect_code) { 14305 if (FLAG_write_protect_code) {
14306 uword address = RawObject::ToAddr(instrs.raw()); 14306 uword address = RawObject::ToAddr(instrs.raw());
14307 bool status = VirtualMemory::Protect( 14307 bool status = VirtualMemory::Protect(
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
14499 return obj.IsFunction(); 14499 return obj.IsFunction();
14500 } 14500 }
14501 14501
14502 14502
14503 void Code::DisableDartCode() const { 14503 void Code::DisableDartCode() const {
14504 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); 14504 DEBUG_ASSERT(IsMutatorOrAtSafepoint());
14505 ASSERT(IsFunctionCode()); 14505 ASSERT(IsFunctionCode());
14506 ASSERT(instructions() == active_instructions()); 14506 ASSERT(instructions() == active_instructions());
14507 const Code& new_code = 14507 const Code& new_code =
14508 Code::Handle(StubCode::FixCallersTarget_entry()->code()); 14508 Code::Handle(StubCode::FixCallersTarget_entry()->code());
14509 SetActiveInstructions(new_code.instructions()); 14509 SetActiveInstructions(Instructions::Handle(new_code.instructions()));
14510 } 14510 }
14511 14511
14512 14512
14513 void Code::DisableStubCode() const { 14513 void Code::DisableStubCode() const {
14514 #if !defined(TARGET_ARCH_DBC) 14514 #if !defined(TARGET_ARCH_DBC)
14515 ASSERT(Thread::Current()->IsMutatorThread()); 14515 ASSERT(Thread::Current()->IsMutatorThread());
14516 ASSERT(IsAllocationStubCode()); 14516 ASSERT(IsAllocationStubCode());
14517 ASSERT(instructions() == active_instructions()); 14517 ASSERT(instructions() == active_instructions());
14518 const Code& new_code = 14518 const Code& new_code =
14519 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code()); 14519 Code::Handle(StubCode::FixAllocationStubTarget_entry()->code());
14520 SetActiveInstructions(new_code.instructions()); 14520 SetActiveInstructions(Instructions::Handle(new_code.instructions()));
14521 #else 14521 #else
14522 // DBC does not use allocation stubs. 14522 // DBC does not use allocation stubs.
14523 UNIMPLEMENTED(); 14523 UNIMPLEMENTED();
14524 #endif // !defined(TARGET_ARCH_DBC) 14524 #endif // !defined(TARGET_ARCH_DBC)
14525 } 14525 }
14526 14526
14527 14527
14528 void Code::SetActiveInstructions(RawInstructions* instructions) const { 14528 void Code::SetActiveInstructions(const Instructions& instructions) const {
14529 #if defined(DART_PRECOMPILED_RUNTIME) 14529 #if defined(DART_PRECOMPILED_RUNTIME)
14530 UNREACHABLE(); 14530 UNREACHABLE();
14531 #else 14531 #else
14532 DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive()); 14532 DEBUG_ASSERT(IsMutatorOrAtSafepoint() || !is_alive());
14533 // RawInstructions are never allocated in New space and hence a 14533 // RawInstructions are never allocated in New space and hence a
14534 // store buffer update is not needed here. 14534 // store buffer update is not needed here.
14535 StorePointer(&raw_ptr()->active_instructions_, instructions); 14535 StorePointer(&raw_ptr()->active_instructions_, instructions.raw());
14536 StoreNonPointer(&raw_ptr()->entry_point_, 14536 StoreNonPointer(&raw_ptr()->entry_point_,
14537 Instructions::UncheckedEntryPoint(instructions)); 14537 Instructions::UncheckedEntryPoint(instructions.raw()));
14538 StoreNonPointer(&raw_ptr()->checked_entry_point_, 14538 StoreNonPointer(&raw_ptr()->checked_entry_point_,
14539 Instructions::CheckedEntryPoint(instructions)); 14539 Instructions::CheckedEntryPoint(instructions.raw()));
14540 #endif 14540 #endif
14541 } 14541 }
14542 14542
14543 14543
14544 RawStackmap* Code::GetStackmap( 14544 RawStackmap* Code::GetStackmap(
14545 uint32_t pc_offset, Array* maps, Stackmap* map) const { 14545 uint32_t pc_offset, Array* maps, Stackmap* map) const {
14546 // This code is used during iterating frames during a GC and hence it 14546 // This code is used during iterating frames during a GC and hence it
14547 // should not in turn start a GC. 14547 // should not in turn start a GC.
14548 NoSafepointScope no_safepoint; 14548 NoSafepointScope no_safepoint;
14549 if (stackmaps() == Array::null()) { 14549 if (stackmaps() == Array::null()) {
(...skipping 8454 matching lines...) Expand 10 before | Expand all | Expand 10 after
23004 return UserTag::null(); 23004 return UserTag::null();
23005 } 23005 }
23006 23006
23007 23007
23008 const char* UserTag::ToCString() const { 23008 const char* UserTag::ToCString() const {
23009 const String& tag_label = String::Handle(label()); 23009 const String& tag_label = String::Handle(label());
23010 return tag_label.ToCString(); 23010 return tag_label.ToCString();
23011 } 23011 }
23012 23012
23013 } // namespace dart 23013 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698