Commit d985948c authored by verwaest@chromium.org's avatar verwaest@chromium.org

Merge BuildLoad/StoreMonomorphic

R=dcarney@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19108 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 14a90fcc
...@@ -5077,8 +5077,8 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) { ...@@ -5077,8 +5077,8 @@ void HOptimizedGraphBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
if (info.CanAccessMonomorphic()) { if (info.CanAccessMonomorphic()) {
HValue* checked_literal = BuildCheckMap(literal, map); HValue* checked_literal = BuildCheckMap(literal, map);
ASSERT(!info.lookup()->IsPropertyCallbacks()); ASSERT(!info.lookup()->IsPropertyCallbacks());
store = BuildStoreMonomorphic( store = BuildMonomorphicAccess(
&info, checked_literal, value, &info, literal, checked_literal, value,
BailoutId::None(), BailoutId::None()); BailoutId::None(), BailoutId::None());
} else { } else {
CHECK_ALIVE( CHECK_ALIVE(
...@@ -5519,18 +5519,19 @@ static bool NeedsWrappingFor(Type* type, Handle<JSFunction> target) { ...@@ -5519,18 +5519,19 @@ static bool NeedsWrappingFor(Type* type, Handle<JSFunction> target) {
} }
HInstruction* HOptimizedGraphBuilder::BuildLoadMonomorphic( HInstruction* HOptimizedGraphBuilder::BuildMonomorphicAccess(
PropertyAccessInfo* info, PropertyAccessInfo* info,
HValue* object, HValue* object,
HValue* checked_object, HValue* checked_object,
HValue* value,
BailoutId ast_id, BailoutId ast_id,
BailoutId return_id, BailoutId return_id,
bool can_inline_accessor) { bool can_inline_accessor) {
HObjectAccess access = HObjectAccess::ForMap(); // bogus default HObjectAccess access = HObjectAccess::ForMap(); // bogus default
if (info->GetJSObjectFieldAccess(&access)) { if (info->GetJSObjectFieldAccess(&access)) {
return New<HLoadNamedField>( ASSERT(info->IsLoad());
checked_object, static_cast<HValue*>(NULL), access); return New<HLoadNamedField>(object, checked_object, access);
} }
HValue* checked_holder = checked_object; HValue* checked_holder = checked_object;
...@@ -5539,74 +5540,53 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadMonomorphic( ...@@ -5539,74 +5540,53 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadMonomorphic(
checked_holder = BuildCheckPrototypeMaps(prototype, info->holder()); checked_holder = BuildCheckPrototypeMaps(prototype, info->holder());
} }
if (!info->lookup()->IsFound()) return graph()->GetConstantUndefined(); if (!info->lookup()->IsFound()) {
ASSERT(info->IsLoad());
if (info->lookup()->IsField()) { return graph()->GetConstantUndefined();
return BuildLoadNamedField(checked_holder, info->access());
} }
if (info->lookup()->IsPropertyCallbacks()) { if (info->lookup()->IsField()) {
if (NeedsWrappingFor(info->type(), info->accessor())) { if (info->IsLoad()) {
HValue* function = Add<HConstant>(info->accessor()); return BuildLoadNamedField(checked_holder, info->access());
Add<HPushArgument>(checked_object);
return New<HCallFunction>(function, 1, WRAP_AND_CALL);
} else { } else {
Push(checked_object); return BuildStoreNamedField(info, checked_object, value);
if (FLAG_inline_accessors &&
can_inline_accessor &&
TryInlineGetter(info->accessor(), ast_id, return_id)) {
return NULL;
}
Add<HPushArgument>(Pop());
return BuildCallConstantFunction(info->accessor(), 1);
} }
} }
ASSERT(info->lookup()->IsConstant()); if (info->lookup()->IsTransition()) {
return New<HConstant>(info->constant()); ASSERT(!info->IsLoad());
} return BuildStoreNamedField(info, checked_object, value);
HInstruction* HOptimizedGraphBuilder::BuildStoreMonomorphic(
PropertyAccessInfo* info,
HValue* checked_object,
HValue* value,
BailoutId ast_id,
BailoutId return_id,
bool can_inline_accessor) {
ASSERT(!info->IsJSObjectFieldAccessor());
if (info->has_holder()) {
Handle<JSObject> prototype(JSObject::cast(info->map()->prototype()));
BuildCheckPrototypeMaps(prototype, info->holder());
} }
if (info->lookup()->IsPropertyCallbacks()) { if (info->lookup()->IsPropertyCallbacks()) {
Push(checked_object);
int argument_count = 1;
if (!info->IsLoad()) {
argument_count = 2;
Push(value);
}
if (NeedsWrappingFor(info->type(), info->accessor())) { if (NeedsWrappingFor(info->type(), info->accessor())) {
HValue* function = Add<HConstant>(info->accessor()); HValue* function = Add<HConstant>(info->accessor());
Add<HPushArgument>(checked_object); PushArgumentsFromEnvironment(argument_count);
Add<HPushArgument>(value); return New<HCallFunction>(function, argument_count, WRAP_AND_CALL);
return New<HCallFunction>(function, 2, WRAP_AND_CALL); } else if (FLAG_inline_accessors && can_inline_accessor) {
} else { bool success = info->IsLoad()
Push(checked_object); ? TryInlineGetter(info->accessor(), ast_id, return_id)
Push(value); : TryInlineSetter(info->accessor(), ast_id, return_id, value);
if (FLAG_inline_accessors && if (success) return NULL;
can_inline_accessor &&
TryInlineSetter(info->accessor(), ast_id, return_id, value)) {
return NULL;
}
PushArgumentsFromEnvironment(2);
return BuildCallConstantFunction(info->accessor(), 2);
} }
PushArgumentsFromEnvironment(argument_count);
return BuildCallConstantFunction(info->accessor(), argument_count);
} }
if (info->lookup()->IsConstant()) { ASSERT(info->lookup()->IsConstant());
// Check whether we are trying to store the same constant. if (info->IsLoad()) {
return New<HConstant>(info->constant());
} else {
return New<HCheckValue>(value, Handle<JSFunction>::cast(info->constant())); return New<HCheckValue>(value, Handle<JSFunction>::cast(info->constant()));
} }
ASSERT(info->lookup()->IsField() || info->lookup()->IsTransition());
return BuildStoreNamedField(info, checked_object, value);
} }
...@@ -5695,19 +5675,16 @@ void HOptimizedGraphBuilder::HandlePolymorphicNamedFieldAccess( ...@@ -5695,19 +5675,16 @@ void HOptimizedGraphBuilder::HandlePolymorphicNamedFieldAccess(
set_current_block(if_true); set_current_block(if_true);
HInstruction* access = NULL; HInstruction* access = BuildMonomorphicAccess(
&info, object, dependency, value, ast_id,
return_id, FLAG_polymorphic_inlining);
HValue* result = NULL; HValue* result = NULL;
switch (access_type) { switch (access_type) {
case LOAD: case LOAD:
access = BuildLoadMonomorphic(
&info, object, dependency, ast_id,
return_id, FLAG_polymorphic_inlining);
result = access; result = access;
break; break;
case STORE: case STORE:
access = BuildStoreMonomorphic(
&info, dependency, value, ast_id, return_id,
FLAG_polymorphic_inlining);
result = value; result = value;
break; break;
} }
...@@ -5844,8 +5821,8 @@ void HOptimizedGraphBuilder::BuildStore(Expression* expr, ...@@ -5844,8 +5821,8 @@ void HOptimizedGraphBuilder::BuildStore(Expression* expr,
} else { } else {
checked_object = Add<HCheckMaps>(object, types); checked_object = Add<HCheckMaps>(object, types);
} }
instr = BuildStoreMonomorphic( instr = BuildMonomorphicAccess(
&info, checked_object, value, ast_id, return_id); &info, object, checked_object, value, ast_id, return_id);
if (instr == NULL) return; if (instr == NULL) return;
ASSERT(!instr->IsLinked()); ASSERT(!instr->IsLinked());
} else { } else {
...@@ -6697,8 +6674,8 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr, ...@@ -6697,8 +6674,8 @@ void HOptimizedGraphBuilder::BuildLoad(Property* expr,
} else { } else {
checked_object = Add<HCheckMaps>(object, types); checked_object = Add<HCheckMaps>(object, types);
} }
instr = BuildLoadMonomorphic( instr = BuildMonomorphicAccess(
&info, object, checked_object, ast_id, expr->LoadId()); &info, object, checked_object, NULL, ast_id, expr->LoadId());
if (instr == NULL) return; if (instr == NULL) return;
if (instr->IsLinked()) return ast_context()->ReturnValue(instr); if (instr->IsLinked()) return ast_context()->ReturnValue(instr);
} else { } else {
......
...@@ -2338,6 +2338,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2338,6 +2338,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
} }
bool has_holder() { return !holder_.is_null(); } bool has_holder() { return !holder_.is_null(); }
bool IsLoad() const { return access_type_ == LOAD; }
LookupResult* lookup() { return &lookup_; } LookupResult* lookup() { return &lookup_; }
Handle<JSObject> holder() { return holder_; } Handle<JSObject> holder() { return holder_; }
...@@ -2360,7 +2361,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2360,7 +2361,6 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
bool LookupDescriptor(); bool LookupDescriptor();
bool LookupInPrototypes(); bool LookupInPrototypes();
bool IsCompatible(PropertyAccessInfo* other); bool IsCompatible(PropertyAccessInfo* other);
bool IsLoad() const { return access_type_ == LOAD; }
void GeneralizeRepresentation(Representation r) { void GeneralizeRepresentation(Representation r) {
access_ = access_.WithRepresentation( access_ = access_.WithRepresentation(
...@@ -2379,19 +2379,13 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor { ...@@ -2379,19 +2379,13 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
HObjectAccess access_; HObjectAccess access_;
}; };
HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, HInstruction* BuildMonomorphicAccess(PropertyAccessInfo* info,
HValue* object, HValue* object,
HValue* checked_object, HValue* checked_object,
BailoutId ast_id, HValue* value,
BailoutId return_id, BailoutId ast_id,
bool can_inline_accessor = true); BailoutId return_id,
bool can_inline_accessor = true);
HInstruction* BuildStoreMonomorphic(PropertyAccessInfo* info,
HValue* checked_object,
HValue* value,
BailoutId ast_id,
BailoutId return_id,
bool can_inline_accessor = true);
void HandlePolymorphicCallNamed(Call* expr, void HandlePolymorphicCallNamed(Call* expr,
HValue* receiver, HValue* receiver,
......
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