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

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

Issue 9569008: MIPS: Implement inlined object allocation in Crankshaft. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | src/mips/lithium-mips.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 4225 matching lines...) Expand 10 before | Expand all | Expand 10 after
4236 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr) 4236 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
4237 : LDeferredCode(codegen), instr_(instr) { } 4237 : LDeferredCode(codegen), instr_(instr) { }
4238 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); } 4238 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
4239 virtual LInstruction* instr() { return instr_; } 4239 virtual LInstruction* instr() { return instr_; }
4240 private: 4240 private:
4241 LAllocateObject* instr_; 4241 LAllocateObject* instr_;
4242 }; 4242 };
4243 4243
4244 DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr); 4244 DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr);
4245 4245
4246 // TODO(mstarzinger): Implement inlined version instead of jumping to 4246 Register result = ToRegister(instr->result());
4247 // deferred runtime call. 4247 Register scratch = ToRegister(instr->TempAt(0));
4248 __ jmp(deferred->entry()); 4248 Register scratch2 = ToRegister(instr->TempAt(1));
4249 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
4250 Handle<Map> initial_map(constructor->initial_map());
4251 int instance_size = initial_map->instance_size();
4252 ASSERT(initial_map->pre_allocated_property_fields() +
4253 initial_map->unused_property_fields() -
4254 initial_map->inobject_properties() == 0);
4255
4256 // Allocate memory for the object. The initial map might change when
4257 // the constructor's prototype changes, but instance size and property
4258 // counts remain unchanged (if slack tracking finished).
4259 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress());
4260 __ AllocateInNewSpace(instance_size,
4261 result,
4262 scratch,
4263 scratch2,
4264 deferred->entry(),
4265 TAG_OBJECT);
4266
4267 // Load the initial map.
4268 Register map = scratch;
4269 __ LoadHeapObject(map, constructor);
4270 __ lw(map, FieldMemOperand(map, JSFunction::kPrototypeOrInitialMapOffset));
4271
4272 // Initialize map and fields of the newly allocated object.
4273 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
4274 __ sw(map, FieldMemOperand(result, JSObject::kMapOffset));
4275 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex);
4276 __ sw(scratch, FieldMemOperand(result, JSObject::kElementsOffset));
4277 __ sw(scratch, FieldMemOperand(result, JSObject::kPropertiesOffset));
4278 if (initial_map->inobject_properties() != 0) {
4279 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
4280 for (int i = 0; i < initial_map->inobject_properties(); i++) {
4281 int property_offset = JSObject::kHeaderSize + i * kPointerSize;
4282 __ sw(scratch, FieldMemOperand(result, property_offset));
4283 }
4284 }
4249 4285
4250 __ bind(deferred->exit()); 4286 __ bind(deferred->exit());
4251 } 4287 }
4252 4288
4253 4289
4254 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { 4290 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
4255 Register result = ToRegister(instr->result()); 4291 Register result = ToRegister(instr->result());
4256 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); 4292 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
4257 4293
4258 // TODO(3095996): Get rid of this. For now, we need to make the 4294 // TODO(3095996): Get rid of this. For now, we need to make the
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
4915 __ Subu(scratch, result, scratch); 4951 __ Subu(scratch, result, scratch);
4916 __ lw(result, FieldMemOperand(scratch, 4952 __ lw(result, FieldMemOperand(scratch,
4917 FixedArray::kHeaderSize - kPointerSize)); 4953 FixedArray::kHeaderSize - kPointerSize));
4918 __ bind(&done); 4954 __ bind(&done);
4919 } 4955 }
4920 4956
4921 4957
4922 #undef __ 4958 #undef __
4923 4959
4924 } } // namespace v8::internal 4960 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/mips/lithium-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698