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

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

Issue 8746015: MIPS: Porting r10023 and r10054 to arm (pointer cache for external strings). (Closed)
Patch Set: Created 9 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
« no previous file with comments | « src/mips/codegen-mips.h ('k') | src/mips/lithium-codegen-mips.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 JSObject::kElementsOffset, 303 JSObject::kElementsOffset,
304 t2, 304 t2,
305 t5, 305 t5,
306 kRAHasBeenSaved, 306 kRAHasBeenSaved,
307 kDontSaveFPRegs, 307 kDontSaveFPRegs,
308 EMIT_REMEMBERED_SET, 308 EMIT_REMEMBERED_SET,
309 OMIT_SMI_CHECK); 309 OMIT_SMI_CHECK);
310 __ pop(ra); 310 __ pop(ra);
311 } 311 }
312 312
313
314 void StringCharLoadGenerator::Generate(MacroAssembler* masm,
315 Register string,
316 Register index,
317 Register result,
318 Label* call_runtime) {
319 // Fetch the instance type of the receiver into result register.
320 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset));
321 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
322
323 // We need special handling for indirect strings.
324 Label check_sequential;
325 __ And(at, result, Operand(kIsIndirectStringMask));
326 __ Branch(&check_sequential, eq, at, Operand(zero_reg));
327
328 // Dispatch on the indirect string shape: slice or cons.
329 Label cons_string;
330 __ And(at, result, Operand(kSlicedNotConsMask));
331 __ Branch(&cons_string, eq, at, Operand(zero_reg));
332
333 // Handle slices.
334 Label indirect_string_loaded;
335 __ lw(result, FieldMemOperand(string, SlicedString::kOffsetOffset));
336 __ sra(at, result, kSmiTagSize);
337 __ Addu(index, index, at);
338 __ lw(string, FieldMemOperand(string, SlicedString::kParentOffset));
339 __ jmp(&indirect_string_loaded);
340
341 // Handle cons strings.
342 // Check whether the right hand side is the empty string (i.e. if
343 // this is really a flat string in a cons string). If that is not
344 // the case we would rather go to the runtime system now to flatten
345 // the string.
346 __ bind(&cons_string);
347 __ lw(result, FieldMemOperand(string, ConsString::kSecondOffset));
348 __ LoadRoot(at, Heap::kEmptyStringRootIndex);
349 __ Branch(call_runtime, ne, result, Operand(at));
350 // Get the first of the two strings and load its instance type.
351 __ lw(string, FieldMemOperand(string, ConsString::kFirstOffset));
352
353 __ bind(&indirect_string_loaded);
354 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset));
355 __ lbu(result, FieldMemOperand(result, Map::kInstanceTypeOffset));
356
357 // Distinguish sequential and external strings. Only these two string
358 // representations can reach here (slices and flat cons strings have been
359 // reduced to the underlying sequential or external string).
360 Label external_string, check_encoding;
361 __ bind(&check_sequential);
362 STATIC_ASSERT(kSeqStringTag == 0);
363 __ And(at, result, Operand(kStringRepresentationMask));
364 __ Branch(&external_string, ne, at, Operand(zero_reg));
365
366 // Prepare sequential strings
367 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize);
368 __ Addu(string,
369 string,
370 SeqTwoByteString::kHeaderSize - kHeapObjectTag);
371 __ jmp(&check_encoding);
372
373 // Handle external strings.
374 __ bind(&external_string);
375 if (FLAG_debug_code) {
376 // Assert that we do not have a cons or slice (indirect strings) here.
377 // Sequential strings have already been ruled out.
378 __ And(at, result, Operand(kIsIndirectStringMask));
379 __ Assert(eq, "external string expected, but not found",
380 at, Operand(zero_reg));
381 }
382 // Rule out short external strings.
383 STATIC_CHECK(kShortExternalStringTag != 0);
384 __ And(at, result, Operand(kShortExternalStringMask));
385 __ Branch(call_runtime, ne, at, Operand(zero_reg));
386 __ lw(string, FieldMemOperand(string, ExternalString::kResourceDataOffset));
387
388 Label ascii, done;
389 __ bind(&check_encoding);
390 STATIC_ASSERT(kTwoByteStringTag == 0);
391 __ And(at, result, Operand(kStringEncodingMask));
392 __ Branch(&ascii, ne, at, Operand(zero_reg));
393 // Two-byte string.
394 __ sll(at, index, 1);
395 __ Addu(at, string, at);
396 __ lhu(result, MemOperand(at));
397 __ jmp(&done);
398 __ bind(&ascii);
399 // Ascii string.
400 __ Addu(at, string, index);
401 __ lbu(result, MemOperand(at));
402 __ bind(&done);
403 }
404
313 #undef __ 405 #undef __
314 406
315 } } // namespace v8::internal 407 } } // namespace v8::internal
316 408
317 #endif // V8_TARGET_ARCH_MIPS 409 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/codegen-mips.h ('k') | src/mips/lithium-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698