OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 8322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8333 | 8333 |
8334 // Get the elements array from the receiver and check that it | 8334 // Get the elements array from the receiver and check that it |
8335 // is not a dictionary. | 8335 // is not a dictionary. |
8336 __ mov(elements.reg(), | 8336 __ mov(elements.reg(), |
8337 FieldOperand(receiver.reg(), JSObject::kElementsOffset)); | 8337 FieldOperand(receiver.reg(), JSObject::kElementsOffset)); |
8338 __ cmp(FieldOperand(elements.reg(), HeapObject::kMapOffset), | 8338 __ cmp(FieldOperand(elements.reg(), HeapObject::kMapOffset), |
8339 Immediate(Factory::fixed_array_map())); | 8339 Immediate(Factory::fixed_array_map())); |
8340 deferred->Branch(not_equal); | 8340 deferred->Branch(not_equal); |
8341 | 8341 |
8342 // Shift the key to get the actual index value and check that | 8342 // Shift the key to get the actual index value and check that |
8343 // it is within bounds. | 8343 // it is within bounds. Use unsigned comparison to handle negative keys. |
8344 __ mov(result.reg(), key.reg()); | 8344 __ mov(result.reg(), key.reg()); |
8345 __ SmiUntag(result.reg()); | 8345 __ SmiUntag(result.reg()); |
8346 __ cmp(result.reg(), | 8346 __ cmp(result.reg(), |
8347 FieldOperand(elements.reg(), FixedArray::kLengthOffset)); | 8347 FieldOperand(elements.reg(), FixedArray::kLengthOffset)); |
8348 deferred->Branch(above_equal); | 8348 deferred->Branch(above_equal); |
8349 | 8349 |
8350 // Load and check that the result is not the hole. | 8350 // Load and check that the result is not the hole. |
8351 __ mov(result.reg(), Operand(elements.reg(), | 8351 __ mov(result.reg(), Operand(elements.reg(), |
8352 result.reg(), | 8352 result.reg(), |
8353 times_4, | 8353 times_4, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8406 receiver.reg(), | 8406 receiver.reg(), |
8407 tmp.reg()); | 8407 tmp.reg()); |
8408 | 8408 |
8409 // Check that the value is a smi if it is not a constant. We can skip | 8409 // Check that the value is a smi if it is not a constant. We can skip |
8410 // the write barrier for smis and constants. | 8410 // the write barrier for smis and constants. |
8411 if (!value_is_constant) { | 8411 if (!value_is_constant) { |
8412 __ test(result.reg(), Immediate(kSmiTagMask)); | 8412 __ test(result.reg(), Immediate(kSmiTagMask)); |
8413 deferred->Branch(not_zero); | 8413 deferred->Branch(not_zero); |
8414 } | 8414 } |
8415 | 8415 |
8416 // Check that the key is a non-negative smi. | 8416 // Check that the key is a smi. |
8417 __ test(key.reg(), Immediate(kSmiTagMask | kSmiSignMask)); | 8417 if (!key.is_smi()) { |
8418 deferred->Branch(not_zero); | 8418 __ test(key.reg(), Immediate(kSmiTagMask)); |
| 8419 deferred->Branch(not_zero); |
| 8420 } else { |
| 8421 if (FLAG_debug_code) __ AbortIfNotSmi(key.reg()); |
| 8422 } |
8419 | 8423 |
8420 // Check that the receiver is not a smi. | 8424 // Check that the receiver is not a smi. |
8421 __ test(receiver.reg(), Immediate(kSmiTagMask)); | 8425 __ test(receiver.reg(), Immediate(kSmiTagMask)); |
8422 deferred->Branch(zero); | 8426 deferred->Branch(zero); |
8423 | 8427 |
8424 // Check that the receiver is a JSArray. | 8428 // Check that the receiver is a JSArray. |
8425 __ mov(tmp.reg(), | 8429 __ CmpObjectType(receiver.reg(), JS_ARRAY_TYPE, tmp.reg()); |
8426 FieldOperand(receiver.reg(), HeapObject::kMapOffset)); | |
8427 __ movzx_b(tmp.reg(), | |
8428 FieldOperand(tmp.reg(), Map::kInstanceTypeOffset)); | |
8429 __ cmp(tmp.reg(), JS_ARRAY_TYPE); | |
8430 deferred->Branch(not_equal); | 8430 deferred->Branch(not_equal); |
8431 | 8431 |
8432 // Check that the key is within bounds. Both the key and the length of | 8432 // Check that the key is within bounds. Both the key and the length of |
8433 // the JSArray are smis. | 8433 // the JSArray are smis. Use unsigned comparison to handle negative keys. |
8434 __ cmp(key.reg(), | 8434 __ cmp(key.reg(), |
8435 FieldOperand(receiver.reg(), JSArray::kLengthOffset)); | 8435 FieldOperand(receiver.reg(), JSArray::kLengthOffset)); |
8436 deferred->Branch(greater_equal); | 8436 deferred->Branch(above_equal); |
8437 | 8437 |
8438 // Get the elements array from the receiver and check that it is not a | 8438 // Get the elements array from the receiver and check that it is not a |
8439 // dictionary. | 8439 // dictionary. |
8440 __ mov(tmp.reg(), | 8440 __ mov(tmp.reg(), |
8441 FieldOperand(receiver.reg(), JSObject::kElementsOffset)); | 8441 FieldOperand(receiver.reg(), JSObject::kElementsOffset)); |
8442 // Bind the deferred code patch site to be able to locate the fixed | 8442 // Bind the deferred code patch site to be able to locate the fixed |
8443 // array map comparison. When debugging, we patch this comparison to | 8443 // array map comparison. When debugging, we patch this comparison to |
8444 // always fail so that we will hit the IC call in the deferred code | 8444 // always fail so that we will hit the IC call in the deferred code |
8445 // which will allow the debugger to break for fast case stores. | 8445 // which will allow the debugger to break for fast case stores. |
8446 __ bind(deferred->patch_site()); | 8446 __ bind(deferred->patch_site()); |
(...skipping 4480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12927 | 12927 |
12928 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 12928 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
12929 // tagged as a small integer. | 12929 // tagged as a small integer. |
12930 __ bind(&runtime); | 12930 __ bind(&runtime); |
12931 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 12931 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
12932 } | 12932 } |
12933 | 12933 |
12934 #undef __ | 12934 #undef __ |
12935 | 12935 |
12936 } } // namespace v8::internal | 12936 } } // namespace v8::internal |
OLD | NEW |