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

Side by Side Diff: src/mips/codegen-mips.cc

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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 | « src/mips/code-stubs-mips.cc ('k') | src/mips/constants-mips.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 21 matching lines...) Expand all
32 #include "codegen.h" 32 #include "codegen.h"
33 #include "macro-assembler.h" 33 #include "macro-assembler.h"
34 #include "simulator-mips.h" 34 #include "simulator-mips.h"
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 39
40 UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) { 40 UnaryMathFunction CreateTranscendentalFunction(TranscendentalCache::Type type) {
41 switch (type) { 41 switch (type) {
42 case TranscendentalCache::SIN: return &sin;
43 case TranscendentalCache::COS: return &cos;
44 case TranscendentalCache::TAN: return &tan;
45 case TranscendentalCache::LOG: return &log; 42 case TranscendentalCache::LOG: return &log;
46 default: UNIMPLEMENTED(); 43 default: UNIMPLEMENTED();
47 } 44 }
48 return NULL; 45 return NULL;
49 } 46 }
50 47
51 48
52 #define __ masm. 49 #define __ masm.
53 50
54 51
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 103
107 #if !defined(USE_SIMULATOR) 104 #if !defined(USE_SIMULATOR)
108 return FUNCTION_CAST<UnaryMathFunction>(buffer); 105 return FUNCTION_CAST<UnaryMathFunction>(buffer);
109 #else 106 #else
110 fast_exp_mips_machine_code = buffer; 107 fast_exp_mips_machine_code = buffer;
111 return &fast_exp_simulator; 108 return &fast_exp_simulator;
112 #endif 109 #endif
113 } 110 }
114 111
115 112
113 #if defined(V8_HOST_ARCH_MIPS)
114 OS::MemCopyUint8Function CreateMemCopyUint8Function(
115 OS::MemCopyUint8Function stub) {
116 #if defined(USE_SIMULATOR)
117 return stub;
118 #else
119 if (Serializer::enabled()) {
120 return stub;
121 }
122
123 size_t actual_size;
124 byte* buffer = static_cast<byte*>(OS::Allocate(3 * KB, &actual_size, true));
125 if (buffer == NULL) return stub;
126
127 // This code assumes that cache lines are 32 bytes and if the cache line is
128 // larger it will not work correctly.
129 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
130
131 {
132 Label lastb, unaligned, aligned, chkw,
133 loop16w, chk1w, wordCopy_loop, skip_pref, lastbloop,
134 leave, ua_chk16w, ua_loop16w, ua_skip_pref, ua_chkw,
135 ua_chk1w, ua_wordCopy_loop, ua_smallCopy, ua_smallCopy_loop;
136
137 // The size of each prefetch.
138 uint32_t pref_chunk = 32;
139 // The maximum size of a prefetch, it must not be less then pref_chunk.
140 // If the real size of a prefetch is greater then max_pref_size and
141 // the kPrefHintPrepareForStore hint is used, the code will not work
142 // correctly.
143 uint32_t max_pref_size = 128;
144 ASSERT(pref_chunk < max_pref_size);
145
146 // pref_limit is set based on the fact that we never use an offset
147 // greater then 5 on a store pref and that a single pref can
148 // never be larger then max_pref_size.
149 uint32_t pref_limit = (5 * pref_chunk) + max_pref_size;
150 int32_t pref_hint_load = kPrefHintLoadStreamed;
151 int32_t pref_hint_store = kPrefHintPrepareForStore;
152 uint32_t loadstore_chunk = 4;
153
154 // The initial prefetches may fetch bytes that are before the buffer being
155 // copied. Start copies with an offset of 4 so avoid this situation when
156 // using kPrefHintPrepareForStore.
157 ASSERT(pref_hint_store != kPrefHintPrepareForStore ||
158 pref_chunk * 4 >= max_pref_size);
159
160 // If the size is less than 8, go to lastb. Regardless of size,
161 // copy dst pointer to v0 for the retuen value.
162 __ slti(t2, a2, 2 * loadstore_chunk);
163 __ bne(t2, zero_reg, &lastb);
164 __ mov(v0, a0); // In delay slot.
165
166 // If src and dst have different alignments, go to unaligned, if they
167 // have the same alignment (but are not actually aligned) do a partial
168 // load/store to make them aligned. If they are both already aligned
169 // we can start copying at aligned.
170 __ xor_(t8, a1, a0);
171 __ andi(t8, t8, loadstore_chunk - 1); // t8 is a0/a1 word-displacement.
172 __ bne(t8, zero_reg, &unaligned);
173 __ subu(a3, zero_reg, a0); // In delay slot.
174
175 __ andi(a3, a3, loadstore_chunk - 1); // Copy a3 bytes to align a0/a1.
176 __ beq(a3, zero_reg, &aligned); // Already aligned.
177 __ subu(a2, a2, a3); // In delay slot. a2 is the remining bytes count.
178
179 __ lwr(t8, MemOperand(a1));
180 __ addu(a1, a1, a3);
181 __ swr(t8, MemOperand(a0));
182 __ addu(a0, a0, a3);
183
184 // Now dst/src are both aligned to (word) aligned addresses. Set a2 to
185 // count how many bytes we have to copy after all the 64 byte chunks are
186 // copied and a3 to the dst pointer after all the 64 byte chunks have been
187 // copied. We will loop, incrementing a0 and a1 until a0 equals a3.
188 __ bind(&aligned);
189 __ andi(t8, a2, 0x3f);
190 __ beq(a2, t8, &chkw); // Less than 64?
191 __ subu(a3, a2, t8); // In delay slot.
192 __ addu(a3, a0, a3); // Now a3 is the final dst after loop.
193
194 // When in the loop we prefetch with kPrefHintPrepareForStore hint,
195 // in this case the a0+x should be past the "t0-32" address. This means:
196 // for x=128 the last "safe" a0 address is "t0-160". Alternatively, for
197 // x=64 the last "safe" a0 address is "t0-96". In the current version we
198 // will use "pref hint, 128(a0)", so "t0-160" is the limit.
199 if (pref_hint_store == kPrefHintPrepareForStore) {
200 __ addu(t0, a0, a2); // t0 is the "past the end" address.
201 __ Subu(t9, t0, pref_limit); // t9 is the "last safe pref" address.
202 }
203
204 __ Pref(pref_hint_load, MemOperand(a1, 0 * pref_chunk));
205 __ Pref(pref_hint_load, MemOperand(a1, 1 * pref_chunk));
206 __ Pref(pref_hint_load, MemOperand(a1, 2 * pref_chunk));
207 __ Pref(pref_hint_load, MemOperand(a1, 3 * pref_chunk));
208
209 if (pref_hint_store != kPrefHintPrepareForStore) {
210 __ Pref(pref_hint_store, MemOperand(a0, 1 * pref_chunk));
211 __ Pref(pref_hint_store, MemOperand(a0, 2 * pref_chunk));
212 __ Pref(pref_hint_store, MemOperand(a0, 3 * pref_chunk));
213 }
214 __ bind(&loop16w);
215 __ lw(t0, MemOperand(a1));
216
217 if (pref_hint_store == kPrefHintPrepareForStore) {
218 __ sltu(v1, t9, a0); // If a0 > t9, don't use next prefetch.
219 __ Branch(USE_DELAY_SLOT, &skip_pref, gt, v1, Operand(zero_reg));
220 }
221 __ lw(t1, MemOperand(a1, 1, loadstore_chunk)); // Maybe in delay slot.
222
223 __ Pref(pref_hint_store, MemOperand(a0, 4 * pref_chunk));
224 __ Pref(pref_hint_store, MemOperand(a0, 5 * pref_chunk));
225
226 __ bind(&skip_pref);
227 __ lw(t2, MemOperand(a1, 2, loadstore_chunk));
228 __ lw(t3, MemOperand(a1, 3, loadstore_chunk));
229 __ lw(t4, MemOperand(a1, 4, loadstore_chunk));
230 __ lw(t5, MemOperand(a1, 5, loadstore_chunk));
231 __ lw(t6, MemOperand(a1, 6, loadstore_chunk));
232 __ lw(t7, MemOperand(a1, 7, loadstore_chunk));
233 __ Pref(pref_hint_load, MemOperand(a1, 4 * pref_chunk));
234
235 __ sw(t0, MemOperand(a0));
236 __ sw(t1, MemOperand(a0, 1, loadstore_chunk));
237 __ sw(t2, MemOperand(a0, 2, loadstore_chunk));
238 __ sw(t3, MemOperand(a0, 3, loadstore_chunk));
239 __ sw(t4, MemOperand(a0, 4, loadstore_chunk));
240 __ sw(t5, MemOperand(a0, 5, loadstore_chunk));
241 __ sw(t6, MemOperand(a0, 6, loadstore_chunk));
242 __ sw(t7, MemOperand(a0, 7, loadstore_chunk));
243
244 __ lw(t0, MemOperand(a1, 8, loadstore_chunk));
245 __ lw(t1, MemOperand(a1, 9, loadstore_chunk));
246 __ lw(t2, MemOperand(a1, 10, loadstore_chunk));
247 __ lw(t3, MemOperand(a1, 11, loadstore_chunk));
248 __ lw(t4, MemOperand(a1, 12, loadstore_chunk));
249 __ lw(t5, MemOperand(a1, 13, loadstore_chunk));
250 __ lw(t6, MemOperand(a1, 14, loadstore_chunk));
251 __ lw(t7, MemOperand(a1, 15, loadstore_chunk));
252 __ Pref(pref_hint_load, MemOperand(a1, 5 * pref_chunk));
253
254 __ sw(t0, MemOperand(a0, 8, loadstore_chunk));
255 __ sw(t1, MemOperand(a0, 9, loadstore_chunk));
256 __ sw(t2, MemOperand(a0, 10, loadstore_chunk));
257 __ sw(t3, MemOperand(a0, 11, loadstore_chunk));
258 __ sw(t4, MemOperand(a0, 12, loadstore_chunk));
259 __ sw(t5, MemOperand(a0, 13, loadstore_chunk));
260 __ sw(t6, MemOperand(a0, 14, loadstore_chunk));
261 __ sw(t7, MemOperand(a0, 15, loadstore_chunk));
262 __ addiu(a0, a0, 16 * loadstore_chunk);
263 __ bne(a0, a3, &loop16w);
264 __ addiu(a1, a1, 16 * loadstore_chunk); // In delay slot.
265 __ mov(a2, t8);
266
267 // Here we have src and dest word-aligned but less than 64-bytes to go.
268 // Check for a 32 bytes chunk and copy if there is one. Otherwise jump
269 // down to chk1w to handle the tail end of the copy.
270 __ bind(&chkw);
271 __ Pref(pref_hint_load, MemOperand(a1, 0 * pref_chunk));
272 __ andi(t8, a2, 0x1f);
273 __ beq(a2, t8, &chk1w); // Less than 32?
274 __ nop(); // In delay slot.
275 __ lw(t0, MemOperand(a1));
276 __ lw(t1, MemOperand(a1, 1, loadstore_chunk));
277 __ lw(t2, MemOperand(a1, 2, loadstore_chunk));
278 __ lw(t3, MemOperand(a1, 3, loadstore_chunk));
279 __ lw(t4, MemOperand(a1, 4, loadstore_chunk));
280 __ lw(t5, MemOperand(a1, 5, loadstore_chunk));
281 __ lw(t6, MemOperand(a1, 6, loadstore_chunk));
282 __ lw(t7, MemOperand(a1, 7, loadstore_chunk));
283 __ addiu(a1, a1, 8 * loadstore_chunk);
284 __ sw(t0, MemOperand(a0));
285 __ sw(t1, MemOperand(a0, 1, loadstore_chunk));
286 __ sw(t2, MemOperand(a0, 2, loadstore_chunk));
287 __ sw(t3, MemOperand(a0, 3, loadstore_chunk));
288 __ sw(t4, MemOperand(a0, 4, loadstore_chunk));
289 __ sw(t5, MemOperand(a0, 5, loadstore_chunk));
290 __ sw(t6, MemOperand(a0, 6, loadstore_chunk));
291 __ sw(t7, MemOperand(a0, 7, loadstore_chunk));
292 __ addiu(a0, a0, 8 * loadstore_chunk);
293
294 // Here we have less than 32 bytes to copy. Set up for a loop to copy
295 // one word at a time. Set a2 to count how many bytes we have to copy
296 // after all the word chunks are copied and a3 to the dst pointer after
297 // all the word chunks have been copied. We will loop, incrementing a0
298 // and a1 untill a0 equals a3.
299 __ bind(&chk1w);
300 __ andi(a2, t8, loadstore_chunk - 1);
301 __ beq(a2, t8, &lastb);
302 __ subu(a3, t8, a2); // In delay slot.
303 __ addu(a3, a0, a3);
304
305 __ bind(&wordCopy_loop);
306 __ lw(t3, MemOperand(a1));
307 __ addiu(a0, a0, loadstore_chunk);
308 __ addiu(a1, a1, loadstore_chunk);
309 __ bne(a0, a3, &wordCopy_loop);
310 __ sw(t3, MemOperand(a0, -1, loadstore_chunk)); // In delay slot.
311
312 __ bind(&lastb);
313 __ Branch(&leave, le, a2, Operand(zero_reg));
314 __ addu(a3, a0, a2);
315
316 __ bind(&lastbloop);
317 __ lb(v1, MemOperand(a1));
318 __ addiu(a0, a0, 1);
319 __ addiu(a1, a1, 1);
320 __ bne(a0, a3, &lastbloop);
321 __ sb(v1, MemOperand(a0, -1)); // In delay slot.
322
323 __ bind(&leave);
324 __ jr(ra);
325 __ nop();
326
327 // Unaligned case. Only the dst gets aligned so we need to do partial
328 // loads of the source followed by normal stores to the dst (once we
329 // have aligned the destination).
330 __ bind(&unaligned);
331 __ andi(a3, a3, loadstore_chunk - 1); // Copy a3 bytes to align a0/a1.
332 __ beq(a3, zero_reg, &ua_chk16w);
333 __ subu(a2, a2, a3); // In delay slot.
334
335 __ lwr(v1, MemOperand(a1));
336 __ lwl(v1,
337 MemOperand(a1, 1, loadstore_chunk, MemOperand::offset_minus_one));
338 __ addu(a1, a1, a3);
339 __ swr(v1, MemOperand(a0));
340 __ addu(a0, a0, a3);
341
342 // Now the dst (but not the source) is aligned. Set a2 to count how many
343 // bytes we have to copy after all the 64 byte chunks are copied and a3 to
344 // the dst pointer after all the 64 byte chunks have been copied. We will
345 // loop, incrementing a0 and a1 until a0 equals a3.
346 __ bind(&ua_chk16w);
347 __ andi(t8, a2, 0x3f);
348 __ beq(a2, t8, &ua_chkw);
349 __ subu(a3, a2, t8); // In delay slot.
350 __ addu(a3, a0, a3);
351
352 if (pref_hint_store == kPrefHintPrepareForStore) {
353 __ addu(t0, a0, a2);
354 __ Subu(t9, t0, pref_limit);
355 }
356
357 __ Pref(pref_hint_load, MemOperand(a1, 0 * pref_chunk));
358 __ Pref(pref_hint_load, MemOperand(a1, 1 * pref_chunk));
359 __ Pref(pref_hint_load, MemOperand(a1, 2 * pref_chunk));
360
361 if (pref_hint_store != kPrefHintPrepareForStore) {
362 __ Pref(pref_hint_store, MemOperand(a0, 1 * pref_chunk));
363 __ Pref(pref_hint_store, MemOperand(a0, 2 * pref_chunk));
364 __ Pref(pref_hint_store, MemOperand(a0, 3 * pref_chunk));
365 }
366
367 __ bind(&ua_loop16w);
368 __ Pref(pref_hint_load, MemOperand(a1, 3 * pref_chunk));
369 __ lwr(t0, MemOperand(a1));
370 __ lwr(t1, MemOperand(a1, 1, loadstore_chunk));
371 __ lwr(t2, MemOperand(a1, 2, loadstore_chunk));
372
373 if (pref_hint_store == kPrefHintPrepareForStore) {
374 __ sltu(v1, t9, a0);
375 __ Branch(USE_DELAY_SLOT, &ua_skip_pref, gt, v1, Operand(zero_reg));
376 }
377 __ lwr(t3, MemOperand(a1, 3, loadstore_chunk)); // Maybe in delay slot.
378
379 __ Pref(pref_hint_store, MemOperand(a0, 4 * pref_chunk));
380 __ Pref(pref_hint_store, MemOperand(a0, 5 * pref_chunk));
381
382 __ bind(&ua_skip_pref);
383 __ lwr(t4, MemOperand(a1, 4, loadstore_chunk));
384 __ lwr(t5, MemOperand(a1, 5, loadstore_chunk));
385 __ lwr(t6, MemOperand(a1, 6, loadstore_chunk));
386 __ lwr(t7, MemOperand(a1, 7, loadstore_chunk));
387 __ lwl(t0,
388 MemOperand(a1, 1, loadstore_chunk, MemOperand::offset_minus_one));
389 __ lwl(t1,
390 MemOperand(a1, 2, loadstore_chunk, MemOperand::offset_minus_one));
391 __ lwl(t2,
392 MemOperand(a1, 3, loadstore_chunk, MemOperand::offset_minus_one));
393 __ lwl(t3,
394 MemOperand(a1, 4, loadstore_chunk, MemOperand::offset_minus_one));
395 __ lwl(t4,
396 MemOperand(a1, 5, loadstore_chunk, MemOperand::offset_minus_one));
397 __ lwl(t5,
398 MemOperand(a1, 6, loadstore_chunk, MemOperand::offset_minus_one));
399 __ lwl(t6,
400 MemOperand(a1, 7, loadstore_chunk, MemOperand::offset_minus_one));
401 __ lwl(t7,
402 MemOperand(a1, 8, loadstore_chunk, MemOperand::offset_minus_one));
403 __ Pref(pref_hint_load, MemOperand(a1, 4 * pref_chunk));
404 __ sw(t0, MemOperand(a0));
405 __ sw(t1, MemOperand(a0, 1, loadstore_chunk));
406 __ sw(t2, MemOperand(a0, 2, loadstore_chunk));
407 __ sw(t3, MemOperand(a0, 3, loadstore_chunk));
408 __ sw(t4, MemOperand(a0, 4, loadstore_chunk));
409 __ sw(t5, MemOperand(a0, 5, loadstore_chunk));
410 __ sw(t6, MemOperand(a0, 6, loadstore_chunk));
411 __ sw(t7, MemOperand(a0, 7, loadstore_chunk));
412 __ lwr(t0, MemOperand(a1, 8, loadstore_chunk));
413 __ lwr(t1, MemOperand(a1, 9, loadstore_chunk));
414 __ lwr(t2, MemOperand(a1, 10, loadstore_chunk));
415 __ lwr(t3, MemOperand(a1, 11, loadstore_chunk));
416 __ lwr(t4, MemOperand(a1, 12, loadstore_chunk));
417 __ lwr(t5, MemOperand(a1, 13, loadstore_chunk));
418 __ lwr(t6, MemOperand(a1, 14, loadstore_chunk));
419 __ lwr(t7, MemOperand(a1, 15, loadstore_chunk));
420 __ lwl(t0,
421 MemOperand(a1, 9, loadstore_chunk, MemOperand::offset_minus_one));
422 __ lwl(t1,
423 MemOperand(a1, 10, loadstore_chunk, MemOperand::offset_minus_one));
424 __ lwl(t2,
425 MemOperand(a1, 11, loadstore_chunk, MemOperand::offset_minus_one));
426 __ lwl(t3,
427 MemOperand(a1, 12, loadstore_chunk, MemOperand::offset_minus_one));
428 __ lwl(t4,
429 MemOperand(a1, 13, loadstore_chunk, MemOperand::offset_minus_one));
430 __ lwl(t5,
431 MemOperand(a1, 14, loadstore_chunk, MemOperand::offset_minus_one));
432 __ lwl(t6,
433 MemOperand(a1, 15, loadstore_chunk, MemOperand::offset_minus_one));
434 __ lwl(t7,
435 MemOperand(a1, 16, loadstore_chunk, MemOperand::offset_minus_one));
436 __ Pref(pref_hint_load, MemOperand(a1, 5 * pref_chunk));
437 __ sw(t0, MemOperand(a0, 8, loadstore_chunk));
438 __ sw(t1, MemOperand(a0, 9, loadstore_chunk));
439 __ sw(t2, MemOperand(a0, 10, loadstore_chunk));
440 __ sw(t3, MemOperand(a0, 11, loadstore_chunk));
441 __ sw(t4, MemOperand(a0, 12, loadstore_chunk));
442 __ sw(t5, MemOperand(a0, 13, loadstore_chunk));
443 __ sw(t6, MemOperand(a0, 14, loadstore_chunk));
444 __ sw(t7, MemOperand(a0, 15, loadstore_chunk));
445 __ addiu(a0, a0, 16 * loadstore_chunk);
446 __ bne(a0, a3, &ua_loop16w);
447 __ addiu(a1, a1, 16 * loadstore_chunk); // In delay slot.
448 __ mov(a2, t8);
449
450 // Here less than 64-bytes. Check for
451 // a 32 byte chunk and copy if there is one. Otherwise jump down to
452 // ua_chk1w to handle the tail end of the copy.
453 __ bind(&ua_chkw);
454 __ Pref(pref_hint_load, MemOperand(a1));
455 __ andi(t8, a2, 0x1f);
456
457 __ beq(a2, t8, &ua_chk1w);
458 __ nop(); // In delay slot.
459 __ lwr(t0, MemOperand(a1));
460 __ lwr(t1, MemOperand(a1, 1, loadstore_chunk));
461 __ lwr(t2, MemOperand(a1, 2, loadstore_chunk));
462 __ lwr(t3, MemOperand(a1, 3, loadstore_chunk));
463 __ lwr(t4, MemOperand(a1, 4, loadstore_chunk));
464 __ lwr(t5, MemOperand(a1, 5, loadstore_chunk));
465 __ lwr(t6, MemOperand(a1, 6, loadstore_chunk));
466 __ lwr(t7, MemOperand(a1, 7, loadstore_chunk));
467 __ lwl(t0,
468 MemOperand(a1, 1, loadstore_chunk, MemOperand::offset_minus_one));
469 __ lwl(t1,
470 MemOperand(a1, 2, loadstore_chunk, MemOperand::offset_minus_one));
471 __ lwl(t2,
472 MemOperand(a1, 3, loadstore_chunk, MemOperand::offset_minus_one));
473 __ lwl(t3,
474 MemOperand(a1, 4, loadstore_chunk, MemOperand::offset_minus_one));
475 __ lwl(t4,
476 MemOperand(a1, 5, loadstore_chunk, MemOperand::offset_minus_one));
477 __ lwl(t5,
478 MemOperand(a1, 6, loadstore_chunk, MemOperand::offset_minus_one));
479 __ lwl(t6,
480 MemOperand(a1, 7, loadstore_chunk, MemOperand::offset_minus_one));
481 __ lwl(t7,
482 MemOperand(a1, 8, loadstore_chunk, MemOperand::offset_minus_one));
483 __ addiu(a1, a1, 8 * loadstore_chunk);
484 __ sw(t0, MemOperand(a0));
485 __ sw(t1, MemOperand(a0, 1, loadstore_chunk));
486 __ sw(t2, MemOperand(a0, 2, loadstore_chunk));
487 __ sw(t3, MemOperand(a0, 3, loadstore_chunk));
488 __ sw(t4, MemOperand(a0, 4, loadstore_chunk));
489 __ sw(t5, MemOperand(a0, 5, loadstore_chunk));
490 __ sw(t6, MemOperand(a0, 6, loadstore_chunk));
491 __ sw(t7, MemOperand(a0, 7, loadstore_chunk));
492 __ addiu(a0, a0, 8 * loadstore_chunk);
493
494 // Less than 32 bytes to copy. Set up for a loop to
495 // copy one word at a time.
496 __ bind(&ua_chk1w);
497 __ andi(a2, t8, loadstore_chunk - 1);
498 __ beq(a2, t8, &ua_smallCopy);
499 __ subu(a3, t8, a2); // In delay slot.
500 __ addu(a3, a0, a3);
501
502 __ bind(&ua_wordCopy_loop);
503 __ lwr(v1, MemOperand(a1));
504 __ lwl(v1,
505 MemOperand(a1, 1, loadstore_chunk, MemOperand::offset_minus_one));
506 __ addiu(a0, a0, loadstore_chunk);
507 __ addiu(a1, a1, loadstore_chunk);
508 __ bne(a0, a3, &ua_wordCopy_loop);
509 __ sw(v1, MemOperand(a0, -1, loadstore_chunk)); // In delay slot.
510
511 // Copy the last 8 bytes.
512 __ bind(&ua_smallCopy);
513 __ beq(a2, zero_reg, &leave);
514 __ addu(a3, a0, a2); // In delay slot.
515
516 __ bind(&ua_smallCopy_loop);
517 __ lb(v1, MemOperand(a1));
518 __ addiu(a0, a0, 1);
519 __ addiu(a1, a1, 1);
520 __ bne(a0, a3, &ua_smallCopy_loop);
521 __ sb(v1, MemOperand(a0, -1)); // In delay slot.
522
523 __ jr(ra);
524 __ nop();
525 }
526 CodeDesc desc;
527 masm.GetCode(&desc);
528 ASSERT(!RelocInfo::RequiresRelocation(desc));
529
530 CPU::FlushICache(buffer, actual_size);
531 OS::ProtectCode(buffer, actual_size);
532 return FUNCTION_CAST<OS::MemCopyUint8Function>(buffer);
533 #endif
534 }
535 #endif
536
116 #undef __ 537 #undef __
117 538
118 539
119 UnaryMathFunction CreateSqrtFunction() { 540 UnaryMathFunction CreateSqrtFunction() {
120 return &sqrt; 541 return &sqrt;
121 } 542 }
122 543
123 544
124 // ------------------------------------------------------------------------- 545 // -------------------------------------------------------------------------
125 // Platform-specific RuntimeCallHelper functions. 546 // Platform-specific RuntimeCallHelper functions.
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 __ bind(&zero); 1017 __ bind(&zero);
597 __ Move(result, kDoubleRegZero); 1018 __ Move(result, kDoubleRegZero);
598 __ Branch(&done); 1019 __ Branch(&done);
599 1020
600 __ bind(&infinity); 1021 __ bind(&infinity);
601 __ ldc1(result, ExpConstant(2, temp3)); 1022 __ ldc1(result, ExpConstant(2, temp3));
602 1023
603 __ bind(&done); 1024 __ bind(&done);
604 } 1025 }
605 1026
606 1027 #ifdef DEBUG
607 // nop(CODE_AGE_MARKER_NOP) 1028 // nop(CODE_AGE_MARKER_NOP)
608 static const uint32_t kCodeAgePatchFirstInstruction = 0x00010180; 1029 static const uint32_t kCodeAgePatchFirstInstruction = 0x00010180;
1030 #endif
609 1031
610 static byte* GetNoCodeAgeSequence(uint32_t* length) { 1032 static byte* GetNoCodeAgeSequence(uint32_t* length) {
611 // The sequence of instructions that is patched out for aging code is the 1033 // The sequence of instructions that is patched out for aging code is the
612 // following boilerplate stack-building prologue that is found in FUNCTIONS 1034 // following boilerplate stack-building prologue that is found in FUNCTIONS
613 static bool initialized = false; 1035 static bool initialized = false;
614 static uint32_t sequence[kNoCodeAgeSequenceLength]; 1036 static uint32_t sequence[kNoCodeAgeSequenceLength];
615 byte* byte_sequence = reinterpret_cast<byte*>(sequence); 1037 byte* byte_sequence = reinterpret_cast<byte*>(sequence);
616 *length = kNoCodeAgeSequenceLength * Assembler::kInstrSize; 1038 *length = kNoCodeAgeSequenceLength * Assembler::kInstrSize;
617 if (!initialized) { 1039 if (!initialized) {
618 CodePatcher patcher(byte_sequence, kNoCodeAgeSequenceLength); 1040 CodePatcher patcher(byte_sequence, kNoCodeAgeSequenceLength);
(...skipping 16 matching lines...) Expand all
635 return result; 1057 return result;
636 } 1058 }
637 1059
638 1060
639 void Code::GetCodeAgeAndParity(byte* sequence, Age* age, 1061 void Code::GetCodeAgeAndParity(byte* sequence, Age* age,
640 MarkingParity* parity) { 1062 MarkingParity* parity) {
641 if (IsYoungSequence(sequence)) { 1063 if (IsYoungSequence(sequence)) {
642 *age = kNoAgeCodeAge; 1064 *age = kNoAgeCodeAge;
643 *parity = NO_MARKING_PARITY; 1065 *parity = NO_MARKING_PARITY;
644 } else { 1066 } else {
645 Address target_address = Memory::Address_at( 1067 Address target_address = Assembler::target_address_at(
646 sequence + Assembler::kInstrSize * (kNoCodeAgeSequenceLength - 1)); 1068 sequence + Assembler::kInstrSize);
647 Code* stub = GetCodeFromTargetAddress(target_address); 1069 Code* stub = GetCodeFromTargetAddress(target_address);
648 GetCodeAgeAndParity(stub, age, parity); 1070 GetCodeAgeAndParity(stub, age, parity);
649 } 1071 }
650 } 1072 }
651 1073
652 1074
653 void Code::PatchPlatformCodeAge(Isolate* isolate, 1075 void Code::PatchPlatformCodeAge(Isolate* isolate,
654 byte* sequence, 1076 byte* sequence,
655 Code::Age age, 1077 Code::Age age,
656 MarkingParity parity) { 1078 MarkingParity parity) {
657 uint32_t young_length; 1079 uint32_t young_length;
658 byte* young_sequence = GetNoCodeAgeSequence(&young_length); 1080 byte* young_sequence = GetNoCodeAgeSequence(&young_length);
659 if (age == kNoAgeCodeAge) { 1081 if (age == kNoAgeCodeAge) {
660 CopyBytes(sequence, young_sequence, young_length); 1082 CopyBytes(sequence, young_sequence, young_length);
661 CPU::FlushICache(sequence, young_length); 1083 CPU::FlushICache(sequence, young_length);
662 } else { 1084 } else {
663 Code* stub = GetCodeAgeStub(isolate, age, parity); 1085 Code* stub = GetCodeAgeStub(isolate, age, parity);
664 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); 1086 CodePatcher patcher(sequence, young_length / Assembler::kInstrSize);
665 // Mark this code sequence for FindPlatformCodeAgeSequence() 1087 // Mark this code sequence for FindPlatformCodeAgeSequence().
666 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP); 1088 patcher.masm()->nop(Assembler::CODE_AGE_MARKER_NOP);
667 // Save the function's original return address 1089 // Load the stub address to t9 and call it,
668 // (it will be clobbered by Call(t9)) 1090 // GetCodeAgeAndParity() extracts the stub address from this instruction.
669 patcher.masm()->mov(at, ra); 1091 patcher.masm()->li(
670 // Load the stub address to t9 and call it 1092 t9,
671 patcher.masm()->li(t9, 1093 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())),
672 Operand(reinterpret_cast<uint32_t>(stub->instruction_start()))); 1094 CONSTANT_SIZE);
673 patcher.masm()->Call(t9); 1095 patcher.masm()->nop(); // Prevent jalr to jal optimization.
674 // Record the stub address in the empty space for GetCodeAgeAndParity() 1096 patcher.masm()->jalr(t9, a0);
675 patcher.masm()->emit_code_stub_address(stub); 1097 patcher.masm()->nop(); // Branch delay slot nop.
1098 patcher.masm()->nop(); // Pad the empty space.
676 } 1099 }
677 } 1100 }
678 1101
679 1102
680 #undef __ 1103 #undef __
681 1104
682 } } // namespace v8::internal 1105 } } // namespace v8::internal
683 1106
684 #endif // V8_TARGET_ARCH_MIPS 1107 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/code-stubs-mips.cc ('k') | src/mips/constants-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698