| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 // Subtracting from length accounts for one of them add one more. | 2370 // Subtracting from length accounts for one of them add one more. |
| 2371 __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize)); | 2371 __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize)); |
| 2372 } | 2372 } |
| 2373 | 2373 |
| 2374 | 2374 |
| 2375 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { | 2375 void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) { |
| 2376 Register result = ToRegister(instr->result()); | 2376 Register result = ToRegister(instr->result()); |
| 2377 | 2377 |
| 2378 // Load the result. | 2378 // Load the result. |
| 2379 __ movq(result, | 2379 __ movq(result, |
| 2380 BuildFastArrayOperand(instr->elements(), instr->key(), | 2380 BuildFastArrayOperand(instr->elements(), |
| 2381 instr->key(), |
| 2381 FAST_ELEMENTS, | 2382 FAST_ELEMENTS, |
| 2382 FixedArray::kHeaderSize - kHeapObjectTag)); | 2383 FixedArray::kHeaderSize - kHeapObjectTag, |
| 2384 instr->additional_index())); |
| 2383 | 2385 |
| 2384 // Check for the hole value. | 2386 // Check for the hole value. |
| 2385 if (instr->hydrogen()->RequiresHoleCheck()) { | 2387 if (instr->hydrogen()->RequiresHoleCheck()) { |
| 2386 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); | 2388 __ CompareRoot(result, Heap::kTheHoleValueRootIndex); |
| 2387 DeoptimizeIf(equal, instr->environment()); | 2389 DeoptimizeIf(equal, instr->environment()); |
| 2388 } | 2390 } |
| 2389 } | 2391 } |
| 2390 | 2392 |
| 2391 | 2393 |
| 2392 void LCodeGen::DoLoadKeyedFastDoubleElement( | 2394 void LCodeGen::DoLoadKeyedFastDoubleElement( |
| 2393 LLoadKeyedFastDoubleElement* instr) { | 2395 LLoadKeyedFastDoubleElement* instr) { |
| 2394 XMMRegister result(ToDoubleRegister(instr->result())); | 2396 XMMRegister result(ToDoubleRegister(instr->result())); |
| 2395 | 2397 |
| 2396 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + | 2398 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + |
| 2397 sizeof(kHoleNanLower32); | 2399 sizeof(kHoleNanLower32); |
| 2398 Operand hole_check_operand = BuildFastArrayOperand( | 2400 Operand hole_check_operand = BuildFastArrayOperand( |
| 2399 instr->elements(), | 2401 instr->elements(), |
| 2400 instr->key(), | 2402 instr->key(), |
| 2401 FAST_DOUBLE_ELEMENTS, | 2403 FAST_DOUBLE_ELEMENTS, |
| 2402 offset); | 2404 offset, |
| 2405 instr->additional_index()); |
| 2403 __ cmpl(hole_check_operand, Immediate(kHoleNanUpper32)); | 2406 __ cmpl(hole_check_operand, Immediate(kHoleNanUpper32)); |
| 2404 DeoptimizeIf(equal, instr->environment()); | 2407 DeoptimizeIf(equal, instr->environment()); |
| 2405 | 2408 |
| 2406 Operand double_load_operand = BuildFastArrayOperand( | 2409 Operand double_load_operand = BuildFastArrayOperand( |
| 2407 instr->elements(), instr->key(), FAST_DOUBLE_ELEMENTS, | 2410 instr->elements(), |
| 2408 FixedDoubleArray::kHeaderSize - kHeapObjectTag); | 2411 instr->key(), |
| 2412 FAST_DOUBLE_ELEMENTS, |
| 2413 FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
| 2414 instr->additional_index()); |
| 2409 __ movsd(result, double_load_operand); | 2415 __ movsd(result, double_load_operand); |
| 2410 } | 2416 } |
| 2411 | 2417 |
| 2412 | 2418 |
| 2413 Operand LCodeGen::BuildFastArrayOperand( | 2419 Operand LCodeGen::BuildFastArrayOperand( |
| 2414 LOperand* elements_pointer, | 2420 LOperand* elements_pointer, |
| 2415 LOperand* key, | 2421 LOperand* key, |
| 2416 ElementsKind elements_kind, | 2422 ElementsKind elements_kind, |
| 2417 uint32_t offset) { | 2423 uint32_t offset, |
| 2424 uint32_t additional_index) { |
| 2418 Register elements_pointer_reg = ToRegister(elements_pointer); | 2425 Register elements_pointer_reg = ToRegister(elements_pointer); |
| 2419 int shift_size = ElementsKindToShiftSize(elements_kind); | 2426 int shift_size = ElementsKindToShiftSize(elements_kind); |
| 2420 if (key->IsConstantOperand()) { | 2427 if (key->IsConstantOperand()) { |
| 2421 int constant_value = ToInteger32(LConstantOperand::cast(key)); | 2428 int constant_value = ToInteger32(LConstantOperand::cast(key)); |
| 2422 if (constant_value & 0xF0000000) { | 2429 if (constant_value & 0xF0000000) { |
| 2423 Abort("array index constant value too big"); | 2430 Abort("array index constant value too big"); |
| 2424 } | 2431 } |
| 2425 return Operand(elements_pointer_reg, | 2432 return Operand(elements_pointer_reg, |
| 2426 constant_value * (1 << shift_size) + offset); | 2433 (constant_value + additional_index) * (1 << shift_size) |
| 2434 + offset); |
| 2427 } else { | 2435 } else { |
| 2428 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); | 2436 ScaleFactor scale_factor = static_cast<ScaleFactor>(shift_size); |
| 2429 return Operand(elements_pointer_reg, ToRegister(key), | 2437 return Operand(elements_pointer_reg, |
| 2430 scale_factor, offset); | 2438 ToRegister(key), |
| 2439 scale_factor, |
| 2440 offset + (additional_index << shift_size)); |
| 2431 } | 2441 } |
| 2432 } | 2442 } |
| 2433 | 2443 |
| 2434 | 2444 |
| 2435 void LCodeGen::DoLoadKeyedSpecializedArrayElement( | 2445 void LCodeGen::DoLoadKeyedSpecializedArrayElement( |
| 2436 LLoadKeyedSpecializedArrayElement* instr) { | 2446 LLoadKeyedSpecializedArrayElement* instr) { |
| 2437 ElementsKind elements_kind = instr->elements_kind(); | 2447 ElementsKind elements_kind = instr->elements_kind(); |
| 2438 Operand operand(BuildFastArrayOperand(instr->external_pointer(), | 2448 Operand operand(BuildFastArrayOperand(instr->external_pointer(), |
| 2439 instr->key(), elements_kind, 0)); | 2449 instr->key(), |
| 2450 elements_kind, |
| 2451 0, |
| 2452 instr->additional_index())); |
| 2440 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { | 2453 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
| 2441 XMMRegister result(ToDoubleRegister(instr->result())); | 2454 XMMRegister result(ToDoubleRegister(instr->result())); |
| 2442 __ movss(result, operand); | 2455 __ movss(result, operand); |
| 2443 __ cvtss2sd(result, result); | 2456 __ cvtss2sd(result, result); |
| 2444 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | 2457 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
| 2445 __ movsd(ToDoubleRegister(instr->result()), operand); | 2458 __ movsd(ToDoubleRegister(instr->result()), operand); |
| 2446 } else { | 2459 } else { |
| 2447 Register result(ToRegister(instr->result())); | 2460 Register result(ToRegister(instr->result())); |
| 2448 switch (elements_kind) { | 2461 switch (elements_kind) { |
| 2449 case EXTERNAL_BYTE_ELEMENTS: | 2462 case EXTERNAL_BYTE_ELEMENTS: |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3331 ? isolate()->builtins()->StoreIC_Initialize_Strict() | 3344 ? isolate()->builtins()->StoreIC_Initialize_Strict() |
| 3332 : isolate()->builtins()->StoreIC_Initialize(); | 3345 : isolate()->builtins()->StoreIC_Initialize(); |
| 3333 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 3346 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 3334 } | 3347 } |
| 3335 | 3348 |
| 3336 | 3349 |
| 3337 void LCodeGen::DoStoreKeyedSpecializedArrayElement( | 3350 void LCodeGen::DoStoreKeyedSpecializedArrayElement( |
| 3338 LStoreKeyedSpecializedArrayElement* instr) { | 3351 LStoreKeyedSpecializedArrayElement* instr) { |
| 3339 ElementsKind elements_kind = instr->elements_kind(); | 3352 ElementsKind elements_kind = instr->elements_kind(); |
| 3340 Operand operand(BuildFastArrayOperand(instr->external_pointer(), | 3353 Operand operand(BuildFastArrayOperand(instr->external_pointer(), |
| 3341 instr->key(), elements_kind, 0)); | 3354 instr->key(), |
| 3355 elements_kind, |
| 3356 0, |
| 3357 instr->additional_index())); |
| 3342 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { | 3358 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS) { |
| 3343 XMMRegister value(ToDoubleRegister(instr->value())); | 3359 XMMRegister value(ToDoubleRegister(instr->value())); |
| 3344 __ cvtsd2ss(value, value); | 3360 __ cvtsd2ss(value, value); |
| 3345 __ movss(operand, value); | 3361 __ movss(operand, value); |
| 3346 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { | 3362 } else if (elements_kind == EXTERNAL_DOUBLE_ELEMENTS) { |
| 3347 __ movsd(operand, ToDoubleRegister(instr->value())); | 3363 __ movsd(operand, ToDoubleRegister(instr->value())); |
| 3348 } else { | 3364 } else { |
| 3349 Register value(ToRegister(instr->value())); | 3365 Register value(ToRegister(instr->value())); |
| 3350 switch (elements_kind) { | 3366 switch (elements_kind) { |
| 3351 case EXTERNAL_PIXEL_ELEMENTS: | 3367 case EXTERNAL_PIXEL_ELEMENTS: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3401 } | 3417 } |
| 3402 DeoptimizeIf(below_equal, instr->environment()); | 3418 DeoptimizeIf(below_equal, instr->environment()); |
| 3403 } | 3419 } |
| 3404 | 3420 |
| 3405 | 3421 |
| 3406 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { | 3422 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
| 3407 Register value = ToRegister(instr->value()); | 3423 Register value = ToRegister(instr->value()); |
| 3408 Register elements = ToRegister(instr->object()); | 3424 Register elements = ToRegister(instr->object()); |
| 3409 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; | 3425 Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg; |
| 3410 | 3426 |
| 3411 // Do the store. | 3427 Operand operand = BuildFastArrayOperand(instr->object(), |
| 3412 if (instr->key()->IsConstantOperand()) { | 3428 instr->key(), |
| 3413 ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); | 3429 FAST_ELEMENTS, |
| 3414 LConstantOperand* const_operand = LConstantOperand::cast(instr->key()); | 3430 FixedArray::kHeaderSize |
| 3415 int offset = | 3431 - kHeapObjectTag, |
| 3416 ToInteger32(const_operand) * kPointerSize + FixedArray::kHeaderSize; | 3432 instr->additional_index()); |
| 3417 __ movq(FieldOperand(elements, offset), value); | 3433 __ movq(operand, value); |
| 3418 } else { | |
| 3419 __ movq(FieldOperand(elements, | |
| 3420 key, | |
| 3421 times_pointer_size, | |
| 3422 FixedArray::kHeaderSize), | |
| 3423 value); | |
| 3424 } | |
| 3425 | 3434 |
| 3426 if (instr->hydrogen()->NeedsWriteBarrier()) { | 3435 if (instr->hydrogen()->NeedsWriteBarrier()) { |
| 3436 ASSERT(!instr->key()->IsConstantOperand()); |
| 3427 HType type = instr->hydrogen()->value()->type(); | 3437 HType type = instr->hydrogen()->value()->type(); |
| 3428 SmiCheck check_needed = | 3438 SmiCheck check_needed = |
| 3429 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; | 3439 type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; |
| 3430 // Compute address of modified element and store it into key register. | 3440 // Compute address of modified element and store it into key register. |
| 3431 __ lea(key, FieldOperand(elements, | 3441 __ lea(key, operand); |
| 3432 key, | |
| 3433 times_pointer_size, | |
| 3434 FixedArray::kHeaderSize)); | |
| 3435 __ RecordWrite(elements, | 3442 __ RecordWrite(elements, |
| 3436 key, | 3443 key, |
| 3437 value, | 3444 value, |
| 3438 kSaveFPRegs, | 3445 kSaveFPRegs, |
| 3439 EMIT_REMEMBERED_SET, | 3446 EMIT_REMEMBERED_SET, |
| 3440 check_needed); | 3447 check_needed); |
| 3441 } | 3448 } |
| 3442 } | 3449 } |
| 3443 | 3450 |
| 3444 | 3451 |
| 3445 void LCodeGen::DoStoreKeyedFastDoubleElement( | 3452 void LCodeGen::DoStoreKeyedFastDoubleElement( |
| 3446 LStoreKeyedFastDoubleElement* instr) { | 3453 LStoreKeyedFastDoubleElement* instr) { |
| 3447 XMMRegister value = ToDoubleRegister(instr->value()); | 3454 XMMRegister value = ToDoubleRegister(instr->value()); |
| 3448 | 3455 |
| 3449 if (instr->NeedsCanonicalization()) { | 3456 if (instr->NeedsCanonicalization()) { |
| 3450 Label have_value; | 3457 Label have_value; |
| 3451 | 3458 |
| 3452 __ ucomisd(value, value); | 3459 __ ucomisd(value, value); |
| 3453 __ j(parity_odd, &have_value); // NaN. | 3460 __ j(parity_odd, &have_value); // NaN. |
| 3454 | 3461 |
| 3455 __ Set(kScratchRegister, BitCast<uint64_t>( | 3462 __ Set(kScratchRegister, BitCast<uint64_t>( |
| 3456 FixedDoubleArray::canonical_not_the_hole_nan_as_double())); | 3463 FixedDoubleArray::canonical_not_the_hole_nan_as_double())); |
| 3457 __ movq(value, kScratchRegister); | 3464 __ movq(value, kScratchRegister); |
| 3458 | 3465 |
| 3459 __ bind(&have_value); | 3466 __ bind(&have_value); |
| 3460 } | 3467 } |
| 3461 | 3468 |
| 3462 Operand double_store_operand = BuildFastArrayOperand( | 3469 Operand double_store_operand = BuildFastArrayOperand( |
| 3463 instr->elements(), instr->key(), FAST_DOUBLE_ELEMENTS, | 3470 instr->elements(), |
| 3464 FixedDoubleArray::kHeaderSize - kHeapObjectTag); | 3471 instr->key(), |
| 3472 FAST_DOUBLE_ELEMENTS, |
| 3473 FixedDoubleArray::kHeaderSize - kHeapObjectTag, |
| 3474 instr->additional_index()); |
| 3465 __ movsd(double_store_operand, value); | 3475 __ movsd(double_store_operand, value); |
| 3466 } | 3476 } |
| 3467 | 3477 |
| 3468 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { | 3478 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) { |
| 3469 ASSERT(ToRegister(instr->object()).is(rdx)); | 3479 ASSERT(ToRegister(instr->object()).is(rdx)); |
| 3470 ASSERT(ToRegister(instr->key()).is(rcx)); | 3480 ASSERT(ToRegister(instr->key()).is(rcx)); |
| 3471 ASSERT(ToRegister(instr->value()).is(rax)); | 3481 ASSERT(ToRegister(instr->value()).is(rax)); |
| 3472 | 3482 |
| 3473 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) | 3483 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode) |
| 3474 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() | 3484 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() |
| (...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4817 FixedArray::kHeaderSize - kPointerSize)); | 4827 FixedArray::kHeaderSize - kPointerSize)); |
| 4818 __ bind(&done); | 4828 __ bind(&done); |
| 4819 } | 4829 } |
| 4820 | 4830 |
| 4821 | 4831 |
| 4822 #undef __ | 4832 #undef __ |
| 4823 | 4833 |
| 4824 } } // namespace v8::internal | 4834 } } // namespace v8::internal |
| 4825 | 4835 |
| 4826 #endif // V8_TARGET_ARCH_X64 | 4836 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |