Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 19207002: Reland deprecation of HAllocateObject in favor of HAllocate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5014 matching lines...) Expand 10 before | Expand all | Expand 10 after
5025 5025
5026 if (!instr->hydrogen()->CanOmitPrototypeChecks()) { 5026 if (!instr->hydrogen()->CanOmitPrototypeChecks()) {
5027 for (int i = 0; i < prototypes->length(); i++) { 5027 for (int i = 0; i < prototypes->length(); i++) {
5028 __ LoadHeapObject(reg, prototypes->at(i)); 5028 __ LoadHeapObject(reg, prototypes->at(i));
5029 DoCheckMapCommon(reg, maps->at(i), instr); 5029 DoCheckMapCommon(reg, maps->at(i), instr);
5030 } 5030 }
5031 } 5031 }
5032 } 5032 }
5033 5033
5034 5034
5035 void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
5036 class DeferredAllocateObject: public LDeferredCode {
5037 public:
5038 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
5039 : LDeferredCode(codegen), instr_(instr) { }
5040 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
5041 virtual LInstruction* instr() { return instr_; }
5042 private:
5043 LAllocateObject* instr_;
5044 };
5045
5046 DeferredAllocateObject* deferred =
5047 new(zone()) DeferredAllocateObject(this, instr);
5048
5049 Register result = ToRegister(instr->result());
5050 Register scratch = ToRegister(instr->temp());
5051 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
5052 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map();
5053 int instance_size = initial_map->instance_size();
5054 ASSERT(initial_map->pre_allocated_property_fields() +
5055 initial_map->unused_property_fields() -
5056 initial_map->inobject_properties() == 0);
5057
5058 __ Allocate(instance_size, result, no_reg, scratch, deferred->entry(),
5059 TAG_OBJECT);
5060
5061 __ bind(deferred->exit());
5062 if (FLAG_debug_code) {
5063 Label is_in_new_space;
5064 __ JumpIfInNewSpace(result, scratch, &is_in_new_space);
5065 __ Abort("Allocated object is not in new-space");
5066 __ bind(&is_in_new_space);
5067 }
5068
5069 // Load the initial map.
5070 Register map = scratch;
5071 __ LoadHeapObject(scratch, constructor);
5072 __ movq(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset));
5073
5074 if (FLAG_debug_code) {
5075 __ AssertNotSmi(map);
5076 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset),
5077 Immediate(instance_size >> kPointerSizeLog2));
5078 __ Assert(equal, "Unexpected instance size");
5079 __ cmpb(FieldOperand(map, Map::kPreAllocatedPropertyFieldsOffset),
5080 Immediate(initial_map->pre_allocated_property_fields()));
5081 __ Assert(equal, "Unexpected pre-allocated property fields count");
5082 __ cmpb(FieldOperand(map, Map::kUnusedPropertyFieldsOffset),
5083 Immediate(initial_map->unused_property_fields()));
5084 __ Assert(equal, "Unexpected unused property fields count");
5085 __ cmpb(FieldOperand(map, Map::kInObjectPropertiesOffset),
5086 Immediate(initial_map->inobject_properties()));
5087 __ Assert(equal, "Unexpected in-object property fields count");
5088 }
5089
5090 // Initialize map and fields of the newly allocated object.
5091 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
5092 __ movq(FieldOperand(result, JSObject::kMapOffset), map);
5093 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex);
5094 __ movq(FieldOperand(result, JSObject::kElementsOffset), scratch);
5095 __ movq(FieldOperand(result, JSObject::kPropertiesOffset), scratch);
5096 if (initial_map->inobject_properties() != 0) {
5097 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
5098 for (int i = 0; i < initial_map->inobject_properties(); i++) {
5099 int property_offset = JSObject::kHeaderSize + i * kPointerSize;
5100 __ movq(FieldOperand(result, property_offset), scratch);
5101 }
5102 }
5103 }
5104
5105
5106 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
5107 Register result = ToRegister(instr->result());
5108 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map();
5109 int instance_size = initial_map->instance_size();
5110
5111 // TODO(3095996): Get rid of this. For now, we need to make the
5112 // result register contain a valid pointer because it is already
5113 // contained in the register pointer map.
5114 __ Set(result, 0);
5115
5116 PushSafepointRegistersScope scope(this);
5117 __ Push(Smi::FromInt(instance_size));
5118 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr);
5119 __ StoreToSafepointRegisterSlot(result, rax);
5120 }
5121
5122
5123 void LCodeGen::DoAllocate(LAllocate* instr) { 5035 void LCodeGen::DoAllocate(LAllocate* instr) {
5124 class DeferredAllocate: public LDeferredCode { 5036 class DeferredAllocate: public LDeferredCode {
5125 public: 5037 public:
5126 DeferredAllocate(LCodeGen* codegen, LAllocate* instr) 5038 DeferredAllocate(LCodeGen* codegen, LAllocate* instr)
5127 : LDeferredCode(codegen), instr_(instr) { } 5039 : LDeferredCode(codegen), instr_(instr) { }
5128 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } 5040 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); }
5129 virtual LInstruction* instr() { return instr_; } 5041 virtual LInstruction* instr() { return instr_; }
5130 private: 5042 private:
5131 LAllocate* instr_; 5043 LAllocate* instr_;
5132 }; 5044 };
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
5604 FixedArray::kHeaderSize - kPointerSize)); 5516 FixedArray::kHeaderSize - kPointerSize));
5605 __ bind(&done); 5517 __ bind(&done);
5606 } 5518 }
5607 5519
5608 5520
5609 #undef __ 5521 #undef __
5610 5522
5611 } } // namespace v8::internal 5523 } } // namespace v8::internal
5612 5524
5613 #endif // V8_TARGET_ARCH_X64 5525 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.h ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698