Reviewers: Jakob,
Message:
Hi Jakob,
this is the change in BuildCompareNil we discussed. PTAL.
If this sticks, I'll prepare CL that removes special weak-mechanism of
monomorphic IC because all maps will be embedded via WeakCells in IC.
Description:
Use weak cell to embed map in CompareNil IC.
BUG=v8:3629
LOG=N
Please review this at https://codereview.chromium.org/812353002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+33, -12 lines):
M src/code-stubs-hydrogen.cc
M src/hydrogen.h
M src/hydrogen.cc
M src/hydrogen-instructions.h
M src/ic/ic-compiler.cc
M src/objects.cc
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index
0ede93b4de9f0d68fa4dc22ca38c5cd09e9ff10a..3b5002b7ff6a97adc5ddb62c76a1b13a40f14e08
100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -1102,7 +1102,7 @@ HValue*
CodeStubGraphBuilder<CompareNilICStub>::BuildCodeInitializedStub() {
HIfContinuation continuation;
Handle<Map> sentinel_map(isolate->heap()->meta_map());
Type* type = stub->GetType(zone(), sentinel_map);
- BuildCompareNil(GetParameter(0), type, &continuation);
+ BuildCompareNil(GetParameter(0), type, &continuation,
kEmbedMapsViaWeakCells);
IfBuilder if_nil(this, &continuation);
if_nil.Then();
if (continuation.IsFalseReachable()) {
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
b933f10ba80f266d67f3ead95ca21a42ee43f216..1fc49cc85f57098502ffdcb09e53a4f97220e480
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -6251,6 +6251,10 @@ class HObjectAccess FINAL {
return HObjectAccess(kInobject, Cell::kValueOffset);
}
+ static HObjectAccess ForWeakCellValue() {
+ return HObjectAccess(kInobject, WeakCell::kValueOffset);
+ }
+
static HObjectAccess ForAllocationMementoSite() {
return HObjectAccess(kInobject,
AllocationMemento::kAllocationSiteOffset);
}
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
987d60b334115809200ccec79c35c489da3ffaa6..74463fde98e95546abde7618dff75f2e372eef1e
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -3016,10 +3016,9 @@ HValue*
HGraphBuilder::BuildCloneShallowArrayNonEmpty(HValue* boilerplate,
}
-void HGraphBuilder::BuildCompareNil(
- HValue* value,
- Type* type,
- HIfContinuation* continuation) {
+void HGraphBuilder::BuildCompareNil(HValue* value, Type* type,
+ HIfContinuation* continuation,
+ MapEmbedding map_embedding) {
IfBuilder if_nil(this);
bool some_case_handled = false;
bool some_case_missing = false;
@@ -3058,7 +3057,22 @@ void HGraphBuilder::BuildCompareNil(
// the monomorphic map when the code is used as a template to
generate a
// new IC. For optimized functions, there is no sentinel map, the map
// emitted below is the actual monomorphic map.
- Add<HCheckMaps>(value, type->Classes().Current());
+ if (map_embedding == kEmbedMapsViaWeakCells) {
+ HValue* cell =
+ Add<HConstant>(Map::WeakCellForMap(type->Classes().Current()));
+ HValue* expected_map = Add<HLoadNamedField>(
+ cell, nullptr, HObjectAccess::ForWeakCellValue());
+ HValue* map =
+ Add<HLoadNamedField>(value, nullptr, HObjectAccess::ForMap());
+ IfBuilder builder(this);
+ builder.If<HCompareObjectEqAndBranch>(expected_map, map);
+ builder.Then();
+ builder.Else();
+ Add<HDeoptimize>("Unknown map", Deoptimizer::EAGER);
+ builder.End();
+ } else {
+ Add<HCheckMaps>(value, type->Classes().Current());
+ }
} else {
if_nil.Deopt("Too many undetectable types");
}
Index: src/hydrogen.h
diff --git a/src/hydrogen.h b/src/hydrogen.h
index
af7671b38bad3b40b1d649d61186e4a57bfdcfd3..c1ed797c96f0a37cca3c929d42852bcc1a91bbf7
100644
--- a/src/hydrogen.h
+++ b/src/hydrogen.h
@@ -1864,10 +1864,10 @@ class HGraphBuilder {
HValue* BuildElementIndexHash(HValue* index);
- void BuildCompareNil(
- HValue* value,
- Type* type,
- HIfContinuation* continuation);
+ enum MapEmbedding { kEmbedMapsDirectly, kEmbedMapsViaWeakCells };
+
+ void BuildCompareNil(HValue* value, Type* type, HIfContinuation*
continuation,
+ MapEmbedding map_embedding = kEmbedMapsDirectly);
void BuildCreateAllocationMemento(HValue* previous_object,
HValue* previous_object_size,
Index: src/ic/ic-compiler.cc
diff --git a/src/ic/ic-compiler.cc b/src/ic/ic-compiler.cc
index
69d707b03554ff3ecf66e41cec8f812ef8109881..3a1731268fc2ad1ae807cb7e8a899d6c49c4abb8
100644
--- a/src/ic/ic-compiler.cc
+++ b/src/ic/ic-compiler.cc
@@ -244,7 +244,8 @@ Handle<Code>
PropertyICCompiler::ComputeCompareNil(Handle<Map> receiver_map,
}
Code::FindAndReplacePattern pattern;
- pattern.Add(isolate->factory()->meta_map(), receiver_map);
+ Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
+ pattern.Add(isolate->factory()->meta_map(), cell);
Handle<Code> ic = stub->GetCodeCopy(pattern);
if (!receiver_map->is_dictionary_map()) {
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
9d17f1f8bd4e6f9275c00b106dee86174b2edae1..f3090011809f2380ddae0249ef8919fd26b604ba
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -10824,7 +10824,9 @@ void Code::FindAndReplace(const
FindAndReplacePattern& pattern) {
RelocInfo* info = it.rinfo();
Object* object = info->target_object();
if (object->IsHeapObject()) {
- DCHECK(!object->IsWeakCell());
+ if (object->IsWeakCell()) {
+ object = HeapObject::cast(WeakCell::cast(object)->value());
+ }
Map* map = HeapObject::cast(object)->map();
if (map == *pattern.find_[current_pattern]) {
info->set_target_object(*pattern.replace_[current_pattern]);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.