HInnerAllocatedObject instruction allows hydrogen code to carve up

allocated regions into sub objects.

BUG=

Review URL: https://codereview.chromium.org/12812002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13928 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9bfc8e21
......@@ -290,6 +290,13 @@ void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
}
void LInnerAllocatedObject::PrintDataTo(StringStream* stream) {
stream->Add(" = ");
base_object()->PrintTo(stream);
stream->Add(" + %d", offset());
}
void LCallConstantFunction::PrintDataTo(StringStream* stream) {
stream->Add("#%d / ", arity());
}
......@@ -1017,6 +1024,15 @@ LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
}
LInstruction* LChunkBuilder::DoInnerAllocatedObject(
HInnerAllocatedObject* inner_object) {
LOperand* base_object = UseRegisterAtStart(inner_object->base_object());
LInnerAllocatedObject* result =
new(zone()) LInnerAllocatedObject(base_object);
return DefineAsRegister(result);
}
LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
return instr->HasNoUses()
? NULL
......
......@@ -191,7 +191,8 @@ class LCodeGen;
V(LoadFieldByIndex) \
V(DateField) \
V(WrapReceiver) \
V(Drop)
V(Drop) \
V(InnerAllocatedObject)
#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
......@@ -1655,6 +1656,22 @@ class LDrop: public LTemplateInstruction<0, 0, 0> {
};
class LInnerAllocatedObject: public LTemplateInstruction<1, 1, 0> {
public:
explicit LInnerAllocatedObject(LOperand* base_object) {
inputs_[0] = base_object;
}
LOperand* base_object() { return inputs_[0]; }
int offset() { return hydrogen()->offset(); }
virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
};
class LThisFunction: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
......
......@@ -4341,6 +4341,13 @@ void LCodeGen::DoCallRuntime(LCallRuntime* instr) {
}
void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) {
Register result = ToRegister(instr->result());
Register base = ToRegister(instr->base_object());
__ add(result, base, Operand(instr->offset()));
}
void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
Register object = ToRegister(instr->object());
Register value = ToRegister(instr->value());
......
......@@ -2514,6 +2514,12 @@ void HLoadGlobalGeneric::PrintDataTo(StringStream* stream) {
}
void HInnerAllocatedObject::PrintDataTo(StringStream* stream) {
base_object()->PrintNameTo(stream);
stream->Add(" offset %d", offset());
}
void HStoreGlobalCell::PrintDataTo(StringStream* stream) {
stream->Add("[%p] = ", *cell());
value()->PrintNameTo(stream);
......
......@@ -122,6 +122,7 @@ class LChunkBuilder;
V(HasInstanceTypeAndBranch) \
V(InductionVariableAnnotation) \
V(In) \
V(InnerAllocatedObject) \
V(InstanceOf) \
V(InstanceOfKnownGlobal) \
V(InstanceSize) \
......@@ -4684,6 +4685,31 @@ class HAllocate: public HTemplateInstruction<2> {
};
class HInnerAllocatedObject: public HTemplateInstruction<1> {
public:
HInnerAllocatedObject(HValue* value, int offset)
: offset_(offset) {
ASSERT(value->IsAllocate());
SetOperandAt(0, value);
set_representation(Representation::Tagged());
}
HValue* base_object() { return OperandAt(0); }
int offset() { return offset_; }
virtual Representation RequiredInputRepresentation(int index) {
return Representation::Tagged();
}
virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
private:
int offset_;
};
inline bool StoringValueNeedsWriteBarrier(HValue* value) {
return !value->type().IsBoolean()
&& !value->type().IsSmi()
......@@ -4693,6 +4719,11 @@ inline bool StoringValueNeedsWriteBarrier(HValue* value) {
inline bool ReceiverObjectNeedsWriteBarrier(HValue* object,
HValue* new_space_dominator) {
if (object->IsInnerAllocatedObject()) {
return ReceiverObjectNeedsWriteBarrier(
HInnerAllocatedObject::cast(object)->base_object(),
new_space_dominator);
}
if (object != new_space_dominator) return true;
if (object->IsFastLiteral()) return false;
if (object->IsAllocateObject()) return false;
......
......@@ -4195,6 +4195,13 @@ void LCodeGen::DoCallRuntime(LCallRuntime* instr) {
}
void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) {
Register result = ToRegister(instr->result());
Register base = ToRegister(instr->base_object());
__ lea(result, Operand(base, instr->offset()));
}
void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
Register object = ToRegister(instr->object());
Register value = ToRegister(instr->value());
......
......@@ -292,6 +292,13 @@ void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
}
void LInnerAllocatedObject::PrintDataTo(StringStream* stream) {
stream->Add(" = ");
base_object()->PrintTo(stream);
stream->Add(" + %d", offset());
}
void LCallConstantFunction::PrintDataTo(StringStream* stream) {
stream->Add("#%d / ", arity());
}
......@@ -1081,6 +1088,15 @@ LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
}
LInstruction* LChunkBuilder::DoInnerAllocatedObject(
HInnerAllocatedObject* inner_object) {
LOperand* base_object = UseRegisterAtStart(inner_object->base_object());
LInnerAllocatedObject* result =
new(zone()) LInnerAllocatedObject(base_object);
return DefineAsRegister(result);
}
LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
return instr->HasNoUses()
? NULL
......
......@@ -184,7 +184,8 @@ class LCodeGen;
V(LoadFieldByIndex) \
V(DateField) \
V(WrapReceiver) \
V(Drop)
V(Drop) \
V(InnerAllocatedObject)
#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
......@@ -1681,6 +1682,22 @@ class LDrop: public LTemplateInstruction<0, 0, 0> {
};
class LInnerAllocatedObject: public LTemplateInstruction<1, 1, 0> {
public:
explicit LInnerAllocatedObject(LOperand* base_object) {
inputs_[0] = base_object;
}
LOperand* base_object() { return inputs_[0]; }
int offset() { return hydrogen()->offset(); }
virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
};
class LThisFunction: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
......
......@@ -3949,6 +3949,13 @@ void LCodeGen::DoCallRuntime(LCallRuntime* instr) {
}
void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) {
Register result = ToRegister(instr->result());
Register base = ToRegister(instr->base_object());
__ lea(result, Operand(base, instr->offset()));
}
void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
Register object = ToRegister(instr->object());
Register value = ToRegister(instr->value());
......
......@@ -292,6 +292,13 @@ void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
}
void LInnerAllocatedObject::PrintDataTo(StringStream* stream) {
stream->Add(" = ");
base_object()->PrintTo(stream);
stream->Add(" + %d", offset());
}
void LCallConstantFunction::PrintDataTo(StringStream* stream) {
stream->Add("#%d / ", arity());
}
......@@ -1024,6 +1031,15 @@ LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
}
LInstruction* LChunkBuilder::DoInnerAllocatedObject(
HInnerAllocatedObject* inner_object) {
LOperand* base_object = UseRegisterAtStart(inner_object->base_object());
LInnerAllocatedObject* result =
new(zone()) LInnerAllocatedObject(base_object);
return DefineAsRegister(result);
}
LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
return instr->HasNoUses()
? NULL
......
......@@ -188,7 +188,8 @@ class LCodeGen;
V(LoadFieldByIndex) \
V(DateField) \
V(WrapReceiver) \
V(Drop)
V(Drop) \
V(InnerAllocatedObject)
#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
......@@ -1594,6 +1595,22 @@ class LDrop: public LTemplateInstruction<0, 0, 0> {
};
class LInnerAllocatedObject: public LTemplateInstruction<1, 1, 0> {
public:
explicit LInnerAllocatedObject(LOperand* base_object) {
inputs_[0] = base_object;
}
LOperand* base_object() { return inputs_[0]; }
int offset() { return hydrogen()->offset(); }
virtual void PrintDataTo(StringStream* stream);
DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object")
DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject)
};
class LThisFunction: public LTemplateInstruction<1, 0, 0> {
public:
DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment