OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 3315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3326 MemOperand LCodeGen::PrepareKeyedExternalArrayOperand( | 3326 MemOperand LCodeGen::PrepareKeyedExternalArrayOperand( |
3327 Register key, | 3327 Register key, |
3328 Register base, | 3328 Register base, |
3329 Register scratch, | 3329 Register scratch, |
3330 bool key_is_smi, | 3330 bool key_is_smi, |
3331 bool key_is_constant, | 3331 bool key_is_constant, |
3332 int constant_key, | 3332 int constant_key, |
3333 ElementsKind elements_kind, | 3333 ElementsKind elements_kind, |
3334 int additional_index) { | 3334 int additional_index) { |
3335 int element_size_shift = ElementsKindToShiftSize(elements_kind); | 3335 int element_size_shift = ElementsKindToShiftSize(elements_kind); |
3336 int additional_offset = IsFixedTypedArrayElementsKind(elements_kind) | 3336 int additional_offset = additional_index << element_size_shift; |
3337 ? FixedTypedArrayBase::kDataOffset - kHeapObjectTag | 3337 if (IsFixedTypedArrayElementsKind(elements_kind)) { |
3338 : 0; | 3338 additional_offset += FixedTypedArrayBase::kDataOffset - kHeapObjectTag; |
| 3339 } |
3339 | 3340 |
3340 if (key_is_constant) { | 3341 if (key_is_constant) { |
3341 int base_offset = ((constant_key + additional_index) << element_size_shift); | 3342 int key_offset = constant_key << element_size_shift; |
3342 return MemOperand(base, base_offset + additional_offset); | 3343 return MemOperand(base, key_offset + additional_offset); |
3343 } | 3344 } |
3344 | 3345 |
3345 if (additional_index == 0) { | 3346 if (key_is_smi) { |
3346 if (key_is_smi) { | 3347 __ Add(scratch, base, Operand::UntagSmiAndScale(key, element_size_shift)); |
3347 // Key is smi: untag, and scale by element size. | 3348 return MemOperand(scratch, additional_offset); |
3348 __ Add(scratch, base, Operand::UntagSmiAndScale(key, element_size_shift)); | |
3349 return MemOperand(scratch, additional_offset); | |
3350 } else { | |
3351 // Key is not smi, and element size is not byte: scale by element size. | |
3352 if (additional_offset == 0) { | |
3353 return MemOperand(base, key, SXTW, element_size_shift); | |
3354 } else { | |
3355 __ Add(scratch, base, Operand(key, SXTW, element_size_shift)); | |
3356 return MemOperand(scratch, additional_offset); | |
3357 } | |
3358 } | |
3359 } else { | |
3360 // TODO(all): Try to combine these cases a bit more intelligently. | |
3361 if (additional_offset == 0) { | |
3362 if (key_is_smi) { | |
3363 __ SmiUntag(scratch, key); | |
3364 __ Add(scratch.W(), scratch.W(), additional_index); | |
3365 } else { | |
3366 __ Add(scratch.W(), key.W(), additional_index); | |
3367 } | |
3368 return MemOperand(base, scratch, LSL, element_size_shift); | |
3369 } else { | |
3370 if (key_is_smi) { | |
3371 __ Add(scratch, base, | |
3372 Operand::UntagSmiAndScale(key, element_size_shift)); | |
3373 } else { | |
3374 __ Add(scratch, base, Operand(key, SXTW, element_size_shift)); | |
3375 } | |
3376 return MemOperand( | |
3377 scratch, | |
3378 (additional_index << element_size_shift) + additional_offset); | |
3379 } | |
3380 } | 3349 } |
| 3350 |
| 3351 if (additional_offset == 0) { |
| 3352 return MemOperand(base, key, SXTW, element_size_shift); |
| 3353 } |
| 3354 |
| 3355 ASSERT(!AreAliased(scratch, key)); |
| 3356 __ Add(scratch, base, additional_offset); |
| 3357 return MemOperand(scratch, key, SXTW, element_size_shift); |
3381 } | 3358 } |
3382 | 3359 |
3383 | 3360 |
3384 void LCodeGen::DoLoadKeyedExternal(LLoadKeyedExternal* instr) { | 3361 void LCodeGen::DoLoadKeyedExternal(LLoadKeyedExternal* instr) { |
3385 Register ext_ptr = ToRegister(instr->elements()); | 3362 Register ext_ptr = ToRegister(instr->elements()); |
3386 Register scratch; | 3363 Register scratch; |
3387 ElementsKind elements_kind = instr->elements_kind(); | 3364 ElementsKind elements_kind = instr->elements_kind(); |
3388 | 3365 |
3389 bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); | 3366 bool key_is_smi = instr->hydrogen()->key()->representation().IsSmi(); |
3390 bool key_is_constant = instr->key()->IsConstantOperand(); | 3367 bool key_is_constant = instr->key()->IsConstantOperand(); |
(...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4666 String::Encoding encoding) { | 4643 String::Encoding encoding) { |
4667 if (index->IsConstantOperand()) { | 4644 if (index->IsConstantOperand()) { |
4668 int offset = ToInteger32(LConstantOperand::cast(index)); | 4645 int offset = ToInteger32(LConstantOperand::cast(index)); |
4669 if (encoding == String::TWO_BYTE_ENCODING) { | 4646 if (encoding == String::TWO_BYTE_ENCODING) { |
4670 offset *= kUC16Size; | 4647 offset *= kUC16Size; |
4671 } | 4648 } |
4672 STATIC_ASSERT(kCharSize == 1); | 4649 STATIC_ASSERT(kCharSize == 1); |
4673 return FieldMemOperand(string, SeqString::kHeaderSize + offset); | 4650 return FieldMemOperand(string, SeqString::kHeaderSize + offset); |
4674 } | 4651 } |
4675 | 4652 |
| 4653 __ Add(temp, string, SeqString::kHeaderSize - kHeapObjectTag); |
4676 if (encoding == String::ONE_BYTE_ENCODING) { | 4654 if (encoding == String::ONE_BYTE_ENCODING) { |
4677 __ Add(temp, string, Operand(ToRegister32(index), SXTW)); | 4655 return MemOperand(temp, ToRegister32(index), SXTW); |
4678 } else { | 4656 } else { |
4679 STATIC_ASSERT(kUC16Size == 2); | 4657 STATIC_ASSERT(kUC16Size == 2); |
4680 __ Add(temp, string, Operand(ToRegister32(index), SXTW, 1)); | 4658 return MemOperand(temp, ToRegister32(index), SXTW, 1); |
4681 } | 4659 } |
4682 return FieldMemOperand(temp, SeqString::kHeaderSize); | |
4683 } | 4660 } |
4684 | 4661 |
4685 | 4662 |
4686 void LCodeGen::DoSeqStringGetChar(LSeqStringGetChar* instr) { | 4663 void LCodeGen::DoSeqStringGetChar(LSeqStringGetChar* instr) { |
4687 String::Encoding encoding = instr->hydrogen()->encoding(); | 4664 String::Encoding encoding = instr->hydrogen()->encoding(); |
4688 Register string = ToRegister(instr->string()); | 4665 Register string = ToRegister(instr->string()); |
4689 Register result = ToRegister(instr->result()); | 4666 Register result = ToRegister(instr->result()); |
4690 Register temp = ToRegister(instr->temp()); | 4667 Register temp = ToRegister(instr->temp()); |
4691 | 4668 |
4692 if (FLAG_debug_code) { | 4669 if (FLAG_debug_code) { |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5403 DeferredStringCharFromCode* deferred = | 5380 DeferredStringCharFromCode* deferred = |
5404 new(zone()) DeferredStringCharFromCode(this, instr); | 5381 new(zone()) DeferredStringCharFromCode(this, instr); |
5405 | 5382 |
5406 ASSERT(instr->hydrogen()->value()->representation().IsInteger32()); | 5383 ASSERT(instr->hydrogen()->value()->representation().IsInteger32()); |
5407 Register char_code = ToRegister32(instr->char_code()); | 5384 Register char_code = ToRegister32(instr->char_code()); |
5408 Register result = ToRegister(instr->result()); | 5385 Register result = ToRegister(instr->result()); |
5409 | 5386 |
5410 __ Cmp(char_code, String::kMaxOneByteCharCode); | 5387 __ Cmp(char_code, String::kMaxOneByteCharCode); |
5411 __ B(hi, deferred->entry()); | 5388 __ B(hi, deferred->entry()); |
5412 __ LoadRoot(result, Heap::kSingleCharacterStringCacheRootIndex); | 5389 __ LoadRoot(result, Heap::kSingleCharacterStringCacheRootIndex); |
5413 __ Add(result, result, Operand(char_code, SXTW, kPointerSizeLog2)); | 5390 __ Add(result, result, FixedArray::kHeaderSize - kHeapObjectTag); |
5414 __ Ldr(result, FieldMemOperand(result, FixedArray::kHeaderSize)); | 5391 __ Ldr(result, MemOperand(result, char_code, SXTW, kPointerSizeLog2)); |
5415 __ CompareRoot(result, Heap::kUndefinedValueRootIndex); | 5392 __ CompareRoot(result, Heap::kUndefinedValueRootIndex); |
5416 __ B(eq, deferred->entry()); | 5393 __ B(eq, deferred->entry()); |
5417 __ Bind(deferred->exit()); | 5394 __ Bind(deferred->exit()); |
5418 } | 5395 } |
5419 | 5396 |
5420 | 5397 |
5421 void LCodeGen::DoDeferredStringCharFromCode(LStringCharFromCode* instr) { | 5398 void LCodeGen::DoDeferredStringCharFromCode(LStringCharFromCode* instr) { |
5422 Register char_code = ToRegister(instr->char_code()); | 5399 Register char_code = ToRegister(instr->char_code()); |
5423 Register result = ToRegister(instr->result()); | 5400 Register result = ToRegister(instr->result()); |
5424 | 5401 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5918 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 5895 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
5919 // Index is equal to negated out of object property index plus 1. | 5896 // Index is equal to negated out of object property index plus 1. |
5920 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 5897 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
5921 __ Ldr(result, FieldMemOperand(result, | 5898 __ Ldr(result, FieldMemOperand(result, |
5922 FixedArray::kHeaderSize - kPointerSize)); | 5899 FixedArray::kHeaderSize - kPointerSize)); |
5923 __ Bind(deferred->exit()); | 5900 __ Bind(deferred->exit()); |
5924 __ Bind(&done); | 5901 __ Bind(&done); |
5925 } | 5902 } |
5926 | 5903 |
5927 } } // namespace v8::internal | 5904 } } // namespace v8::internal |
OLD | NEW |