| 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 5296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5307 if (!instr->hydrogen()->CanOmitPrototypeChecks()) { | 5307 if (!instr->hydrogen()->CanOmitPrototypeChecks()) { |
| 5308 for (int i = 0; i < prototypes->length(); i++) { | 5308 for (int i = 0; i < prototypes->length(); i++) { |
| 5309 __ LoadHeapObject(prototype_reg, prototypes->at(i)); | 5309 __ LoadHeapObject(prototype_reg, prototypes->at(i)); |
| 5310 __ ldr(map_reg, FieldMemOperand(prototype_reg, HeapObject::kMapOffset)); | 5310 __ ldr(map_reg, FieldMemOperand(prototype_reg, HeapObject::kMapOffset)); |
| 5311 DoCheckMapCommon(map_reg, maps->at(i), instr->environment()); | 5311 DoCheckMapCommon(map_reg, maps->at(i), instr->environment()); |
| 5312 } | 5312 } |
| 5313 } | 5313 } |
| 5314 } | 5314 } |
| 5315 | 5315 |
| 5316 | 5316 |
| 5317 void LCodeGen::DoAllocateObject(LAllocateObject* instr) { | |
| 5318 class DeferredAllocateObject: public LDeferredCode { | |
| 5319 public: | |
| 5320 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr) | |
| 5321 : LDeferredCode(codegen), instr_(instr) { } | |
| 5322 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); } | |
| 5323 virtual LInstruction* instr() { return instr_; } | |
| 5324 private: | |
| 5325 LAllocateObject* instr_; | |
| 5326 }; | |
| 5327 | |
| 5328 DeferredAllocateObject* deferred = | |
| 5329 new(zone()) DeferredAllocateObject(this, instr); | |
| 5330 | |
| 5331 Register result = ToRegister(instr->result()); | |
| 5332 Register scratch = ToRegister(instr->temp()); | |
| 5333 Register scratch2 = ToRegister(instr->temp2()); | |
| 5334 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); | |
| 5335 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map(); | |
| 5336 int instance_size = initial_map->instance_size(); | |
| 5337 ASSERT(initial_map->pre_allocated_property_fields() + | |
| 5338 initial_map->unused_property_fields() - | |
| 5339 initial_map->inobject_properties() == 0); | |
| 5340 | |
| 5341 __ Allocate(instance_size, result, scratch, scratch2, deferred->entry(), | |
| 5342 TAG_OBJECT); | |
| 5343 | |
| 5344 __ bind(deferred->exit()); | |
| 5345 if (FLAG_debug_code) { | |
| 5346 Label is_in_new_space; | |
| 5347 __ JumpIfInNewSpace(result, scratch, &is_in_new_space); | |
| 5348 __ Abort("Allocated object is not in new-space"); | |
| 5349 __ bind(&is_in_new_space); | |
| 5350 } | |
| 5351 | |
| 5352 // Load the initial map. | |
| 5353 Register map = scratch; | |
| 5354 __ LoadHeapObject(map, constructor); | |
| 5355 __ ldr(map, FieldMemOperand(map, JSFunction::kPrototypeOrInitialMapOffset)); | |
| 5356 | |
| 5357 // Initialize map and fields of the newly allocated object. | |
| 5358 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); | |
| 5359 __ str(map, FieldMemOperand(result, JSObject::kMapOffset)); | |
| 5360 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex); | |
| 5361 __ str(scratch, FieldMemOperand(result, JSObject::kElementsOffset)); | |
| 5362 __ str(scratch, FieldMemOperand(result, JSObject::kPropertiesOffset)); | |
| 5363 if (initial_map->inobject_properties() != 0) { | |
| 5364 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | |
| 5365 for (int i = 0; i < initial_map->inobject_properties(); i++) { | |
| 5366 int property_offset = JSObject::kHeaderSize + i * kPointerSize; | |
| 5367 __ str(scratch, FieldMemOperand(result, property_offset)); | |
| 5368 } | |
| 5369 } | |
| 5370 } | |
| 5371 | |
| 5372 | |
| 5373 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { | |
| 5374 Register result = ToRegister(instr->result()); | |
| 5375 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map(); | |
| 5376 int instance_size = initial_map->instance_size(); | |
| 5377 | |
| 5378 // TODO(3095996): Get rid of this. For now, we need to make the | |
| 5379 // result register contain a valid pointer because it is already | |
| 5380 // contained in the register pointer map. | |
| 5381 __ mov(result, Operand::Zero()); | |
| 5382 | |
| 5383 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); | |
| 5384 __ mov(r0, Operand(Smi::FromInt(instance_size))); | |
| 5385 __ push(r0); | |
| 5386 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); | |
| 5387 __ StoreToSafepointRegisterSlot(r0, result); | |
| 5388 } | |
| 5389 | |
| 5390 | |
| 5391 void LCodeGen::DoAllocate(LAllocate* instr) { | 5317 void LCodeGen::DoAllocate(LAllocate* instr) { |
| 5392 class DeferredAllocate: public LDeferredCode { | 5318 class DeferredAllocate: public LDeferredCode { |
| 5393 public: | 5319 public: |
| 5394 DeferredAllocate(LCodeGen* codegen, LAllocate* instr) | 5320 DeferredAllocate(LCodeGen* codegen, LAllocate* instr) |
| 5395 : LDeferredCode(codegen), instr_(instr) { } | 5321 : LDeferredCode(codegen), instr_(instr) { } |
| 5396 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } | 5322 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } |
| 5397 virtual LInstruction* instr() { return instr_; } | 5323 virtual LInstruction* instr() { return instr_; } |
| 5398 private: | 5324 private: |
| 5399 LAllocate* instr_; | 5325 LAllocate* instr_; |
| 5400 }; | 5326 }; |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5870 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5796 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
| 5871 __ ldr(result, FieldMemOperand(scratch, | 5797 __ ldr(result, FieldMemOperand(scratch, |
| 5872 FixedArray::kHeaderSize - kPointerSize)); | 5798 FixedArray::kHeaderSize - kPointerSize)); |
| 5873 __ bind(&done); | 5799 __ bind(&done); |
| 5874 } | 5800 } |
| 5875 | 5801 |
| 5876 | 5802 |
| 5877 #undef __ | 5803 #undef __ |
| 5878 | 5804 |
| 5879 } } // namespace v8::internal | 5805 } } // namespace v8::internal |
| OLD | NEW |