| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 5021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5032 | 5032 |
| 5033 Register result = ToRegister(instr->result()); | 5033 Register result = ToRegister(instr->result()); |
| 5034 Register scratch = ToRegister(instr->temp()); | 5034 Register scratch = ToRegister(instr->temp()); |
| 5035 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); | 5035 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); |
| 5036 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map(); | 5036 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map(); |
| 5037 int instance_size = initial_map->instance_size(); | 5037 int instance_size = initial_map->instance_size(); |
| 5038 ASSERT(initial_map->pre_allocated_property_fields() + | 5038 ASSERT(initial_map->pre_allocated_property_fields() + |
| 5039 initial_map->unused_property_fields() - | 5039 initial_map->unused_property_fields() - |
| 5040 initial_map->inobject_properties() == 0); | 5040 initial_map->inobject_properties() == 0); |
| 5041 | 5041 |
| 5042 __ Allocate(instance_size, result, no_reg, scratch, deferred->entry(), | 5042 AllocationFlags flags = TAG_OBJECT; |
| 5043 TAG_OBJECT); | 5043 if (instr->hydrogen()->CanAllocateInOldPointerSpace()) { |
| 5044 flags = static_cast<AllocationFlags>(flags | PRETENURE_OLD_POINTER_SPACE); |
| 5045 } |
| 5046 |
| 5047 __ Allocate(instance_size, result, no_reg, scratch, deferred->entry(), flags); |
| 5044 | 5048 |
| 5045 __ bind(deferred->exit()); | 5049 __ bind(deferred->exit()); |
| 5046 if (FLAG_debug_code) { | 5050 if (FLAG_debug_code && !instr->hydrogen()->CanAllocateInOldPointerSpace()) { |
| 5047 Label is_in_new_space; | 5051 Label is_in_new_space; |
| 5048 __ JumpIfInNewSpace(result, scratch, &is_in_new_space); | 5052 __ JumpIfInNewSpace(result, scratch, &is_in_new_space); |
| 5049 __ Abort("Allocated object is not in new-space"); | 5053 __ Abort("Allocated object is not in new-space"); |
| 5050 __ bind(&is_in_new_space); | 5054 __ bind(&is_in_new_space); |
| 5051 } | 5055 } |
| 5052 | 5056 |
| 5053 // Load the initial map. | 5057 // Load the initial map. |
| 5054 Register map = scratch; | 5058 Register map = scratch; |
| 5055 __ LoadHeapObject(scratch, constructor); | 5059 __ LoadHeapObject(scratch, constructor); |
| 5060 // Recording the map slot can be skipped, because maps are not compacted. |
| 5056 __ movq(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset)); | 5061 __ movq(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset)); |
| 5057 | 5062 |
| 5058 if (FLAG_debug_code) { | 5063 if (FLAG_debug_code) { |
| 5059 __ AssertNotSmi(map); | 5064 __ AssertNotSmi(map); |
| 5060 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset), | 5065 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset), |
| 5061 Immediate(instance_size >> kPointerSizeLog2)); | 5066 Immediate(instance_size >> kPointerSizeLog2)); |
| 5062 __ Assert(equal, "Unexpected instance size"); | 5067 __ Assert(equal, "Unexpected instance size"); |
| 5063 __ cmpb(FieldOperand(map, Map::kPreAllocatedPropertyFieldsOffset), | 5068 __ cmpb(FieldOperand(map, Map::kPreAllocatedPropertyFieldsOffset), |
| 5064 Immediate(initial_map->pre_allocated_property_fields())); | 5069 Immediate(initial_map->pre_allocated_property_fields())); |
| 5065 __ Assert(equal, "Unexpected pre-allocated property fields count"); | 5070 __ Assert(equal, "Unexpected pre-allocated property fields count"); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 5092 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map(); | 5097 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map(); |
| 5093 int instance_size = initial_map->instance_size(); | 5098 int instance_size = initial_map->instance_size(); |
| 5094 | 5099 |
| 5095 // TODO(3095996): Get rid of this. For now, we need to make the | 5100 // TODO(3095996): Get rid of this. For now, we need to make the |
| 5096 // result register contain a valid pointer because it is already | 5101 // result register contain a valid pointer because it is already |
| 5097 // contained in the register pointer map. | 5102 // contained in the register pointer map. |
| 5098 __ Set(result, 0); | 5103 __ Set(result, 0); |
| 5099 | 5104 |
| 5100 PushSafepointRegistersScope scope(this); | 5105 PushSafepointRegistersScope scope(this); |
| 5101 __ Push(Smi::FromInt(instance_size)); | 5106 __ Push(Smi::FromInt(instance_size)); |
| 5102 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); | 5107 if (instr->hydrogen()->CanAllocateInOldPointerSpace()) { |
| 5108 CallRuntimeFromDeferred(Runtime::kAllocateInOldPointerSpace, 1, instr); |
| 5109 } else { |
| 5110 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); |
| 5111 } |
| 5103 __ StoreToSafepointRegisterSlot(result, rax); | 5112 __ StoreToSafepointRegisterSlot(result, rax); |
| 5104 } | 5113 } |
| 5105 | 5114 |
| 5106 | 5115 |
| 5107 void LCodeGen::DoAllocate(LAllocate* instr) { | 5116 void LCodeGen::DoAllocate(LAllocate* instr) { |
| 5108 class DeferredAllocate: public LDeferredCode { | 5117 class DeferredAllocate: public LDeferredCode { |
| 5109 public: | 5118 public: |
| 5110 DeferredAllocate(LCodeGen* codegen, LAllocate* instr) | 5119 DeferredAllocate(LCodeGen* codegen, LAllocate* instr) |
| 5111 : LDeferredCode(codegen), instr_(instr) { } | 5120 : LDeferredCode(codegen), instr_(instr) { } |
| 5112 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } | 5121 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5620 FixedArray::kHeaderSize - kPointerSize)); | 5629 FixedArray::kHeaderSize - kPointerSize)); |
| 5621 __ bind(&done); | 5630 __ bind(&done); |
| 5622 } | 5631 } |
| 5623 | 5632 |
| 5624 | 5633 |
| 5625 #undef __ | 5634 #undef __ |
| 5626 | 5635 |
| 5627 } } // namespace v8::internal | 5636 } } // namespace v8::internal |
| 5628 | 5637 |
| 5629 #endif // V8_TARGET_ARCH_X64 | 5638 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |