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

Side by Side Diff: src/ia32/lithium-codegen-ia32.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/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 5989 matching lines...) Expand 10 before | Expand all | Expand 10 after
6000 6000
6001 if (!instr->hydrogen()->CanOmitPrototypeChecks()) { 6001 if (!instr->hydrogen()->CanOmitPrototypeChecks()) {
6002 for (int i = 0; i < prototypes->length(); i++) { 6002 for (int i = 0; i < prototypes->length(); i++) {
6003 __ LoadHeapObject(reg, prototypes->at(i)); 6003 __ LoadHeapObject(reg, prototypes->at(i));
6004 DoCheckMapCommon(reg, maps->at(i), instr); 6004 DoCheckMapCommon(reg, maps->at(i), instr);
6005 } 6005 }
6006 } 6006 }
6007 } 6007 }
6008 6008
6009 6009
6010 void LCodeGen::DoAllocateObject(LAllocateObject* instr) {
6011 class DeferredAllocateObject: public LDeferredCode {
6012 public:
6013 DeferredAllocateObject(LCodeGen* codegen, LAllocateObject* instr)
6014 : LDeferredCode(codegen), instr_(instr) { }
6015 virtual void Generate() { codegen()->DoDeferredAllocateObject(instr_); }
6016 virtual LInstruction* instr() { return instr_; }
6017 private:
6018 LAllocateObject* instr_;
6019 };
6020
6021 DeferredAllocateObject* deferred =
6022 new(zone()) DeferredAllocateObject(this, instr);
6023
6024 Register result = ToRegister(instr->result());
6025 Register scratch = ToRegister(instr->temp());
6026 Handle<JSFunction> constructor = instr->hydrogen()->constructor();
6027 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map();
6028 int instance_size = initial_map->instance_size();
6029 ASSERT(initial_map->pre_allocated_property_fields() +
6030 initial_map->unused_property_fields() -
6031 initial_map->inobject_properties() == 0);
6032
6033 __ Allocate(instance_size, result, no_reg, scratch, deferred->entry(),
6034 TAG_OBJECT);
6035
6036 __ bind(deferred->exit());
6037 if (FLAG_debug_code) {
6038 Label is_in_new_space;
6039 __ JumpIfInNewSpace(result, scratch, &is_in_new_space);
6040 __ Abort("Allocated object is not in new-space");
6041 __ bind(&is_in_new_space);
6042 }
6043
6044 // Load the initial map.
6045 Register map = scratch;
6046 __ LoadHeapObject(scratch, constructor);
6047 __ mov(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset));
6048
6049 if (FLAG_debug_code) {
6050 __ AssertNotSmi(map);
6051 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset),
6052 instance_size >> kPointerSizeLog2);
6053 __ Assert(equal, "Unexpected instance size");
6054 __ cmpb(FieldOperand(map, Map::kPreAllocatedPropertyFieldsOffset),
6055 initial_map->pre_allocated_property_fields());
6056 __ Assert(equal, "Unexpected pre-allocated property fields count");
6057 __ cmpb(FieldOperand(map, Map::kUnusedPropertyFieldsOffset),
6058 initial_map->unused_property_fields());
6059 __ Assert(equal, "Unexpected unused property fields count");
6060 __ cmpb(FieldOperand(map, Map::kInObjectPropertiesOffset),
6061 initial_map->inobject_properties());
6062 __ Assert(equal, "Unexpected in-object property fields count");
6063 }
6064
6065 // Initialize map and fields of the newly allocated object.
6066 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
6067 __ mov(FieldOperand(result, JSObject::kMapOffset), map);
6068 __ mov(scratch, factory()->empty_fixed_array());
6069 __ mov(FieldOperand(result, JSObject::kElementsOffset), scratch);
6070 __ mov(FieldOperand(result, JSObject::kPropertiesOffset), scratch);
6071 if (initial_map->inobject_properties() != 0) {
6072 __ mov(scratch, factory()->undefined_value());
6073 for (int i = 0; i < initial_map->inobject_properties(); i++) {
6074 int property_offset = JSObject::kHeaderSize + i * kPointerSize;
6075 __ mov(FieldOperand(result, property_offset), scratch);
6076 }
6077 }
6078 }
6079
6080
6081 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) {
6082 Register result = ToRegister(instr->result());
6083 Handle<Map> initial_map = instr->hydrogen()->constructor_initial_map();
6084 int instance_size = initial_map->instance_size();
6085
6086 // TODO(3095996): Get rid of this. For now, we need to make the
6087 // result register contain a valid pointer because it is already
6088 // contained in the register pointer map.
6089 __ Set(result, Immediate(0));
6090
6091 PushSafepointRegistersScope scope(this);
6092 __ push(Immediate(Smi::FromInt(instance_size)));
6093 CallRuntimeFromDeferred(
6094 Runtime::kAllocateInNewSpace, 1, instr, instr->context());
6095 __ StoreToSafepointRegisterSlot(result, eax);
6096 }
6097
6098
6099 void LCodeGen::DoAllocate(LAllocate* instr) { 6010 void LCodeGen::DoAllocate(LAllocate* instr) {
6100 class DeferredAllocate: public LDeferredCode { 6011 class DeferredAllocate: public LDeferredCode {
6101 public: 6012 public:
6102 DeferredAllocate(LCodeGen* codegen, LAllocate* instr) 6013 DeferredAllocate(LCodeGen* codegen, LAllocate* instr)
6103 : LDeferredCode(codegen), instr_(instr) { } 6014 : LDeferredCode(codegen), instr_(instr) { }
6104 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } 6015 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); }
6105 virtual LInstruction* instr() { return instr_; } 6016 virtual LInstruction* instr() { return instr_; }
6106 private: 6017 private:
6107 LAllocate* instr_; 6018 LAllocate* instr_;
6108 }; 6019 };
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
6572 FixedArray::kHeaderSize - kPointerSize)); 6483 FixedArray::kHeaderSize - kPointerSize));
6573 __ bind(&done); 6484 __ bind(&done);
6574 } 6485 }
6575 6486
6576 6487
6577 #undef __ 6488 #undef __
6578 6489
6579 } } // namespace v8::internal 6490 } } // namespace v8::internal
6580 6491
6581 #endif // V8_TARGET_ARCH_IA32 6492 #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