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

Side by Side Diff: runtime/vm/code_patcher.h

Issue 136563002: Landing: Write protect executable pages in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Added command line flag Created 6 years, 10 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 | Annotate | Revision Log
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 // Class for patching compiled code. 4 // Class for patching compiled code.
5 5
6 #ifndef VM_CODE_PATCHER_H_ 6 #ifndef VM_CODE_PATCHER_H_
7 #define VM_CODE_PATCHER_H_ 7 #define VM_CODE_PATCHER_H_
8 8
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 // Forward declaration. 13 // Forward declaration.
14 class Array; 14 class Array;
15 class Code; 15 class Code;
16 class ExternalLabel; 16 class ExternalLabel;
17 class Function; 17 class Function;
18 class ICData; 18 class ICData;
19 class RawArray; 19 class RawArray;
20 class RawFunction; 20 class RawFunction;
21 class RawICData; 21 class RawICData;
22 class RawObject; 22 class RawObject;
23 class String; 23 class String;
24 24
25
26 // Stack-allocated class to create a scope where the specified region
27 // [address, addresss + size] has write access enabled. This is used
28 // when patching generated code. Access is reset to read-execute in
29 // the destructor of this scope.
30 class WritableInstructionsScope : public ValueObject {
31 public:
32 WritableInstructionsScope(uword address, intptr_t size);
33 ~WritableInstructionsScope();
34
35 private:
36 const uword address_;
37 const intptr_t size_;
38 };
39
40
25 class CodePatcher : public AllStatic { 41 class CodePatcher : public AllStatic {
26 public: 42 public:
27 // Dart static calls have a distinct, machine-dependent code pattern. 43 // Dart static calls have a distinct, machine-dependent code pattern.
28 44
29 // Patch static call before return_address in given code to the new target. 45 // Patch static call before return_address in given code to the new target.
30 static void PatchStaticCallAt(uword return_address, 46 static void PatchStaticCallAt(uword return_address,
31 const Code& code, 47 const Code& code,
32 uword new_target_address); 48 uword new_target_address);
33 49
34 // Patch instance call before return_address in given code to the new target. 50 // Patch instance call before return_address in given code to the new target.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 93
78 static RawObject* GetEdgeCounterAt(uword pc, const Code& code); 94 static RawObject* GetEdgeCounterAt(uword pc, const Code& code);
79 95
80 static int32_t GetPoolOffsetAt(uword return_address); 96 static int32_t GetPoolOffsetAt(uword return_address);
81 static void SetPoolOffsetAt(uword return_address, int32_t offset); 97 static void SetPoolOffsetAt(uword return_address, int32_t offset);
82 }; 98 };
83 99
84 } // namespace dart 100 } // namespace dart
85 101
86 #endif // VM_CODE_PATCHER_H_ 102 #endif // VM_CODE_PATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698