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
// that will be replaced later with the global object's map.
+ HParameter* proxy = GetParameter(StoreDescriptor::kReceiverIndex);
+ HValue* proxy_map =
+ Add<HLoadNamedField>(proxy, nullptr, HObjectAccess::ForMap());
+ HValue* global =
+ Add<HLoadNamedField>(proxy_map, nullptr, HObjectAccess::ForPrototype());
Handle<Map> placeholder_map = isolate()->factory()->meta_map();
- HValue* global = Add<HConstant>(
- StoreGlobalStub::global_placeholder(isolate()));
- Add<HCheckMaps>(global, placeholder_map);
+ HValue* cell = Add<HConstant>(Map::WeakCellForMap(placeholder_map));
+ HValue* expected_map =
+ Add<HLoadNamedField>(cell, nullptr, HObjectAccess::ForWeakCellValue());
+ HValue* map =
+ Add<HLoadNamedField>(global, nullptr, HObjectAccess::ForMap());
+ IfBuilder map_check(this);
+ map_check.IfNot<HCompareObjectEqAndBranch>(expected_map, map);
+ map_check.ThenDeopt("Unknown map");
+ map_check.End();
}
HValue* cell = Add<HConstant>(placeholder_cell);
Handle<PropertyCell> cell) {
if (check_global()) {
Code::FindAndReplacePattern pattern;
- pattern.Add(Handle<Map>(global_placeholder(isolate())->map()), global);
- pattern.Add(isolate()->factory()->meta_map(), Handle<Map>(global->map()));
+ pattern.Add(isolate()->factory()->meta_map(),
+ Map::WeakCellForMap(Handle<Map>(global->map())));
pattern.Add(isolate()->factory()->global_property_cell_map(), cell);
return CodeStub::GetCodeCopy(pattern);
} else {
if (holder->IsGlobalObject()) {
Handle<PropertyCell> cell = lookup->GetPropertyCell();
Handle<HeapType> union_type = PropertyCell::UpdatedType(cell, value);
+ DCHECK(holder.is_identical_to(receiver) ||
+ receiver->map()->prototype() == *holder);
StoreGlobalStub stub(isolate(), union_type->IsConstant(),
receiver->IsJSGlobalProxy());
Handle<Code> code = stub.GetCodeCopyFromTemplate(