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

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

Issue 1574993003: Add --check-code-pointer flag for debug builds (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/assembler_mips.cc ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/globals.h" // NOLINT 5 #include "vm/globals.h" // NOLINT
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
11 #include "vm/instructions.h" 11 #include "vm/instructions.h"
12 #include "vm/locations.h" 12 #include "vm/locations.h"
13 #include "vm/memory_region.h" 13 #include "vm/memory_region.h"
14 #include "vm/runtime_entry.h" 14 #include "vm/runtime_entry.h"
15 #include "vm/stack_frame.h" 15 #include "vm/stack_frame.h"
16 #include "vm/stub_code.h" 16 #include "vm/stub_code.h"
17 17
18 namespace dart { 18 namespace dart {
19 19
20 DECLARE_FLAG(bool, allow_absolute_addresses); 20 DECLARE_FLAG(bool, allow_absolute_addresses);
21 DECLARE_FLAG(bool, check_code_pointer);
22 DECLARE_FLAG(bool, inline_alloc);
23
21 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); 24 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message.");
22 DECLARE_FLAG(bool, inline_alloc);
23 25
24 26
25 Assembler::Assembler(bool use_far_branches) 27 Assembler::Assembler(bool use_far_branches)
26 : buffer_(), 28 : buffer_(),
27 prologue_offset_(-1), 29 prologue_offset_(-1),
28 comments_(), 30 comments_(),
29 constant_pool_allowed_(false) { 31 constant_pool_allowed_(false) {
30 // Far branching mode is only needed and implemented for MIPS and ARM. 32 // Far branching mode is only needed and implemented for MIPS and ARM.
31 ASSERT(!use_far_branches); 33 ASSERT(!use_far_branches);
32 } 34 }
(...skipping 3307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3340 CheckCodePointer(); 3342 CheckCodePointer();
3341 movq(pp, FieldAddress(CODE_REG, Code::object_pool_offset())); 3343 movq(pp, FieldAddress(CODE_REG, Code::object_pool_offset()));
3342 set_constant_pool_allowed(pp == PP); 3344 set_constant_pool_allowed(pp == PP);
3343 } 3345 }
3344 3346
3345 3347
3346 void Assembler::EnterDartFrame(intptr_t frame_size, Register new_pp) { 3348 void Assembler::EnterDartFrame(intptr_t frame_size, Register new_pp) {
3347 ASSERT(!constant_pool_allowed()); 3349 ASSERT(!constant_pool_allowed());
3348 EnterFrame(0); 3350 EnterFrame(0);
3349 pushq(CODE_REG); 3351 pushq(CODE_REG);
3350 pushq(PP); 3352 pushq(PP);
Florian Schneider 2016/01/12 11:31:23 Would it work to do CheckCodePointer here instead,
3351 if (new_pp == kNoRegister) { 3353 if (new_pp == kNoRegister) {
3352 LoadPoolPointer(PP); 3354 LoadPoolPointer(PP);
3353 } else { 3355 } else {
3354 movq(PP, new_pp); 3356 movq(PP, new_pp);
3355 } 3357 }
3356 set_constant_pool_allowed(true); 3358 set_constant_pool_allowed(true);
3357 if (frame_size != 0) { 3359 if (frame_size != 0) {
3358 subq(RSP, Immediate(frame_size)); 3360 subq(RSP, Immediate(frame_size));
3359 } 3361 }
3360 } 3362 }
3361 3363
3362 3364
3363 void Assembler::LeaveDartFrame(RestorePP restore_pp) { 3365 void Assembler::LeaveDartFrame(RestorePP restore_pp) {
3364 // Restore caller's PP register that was pushed in EnterDartFrame. 3366 // Restore caller's PP register that was pushed in EnterDartFrame.
3365 if (restore_pp == kRestoreCallerPP) { 3367 if (restore_pp == kRestoreCallerPP) {
3366 movq(PP, Address(RBP, (kSavedCallerPpSlotFromFp * kWordSize))); 3368 movq(PP, Address(RBP, (kSavedCallerPpSlotFromFp * kWordSize)));
3367 set_constant_pool_allowed(false); 3369 set_constant_pool_allowed(false);
3368 } 3370 }
3369 LeaveFrame(); 3371 LeaveFrame();
3370 } 3372 }
3371 3373
3372 3374
3373 void Assembler::CheckCodePointer() { 3375 void Assembler::CheckCodePointer() {
3374 #ifdef DEBUG 3376 #ifdef DEBUG
3377 if (!FLAG_check_code_pointer) {
3378 return;
3379 }
3375 Comment("CheckCodePointer"); 3380 Comment("CheckCodePointer");
3376 Label cid_ok, instructions_ok; 3381 Label cid_ok, instructions_ok;
3377 pushq(RAX); 3382 pushq(RAX);
3378 LoadClassId(RAX, CODE_REG); 3383 LoadClassId(RAX, CODE_REG);
3379 cmpq(RAX, Immediate(kCodeCid)); 3384 cmpq(RAX, Immediate(kCodeCid));
3380 j(EQUAL, &cid_ok); 3385 j(EQUAL, &cid_ok);
3381 int3(); 3386 int3();
3382 Bind(&cid_ok); 3387 Bind(&cid_ok);
3383 { 3388 {
3384 const intptr_t kRIPRelativeLeaqSize = 7; 3389 const intptr_t kRIPRelativeLeaqSize = 7;
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
3921 3926
3922 3927
3923 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3928 const char* Assembler::FpuRegisterName(FpuRegister reg) {
3924 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 3929 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
3925 return xmm_reg_names[reg]; 3930 return xmm_reg_names[reg];
3926 } 3931 }
3927 3932
3928 } // namespace dart 3933 } // namespace dart
3929 3934
3930 #endif // defined TARGET_ARCH_X64 3935 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698