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 4349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4360 // the constructor's prototype changes, but instance size and property | 4360 // the constructor's prototype changes, but instance size and property |
4361 // counts remain unchanged (if slack tracking finished). | 4361 // counts remain unchanged (if slack tracking finished). |
4362 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); | 4362 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); |
4363 __ AllocateInNewSpace(instance_size, | 4363 __ AllocateInNewSpace(instance_size, |
4364 result, | 4364 result, |
4365 scratch, | 4365 scratch, |
4366 scratch2, | 4366 scratch2, |
4367 deferred->entry(), | 4367 deferred->entry(), |
4368 TAG_OBJECT); | 4368 TAG_OBJECT); |
4369 | 4369 |
| 4370 __ bind(deferred->exit()); |
| 4371 if (FLAG_debug_code) { |
| 4372 Label is_in_new_space; |
| 4373 __ JumpIfInNewSpace(result, scratch, &is_in_new_space); |
| 4374 __ Abort("Allocated object is not in new-space"); |
| 4375 __ bind(&is_in_new_space); |
| 4376 } |
| 4377 |
4370 // Load the initial map. | 4378 // Load the initial map. |
4371 Register map = scratch; | 4379 Register map = scratch; |
4372 __ LoadHeapObject(map, constructor); | 4380 __ LoadHeapObject(map, constructor); |
4373 __ lw(map, FieldMemOperand(map, JSFunction::kPrototypeOrInitialMapOffset)); | 4381 __ lw(map, FieldMemOperand(map, JSFunction::kPrototypeOrInitialMapOffset)); |
4374 | 4382 |
4375 // Initialize map and fields of the newly allocated object. | 4383 // Initialize map and fields of the newly allocated object. |
4376 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); | 4384 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); |
4377 __ sw(map, FieldMemOperand(result, JSObject::kMapOffset)); | 4385 __ sw(map, FieldMemOperand(result, JSObject::kMapOffset)); |
4378 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex); | 4386 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex); |
4379 __ sw(scratch, FieldMemOperand(result, JSObject::kElementsOffset)); | 4387 __ sw(scratch, FieldMemOperand(result, JSObject::kElementsOffset)); |
4380 __ sw(scratch, FieldMemOperand(result, JSObject::kPropertiesOffset)); | 4388 __ sw(scratch, FieldMemOperand(result, JSObject::kPropertiesOffset)); |
4381 if (initial_map->inobject_properties() != 0) { | 4389 if (initial_map->inobject_properties() != 0) { |
4382 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 4390 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
4383 for (int i = 0; i < initial_map->inobject_properties(); i++) { | 4391 for (int i = 0; i < initial_map->inobject_properties(); i++) { |
4384 int property_offset = JSObject::kHeaderSize + i * kPointerSize; | 4392 int property_offset = JSObject::kHeaderSize + i * kPointerSize; |
4385 __ sw(scratch, FieldMemOperand(result, property_offset)); | 4393 __ sw(scratch, FieldMemOperand(result, property_offset)); |
4386 } | 4394 } |
4387 } | 4395 } |
4388 | |
4389 __ bind(deferred->exit()); | |
4390 } | 4396 } |
4391 | 4397 |
4392 | 4398 |
4393 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { | 4399 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { |
4394 Register result = ToRegister(instr->result()); | 4400 Register result = ToRegister(instr->result()); |
4395 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); | 4401 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); |
| 4402 Handle<Map> initial_map(constructor->initial_map()); |
| 4403 int instance_size = initial_map->instance_size(); |
4396 | 4404 |
4397 // TODO(3095996): Get rid of this. For now, we need to make the | 4405 // TODO(3095996): Get rid of this. For now, we need to make the |
4398 // result register contain a valid pointer because it is already | 4406 // result register contain a valid pointer because it is already |
4399 // contained in the register pointer map. | 4407 // contained in the register pointer map. |
4400 __ mov(result, zero_reg); | 4408 __ mov(result, zero_reg); |
4401 | 4409 |
4402 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); | 4410 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); |
4403 __ LoadHeapObject(a0, constructor); | 4411 __ li(a0, Operand(Smi::FromInt(instance_size))); |
4404 __ push(a0); | 4412 __ push(a0); |
4405 CallRuntimeFromDeferred(Runtime::kNewObject, 1, instr); | 4413 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); |
4406 __ StoreToSafepointRegisterSlot(v0, result); | 4414 __ StoreToSafepointRegisterSlot(v0, result); |
4407 } | 4415 } |
4408 | 4416 |
4409 | 4417 |
4410 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4418 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4411 Heap* heap = isolate()->heap(); | 4419 Heap* heap = isolate()->heap(); |
4412 ElementsKind boilerplate_elements_kind = | 4420 ElementsKind boilerplate_elements_kind = |
4413 instr->hydrogen()->boilerplate_elements_kind(); | 4421 instr->hydrogen()->boilerplate_elements_kind(); |
4414 | 4422 |
4415 // Deopt if the array literal boilerplate ElementsKind is of a type different | 4423 // Deopt if the array literal boilerplate ElementsKind is of a type different |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5071 __ Subu(scratch, result, scratch); | 5079 __ Subu(scratch, result, scratch); |
5072 __ lw(result, FieldMemOperand(scratch, | 5080 __ lw(result, FieldMemOperand(scratch, |
5073 FixedArray::kHeaderSize - kPointerSize)); | 5081 FixedArray::kHeaderSize - kPointerSize)); |
5074 __ bind(&done); | 5082 __ bind(&done); |
5075 } | 5083 } |
5076 | 5084 |
5077 | 5085 |
5078 #undef __ | 5086 #undef __ |
5079 | 5087 |
5080 } } // namespace v8::internal | 5088 } } // namespace v8::internal |
OLD | NEW |