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

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

Issue 24744002: Pattern match on generated code to find edge counters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated review comments. Created 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_patcher.h ('k') | runtime/vm/code_patcher_ia32.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) 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" // Needed here to get TARGET_ARCH_ARM. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM.
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 9
10 #include "vm/instructions.h" 10 #include "vm/instructions.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ASSERT(code.ContainsInstructionAt(return_address)); 77 ASSERT(code.ContainsInstructionAt(return_address));
78 CallPattern static_call(return_address, code); 78 CallPattern static_call(return_address, code);
79 ICData& ic_data = ICData::Handle(); 79 ICData& ic_data = ICData::Handle();
80 ic_data ^= static_call.IcData(); 80 ic_data ^= static_call.IcData();
81 if (ic_data_result != NULL) { 81 if (ic_data_result != NULL) {
82 *ic_data_result = ic_data.raw(); 82 *ic_data_result = ic_data.raw();
83 } 83 }
84 return ic_data.GetTargetAt(0); 84 return ic_data.GetTargetAt(0);
85 } 85 }
86 86
87
88 // This class pattern matches on a load from the object pool. Loading on
89 // ARM is complicated because it can take four possible different forms. We
90 // match backwards from the end of the sequence so we can reuse the code for
91 // matching object pool loads at calls.
92 class EdgeCounter : public ValueObject {
93 public:
94 EdgeCounter(uword pc, const Code& code)
95 : end_(pc - kAdjust), object_pool_(Array::Handle(code.ObjectPool())) {
96 // An IsValid predicate is complicated and duplicates the code in the
97 // decoding function. Instead we rely on decoding the pattern which
98 // will assert partial validity.
99 }
100
101 RawObject* edge_counter() const {
102 Register ignored;
103 intptr_t index;
104 InstructionPattern::DecodeLoadWordFromPool(end_, &ignored, &index);
105 ASSERT(ignored == R0);
106 return object_pool_.At(index);
107 }
108
109 private:
110 // The object pool load is followed by the fixed-size edge counter
111 // incrementing code:
112 // ldr ip, [r0, #+11]
113 // adds ip, ip, #2
114 // str ip, [r0, #+11]
115 static const intptr_t kAdjust = 3 * Instr::kInstrSize;
116
117 uword end_;
118 const Array& object_pool_;
119 };
120
121
122 RawObject* CodePatcher::GetEdgeCounterAt(uword pc, const Code& code) {
123 ASSERT(code.ContainsInstructionAt(pc));
124 EdgeCounter counter(pc, code);
125 return counter.edge_counter();
126 }
127
87 } // namespace dart 128 } // namespace dart
88 129
89 #endif // defined TARGET_ARCH_ARM 130 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/code_patcher.h ('k') | runtime/vm/code_patcher_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698