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

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

Issue 9370019: Implement inlined object allocation in Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Vyacheslav Egorov. Created 8 years, 9 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/hydrogen.cc ('k') | src/ia32/lithium-ia32.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 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 4197 matching lines...) Expand 10 before | Expand all | Expand 10 after
4208 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr) 4208 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
4209 : LDeferredCode(codegen), instr_(instr) { } 4209 : LDeferredCode(codegen), instr_(instr) { }
4210 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); } 4210 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
4211 virtual LInstruction* instr() { return instr_; } 4211 virtual LInstruction* instr() { return instr_; }
4212 private: 4212 private:
4213 LAllocateObject* instr_; 4213 LAllocateObject* instr_;
4214 }; 4214 };
4215 4215
4216 DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr); 4216 DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr);
4217 4217
4218 // TODO(mstarzinger): Implement inlined version instead of jumping to 4218 Register result = ToRegister(instr->result());
4219 // deferred runtime call. 4219 Register scratch = ToRegister(instr->TempAt(0));
4220 __ jmp(deferred->entry()); 4220 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
4221 Handle<Map> initial_map(constructor->initial_map());
4222 int instance_size = initial_map->instance_size();
4223 ASSERT(initial_map->pre_allocated_property_fields() +
4224 initial_map->unused_property_fields() -
4225 initial_map->inobject_properties() == 0);
4226
4227 // Allocate memory for the object. The initial map might change when
4228 // the constructor's prototype changes, but instance size and property
4229 // counts remain unchanged (if slack tracking finished).
4230 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress());
4231 __ AllocateInNewSpace(instance_size,
4232 result,
4233 no_reg,
4234 scratch,
4235 deferred->entry(),
4236 TAG_OBJECT);
4237
4238 // Load the initial map.
4239 Register map = scratch;
4240 __ LoadHeapObject(scratch, constructor);
4241 __ mov(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset));
4242
4243 if (FLAG_debug_code) {
4244 __ AbortIfSmi(map);
4245 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset),
4246 instance_size >> kPointerSizeLog2);
4247 __ Assert(equal, "Unexpected instance size");
4248 __ cmpb(FieldOperand(map, Map::kPreAllocatedPropertyFieldsOffset),
4249 initial_map->pre_allocated_property_fields());
4250 __ Assert(equal, "Unexpected pre-allocated property fields count");
4251 __ cmpb(FieldOperand(map, Map::kUnusedPropertyFieldsOffset),
4252 initial_map->unused_property_fields());
4253 __ Assert(equal, "Unexpected unused property fields count");
4254 __ cmpb(FieldOperand(map, Map::kInObjectPropertiesOffset),
4255 initial_map->inobject_properties());
4256 __ Assert(equal, "Unexpected in-object property fields count");
4257 }
4258
4259 // Initialize map and fields of the newly allocated object.
4260 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
4261 __ mov(FieldOperand(result, JSObject::kMapOffset), map);
4262 __ mov(scratch, factory()->empty_fixed_array());
4263 __ mov(FieldOperand(result, JSObject::kElementsOffset), scratch);
4264 __ mov(FieldOperand(result, JSObject::kPropertiesOffset), scratch);
4265 if (initial_map->inobject_properties() != 0) {
4266 __ mov(scratch, factory()->undefined_value());
4267 for (int i = 0; i < initial_map->inobject_properties(); i++) {
4268 int property_offset = JSObject::kHeaderSize + i * kPointerSize;
4269 __ mov(FieldOperand(result, property_offset), scratch);
4270 }
4271 }
4221 4272
4222 __ bind(deferred->exit()); 4273 __ bind(deferred->exit());
4223 } 4274 }
4224 4275
4225 4276
4226 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { 4277 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
4227 Register result = ToRegister(instr->result()); 4278 Register result = ToRegister(instr->result());
4228 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); 4279 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
4229 4280
4230 // TODO(3095996): Get rid of this. For now, we need to make the 4281 // TODO(3095996): Get rid of this. For now, we need to make the
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
4850 FixedArray::kHeaderSize - kPointerSize)); 4901 FixedArray::kHeaderSize - kPointerSize));
4851 __ bind(&done); 4902 __ bind(&done);
4852 } 4903 }
4853 4904
4854 4905
4855 #undef __ 4906 #undef __
4856 4907
4857 } } // namespace v8::internal 4908 } } // namespace v8::internal
4858 4909
4859 #endif // V8_TARGET_ARCH_IA32 4910 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698