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

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

Issue 1294113004: VM: Link native calls lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 years, 4 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/instructions_mips.h ('k') | runtime/vm/intermediate_language.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) 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_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/constants_mips.h" 8 #include "vm/constants_mips.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/instructions.h" 10 #include "vm/instructions.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 return object_pool_.RawValueAt(target_address_pool_index_); 138 return object_pool_.RawValueAt(target_address_pool_index_);
139 } 139 }
140 140
141 141
142 void CallPattern::SetTargetAddress(uword target_address) const { 142 void CallPattern::SetTargetAddress(uword target_address) const {
143 object_pool_.SetRawValueAt(target_address_pool_index_, target_address); 143 object_pool_.SetRawValueAt(target_address_pool_index_, target_address);
144 // No need to flush the instruction cache, since the code is not modified. 144 // No need to flush the instruction cache, since the code is not modified.
145 } 145 }
146 146
147 147
148 NativeCallPattern::NativeCallPattern(uword pc, const Code& code)
149 : object_pool_(ObjectPool::Handle(code.GetObjectPool())),
150 end_(pc),
151 native_function_pool_index_(-1),
152 target_address_pool_index_(-1) {
153 ASSERT(code.ContainsInstructionAt(pc));
154 // Last instruction: jalr RA, T9(=R25).
155 ASSERT(*(reinterpret_cast<uword*>(end_) - 2) == 0x0320f809);
156
157 Register reg;
158 uword native_function_load_end =
159 InstructionPattern::DecodeLoadWordFromPool(end_ - 2 * Instr::kInstrSize,
160 &reg,
161 &target_address_pool_index_);
162 ASSERT(reg == T9);
163 InstructionPattern::DecodeLoadWordFromPool(native_function_load_end,
164 &reg,
165 &native_function_pool_index_);
166 ASSERT(reg == T5);
167 }
168
169
170 uword NativeCallPattern::target() const {
171 return object_pool_.RawValueAt(target_address_pool_index_);
172 }
173
174
175 void NativeCallPattern::set_target(uword target_address) const {
176 object_pool_.SetRawValueAt(target_address_pool_index_, target_address);
177 // No need to flush the instruction cache, since the code is not modified.
178 }
179
180
181 NativeFunction NativeCallPattern::native_function() const {
182 return reinterpret_cast<NativeFunction>(
183 object_pool_.RawValueAt(native_function_pool_index_));
184 }
185
186
187 void NativeCallPattern::set_native_function(NativeFunction func) const {
188 object_pool_.SetRawValueAt(native_function_pool_index_,
189 reinterpret_cast<uword>(func));
190 }
191
192
148 void CallPattern::InsertAt(uword pc, uword target_address) { 193 void CallPattern::InsertAt(uword pc, uword target_address) {
149 Instr* lui = Instr::At(pc + (0 * Instr::kInstrSize)); 194 Instr* lui = Instr::At(pc + (0 * Instr::kInstrSize));
150 Instr* ori = Instr::At(pc + (1 * Instr::kInstrSize)); 195 Instr* ori = Instr::At(pc + (1 * Instr::kInstrSize));
151 Instr* jr = Instr::At(pc + (2 * Instr::kInstrSize)); 196 Instr* jr = Instr::At(pc + (2 * Instr::kInstrSize));
152 Instr* nop = Instr::At(pc + (3 * Instr::kInstrSize)); 197 Instr* nop = Instr::At(pc + (3 * Instr::kInstrSize));
153 uint16_t target_lo = target_address & 0xffff; 198 uint16_t target_lo = target_address & 0xffff;
154 uint16_t target_hi = target_address >> 16; 199 uint16_t target_hi = target_address >> 16;
155 200
156 lui->SetImmInstrBits(LUI, ZR, T9, target_hi); 201 lui->SetImmInstrBits(LUI, ZR, T9, target_hi);
157 ori->SetImmInstrBits(ORI, T9, T9, target_lo); 202 ori->SetImmInstrBits(ORI, T9, T9, target_lo);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 bool ReturnPattern::IsValid() const { 254 bool ReturnPattern::IsValid() const {
210 Instr* jr = Instr::At(pc_); 255 Instr* jr = Instr::At(pc_);
211 return (jr->OpcodeField() == SPECIAL) && 256 return (jr->OpcodeField() == SPECIAL) &&
212 (jr->FunctionField() == JR) && 257 (jr->FunctionField() == JR) &&
213 (jr->RsField() == RA); 258 (jr->RsField() == RA);
214 } 259 }
215 260
216 } // namespace dart 261 } // namespace dart
217 262
218 #endif // defined TARGET_ARCH_MIPS 263 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/instructions_mips.h ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698