Chromium Code Reviews| Index: src/code-stubs-hydrogen.cc |
| diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc |
| index 3ca301ca6c3a6c215097d6f0afbfa575e5df08e7..1614af351331e4d5cff9bcbb6accee835437e4eb 100644 |
| --- a/src/code-stubs-hydrogen.cc |
| +++ b/src/code-stubs-hydrogen.cc |
| @@ -1324,10 +1324,10 @@ HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { |
| Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap()); |
| HValue* global = |
| Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype()); |
| - Handle<Map> placeholder_map = isolate()->factory()->meta_map(); |
| - HValue* cell = Add<HConstant>(Map::WeakCellForMap(placeholder_map)); |
| - HValue* expected_map = |
| - Add<HLoadNamedField>(cell, nullptr, HObjectAccess::ForWeakCellValue()); |
| + HValue* map_cell = Add<HConstant>(isolate()->factory()->NewWeakCell( |
| + StoreGlobalStub::global_map_placeholder(isolate()))); |
| + HValue* expected_map = Add<HLoadNamedField>( |
| + map_cell, nullptr, HObjectAccess::ForWeakCellValue()); |
| HValue* map = |
| Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap()); |
| IfBuilder map_check(this); |
| @@ -1342,9 +1342,15 @@ HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { |
| HObjectAccess::ForWeakCellValue()); |
| Add<HCheckHeapObject>(cell); |
| HObjectAccess access = HObjectAccess::ForPropertyCellValue(); |
| + // Load the payload of the global parameter cell. A hole indicates that the |
| + // cell has been invalidated and that the store must be handled by the |
| + // runtime. |
| HValue* cell_contents = Add<HLoadNamedField>(cell, nullptr, access); |
| - if (stub->is_constant()) { |
| + auto cell_type = stub->cell_type(); |
| + if (cell_type == PropertyCellType::kConstant || |
| + cell_type == PropertyCellType::kUndefined) { |
| + // This is always valid for all states a cell can be in. |
| IfBuilder builder(this); |
| builder.If<HCompareObjectEqAndBranch>(cell_contents, value); |
| builder.Then(); |
| @@ -1352,16 +1358,44 @@ HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { |
| Deoptimizer::kUnexpectedCellContentsInConstantGlobalStore); |
| builder.End(); |
| } else { |
| - // Load the payload of the global parameter cell. A hole indicates that the |
| - // property has been deleted and that the store must be handled by the |
| - // runtime. |
| IfBuilder builder(this); |
| HValue* hole_value = graph()->GetConstantHole(); |
| builder.If<HCompareObjectEqAndBranch>(cell_contents, hole_value); |
| builder.Then(); |
| builder.Deopt(Deoptimizer::kUnexpectedCellContentsInGlobalStore); |
| builder.Else(); |
| - Add<HStoreNamedField>(cell, access, value); |
| + // When dealing with constant types, the type may be allowed to change, as |
| + // long as optimized code remains valid. |
| + StoreFieldOrKeyedMode store_mode = INITIALIZING_STORE; |
| + if (cell_type == PropertyCellType::kConstantType) { |
| + // store_mode = STORE_TO_INITIALIZED_ENTRY; |
|
dcarney
2015/04/21 07:20:07
i had to comment these out because there was some
|
| + switch (stub->constant_type()) { |
| + case PropertyCellConstantType::kSmi: |
| + Add<HCheckSmi>(value); |
|
Toon Verwaest
2015/04/21 08:06:23
This shouldn't be necessary; there'll be (should b
|
| + access = access.WithRepresentation(Representation::Smi()); |
|
dcarney
2015/04/21 07:20:07
here i have a smi check and a withrepresentation.
|
| + break; |
| + case PropertyCellConstantType::kStableMap: { |
| + // It is sufficient here to check that the value and cell contents |
| + // have identical maps, no matter if they are stable or not or if they |
| + // are the maps that were originally in the cell or not. If optimized |
| + // code will deopt when a cell has a unstable map and if it has a |
| + // dependency on a stable map, it will deopt if the map destabilizes. |
| + Add<HCheckHeapObject>(value); |
|
Toon Verwaest
2015/04/21 08:06:23
This OTOH is necessary since there's no such thing
|
| + Add<HCheckHeapObject>(cell_contents); |
| + HValue* expected_map = Add<HLoadNamedField>(cell_contents, nullptr, |
| + HObjectAccess::ForMap()); |
| + HValue* map = |
| + Add<HLoadNamedField>(value, nullptr, HObjectAccess::ForMap()); |
| + IfBuilder map_check(this); |
| + map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map); |
| + map_check.ThenDeopt(Deoptimizer::kUnknownMap); |
| + map_check.End(); |
| + access = access.WithRepresentation(Representation::HeapObject()); |
| + break; |
| + } |
| + } |
| + } |
| + Add<HStoreNamedField>(cell, access, value, store_mode); |
| builder.End(); |
| } |