Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 JSObject::kElementsOffset, | 360 JSObject::kElementsOffset, |
| 361 r11, | 361 r11, |
| 362 r15, | 362 r15, |
| 363 kDontSaveFPRegs, | 363 kDontSaveFPRegs, |
| 364 EMIT_REMEMBERED_SET, | 364 EMIT_REMEMBERED_SET, |
| 365 OMIT_SMI_CHECK); | 365 OMIT_SMI_CHECK); |
| 366 __ pop(rax); | 366 __ pop(rax); |
| 367 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 367 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 368 } | 368 } |
| 369 | 369 |
| 370 | |
| 371 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | |
| 372 Register string, | |
| 373 Register index, | |
| 374 Register result, | |
| 375 Label* call_runtime) { | |
| 376 // Fetch the instance type of the receiver into result register. | |
| 377 __ movq(result, FieldOperand(string, HeapObject::kMapOffset)); | |
| 378 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); | |
|
Lasse Reichstein
2011/11/24 09:21:42
If we know that only strings get here, is it possi
| |
| 379 | |
| 380 // We need special handling for indirect strings. | |
| 381 Label check_sequential; | |
| 382 __ testb(result, Immediate(kIsIndirectStringMask)); | |
|
Lasse Reichstein
2011/11/24 09:21:42
Would it make sense to have kShortExternalStringMa
| |
| 383 __ j(zero, &check_sequential); | |
| 384 | |
| 385 // Dispatch on the indirect string shape: slice or cons. | |
| 386 Label cons_string; | |
| 387 __ testb(result, Immediate(kSlicedNotConsMask)); | |
| 388 __ j(zero, &cons_string, Label::kNear); | |
| 389 | |
| 390 // Handle slices. | |
| 391 Label indirect_string_loaded; | |
| 392 __ SmiToInteger32(result, FieldOperand(string, SlicedString::kOffsetOffset)); | |
| 393 __ addq(index, result); | |
| 394 __ movq(string, FieldOperand(string, SlicedString::kParentOffset)); | |
| 395 __ jmp(&indirect_string_loaded, Label::kNear); | |
| 396 | |
| 397 // Handle external strings. | |
| 398 Label external_string, ascii_external, done; | |
| 399 __ bind(&external_string); | |
| 400 if (FLAG_debug_code) { | |
| 401 // Assert that we do not have a cons or slice (indirect strings) here. | |
| 402 // Sequential strings have already been ruled out. | |
| 403 __ testb(result, Immediate(kIsIndirectStringMask)); | |
| 404 __ Assert(zero, "external string expected, but not found"); | |
| 405 } | |
| 406 __ movq(result, FieldOperand(string, ExternalString::kResourceDataOffset)); | |
|
Lasse Reichstein
2011/11/24 09:21:42
Should you be testing for short external strings h
| |
| 407 // Assert that the data pointer cache is valid. | |
| 408 __ testq(result, result); | |
| 409 __ j(zero, call_runtime); | |
|
Lasse Reichstein
2011/11/24 09:21:42
Not necessary?
| |
| 410 Register scratch = string; | |
| 411 __ movq(scratch, FieldOperand(string, HeapObject::kMapOffset)); | |
| 412 STATIC_ASSERT(kTwoByteStringTag == 0); | |
| 413 __ testb(FieldOperand(scratch, Map::kInstanceTypeOffset), | |
| 414 Immediate(kStringEncodingMask)); | |
| 415 __ j(not_equal, &ascii_external, Label::kNear); | |
| 416 // Two-byte string. | |
| 417 __ movzxwl(result, Operand(result, index, times_2, 0)); | |
| 418 __ jmp(&done); | |
| 419 __ bind(&ascii_external); | |
| 420 // Ascii string. | |
| 421 __ movzxbl(result, Operand(result, index, times_1, 0)); | |
| 422 __ jmp(&done); | |
| 423 | |
| 424 // Handle conses. | |
| 425 // Check whether the right hand side is the empty string (i.e. if | |
| 426 // this is really a flat string in a cons string). If that is not | |
| 427 // the case we would rather go to the runtime system now to flatten | |
| 428 // the string. | |
| 429 __ bind(&cons_string); | |
| 430 __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset), | |
| 431 Heap::kEmptyStringRootIndex); | |
| 432 __ j(not_equal, call_runtime); | |
| 433 __ movq(string, FieldOperand(string, ConsString::kFirstOffset)); | |
| 434 | |
| 435 __ bind(&indirect_string_loaded); | |
| 436 __ movq(result, FieldOperand(string, HeapObject::kMapOffset)); | |
| 437 __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset)); | |
| 438 | |
| 439 // Check whether the string is sequential. The only non-sequential | |
|
Lasse Reichstein
2011/11/24 09:21:42
Comment seems a little off.
When we get here, we k
| |
| 440 // shapes we support have just been unwrapped above. | |
| 441 // Note that if the original string is a cons or slice with an external | |
| 442 // string as underlying string, we pass that unpacked underlying string with | |
| 443 // the adjusted index to the runtime function. | |
| 444 __ bind(&check_sequential); | |
| 445 STATIC_ASSERT(kSeqStringTag == 0); | |
| 446 __ testb(result, Immediate(kStringRepresentationMask)); | |
| 447 __ j(not_zero, &external_string); | |
| 448 | |
| 449 // Dispatch on the encoding: ASCII or two-byte. | |
| 450 Label ascii_string; | |
| 451 STATIC_ASSERT((kStringEncodingMask & kAsciiStringTag) != 0); | |
| 452 STATIC_ASSERT((kStringEncodingMask & kTwoByteStringTag) == 0); | |
| 453 __ testb(result, Immediate(kStringEncodingMask)); | |
| 454 __ j(not_zero, &ascii_string, Label::kNear); | |
| 455 | |
| 456 // Two-byte string. | |
| 457 // Load the two-byte character code into the result register. | |
| 458 STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1); | |
| 459 __ movzxwl(result, FieldOperand(string, | |
| 460 index, | |
| 461 times_2, | |
| 462 SeqTwoByteString::kHeaderSize)); | |
| 463 __ jmp(&done, Label::kNear); | |
| 464 | |
| 465 // ASCII string. | |
| 466 // Load the byte into the result register. | |
| 467 __ bind(&ascii_string); | |
| 468 __ movzxbl(result, FieldOperand(string, | |
| 469 index, | |
| 470 times_1, | |
| 471 SeqAsciiString::kHeaderSize)); | |
| 472 __ bind(&done); | |
| 473 } | |
| 474 | |
| 370 #undef __ | 475 #undef __ |
| 371 | 476 |
| 372 } } // namespace v8::internal | 477 } } // namespace v8::internal |
| 373 | 478 |
| 374 #endif // V8_TARGET_ARCH_X64 | 479 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |