Reviewers: Toon Verwaest,
Message:
PTAL. This is a follow-up for r26385. Remove the last raw pointer embedded
in
store handler.
Description:
Use weak cell to embed property cell in StoreGlobal.
BUG=v8:3629
LOG=N
Please review this at https://codereview.chromium.org/898723002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+21, -8 lines):
M src/code-stubs.h
M src/code-stubs-hydrogen.cc
M src/hydrogen-instructions.h
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index
826c1dd730031deef5332b8cbfeb2083d60e939f..dd2f788b4bfa1283aa3fc420aa656b6c5631f5e9
100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -1310,9 +1310,6 @@ Handle<Code> ToBooleanStub::GenerateCode() {
template <>
HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
StoreGlobalStub* stub = casted_stub();
- Handle<Object> placeholer_value(Smi::FromInt(0), isolate());
- Handle<PropertyCell> placeholder_cell =
- isolate()->factory()->NewPropertyCell(placeholer_value);
HParameter* value = GetParameter(StoreDescriptor::kValueIndex);
if (stub->check_global()) {
// Check that the map of the global has not changed: use a placeholder
map
@@ -1334,7 +1331,10 @@ HValue*
CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
map_check.End();
}
- HValue* cell = Add<HConstant>(placeholder_cell);
+ HValue* weak_cell = Add<HConstant>(isolate()->factory()->NewWeakCell(
+ StoreGlobalStub::property_cell_placeholder(isolate())));
+ HValue* cell = Add<HLoadNamedField>(weak_cell, nullptr,
+ HObjectAccess::ForWeakCellValue());
HObjectAccess access(HObjectAccess::ForCellPayload(isolate()));
HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access);
@@ -1354,7 +1354,8 @@ HValue*
CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
builder.Then();
builder.Deopt("Unexpected cell contents in global store");
builder.Else();
- Add<HStoreNamedField>(cell, access, value);
+ HStoreNamedField* store = Add<HStoreNamedField>(cell, access, value);
+ store->MarkReceiverAsCell();
builder.End();
}
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index
f8009a2697428b0241558a77015080b98000f1e0..2c9f1fb94d264c93044d0386dc097dcdbea7f10b
100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -1084,7 +1084,7 @@ class StoreGlobalStub : public HandlerStub {
CheckGlobalBits::encode(check_global));
}
- static Handle<HeapObject> global_placeholder(Isolate* isolate) {
+ static Handle<HeapObject> property_cell_placeholder(Isolate* isolate) {
return isolate->factory()->uninitialized_value();
}
@@ -1094,11 +1094,13 @@ class StoreGlobalStub : public HandlerStub {
Code::FindAndReplacePattern pattern;
pattern.Add(isolate()->factory()->meta_map(),
Map::WeakCellForMap(Handle<Map>(global->map())));
- pattern.Add(isolate()->factory()->global_property_cell_map(), cell);
+ pattern.Add(Handle<Map>(property_cell_placeholder(isolate())->map()),
+ isolate()->factory()->NewWeakCell(cell));
return CodeStub::GetCodeCopy(pattern);
} else {
Code::FindAndReplacePattern pattern;
- pattern.Add(isolate()->factory()->global_property_cell_map(), cell);
+ pattern.Add(Handle<Map>(property_cell_placeholder(isolate())->map()),
+ isolate()->factory()->NewWeakCell(cell));
return CodeStub::GetCodeCopy(pattern);
}
}
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
ed4b065efad25123fe081ad40847db3b36213341..b69ce7952dd917a918beb470806486b1637e4708
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -6969,6 +6969,14 @@ class HStoreNamedField FINAL : public
HTemplateInstruction<3> {
SetChangesFlag(kMaps);
}
+ void MarkReceiverAsCell() {
+ bit_field_ = ReceiverIsCellField::update(bit_field_, true);
+ }
+
+ bool receiver_is_cell() const {
+ return ReceiverIsCellField::decode(bit_field_);
+ }
+
bool NeedsWriteBarrier() const {
DCHECK(!field_representation().IsDouble() ||
(FLAG_unbox_double_fields && access_.IsInobject()) ||
@@ -6977,6 +6985,7 @@ class HStoreNamedField FINAL : public
HTemplateInstruction<3> {
if (field_representation().IsSmi()) return false;
if (field_representation().IsInteger32()) return false;
if (field_representation().IsExternal()) return false;
+ if (receiver_is_cell()) return false;
return StoringValueNeedsWriteBarrier(value()) &&
ReceiverObjectNeedsWriteBarrier(object(), value(), dominator());
}
@@ -7036,6 +7045,7 @@ class HStoreNamedField FINAL : public
HTemplateInstruction<3> {
class HasTransitionField : public BitField<bool, 0, 1> {};
class StoreModeField : public BitField<StoreFieldOrKeyedMode, 1, 1> {};
+ class ReceiverIsCellField : public BitField<bool, 2, 1> {};
HObjectAccess access_;
HValue* dominator_;
--
--
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.