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

Side by Side Diff: src/x64/lithium-codegen-x64.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/ia32/lithium-ia32.cc ('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 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 3928 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr) 3939 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
3940 : LDeferredCode(codegen), instr_(instr) { } 3940 : LDeferredCode(codegen), instr_(instr) { }
3941 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); } 3941 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
3942 virtual LInstruction* instr() { return instr_; } 3942 virtual LInstruction* instr() { return instr_; }
3943 private: 3943 private:
3944 LAllocateObject* instr_; 3944 LAllocateObject* instr_;
3945 }; 3945 };
3946 3946
3947 DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr); 3947 DeferredAllocateObject* deferred = new DeferredAllocateObject(this, instr);
3948 3948
3949 // TODO(mstarzinger): Implement inlined version instead of jumping to 3949 Register result = ToRegister(instr->result());
3950 // deferred runtime call. 3950 Register scratch = ToRegister(instr->TempAt(0));
3951 __ jmp(deferred->entry()); 3951 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
3952 Handle<Map> initial_map(constructor->initial_map());
3953 int instance_size = initial_map->instance_size();
3954 ASSERT(initial_map->pre_allocated_property_fields() +
3955 initial_map->unused_property_fields() -
3956 initial_map->inobject_properties() == 0);
3957
3958 // Allocate memory for the object. The initial map might change when
3959 // the constructor's prototype changes, but instance size and property
3960 // counts remain unchanged (if slack tracking finished).
3961 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress());
3962 __ AllocateInNewSpace(instance_size,
3963 result,
3964 no_reg,
3965 scratch,
3966 deferred->entry(),
3967 TAG_OBJECT);
3968
3969 // Load the initial map.
3970 Register map = scratch;
3971 __ LoadHeapObject(scratch, constructor);
3972 __ movq(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset));
3973
3974 if (FLAG_debug_code) {
3975 __ AbortIfSmi(map);
3976 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset),
3977 Immediate(instance_size >> kPointerSizeLog2));
3978 __ Assert(equal, "Unexpected instance size");
3979 __ cmpb(FieldOperand(map, Map::kPreAllocatedPropertyFieldsOffset),
3980 Immediate(initial_map->pre_allocated_property_fields()));
3981 __ Assert(equal, "Unexpected pre-allocated property fields count");
3982 __ cmpb(FieldOperand(map, Map::kUnusedPropertyFieldsOffset),
3983 Immediate(initial_map->unused_property_fields()));
3984 __ Assert(equal, "Unexpected unused property fields count");
3985 __ cmpb(FieldOperand(map, Map::kInObjectPropertiesOffset),
3986 Immediate(initial_map->inobject_properties()));
3987 __ Assert(equal, "Unexpected in-object property fields count");
3988 }
3989
3990 // Initialize map and fields of the newly allocated object.
3991 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
3992 __ movq(FieldOperand(result, JSObject::kMapOffset), map);
3993 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex);
3994 __ movq(FieldOperand(result, JSObject::kElementsOffset), scratch);
3995 __ movq(FieldOperand(result, JSObject::kPropertiesOffset), scratch);
3996 if (initial_map->inobject_properties() != 0) {
3997 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
3998 for (int i = 0; i < initial_map->inobject_properties(); i++) {
3999 int property_offset = JSObject::kHeaderSize + i * kPointerSize;
4000 __ movq(FieldOperand(result, property_offset), scratch);
4001 }
4002 }
3952 4003
3953 __ bind(deferred->exit()); 4004 __ bind(deferred->exit());
3954 } 4005 }
3955 4006
3956 4007
3957 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { 4008 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
3958 Register result = ToRegister(instr->result()); 4009 Register result = ToRegister(instr->result());
3959 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); 4010 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
3960 4011
3961 // TODO(3095996): Get rid of this. For now, we need to make the 4012 // TODO(3095996): Get rid of this. For now, we need to make the
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
4586 FixedArray::kHeaderSize - kPointerSize)); 4637 FixedArray::kHeaderSize - kPointerSize));
4587 __ bind(&done); 4638 __ bind(&done);
4588 } 4639 }
4589 4640
4590 4641
4591 #undef __ 4642 #undef __
4592 4643
4593 } } // namespace v8::internal 4644 } } // namespace v8::internal
4594 4645
4595 #endif // V8_TARGET_ARCH_X64 4646 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/x64/lithium-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698