Commit 5aaf1487 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Load constants from the DescriptorArray

BUG=
R=jkummerow@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22899 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0fb57e51
......@@ -841,14 +841,6 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
}
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, FieldIndex field, Representation representation) {
if (!reg.is(receiver())) __ mov(receiver(), reg);
LoadFieldStub stub(isolate(), field);
GenerateTailCall(masm(), stub.GetCode());
}
void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
// Return the constant value.
__ Move(r0, value);
......
......@@ -797,21 +797,6 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
}
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, FieldIndex field, Representation representation) {
__ Mov(receiver(), reg);
LoadFieldStub stub(isolate(), field);
GenerateTailCall(masm(), stub.GetCode());
}
void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
// Return the constant value.
__ LoadObject(x0, value);
__ Ret();
}
void NamedLoadHandlerCompiler::GenerateLoadCallback(
Register reg, Handle<ExecutableAccessorInfo> callback) {
DCHECK(!AreAliased(scratch2(), scratch3(), scratch4(), reg));
......
......@@ -590,7 +590,24 @@ Handle<Code> LoadFieldStub::GenerateCode() {
}
template<>
template <>
HValue* CodeStubGraphBuilder<LoadConstantStub>::BuildCodeStub() {
HValue* map = AddLoadMap(GetParameter(0), NULL);
HObjectAccess descriptors_access = HObjectAccess::ForObservableJSObjectOffset(
Map::kDescriptorsOffset, Representation::Tagged());
HValue* descriptors =
Add<HLoadNamedField>(map, static_cast<HValue*>(NULL), descriptors_access);
HObjectAccess value_access = HObjectAccess::ForObservableJSObjectOffset(
DescriptorArray::GetValueOffset(casted_stub()->descriptor()));
return Add<HLoadNamedField>(descriptors, static_cast<HValue*>(NULL),
value_access);
}
Handle<Code> LoadConstantStub::GenerateCode() { return DoGenerateCode(this); }
template <>
HValue* CodeStubGraphBuilder<StringLengthStub>::BuildCodeStub() {
HValue* string = BuildLoadNamedField(GetParameter(0),
FieldIndex::ForInObjectOffset(JSValue::kValueOffset));
......
......@@ -613,20 +613,20 @@ void KeyedLoadGenericStub::InitializeInterfaceDescriptor(
}
void LoadFieldStub::InitializeInterfaceDescriptor(
void HandlerStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { InterfaceDescriptor::ContextRegister(),
LoadIC::ReceiverRegister() };
descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
}
void StringLengthStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { InterfaceDescriptor::ContextRegister(),
LoadIC::ReceiverRegister(),
LoadIC::NameRegister() };
descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
if (kind() == Code::LOAD_IC) {
Register registers[] = {InterfaceDescriptor::ContextRegister(),
LoadIC::ReceiverRegister(), LoadIC::NameRegister()};
descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers);
} else {
DCHECK_EQ(Code::STORE_IC, kind());
Register registers[] = {InterfaceDescriptor::ContextRegister(),
StoreIC::ReceiverRegister(),
StoreIC::NameRegister(), StoreIC::ValueRegister()};
descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
FUNCTION_ADDR(StoreIC_MissFromStubFailure));
}
}
......@@ -653,17 +653,6 @@ void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor(
}
void StoreGlobalStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { InterfaceDescriptor::ContextRegister(),
StoreIC::ReceiverRegister(),
StoreIC::NameRegister(),
StoreIC::ValueRegister() };
descriptor->Initialize(MajorKey(), ARRAY_SIZE(registers), registers,
FUNCTION_ADDR(StoreIC_MissFromStubFailure));
}
void InstanceofStub::InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) {
Register registers[] = { InterfaceDescriptor::ContextRegister(),
......
......@@ -76,6 +76,7 @@ namespace internal {
V(CallApiGetter) \
/* IC Handler stubs */ \
V(LoadField) \
V(LoadConstant) \
V(StringLength)
// List of code stubs only used on ARM 32 bits platforms.
......@@ -903,6 +904,9 @@ class HandlerStub : public HydrogenCodeStub {
virtual ExtraICState GetExtraICState() const { return kind(); }
virtual InlineCacheState GetICState() { return MONOMORPHIC; }
virtual void InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
protected:
explicit HandlerStub(Isolate* isolate)
: HydrogenCodeStub(isolate), bit_field_(0) {}
......@@ -922,9 +926,6 @@ class LoadFieldStub: public HandlerStub {
virtual Handle<Code> GenerateCode() V8_OVERRIDE;
virtual void InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
Representation representation() {
if (unboxed_double()) return Representation::Double();
return Representation::Tagged();
......@@ -945,12 +946,30 @@ class LoadFieldStub: public HandlerStub {
};
class LoadConstantStub : public HandlerStub {
public:
LoadConstantStub(Isolate* isolate, int descriptor) : HandlerStub(isolate) {
bit_field_ = descriptor;
}
virtual Handle<Code> GenerateCode() V8_OVERRIDE;
int descriptor() const { return bit_field_; }
protected:
explicit LoadConstantStub(Isolate* isolate);
virtual Code::Kind kind() const { return Code::LOAD_IC; }
virtual Code::StubType GetStubType() { return Code::FAST; }
private:
virtual CodeStub::Major MajorKey() const { return LoadConstant; }
};
class StringLengthStub: public HandlerStub {
public:
explicit StringLengthStub(Isolate* isolate) : HandlerStub(isolate) {}
virtual Handle<Code> GenerateCode() V8_OVERRIDE;
virtual void InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
protected:
virtual Code::Kind kind() const { return Code::LOAD_IC; }
......@@ -992,9 +1011,6 @@ class StoreGlobalStub : public HandlerStub {
virtual Handle<Code> GenerateCode() V8_OVERRIDE;
virtual void InitializeInterfaceDescriptor(
CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
bool is_constant() const {
return IsConstantBits::decode(bit_field_);
}
......
......@@ -810,14 +810,6 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
}
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, FieldIndex field, Representation representation) {
if (!reg.is(receiver())) __ mov(receiver(), reg);
LoadFieldStub stub(isolate(), field);
GenerateTailCall(masm(), stub.GetCode());
}
void NamedLoadHandlerCompiler::GenerateLoadCallback(
Register reg, Handle<ExecutableAccessorInfo> callback) {
// Insert additional parameters into the stack frame above return address.
......
......@@ -1089,13 +1089,16 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
if (receiver_is_holder) {
return SimpleFieldLoad(field);
}
return compiler.CompileLoadField(name, field, lookup->representation());
return compiler.CompileLoadField(name, field);
}
// -------------- Constant properties --------------
DCHECK(lookup->property_details().type() == CONSTANT);
Handle<Object> constant = lookup->GetDataValue();
return compiler.CompileLoadConstant(name, constant);
if (receiver_is_holder) {
LoadConstantStub stub(isolate(), lookup->GetConstantIndex());
return stub.GetCode();
}
return compiler.CompileLoadConstant(name, lookup->GetConstantIndex());
}
......
......@@ -205,8 +205,18 @@ Handle<Object> LookupIterator::FetchValue() const {
}
int LookupIterator::GetConstantIndex() const {
DCHECK(has_property_);
DCHECK_EQ(DESCRIPTOR, property_encoding_);
DCHECK_EQ(v8::internal::CONSTANT, property_details_.type());
return descriptor_number();
}
FieldIndex LookupIterator::GetFieldIndex() const {
DCHECK_EQ(PROPERTY, state_);
DCHECK(has_property_);
DCHECK_EQ(DESCRIPTOR, property_encoding_);
DCHECK_EQ(v8::internal::FIELD, property_details_.type());
int index =
holder_map()->instance_descriptors()->GetFieldIndex(descriptor_number());
bool is_double = representation().IsDouble();
......
......@@ -140,6 +140,7 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
return property_details().representation();
}
FieldIndex GetFieldIndex() const;
int GetConstantIndex() const;
Handle<PropertyCell> GetPropertyCell() const;
Handle<Object> GetAccessors() const;
Handle<Object> GetDataValue() const;
......
......@@ -840,14 +840,6 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
}
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, FieldIndex field, Representation representation) {
if (!reg.is(receiver())) __ mov(receiver(), reg);
LoadFieldStub stub(isolate(), field);
GenerateTailCall(masm(), stub.GetCode());
}
void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
// Return the constant value.
__ li(v0, value);
......
......@@ -844,14 +844,6 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
}
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, FieldIndex field, Representation representation) {
if (!reg.is(receiver())) __ mov(receiver(), reg);
LoadFieldStub stub(isolate(), field);
GenerateTailCall(masm(), stub.GetCode());
}
void NamedLoadHandlerCompiler::GenerateLoadConstant(Handle<Object> value) {
// Return the constant value.
__ li(v0, value);
......
......@@ -2982,6 +2982,11 @@ Object** DescriptorArray::GetValueSlot(int descriptor_number) {
}
int DescriptorArray::GetValueOffset(int descriptor_number) {
return OffsetOfElementAt(ToValueIndex(descriptor_number));
}
Object* DescriptorArray::GetValue(int descriptor_number) {
DCHECK(descriptor_number < number_of_descriptors());
return get(ToValueIndex(descriptor_number));
......
......@@ -3417,6 +3417,7 @@ class DescriptorArray: public FixedArray {
inline Object* GetValue(int descriptor_number);
inline void SetValue(int descriptor_number, Object* value);
inline Object** GetValueSlot(int descriptor_number);
static inline int GetValueOffset(int descriptor_number);
inline Object** GetDescriptorStartSlot(int descriptor_number);
inline Object** GetDescriptorEndSlot(int descriptor_number);
inline PropertyDetails GetDetails(int descriptor_number);
......
......@@ -842,18 +842,22 @@ void PropertyHandlerCompiler::NonexistentFrontendHeader(Handle<Name> name,
}
Handle<Code> NamedLoadHandlerCompiler::CompileLoadField(
Handle<Name> name, FieldIndex field, Representation representation) {
Handle<Code> NamedLoadHandlerCompiler::CompileLoadField(Handle<Name> name,
FieldIndex field) {
Register reg = Frontend(receiver(), name);
GenerateLoadField(reg, field, representation);
__ Move(receiver(), reg);
LoadFieldStub stub(isolate(), field);
GenerateTailCall(masm(), stub.GetCode());
return GetCode(kind(), Code::FAST, name);
}
Handle<Code> NamedLoadHandlerCompiler::CompileLoadConstant(
Handle<Name> name, Handle<Object> value) {
Frontend(receiver(), name);
GenerateLoadConstant(value);
Handle<Code> NamedLoadHandlerCompiler::CompileLoadConstant(Handle<Name> name,
int constant_index) {
Register reg = Frontend(receiver(), name);
__ Move(receiver(), reg);
LoadConstantStub stub(isolate(), constant_index);
GenerateTailCall(masm(), stub.GetCode());
return GetCode(kind(), Code::FAST, name);
}
......@@ -917,7 +921,9 @@ void NamedLoadHandlerCompiler::GenerateLoadPostInterceptor(
Register reg = Frontend(interceptor_reg, name);
if (lookup->IsField()) {
GenerateLoadField(reg, lookup->GetFieldIndex(), lookup->representation());
__ Move(receiver(), reg);
LoadFieldStub stub(isolate(), lookup->GetFieldIndex());
GenerateTailCall(masm(), stub.GetCode());
} else {
DCHECK(lookup->type() == CALLBACKS);
Handle<ExecutableAccessorInfo> callback(
......
......@@ -463,8 +463,7 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
virtual ~NamedLoadHandlerCompiler() {}
Handle<Code> CompileLoadField(Handle<Name> name, FieldIndex index,
Representation representation);
Handle<Code> CompileLoadField(Handle<Name> name, FieldIndex index);
Handle<Code> CompileLoadCallback(Handle<Name> name,
Handle<ExecutableAccessorInfo> callback);
......@@ -472,7 +471,7 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
Handle<Code> CompileLoadCallback(Handle<Name> name,
const CallOptimization& call_optimization);
Handle<Code> CompileLoadConstant(Handle<Name> name, Handle<Object> value);
Handle<Code> CompileLoadConstant(Handle<Name> name, int constant_index);
Handle<Code> CompileLoadInterceptor(Handle<Name> name);
......@@ -519,9 +518,6 @@ class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
private:
Handle<Code> CompileLoadNonexistent(Handle<Name> name);
void GenerateLoadField(Register reg,
FieldIndex field,
Representation representation);
void GenerateLoadConstant(Handle<Object> value);
void GenerateLoadCallback(Register reg,
Handle<ExecutableAccessorInfo> callback);
......
......@@ -751,14 +751,6 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
}
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, FieldIndex field, Representation representation) {
if (!reg.is(receiver())) __ movp(receiver(), reg);
LoadFieldStub stub(isolate(), field);
GenerateTailCall(masm(), stub.GetCode());
}
void NamedLoadHandlerCompiler::GenerateLoadCallback(
Register reg, Handle<ExecutableAccessorInfo> callback) {
// Insert additional parameters into the stack frame above return address.
......
......@@ -809,14 +809,6 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
}
void NamedLoadHandlerCompiler::GenerateLoadField(
Register reg, FieldIndex field, Representation representation) {
if (!reg.is(receiver())) __ mov(receiver(), reg);
LoadFieldStub stub(isolate(), field);
GenerateTailCall(masm(), stub.GetCode());
}
void NamedLoadHandlerCompiler::GenerateLoadCallback(
Register reg, Handle<ExecutableAccessorInfo> callback) {
// Insert additional parameters into the stack frame above return address.
......
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