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

Unified Diff: src/hydrogen.cc

Issue 21065006: Replace HCheckPrototypeMaps by explicit map checks of constant values. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Prepare all HConstant js objects 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 45c5780cdecb2f129cbdf2843f7c08db4c145c87..ace45256287a721461985711bd36f8fe06a729a7 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4102,8 +4102,7 @@ static bool IsFastLiteral(Handle<JSObject> boilerplate,
int* data_size,
int* pointer_size) {
if (boilerplate->map()->is_deprecated()) {
- Handle<Object> result =
- JSObject::TryMigrateInstance(boilerplate);
+ Handle<Object> result = JSObject::TryMigrateInstance(boilerplate);
if (result->IsSmi()) return false;
}
@@ -4503,9 +4502,9 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
ASSERT(proto->GetPrototype(isolate())->IsNull());
}
ASSERT(proto->IsJSObject());
- Add<HCheckPrototypeMaps>(
+ BuildCheckPrototypeMaps(
Handle<JSObject>(JSObject::cast(map->prototype())),
- Handle<JSObject>(JSObject::cast(proto)), top_info());
+ Handle<JSObject>(JSObject::cast(proto)));
}
HObjectAccess field_access = HObjectAccess::ForField(map, lookup, name);
@@ -4658,8 +4657,7 @@ HInstruction* HOptimizedGraphBuilder::TryLoadPolymorphicAsMonomorphic(
Handle<JSObject> holder(lookup.holder());
Handle<Map> holder_map(holder->map());
- Add<HCheckPrototypeMaps>(
- Handle<JSObject>::cast(prototype), holder, top_info());
+ BuildCheckPrototypeMaps(Handle<JSObject>::cast(prototype), holder);
HValue* holder_value = Add<HConstant>(holder);
return BuildLoadNamedField(holder_value,
HObjectAccess::ForField(holder_map, &lookup, name));
@@ -5379,7 +5377,7 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic(
Handle<JSObject> holder(lookup.holder());
Handle<Map> holder_map(holder->map());
AddCheckMap(object, map);
- Add<HCheckPrototypeMaps>(prototype, holder, top_info());
+ BuildCheckPrototypeMaps(prototype, holder);
HValue* holder_value = Add<HConstant>(holder);
return BuildLoadNamedField(holder_value,
HObjectAccess::ForField(holder_map, &lookup, name));
@@ -5391,7 +5389,7 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic(
Handle<JSObject> holder(lookup.holder());
Handle<Map> holder_map(holder->map());
AddCheckMap(object, map);
- Add<HCheckPrototypeMaps>(prototype, holder, top_info());
+ BuildCheckPrototypeMaps(prototype, holder);
Handle<Object> constant(lookup.GetConstantFromMap(*holder_map), isolate());
return New<HConstant>(constant);
}
@@ -5427,7 +5425,7 @@ HInstruction* HOptimizedGraphBuilder::BuildMonomorphicElementAccess(
isolate()->IsFastArrayConstructorPrototypeChainIntact()) {
Handle<JSObject> prototype(JSObject::cast(map->prototype()), isolate());
Handle<JSObject> object_prototype = isolate()->initial_object_prototype();
- Add<HCheckPrototypeMaps>(prototype, object_prototype, top_info());
+ BuildCheckPrototypeMaps(prototype, object_prototype);
load_mode = ALLOW_RETURN_HOLE;
graph()->MarkDependsOnEmptyArrayProtoElements();
}
@@ -5872,11 +5870,38 @@ void HOptimizedGraphBuilder::VisitProperty(Property* expr) {
}
+void HGraphBuilder::BuildConstantMapCheck(Handle<JSObject> constant,
+ CompilationInfo* info) {
+ HConstant* constant_value = New<HConstant>(constant);
+
+ if (constant->map()->CanOmitMapChecks()) {
+ constant->map()->AddDependentCompilationInfo(
+ DependentCode::kPrototypeCheckGroup, info);
+ return;
+ }
+
+ AddInstruction(constant_value);
+ HCheckMaps* check =
+ Add<HCheckMaps>(constant_value, handle(constant->map()), info);
+ check->ClearGVNFlag(kDependsOnElementsKind);
+}
+
+
+void HGraphBuilder::BuildCheckPrototypeMaps(Handle<JSObject> prototype,
+ Handle<JSObject> holder) {
+ BuildConstantMapCheck(prototype, top_info());
+ while (!prototype.is_identical_to(holder)) {
+ prototype = handle(JSObject::cast(prototype->GetPrototype()));
+ BuildConstantMapCheck(prototype, top_info());
+ }
+}
+
+
void HOptimizedGraphBuilder::AddCheckPrototypeMaps(Handle<JSObject> holder,
Handle<Map> receiver_map) {
if (!holder.is_null()) {
Handle<JSObject> prototype(JSObject::cast(receiver_map->prototype()));
- Add<HCheckPrototypeMaps>(prototype, holder, top_info());
+ BuildCheckPrototypeMaps(prototype, holder);
}
}
@@ -6617,9 +6642,9 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
HValue* string = Pop();
HValue* context = environment()->context();
ASSERT(!expr->holder().is_null());
- Add<HCheckPrototypeMaps>(Call::GetPrototypeForPrimitiveCheck(
+ BuildCheckPrototypeMaps(Call::GetPrototypeForPrimitiveCheck(
STRING_CHECK, expr->holder()->GetIsolate()),
- expr->holder(), top_info());
+ expr->holder());
HInstruction* char_code =
BuildStringCharCodeAt(string, index);
if (id == kStringCharCodeAt) {
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698