Commit 34b72eca authored by ulan's avatar ulan Committed by Commit bot

Fetch global object from jsproxy prototype instead of embedding it in StoreGlobal.

BUG=v8:3629
LOG=N

Review URL: https://codereview.chromium.org/892213003

Cr-Commit-Position: refs/heads/master@{#26385}
parent 6019cbf9
...@@ -1313,16 +1313,25 @@ HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() { ...@@ -1313,16 +1313,25 @@ HValue* CodeStubGraphBuilder<StoreGlobalStub>::BuildCodeInitializedStub() {
Handle<Object> placeholer_value(Smi::FromInt(0), isolate()); Handle<Object> placeholer_value(Smi::FromInt(0), isolate());
Handle<PropertyCell> placeholder_cell = Handle<PropertyCell> placeholder_cell =
isolate()->factory()->NewPropertyCell(placeholer_value); isolate()->factory()->NewPropertyCell(placeholer_value);
HParameter* value = GetParameter(StoreDescriptor::kValueIndex); HParameter* value = GetParameter(StoreDescriptor::kValueIndex);
if (stub->check_global()) { if (stub->check_global()) {
// Check that the map of the global has not changed: use a placeholder map // 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. // 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(); Handle<Map> placeholder_map = isolate()->factory()->meta_map();
HValue* global = Add<HConstant>( HValue* cell = Add<HConstant>(Map::WeakCellForMap(placeholder_map));
StoreGlobalStub::global_placeholder(isolate())); HValue* expected_map =
Add<HCheckMaps>(global, placeholder_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); HValue* cell = Add<HConstant>(placeholder_cell);
......
...@@ -1092,8 +1092,8 @@ class StoreGlobalStub : public HandlerStub { ...@@ -1092,8 +1092,8 @@ class StoreGlobalStub : public HandlerStub {
Handle<PropertyCell> cell) { Handle<PropertyCell> cell) {
if (check_global()) { if (check_global()) {
Code::FindAndReplacePattern pattern; Code::FindAndReplacePattern pattern;
pattern.Add(Handle<Map>(global_placeholder(isolate())->map()), global); pattern.Add(isolate()->factory()->meta_map(),
pattern.Add(isolate()->factory()->meta_map(), Handle<Map>(global->map())); Map::WeakCellForMap(Handle<Map>(global->map())));
pattern.Add(isolate()->factory()->global_property_cell_map(), cell); pattern.Add(isolate()->factory()->global_property_cell_map(), cell);
return CodeStub::GetCodeCopy(pattern); return CodeStub::GetCodeCopy(pattern);
} else { } else {
......
...@@ -1747,6 +1747,8 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup, ...@@ -1747,6 +1747,8 @@ Handle<Code> StoreIC::CompileHandler(LookupIterator* lookup,
if (holder->IsGlobalObject()) { if (holder->IsGlobalObject()) {
Handle<PropertyCell> cell = lookup->GetPropertyCell(); Handle<PropertyCell> cell = lookup->GetPropertyCell();
Handle<HeapType> union_type = PropertyCell::UpdatedType(cell, value); Handle<HeapType> union_type = PropertyCell::UpdatedType(cell, value);
DCHECK(holder.is_identical_to(receiver) ||
receiver->map()->prototype() == *holder);
StoreGlobalStub stub(isolate(), union_type->IsConstant(), StoreGlobalStub stub(isolate(), union_type->IsConstant(),
receiver->IsJSGlobalProxy()); receiver->IsJSGlobalProxy());
Handle<Code> code = stub.GetCodeCopyFromTemplate( Handle<Code> code = stub.GetCodeCopyFromTemplate(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment