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 4444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4455 Register result, | 4455 Register result, |
4456 Register source, | 4456 Register source, |
4457 int* offset) { | 4457 int* offset) { |
4458 ASSERT(!source.is(ecx)); | 4458 ASSERT(!source.is(ecx)); |
4459 ASSERT(!result.is(ecx)); | 4459 ASSERT(!result.is(ecx)); |
4460 | 4460 |
4461 if (FLAG_debug_code) { | 4461 if (FLAG_debug_code) { |
4462 __ LoadHeapObject(ecx, object); | 4462 __ LoadHeapObject(ecx, object); |
4463 __ cmp(source, ecx); | 4463 __ cmp(source, ecx); |
4464 __ Assert(equal, "Unexpected object literal boilerplate"); | 4464 __ Assert(equal, "Unexpected object literal boilerplate"); |
| 4465 __ mov(ecx, FieldOperand(source, HeapObject::kMapOffset)); |
| 4466 __ cmp(ecx, Handle<Map>(object->map())); |
| 4467 __ Assert(equal, "Unexpected boilerplate map"); |
| 4468 __ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset)); |
| 4469 __ and_(ecx, Map::kElementsKindMask); |
| 4470 __ cmp(ecx, object->GetElementsKind() << Map::kElementsKindShift); |
| 4471 __ Assert(equal, "Unexpected boilerplate elements kind"); |
4465 } | 4472 } |
4466 | 4473 |
4467 // Only elements backing stores for non-COW arrays need to be copied. | 4474 // Only elements backing stores for non-COW arrays need to be copied. |
4468 Handle<FixedArrayBase> elements(object->elements()); | 4475 Handle<FixedArrayBase> elements(object->elements()); |
4469 bool has_elements = elements->length() > 0 && | 4476 bool has_elements = elements->length() > 0 && |
4470 elements->map() != isolate()->heap()->fixed_cow_array_map(); | 4477 elements->map() != isolate()->heap()->fixed_cow_array_map(); |
4471 | 4478 |
4472 // Increase the offset so that subsequent objects end up right after | 4479 // Increase the offset so that subsequent objects end up right after |
4473 // this object and its backing store. | 4480 // this object and its backing store. |
4474 int object_offset = *offset; | 4481 int object_offset = *offset; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4551 } else { | 4558 } else { |
4552 UNREACHABLE(); | 4559 UNREACHABLE(); |
4553 } | 4560 } |
4554 } | 4561 } |
4555 } | 4562 } |
4556 | 4563 |
4557 | 4564 |
4558 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { | 4565 void LCodeGen::DoFastLiteral(LFastLiteral* instr) { |
4559 ASSERT(ToRegister(instr->context()).is(esi)); | 4566 ASSERT(ToRegister(instr->context()).is(esi)); |
4560 int size = instr->hydrogen()->total_size(); | 4567 int size = instr->hydrogen()->total_size(); |
| 4568 ElementsKind boilerplate_elements_kind = |
| 4569 instr->hydrogen()->boilerplate()->GetElementsKind(); |
| 4570 |
| 4571 // Deopt if the literal boilerplate ElementsKind is of a type different than |
| 4572 // the expected one. The check isn't necessary if the boilerplate has already |
| 4573 // been converted to FAST_ELEMENTS. |
| 4574 if (boilerplate_elements_kind != FAST_ELEMENTS) { |
| 4575 __ LoadHeapObject(ebx, instr->hydrogen()->boilerplate()); |
| 4576 __ mov(ecx, FieldOperand(ebx, HeapObject::kMapOffset)); |
| 4577 // Load the map's "bit field 2". We only need the first byte, |
| 4578 // but the following masking takes care of that anyway. |
| 4579 __ mov(ecx, FieldOperand(ecx, Map::kBitField2Offset)); |
| 4580 // Retrieve elements_kind from bit field 2. |
| 4581 __ and_(ecx, Map::kElementsKindMask); |
| 4582 __ cmp(ecx, boilerplate_elements_kind << Map::kElementsKindShift); |
| 4583 DeoptimizeIf(not_equal, instr->environment()); |
| 4584 } |
4561 | 4585 |
4562 // Allocate all objects that are part of the literal in one big | 4586 // Allocate all objects that are part of the literal in one big |
4563 // allocation. This avoids multiple limit checks. | 4587 // allocation. This avoids multiple limit checks. |
4564 Label allocated, runtime_allocate; | 4588 Label allocated, runtime_allocate; |
4565 __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT); | 4589 __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT); |
4566 __ jmp(&allocated); | 4590 __ jmp(&allocated); |
4567 | 4591 |
4568 __ bind(&runtime_allocate); | 4592 __ bind(&runtime_allocate); |
4569 __ push(Immediate(Smi::FromInt(size))); | 4593 __ push(Immediate(Smi::FromInt(size))); |
4570 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); | 4594 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5025 FixedArray::kHeaderSize - kPointerSize)); | 5049 FixedArray::kHeaderSize - kPointerSize)); |
5026 __ bind(&done); | 5050 __ bind(&done); |
5027 } | 5051 } |
5028 | 5052 |
5029 | 5053 |
5030 #undef __ | 5054 #undef __ |
5031 | 5055 |
5032 } } // namespace v8::internal | 5056 } } // namespace v8::internal |
5033 | 5057 |
5034 #endif // V8_TARGET_ARCH_IA32 | 5058 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |