Index: src/ic/arm64/handler-compiler-arm64.cc |
diff --git a/src/ic/arm64/handler-compiler-arm64.cc b/src/ic/arm64/handler-compiler-arm64.cc |
index 36d88c0a2ca8948a4abe2f09954a5325f105e558..516bf640d9a274cd6fb0b6a442bc851d1bc9ac02 100644 |
--- a/src/ic/arm64/handler-compiler-arm64.cc |
+++ b/src/ic/arm64/handler-compiler-arm64.cc |
@@ -339,7 +339,7 @@ Handle<Code> NamedLoadHandlerCompiler::CompileLoadGlobal( |
if (IC::ICUseVector(kind())) { |
PushVectorAndSlot(); |
} |
- FrontendHeader(receiver(), name, &miss); |
+ FrontendHeader(receiver(), name, &miss, DONT_RETURN_ANYTHING); |
// Get the value from the cell. |
Register result = StoreDescriptor::ValueRegister(); |
@@ -461,14 +461,38 @@ void NamedStoreHandlerCompiler::GenerateFieldTypeChecks(HeapType* field_type, |
Register PropertyHandlerCompiler::CheckPrototypes( |
Register object_reg, Register holder_reg, Register scratch1, |
- Register scratch2, Handle<Name> name, Label* miss, |
- PrototypeCheckType check) { |
+ Register scratch2, Handle<Name> name, Label* miss, PrototypeCheckType check, |
+ ReturnHolder return_what) { |
Handle<Map> receiver_map = map(); |
// object_reg and holder_reg registers can alias. |
DCHECK(!AreAliased(object_reg, scratch1, scratch2)); |
DCHECK(!AreAliased(holder_reg, scratch1, scratch2)); |
+ if (FLAG_eliminate_prototype_chain_checks) { |
+ Handle<Cell> validity_cell = |
+ Map::GetOrCreatePrototypeChainValidityCell(receiver_map, isolate()); |
+ if (!validity_cell.is_null()) { |
+ DCHECK_EQ(Smi::FromInt(Map::kPrototypeChainValid), |
+ validity_cell->value()); |
+ __ Mov(scratch1, Operand(validity_cell)); |
+ __ Ldr(scratch1, FieldMemOperand(scratch1, Cell::kValueOffset)); |
+ __ Cmp(scratch1, Operand(Smi::FromInt(Map::kPrototypeChainValid))); |
+ __ B(ne, miss); |
+ } |
+ |
+ // The prototype chain of primitives (and their JSValue wrappers) depends |
+ // on the native context, which can't be guarded by validity cells. |
+ // |object_reg| holds the native context specific prototype in this case; |
+ // we need to check its map. |
+ if (check == CHECK_ALL_MAPS) { |
+ __ Ldr(scratch1, FieldMemOperand(object_reg, HeapObject::kMapOffset)); |
+ Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); |
+ __ CmpWeakValue(scratch1, cell, scratch2); |
+ __ B(ne, miss); |
+ } |
+ } |
+ |
// Keep track of the current object in register reg. |
Register reg = object_reg; |
int depth = 0; |
@@ -513,30 +537,37 @@ Register PropertyHandlerCompiler::CheckPrototypes( |
DCHECK(current.is_null() || (current->property_dictionary()->FindEntry( |
name) == NameDictionary::kNotFound)); |
+ if (FLAG_eliminate_prototype_chain_checks && depth > 1) { |
+ // TODO(jkummerow): Cache and re-use weak cell. |
+ __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); |
+ } |
GenerateDictionaryNegativeLookup(masm(), miss, reg, name, scratch1, |
scratch2); |
- __ Ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); |
- reg = holder_reg; // From now on the object will be in holder_reg. |
- __ Ldr(reg, FieldMemOperand(scratch1, Map::kPrototypeOffset)); |
+ if (!FLAG_eliminate_prototype_chain_checks) { |
+ __ Ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); |
+ __ Ldr(holder_reg, FieldMemOperand(scratch1, Map::kPrototypeOffset)); |
+ } |
} else { |
Register map_reg = scratch1; |
- __ Ldr(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset)); |
- |
+ if (!FLAG_eliminate_prototype_chain_checks) { |
+ __ Ldr(map_reg, FieldMemOperand(reg, HeapObject::kMapOffset)); |
+ } |
if (current_map->IsJSGlobalObjectMap()) { |
GenerateCheckPropertyCell(masm(), Handle<JSGlobalObject>::cast(current), |
name, scratch2, miss); |
- } else if (depth != 1 || check == CHECK_ALL_MAPS) { |
+ } else if (!FLAG_eliminate_prototype_chain_checks && |
+ (depth != 1 || check == CHECK_ALL_MAPS)) { |
Handle<WeakCell> cell = Map::WeakCellForMap(current_map); |
__ CmpWeakValue(map_reg, cell, scratch2); |
__ B(ne, miss); |
} |
- |
- reg = holder_reg; // From now on the object will be in holder_reg. |
- |
- __ Ldr(reg, FieldMemOperand(map_reg, Map::kPrototypeOffset)); |
+ if (!FLAG_eliminate_prototype_chain_checks) { |
+ __ Ldr(holder_reg, FieldMemOperand(map_reg, Map::kPrototypeOffset)); |
+ } |
} |
+ reg = holder_reg; // From now on the object will be in holder_reg. |
// Go to the next object in the prototype chain. |
current = prototype; |
current_map = handle(current->map()); |
@@ -547,8 +578,8 @@ Register PropertyHandlerCompiler::CheckPrototypes( |
// Log the check depth. |
LOG(isolate(), IntEvent("check-maps-depth", depth + 1)); |
- // Check the holder map. |
- if (depth != 0 || check == CHECK_ALL_MAPS) { |
+ if (!FLAG_eliminate_prototype_chain_checks && |
+ (depth != 0 || check == CHECK_ALL_MAPS)) { |
// Check the holder map. |
__ Ldr(scratch1, FieldMemOperand(reg, HeapObject::kMapOffset)); |
Handle<WeakCell> cell = Map::WeakCellForMap(current_map); |
@@ -556,8 +587,13 @@ Register PropertyHandlerCompiler::CheckPrototypes( |
__ B(ne, miss); |
} |
+ bool return_holder = return_what == RETURN_HOLDER; |
+ if (FLAG_eliminate_prototype_chain_checks && return_holder && depth != 0) { |
+ __ LoadWeakValue(reg, isolate()->factory()->NewWeakCell(current), miss); |
+ } |
+ |
// Return the register containing the holder. |
- return reg; |
+ return return_holder ? reg : no_reg; |
} |