Chromium Code Reviews| 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 __ j(equal, &done, Label::kNear); | 2370 __ j(equal, &done, Label::kNear); |
| 2371 __ cmp(FieldOperand(result, HeapObject::kMapOffset), | 2371 __ cmp(FieldOperand(result, HeapObject::kMapOffset), |
| 2372 Immediate(factory()->fixed_cow_array_map())); | 2372 Immediate(factory()->fixed_cow_array_map())); |
| 2373 __ j(equal, &done, Label::kNear); | 2373 __ j(equal, &done, Label::kNear); |
| 2374 Register temp((result.is(eax)) ? ebx : eax); | 2374 Register temp((result.is(eax)) ? ebx : eax); |
| 2375 __ push(temp); | 2375 __ push(temp); |
| 2376 __ mov(temp, FieldOperand(result, HeapObject::kMapOffset)); | 2376 __ mov(temp, FieldOperand(result, HeapObject::kMapOffset)); |
| 2377 __ movzx_b(temp, FieldOperand(temp, Map::kBitField2Offset)); | 2377 __ movzx_b(temp, FieldOperand(temp, Map::kBitField2Offset)); |
| 2378 __ and_(temp, Map::kElementsKindMask); | 2378 __ and_(temp, Map::kElementsKindMask); |
| 2379 __ shr(temp, Map::kElementsKindShift); | 2379 __ shr(temp, Map::kElementsKindShift); |
| 2380 __ cmp(temp, FAST_ELEMENTS); | 2380 __ cmp(temp, GetInitialFastElementsKind()); |
| 2381 __ j(equal, &ok, Label::kNear); | 2381 __ j(less, &fail, Label::kNear); |
| 2382 __ cmp(temp, TERMINAL_FAST_ELEMENTS_KIND); | |
| 2383 __ j(less_equal, &ok, Label::kNear); | |
| 2382 __ cmp(temp, FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); | 2384 __ cmp(temp, FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND); |
| 2383 __ j(less, &fail, Label::kNear); | 2385 __ j(less, &fail, Label::kNear); |
| 2384 __ cmp(temp, LAST_EXTERNAL_ARRAY_ELEMENTS_KIND); | 2386 __ cmp(temp, LAST_EXTERNAL_ARRAY_ELEMENTS_KIND); |
| 2385 __ j(less_equal, &ok, Label::kNear); | 2387 __ j(less_equal, &ok, Label::kNear); |
| 2386 __ bind(&fail); | 2388 __ bind(&fail); |
| 2387 __ Abort("Check for fast or external elements failed."); | 2389 __ Abort("Check for fast or external elements failed."); |
| 2388 __ bind(&ok); | 2390 __ bind(&ok); |
| 2389 __ pop(temp); | 2391 __ pop(temp); |
| 2390 __ bind(&done); | 2392 __ bind(&done); |
| 2391 } | 2393 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2430 __ cmp(result, factory()->the_hole_value()); | 2432 __ cmp(result, factory()->the_hole_value()); |
| 2431 DeoptimizeIf(equal, instr->environment()); | 2433 DeoptimizeIf(equal, instr->environment()); |
| 2432 } | 2434 } |
| 2433 } | 2435 } |
| 2434 | 2436 |
| 2435 | 2437 |
| 2436 void LCodeGen::DoLoadKeyedFastDoubleElement( | 2438 void LCodeGen::DoLoadKeyedFastDoubleElement( |
| 2437 LLoadKeyedFastDoubleElement* instr) { | 2439 LLoadKeyedFastDoubleElement* instr) { |
| 2438 XMMRegister result = ToDoubleRegister(instr->result()); | 2440 XMMRegister result = ToDoubleRegister(instr->result()); |
| 2439 | 2441 |
| 2440 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + | 2442 if (instr->hydrogen()->RequiresHoleCheck()) { |
| 2441 sizeof(kHoleNanLower32); | 2443 int offset = FixedDoubleArray::kHeaderSize - kHeapObjectTag + |
| 2442 Operand hole_check_operand = BuildFastArrayOperand( | 2444 sizeof(kHoleNanLower32); |
| 2443 instr->elements(), instr->key(), | 2445 Operand hole_check_operand = BuildFastArrayOperand( |
| 2444 FAST_DOUBLE_ELEMENTS, | 2446 instr->elements(), instr->key(), |
| 2445 offset); | 2447 FAST_DOUBLE_ELEMENTS, |
| 2446 __ cmp(hole_check_operand, Immediate(kHoleNanUpper32)); | 2448 offset); |
| 2447 DeoptimizeIf(equal, instr->environment()); | 2449 __ cmp(hole_check_operand, Immediate(kHoleNanUpper32)); |
| 2450 DeoptimizeIf(equal, instr->environment()); | |
| 2451 } | |
| 2448 | 2452 |
| 2449 Operand double_load_operand = BuildFastArrayOperand( | 2453 Operand double_load_operand = BuildFastArrayOperand( |
| 2450 instr->elements(), instr->key(), FAST_DOUBLE_ELEMENTS, | 2454 instr->elements(), instr->key(), FAST_DOUBLE_ELEMENTS, |
| 2451 FixedDoubleArray::kHeaderSize - kHeapObjectTag); | 2455 FixedDoubleArray::kHeaderSize - kHeapObjectTag); |
| 2452 __ movdbl(result, double_load_operand); | 2456 __ movdbl(result, double_load_operand); |
| 2453 } | 2457 } |
| 2454 | 2458 |
| 2455 | 2459 |
| 2456 Operand LCodeGen::BuildFastArrayOperand( | 2460 Operand LCodeGen::BuildFastArrayOperand( |
| 2457 LOperand* elements_pointer, | 2461 LOperand* elements_pointer, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2507 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 2511 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 2508 __ mov(result, operand); | 2512 __ mov(result, operand); |
| 2509 __ test(result, Operand(result)); | 2513 __ test(result, Operand(result)); |
| 2510 // TODO(danno): we could be more clever here, perhaps having a special | 2514 // TODO(danno): we could be more clever here, perhaps having a special |
| 2511 // version of the stub that detects if the overflow case actually | 2515 // version of the stub that detects if the overflow case actually |
| 2512 // happens, and generate code that returns a double rather than int. | 2516 // happens, and generate code that returns a double rather than int. |
| 2513 DeoptimizeIf(negative, instr->environment()); | 2517 DeoptimizeIf(negative, instr->environment()); |
| 2514 break; | 2518 break; |
| 2515 case EXTERNAL_FLOAT_ELEMENTS: | 2519 case EXTERNAL_FLOAT_ELEMENTS: |
| 2516 case EXTERNAL_DOUBLE_ELEMENTS: | 2520 case EXTERNAL_DOUBLE_ELEMENTS: |
| 2517 case FAST_SMI_ONLY_ELEMENTS: | 2521 case FAST_SMI_ELEMENTS: |
| 2518 case FAST_ELEMENTS: | 2522 case FAST_ELEMENTS: |
| 2519 case FAST_DOUBLE_ELEMENTS: | 2523 case FAST_DOUBLE_ELEMENTS: |
| 2524 case FAST_HOLEY_SMI_ELEMENTS: | |
| 2525 case FAST_HOLEY_ELEMENTS: | |
| 2526 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
| 2520 case DICTIONARY_ELEMENTS: | 2527 case DICTIONARY_ELEMENTS: |
| 2521 case NON_STRICT_ARGUMENTS_ELEMENTS: | 2528 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 2522 UNREACHABLE(); | 2529 UNREACHABLE(); |
| 2523 break; | 2530 break; |
| 2524 } | 2531 } |
| 2525 } | 2532 } |
| 2526 } | 2533 } |
| 2527 | 2534 |
| 2528 | 2535 |
| 2529 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { | 2536 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) { |
| (...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3432 case EXTERNAL_SHORT_ELEMENTS: | 3439 case EXTERNAL_SHORT_ELEMENTS: |
| 3433 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 3440 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| 3434 __ mov_w(operand, value); | 3441 __ mov_w(operand, value); |
| 3435 break; | 3442 break; |
| 3436 case EXTERNAL_INT_ELEMENTS: | 3443 case EXTERNAL_INT_ELEMENTS: |
| 3437 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 3444 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| 3438 __ mov(operand, value); | 3445 __ mov(operand, value); |
| 3439 break; | 3446 break; |
| 3440 case EXTERNAL_FLOAT_ELEMENTS: | 3447 case EXTERNAL_FLOAT_ELEMENTS: |
| 3441 case EXTERNAL_DOUBLE_ELEMENTS: | 3448 case EXTERNAL_DOUBLE_ELEMENTS: |
| 3442 case FAST_SMI_ONLY_ELEMENTS: | 3449 case FAST_SMI_ELEMENTS: |
| 3443 case FAST_ELEMENTS: | 3450 case FAST_ELEMENTS: |
| 3444 case FAST_DOUBLE_ELEMENTS: | 3451 case FAST_DOUBLE_ELEMENTS: |
| 3452 case FAST_HOLEY_SMI_ELEMENTS: | |
| 3453 case FAST_HOLEY_ELEMENTS: | |
| 3454 case FAST_HOLEY_DOUBLE_ELEMENTS: | |
| 3445 case DICTIONARY_ELEMENTS: | 3455 case DICTIONARY_ELEMENTS: |
| 3446 case NON_STRICT_ARGUMENTS_ELEMENTS: | 3456 case NON_STRICT_ARGUMENTS_ELEMENTS: |
| 3447 UNREACHABLE(); | 3457 UNREACHABLE(); |
| 3448 break; | 3458 break; |
| 3449 } | 3459 } |
| 3450 } | 3460 } |
| 3451 } | 3461 } |
| 3452 | 3462 |
| 3453 | 3463 |
| 3454 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { | 3464 void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3533 | 3543 |
| 3534 Handle<Map> from_map = instr->original_map(); | 3544 Handle<Map> from_map = instr->original_map(); |
| 3535 Handle<Map> to_map = instr->transitioned_map(); | 3545 Handle<Map> to_map = instr->transitioned_map(); |
| 3536 ElementsKind from_kind = from_map->elements_kind(); | 3546 ElementsKind from_kind = from_map->elements_kind(); |
| 3537 ElementsKind to_kind = to_map->elements_kind(); | 3547 ElementsKind to_kind = to_map->elements_kind(); |
| 3538 | 3548 |
| 3539 Label not_applicable; | 3549 Label not_applicable; |
| 3540 __ cmp(FieldOperand(object_reg, HeapObject::kMapOffset), from_map); | 3550 __ cmp(FieldOperand(object_reg, HeapObject::kMapOffset), from_map); |
| 3541 __ j(not_equal, ¬_applicable); | 3551 __ j(not_equal, ¬_applicable); |
| 3542 __ mov(new_map_reg, to_map); | 3552 __ mov(new_map_reg, to_map); |
| 3543 if (from_kind == FAST_SMI_ONLY_ELEMENTS && to_kind == FAST_ELEMENTS) { | 3553 bool simple_map_change = (GetHoleyElementsKind(from_kind) == to_kind) || |
| 3554 (IsFastSmiElementsKind(from_kind) && | |
| 3555 IsFastObjectElementsKind(to_kind)); | |
| 3556 if (simple_map_change) { | |
| 3544 Register object_reg = ToRegister(instr->object()); | 3557 Register object_reg = ToRegister(instr->object()); |
| 3545 __ mov(FieldOperand(object_reg, HeapObject::kMapOffset), new_map_reg); | 3558 __ mov(FieldOperand(object_reg, HeapObject::kMapOffset), new_map_reg); |
| 3546 // Write barrier. | 3559 // Write barrier. |
| 3547 ASSERT_NE(instr->temp_reg(), NULL); | 3560 ASSERT_NE(instr->temp_reg(), NULL); |
| 3548 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg, | 3561 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg, |
| 3549 ToRegister(instr->temp_reg()), kDontSaveFPRegs); | 3562 ToRegister(instr->temp_reg()), kDontSaveFPRegs); |
| 3550 } else if (from_kind == FAST_SMI_ONLY_ELEMENTS && | 3563 } else if (IsFastSmiElementsKind(from_kind) && |
| 3551 to_kind == FAST_DOUBLE_ELEMENTS) { | 3564 IsFastDoubleElementsKind(to_kind)) { |
| 3552 Register fixed_object_reg = ToRegister(instr->temp_reg()); | 3565 Register fixed_object_reg = ToRegister(instr->temp_reg()); |
| 3553 ASSERT(fixed_object_reg.is(edx)); | 3566 ASSERT(fixed_object_reg.is(edx)); |
| 3554 ASSERT(new_map_reg.is(ebx)); | 3567 ASSERT(new_map_reg.is(ebx)); |
| 3555 __ mov(fixed_object_reg, object_reg); | 3568 __ mov(fixed_object_reg, object_reg); |
| 3556 CallCode(isolate()->builtins()->TransitionElementsSmiToDouble(), | 3569 CallCode(isolate()->builtins()->TransitionElementsSmiToDouble(), |
| 3557 RelocInfo::CODE_TARGET, instr); | 3570 RelocInfo::CODE_TARGET, instr); |
| 3558 } else if (from_kind == FAST_DOUBLE_ELEMENTS && to_kind == FAST_ELEMENTS) { | 3571 } else if (IsFastDoubleElementsKind(from_kind) && |
| 3572 IsFastElementsKind(to_kind)) { | |
|
Jakob Kummerow
2012/05/22 17:36:49
IsFastObjectElementsKind(to_kind) ?
danno
2012/05/23 14:25:36
Done.
| |
| 3559 Register fixed_object_reg = ToRegister(instr->temp_reg()); | 3573 Register fixed_object_reg = ToRegister(instr->temp_reg()); |
| 3560 ASSERT(fixed_object_reg.is(edx)); | 3574 ASSERT(fixed_object_reg.is(edx)); |
| 3561 ASSERT(new_map_reg.is(ebx)); | 3575 ASSERT(new_map_reg.is(ebx)); |
| 3562 __ mov(fixed_object_reg, object_reg); | 3576 __ mov(fixed_object_reg, object_reg); |
| 3563 CallCode(isolate()->builtins()->TransitionElementsDoubleToObject(), | 3577 CallCode(isolate()->builtins()->TransitionElementsDoubleToObject(), |
| 3564 RelocInfo::CODE_TARGET, instr); | 3578 RelocInfo::CODE_TARGET, instr); |
| 3565 } else { | 3579 } else { |
| 3566 UNREACHABLE(); | 3580 UNREACHABLE(); |
| 3567 } | 3581 } |
| 3568 __ bind(¬_applicable); | 3582 __ bind(¬_applicable); |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4408 | 4422 |
| 4409 | 4423 |
| 4410 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4424 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
| 4411 ASSERT(ToRegister(instr->context()).is(esi)); | 4425 ASSERT(ToRegister(instr->context()).is(esi)); |
| 4412 Heap* heap = isolate()->heap(); | 4426 Heap* heap = isolate()->heap(); |
| 4413 ElementsKind boilerplate_elements_kind = | 4427 ElementsKind boilerplate_elements_kind = |
| 4414 instr->hydrogen()->boilerplate_elements_kind(); | 4428 instr->hydrogen()->boilerplate_elements_kind(); |
| 4415 | 4429 |
| 4416 // Deopt if the array literal boilerplate ElementsKind is of a type different | 4430 // Deopt if the array literal boilerplate ElementsKind is of a type different |
| 4417 // than the expected one. The check isn't necessary if the boilerplate has | 4431 // than the expected one. The check isn't necessary if the boilerplate has |
| 4418 // already been converted to FAST_ELEMENTS. | 4432 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. |
| 4419 if (boilerplate_elements_kind != FAST_ELEMENTS) { | 4433 if (CanTransitionToMoreGeneralFastElementsKind( |
| 4434 boilerplate_elements_kind, true)) { | |
| 4420 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object()); | 4435 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object()); |
| 4421 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 4436 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 4422 // Load the map's "bit field 2". We only need the first byte, | 4437 // Load the map's "bit field 2". We only need the first byte, |
| 4423 // but the following masking takes care of that anyway. | 4438 // but the following masking takes care of that anyway. |
| 4424 __ mov(ebx, FieldOperand(ebx, Map::kBitField2Offset)); | 4439 __ mov(ebx, FieldOperand(ebx, Map::kBitField2Offset)); |
| 4425 // Retrieve elements_kind from bit field 2. | 4440 // Retrieve elements_kind from bit field 2. |
| 4426 __ and_(ebx, Map::kElementsKindMask); | 4441 __ and_(ebx, Map::kElementsKindMask); |
| 4427 __ cmp(ebx, boilerplate_elements_kind << Map::kElementsKindShift); | 4442 __ cmp(ebx, boilerplate_elements_kind << Map::kElementsKindShift); |
| 4428 DeoptimizeIf(not_equal, instr->environment()); | 4443 DeoptimizeIf(not_equal, instr->environment()); |
| 4429 } | 4444 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4571 | 4586 |
| 4572 | 4587 |
| 4573 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { | 4588 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { |
| 4574 ASSERT(ToRegister(instr->context()).is(esi)); | 4589 ASSERT(ToRegister(instr->context()).is(esi)); |
| 4575 int size = instr->hydrogen()->total_size(); | 4590 int size = instr->hydrogen()->total_size(); |
| 4576 ElementsKind boilerplate_elements_kind = | 4591 ElementsKind boilerplate_elements_kind = |
| 4577 instr->hydrogen()->boilerplate()->GetElementsKind(); | 4592 instr->hydrogen()->boilerplate()->GetElementsKind(); |
| 4578 | 4593 |
| 4579 // Deopt if the literal boilerplate ElementsKind is of a type different than | 4594 // Deopt if the literal boilerplate ElementsKind is of a type different than |
| 4580 // the expected one. The check isn't necessary if the boilerplate has already | 4595 // the expected one. The check isn't necessary if the boilerplate has already |
| 4581 // been converted to FAST_ELEMENTS. | 4596 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. |
| 4582 if (boilerplate_elements_kind != FAST_ELEMENTS) { | 4597 if (CanTransitionToMoreGeneralFastElementsKind( |
| 4598 boilerplate_elements_kind, true)) { | |
| 4583 __ LoadHeapObject(ebx, instr->hydrogen()->boilerplate()); | 4599 __ LoadHeapObject(ebx, instr->hydrogen()->boilerplate()); |
| 4584 __ mov(ecx, FieldOperand(ebx, HeapObject::kMapOffset)); | 4600 __ mov(ecx, FieldOperand(ebx, HeapObject::kMapOffset)); |
| 4585 // Load the map's "bit field 2". We only need the first byte, | 4601 // Load the map's "bit field 2". We only need the first byte, |
| 4586 // but the following masking takes care of that anyway. | 4602 // but the following masking takes care of that anyway. |
| 4587 __ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset)); | 4603 __ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset)); |
| 4588 // Retrieve elements_kind from bit field 2. | 4604 // Retrieve elements_kind from bit field 2. |
| 4589 __ and_(ecx, Map::kElementsKindMask); | 4605 __ and_(ecx, Map::kElementsKindMask); |
| 4590 __ cmp(ecx, boilerplate_elements_kind << Map::kElementsKindShift); | 4606 __ cmp(ecx, boilerplate_elements_kind << Map::kElementsKindShift); |
| 4591 DeoptimizeIf(not_equal, instr->environment()); | 4607 DeoptimizeIf(not_equal, instr->environment()); |
| 4592 } | 4608 } |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5057 FixedArray::kHeaderSize - kPointerSize)); | 5073 FixedArray::kHeaderSize - kPointerSize)); |
| 5058 __ bind(&done); | 5074 __ bind(&done); |
| 5059 } | 5075 } |
| 5060 | 5076 |
| 5061 | 5077 |
| 5062 #undef __ | 5078 #undef __ |
| 5063 | 5079 |
| 5064 } } // namespace v8::internal | 5080 } } // namespace v8::internal |
| 5065 | 5081 |
| 5066 #endif // V8_TARGET_ARCH_IA32 | 5082 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |