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

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

Issue 15714005: Deprecate HAllocateObject in favor of HAllocate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed moar comments by Hannes Payer. Created 7 years, 6 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-codegen-ia32.h ('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 5981 matching lines...) Expand 10 before | Expand all | Expand 10 after
5992 } 5992 }
5993 } else { 5993 } else {
5994 for (int i = 0; i < prototypes->length(); i++) { 5994 for (int i = 0; i < prototypes->length(); i++) {
5995 __ LoadHeapObject(reg, prototypes->at(i)); 5995 __ LoadHeapObject(reg, prototypes->at(i));
5996 DoCheckMapCommon(reg, maps->at(i), instr); 5996 DoCheckMapCommon(reg, maps->at(i), instr);
5997 } 5997 }
5998 } 5998 }
5999 } 5999 }
6000 6000
6001 6001
6002 void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
6003 class DeferredAllocateObject: public LDeferredCode {
6004 public:
6005 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
6006 : LDeferredCode(codegen), instr_(instr) { }
6007 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
6008 virtual LInstruction* instr() { return instr_; }
6009 private:
6010 LAllocateObject* instr_;
6011 };
6012
6013 DeferredAllocateObject* deferred =
6014 new(zone()) DeferredAllocateObject(this, instr);
6015
6016 Register result = ToRegister(instr->result());
6017 Register scratch = ToRegister(instr->temp());
6018 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
6019 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map();
6020 int instance_size = initial_map->instance_size();
6021 ASSERT(initial_map->pre_allocated_property_fields() +
6022 initial_map->unused_property_fields() -
6023 initial_map->inobject_properties() == 0);
6024
6025 __ Allocate(instance_size, result, no_reg, scratch, deferred->entry(),
6026 TAG_OBJECT);
6027
6028 __ bind(deferred->exit());
6029 if (FLAG_debug_code) {
6030 Label is_in_new_space;
6031 __ JumpIfInNewSpace(result, scratch, &is_in_new_space);
6032 __ Abort("Allocated object is not in new-space");
6033 __ bind(&is_in_new_space);
6034 }
6035
6036 // Load the initial map.
6037 Register map = scratch;
6038 __ LoadHeapObject(scratch, constructor);
6039 __ mov(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset));
6040
6041 if (FLAG_debug_code) {
6042 __ AssertNotSmi(map);
6043 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset),
6044 instance_size >> kPointerSizeLog2);
6045 __ Assert(equal, "Unexpected instance size");
6046 __ cmpb(FieldOperand(map, Map::kPreAllocatedPropertyFieldsOffset),
6047 initial_map->pre_allocated_property_fields());
6048 __ Assert(equal, "Unexpected pre-allocated property fields count");
6049 __ cmpb(FieldOperand(map, Map::kUnusedPropertyFieldsOffset),
6050 initial_map->unused_property_fields());
6051 __ Assert(equal, "Unexpected unused property fields count");
6052 __ cmpb(FieldOperand(map, Map::kInObjectPropertiesOffset),
6053 initial_map->inobject_properties());
6054 __ Assert(equal, "Unexpected in-object property fields count");
6055 }
6056
6057 // Initialize map and fields of the newly allocated object.
6058 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
6059 __ mov(FieldOperand(result, JSObject::kMapOffset), map);
6060 __ mov(scratch, factory()->empty_fixed_array());
6061 __ mov(FieldOperand(result, JSObject::kElementsOffset), scratch);
6062 __ mov(FieldOperand(result, JSObject::kPropertiesOffset), scratch);
6063 if (initial_map->inobject_properties() != 0) {
6064 __ mov(scratch, factory()->undefined_value());
6065 for (int i = 0; i < initial_map->inobject_properties(); i++) {
6066 int property_offset = JSObject::kHeaderSize + i * kPointerSize;
6067 __ mov(FieldOperand(result, property_offset), scratch);
6068 }
6069 }
6070 }
6071
6072
6073 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
6074 Register result = ToRegister(instr->result());
6075 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map();
6076 int instance_size = initial_map->instance_size();
6077
6078 // TODO(3095996): Get rid of this. For now, we need to make the
6079 // result register contain a valid pointer because it is already
6080 // contained in the register pointer map.
6081 __ Set(result, Immediate(0));
6082
6083 PushSafepointRegistersScope scope(this);
6084 __ push(Immediate(Smi::FromInt(instance_size)));
6085 CallRuntimeFromDeferred(
6086 Runtime::kAllocateInNewSpace, 1, instr, instr->context());
6087 __ StoreToSafepointRegisterSlot(result, eax);
6088 }
6089
6090
6091 void LCodeGen::DoAllocate(LAllocate* instr) { 6002 void LCodeGen::DoAllocate(LAllocate* instr) {
6092 class DeferredAllocate: public LDeferredCode { 6003 class DeferredAllocate: public LDeferredCode {
6093 public: 6004 public:
6094 DeferredAllocate(LCodeGen* codegen, LAllocate* instr) 6005 DeferredAllocate(LCodeGen* codegen, LAllocate* instr)
6095 : LDeferredCode(codegen), instr_(instr) { } 6006 : LDeferredCode(codegen), instr_(instr) { }
6096 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } 6007 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); }
6097 virtual LInstruction* instr() { return instr_; } 6008 virtual LInstruction* instr() { return instr_; }
6098 private: 6009 private:
6099 LAllocate* instr_; 6010 LAllocate* instr_;
6100 }; 6011 };
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
6601 FixedArray::kHeaderSize - kPointerSize)); 6512 FixedArray::kHeaderSize - kPointerSize));
6602 __ bind(&done); 6513 __ bind(&done);
6603 } 6514 }
6604 6515
6605 6516
6606 #undef __ 6517 #undef __
6607 6518
6608 } } // namespace v8::internal 6519 } } // namespace v8::internal
6609 6520
6610 #endif // V8_TARGET_ARCH_IA32 6521 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698