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 4396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4407 // Restore registers. | 4407 // Restore registers. |
4408 __ pop(rcx); | 4408 __ pop(rcx); |
4409 __ pop(rax); | 4409 __ pop(rax); |
4410 __ pop(rdx); | 4410 __ pop(rdx); |
4411 __ push(rcx); | 4411 __ push(rcx); |
4412 | 4412 |
4413 // Do a tail call to the rewritten stub. | 4413 // Do a tail call to the rewritten stub. |
4414 __ jmp(rdi); | 4414 __ jmp(rdi); |
4415 } | 4415 } |
4416 | 4416 |
| 4417 |
| 4418 void GenerateFastPixelArrayLoad(MacroAssembler* masm, |
| 4419 Register receiver, |
| 4420 Register key, |
| 4421 Register elements, |
| 4422 Register untagged_key, |
| 4423 Register result, |
| 4424 Label* not_pixel_array, |
| 4425 Label* key_not_smi, |
| 4426 Label* out_of_range) { |
| 4427 // Register use: |
| 4428 // receiver - holds the receiver and is unchanged. |
| 4429 // key - holds the key and is unchanged (must be a smi). |
| 4430 // elements - is set to the the receiver's element if |
| 4431 // the receiver doesn't have a pixel array or the |
| 4432 // key is not a smi, otherwise it's the elements' |
| 4433 // external pointer. |
| 4434 // untagged_key - is set to the untagged key |
| 4435 |
| 4436 // Some callers already have verified that the key is a smi. key_not_smi is |
| 4437 // set to NULL as a sentinel for that case. Otherwise, add an explicit check |
| 4438 // to ensure the key is a smi must be added. |
| 4439 if (key_not_smi != NULL) { |
| 4440 __ JumpIfNotSmi(key, key_not_smi); |
| 4441 } else { |
| 4442 if (FLAG_debug_code) { |
| 4443 __ AbortIfNotSmi(key); |
| 4444 } |
| 4445 } |
| 4446 __ SmiToInteger32(untagged_key, key); |
| 4447 |
| 4448 // Verify that the receiver has pixel array elements. |
| 4449 __ movq(elements, FieldOperand(receiver, JSObject::kElementsOffset)); |
| 4450 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true); |
| 4451 |
| 4452 // Check that the smi is in range. |
| 4453 __ cmpl(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset)); |
| 4454 __ j(above_equal, out_of_range); // unsigned check handles negative keys. |
| 4455 |
| 4456 // Load and tag the element as a smi. |
| 4457 __ movq(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset)); |
| 4458 __ movzxbq(result, Operand(elements, untagged_key, times_1, 0)); |
| 4459 __ Integer32ToSmi(result, result); |
| 4460 __ ret(0); |
| 4461 } |
| 4462 |
| 4463 |
4417 #undef __ | 4464 #undef __ |
4418 | 4465 |
4419 } } // namespace v8::internal | 4466 } } // namespace v8::internal |
4420 | 4467 |
4421 #endif // V8_TARGET_ARCH_X64 | 4468 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |