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 4288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4299 // the constructor's prototype changes, but instance size and property | 4299 // the constructor's prototype changes, but instance size and property |
4300 // counts remain unchanged (if slack tracking finished). | 4300 // counts remain unchanged (if slack tracking finished). |
4301 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); | 4301 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); |
4302 __ AllocateInNewSpace(instance_size, | 4302 __ AllocateInNewSpace(instance_size, |
4303 result, | 4303 result, |
4304 no_reg, | 4304 no_reg, |
4305 scratch, | 4305 scratch, |
4306 deferred->entry(), | 4306 deferred->entry(), |
4307 TAG_OBJECT); | 4307 TAG_OBJECT); |
4308 | 4308 |
| 4309 __ bind(deferred->exit()); |
| 4310 if (FLAG_debug_code) { |
| 4311 Label is_in_new_space; |
| 4312 __ JumpIfInNewSpace(result, scratch, &is_in_new_space); |
| 4313 __ Abort("Allocated object is not in new-space"); |
| 4314 __ bind(&is_in_new_space); |
| 4315 } |
| 4316 |
4309 // Load the initial map. | 4317 // Load the initial map. |
4310 Register map = scratch; | 4318 Register map = scratch; |
4311 __ LoadHeapObject(scratch, constructor); | 4319 __ LoadHeapObject(scratch, constructor); |
4312 __ mov(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset)); | 4320 __ mov(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset)); |
4313 | 4321 |
4314 if (FLAG_debug_code) { | 4322 if (FLAG_debug_code) { |
4315 __ AbortIfSmi(map); | 4323 __ AbortIfSmi(map); |
4316 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset), | 4324 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset), |
4317 instance_size >> kPointerSizeLog2); | 4325 instance_size >> kPointerSizeLog2); |
4318 __ Assert(equal, "Unexpected instance size"); | 4326 __ Assert(equal, "Unexpected instance size"); |
(...skipping 14 matching lines...) Expand all Loading... |
4333 __ mov(scratch, factory()->empty_fixed_array()); | 4341 __ mov(scratch, factory()->empty_fixed_array()); |
4334 __ mov(FieldOperand(result, JSObject::kElementsOffset), scratch); | 4342 __ mov(FieldOperand(result, JSObject::kElementsOffset), scratch); |
4335 __ mov(FieldOperand(result, JSObject::kPropertiesOffset), scratch); | 4343 __ mov(FieldOperand(result, JSObject::kPropertiesOffset), scratch); |
4336 if (initial_map->inobject_properties() != 0) { | 4344 if (initial_map->inobject_properties() != 0) { |
4337 __ mov(scratch, factory()->undefined_value()); | 4345 __ mov(scratch, factory()->undefined_value()); |
4338 for (int i = 0; i < initial_map->inobject_properties(); i++) { | 4346 for (int i = 0; i < initial_map->inobject_properties(); i++) { |
4339 int property_offset = JSObject::kHeaderSize + i * kPointerSize; | 4347 int property_offset = JSObject::kHeaderSize + i * kPointerSize; |
4340 __ mov(FieldOperand(result, property_offset), scratch); | 4348 __ mov(FieldOperand(result, property_offset), scratch); |
4341 } | 4349 } |
4342 } | 4350 } |
4343 | |
4344 __ bind(deferred->exit()); | |
4345 } | 4351 } |
4346 | 4352 |
4347 | 4353 |
4348 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { | 4354 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { |
4349 Register result = ToRegister(instr->result()); | 4355 Register result = ToRegister(instr->result()); |
4350 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); | 4356 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); |
| 4357 Handle<Map> initial_map(constructor->initial_map()); |
| 4358 int instance_size = initial_map->instance_size(); |
4351 | 4359 |
4352 // TODO(3095996): Get rid of this. For now, we need to make the | 4360 // TODO(3095996): Get rid of this. For now, we need to make the |
4353 // result register contain a valid pointer because it is already | 4361 // result register contain a valid pointer because it is already |
4354 // contained in the register pointer map. | 4362 // contained in the register pointer map. |
4355 __ Set(result, Immediate(0)); | 4363 __ Set(result, Immediate(0)); |
4356 | 4364 |
4357 PushSafepointRegistersScope scope(this); | 4365 PushSafepointRegistersScope scope(this); |
4358 __ PushHeapObject(constructor); | 4366 __ push(Immediate(Smi::FromInt(instance_size))); |
4359 CallRuntimeFromDeferred(Runtime::kNewObject, 1, instr, instr->context()); | 4367 CallRuntimeFromDeferred( |
| 4368 Runtime::kAllocateInNewSpace, 1, instr, instr->context()); |
4360 __ StoreToSafepointRegisterSlot(result, eax); | 4369 __ StoreToSafepointRegisterSlot(result, eax); |
4361 } | 4370 } |
4362 | 4371 |
4363 | 4372 |
4364 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4373 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4365 ASSERT(ToRegister(instr->context()).is(esi)); | 4374 ASSERT(ToRegister(instr->context()).is(esi)); |
4366 Heap* heap = isolate()->heap(); | 4375 Heap* heap = isolate()->heap(); |
4367 ElementsKind boilerplate_elements_kind = | 4376 ElementsKind boilerplate_elements_kind = |
4368 instr->hydrogen()->boilerplate_elements_kind(); | 4377 instr->hydrogen()->boilerplate_elements_kind(); |
4369 | 4378 |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4986 FixedArray::kHeaderSize - kPointerSize)); | 4995 FixedArray::kHeaderSize - kPointerSize)); |
4987 __ bind(&done); | 4996 __ bind(&done); |
4988 } | 4997 } |
4989 | 4998 |
4990 | 4999 |
4991 #undef __ | 5000 #undef __ |
4992 | 5001 |
4993 } } // namespace v8::internal | 5002 } } // namespace v8::internal |
4994 | 5003 |
4995 #endif // V8_TARGET_ARCH_IA32 | 5004 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |