Commit ccf428bb authored by petermarshall's avatar petermarshall Committed by Commit bot

Convert the array iterator protector to a PropertyCell.

We need it to be a PropertyCell so that we can list it as a dependency for
optimised code.

Also drive-by clean up some variable names in src/isolate-inl.h.

BUG=v8:5895

Review-Url: https://codereview.chromium.org/2658573008
Cr-Commit-Position: refs/heads/master@{#42764}
parent 5ed73373
......@@ -2718,7 +2718,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
__ ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
__ ldr(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
__ cmp(scratch, Operand(Smi::FromInt(Isolate::kProtectorValid)));
__ b(ne, &runtime_call);
......
......@@ -2797,7 +2797,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
__ Ldr(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
__ Ldr(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
__ Cmp(scratch, Smi::FromInt(Isolate::kProtectorValid));
__ B(ne, &runtime_call);
......
......@@ -2789,7 +2789,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
__ cmp(FieldOperand(scratch, Cell::kValueOffset),
__ cmp(FieldOperand(scratch, PropertyCell::kValueOffset),
Immediate(Smi::FromInt(Isolate::kProtectorValid)));
__ j(not_equal, &runtime_call);
......
......@@ -2728,7 +2728,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
__ lw(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
__ lw(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
__ Branch(&runtime_call, ne, scratch,
Operand(Smi::FromInt(Isolate::kProtectorValid)));
......
......@@ -2754,7 +2754,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
__ lw(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
__ lw(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
__ Branch(&runtime_call, ne, scratch,
Operand(Smi::FromInt(Isolate::kProtectorValid)));
......
......@@ -2791,7 +2791,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
__ LoadP(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
__ LoadP(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
__ CmpSmiLiteral(scratch, Smi::FromInt(Isolate::kProtectorValid), r0);
__ bne(&runtime_call);
......
......@@ -2803,7 +2803,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
__ LoadP(scratch, FieldMemOperand(scratch, Cell::kValueOffset));
__ LoadP(scratch, FieldMemOperand(scratch, PropertyCell::kValueOffset));
__ CmpSmiLiteral(scratch, Smi::FromInt(Isolate::kProtectorValid), r0);
__ bne(&runtime_call);
......
......@@ -2849,7 +2849,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(rcx, Heap::kArrayIteratorProtectorRootIndex);
__ Cmp(FieldOperand(rcx, Cell::kValueOffset),
__ Cmp(FieldOperand(rcx, PropertyCell::kValueOffset),
Smi::FromInt(Isolate::kProtectorValid));
__ j(not_equal, &runtime_call);
......
......@@ -2741,7 +2741,7 @@ static void CheckSpreadAndPushToStack(MacroAssembler* masm) {
// Check that the ArrayPrototype hasn't been modified in a way that would
// affect iteration.
__ LoadRoot(scratch, Heap::kArrayIteratorProtectorRootIndex);
__ cmp(FieldOperand(scratch, Cell::kValueOffset),
__ cmp(FieldOperand(scratch, PropertyCell::kValueOffset),
Immediate(Smi::FromInt(Isolate::kProtectorValid)));
__ j(not_equal, &runtime_call);
......
......@@ -2864,6 +2864,10 @@ void Heap::CreateInitialObjects() {
cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
set_has_instance_protector(*cell);
cell = factory->NewPropertyCell();
cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
set_array_iterator_protector(*cell);
Handle<Cell> is_concat_spreadable_cell = factory->NewCell(
handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
set_is_concat_spreadable_protector(*is_concat_spreadable_cell);
......@@ -2880,10 +2884,6 @@ void Heap::CreateInitialObjects() {
handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
set_fast_array_iteration_protector(*fast_array_iteration_cell);
Handle<Cell> array_iterator_cell = factory->NewCell(
handle(Smi::FromInt(Isolate::kProtectorValid), isolate()));
set_array_iterator_protector(*array_iterator_cell);
cell = factory->NewPropertyCell();
cell->set_value(Smi::FromInt(Isolate::kProtectorValid));
set_array_buffer_neutering_protector(*cell);
......
......@@ -172,7 +172,7 @@ using v8::MemoryPressureLevel;
V(Cell, species_protector, SpeciesProtector) \
V(PropertyCell, string_length_protector, StringLengthProtector) \
V(Cell, fast_array_iteration_protector, FastArrayIterationProtector) \
V(Cell, array_iterator_protector, ArrayIteratorProtector) \
V(PropertyCell, array_iterator_protector, ArrayIteratorProtector) \
V(PropertyCell, array_buffer_neutering_protector, \
ArrayBufferNeuteringProtector) \
/* Special numbers */ \
......
......@@ -139,22 +139,22 @@ bool Isolate::IsHasInstanceLookupChainIntact() {
}
bool Isolate::IsStringLengthOverflowIntact() {
PropertyCell* has_instance_cell = heap()->string_length_protector();
return has_instance_cell->value() == Smi::FromInt(kProtectorValid);
PropertyCell* string_length_cell = heap()->string_length_protector();
return string_length_cell->value() == Smi::FromInt(kProtectorValid);
}
bool Isolate::IsFastArrayIterationIntact() {
Cell* fast_iteration = heap()->fast_array_iteration_protector();
return fast_iteration->value() == Smi::FromInt(kProtectorValid);
Cell* fast_iteration_cell = heap()->fast_array_iteration_protector();
return fast_iteration_cell->value() == Smi::FromInt(kProtectorValid);
}
bool Isolate::IsArrayBufferNeuteringIntact() {
PropertyCell* fast_iteration = heap()->array_buffer_neutering_protector();
return fast_iteration->value() == Smi::FromInt(kProtectorValid);
PropertyCell* buffer_neutering = heap()->array_buffer_neutering_protector();
return buffer_neutering->value() == Smi::FromInt(kProtectorValid);
}
bool Isolate::IsArrayIteratorLookupChainIntact() {
Cell* array_iterator_cell = heap()->array_iterator_protector();
PropertyCell* array_iterator_cell = heap()->array_iterator_protector();
return array_iterator_cell->value() == Smi::FromInt(kProtectorValid);
}
......
......@@ -3096,8 +3096,9 @@ void Isolate::InvalidateStringLengthOverflowProtector() {
void Isolate::InvalidateArrayIteratorProtector() {
DCHECK(factory()->array_iterator_protector()->value()->IsSmi());
DCHECK(IsArrayIteratorLookupChainIntact());
factory()->array_iterator_protector()->set_value(
Smi::FromInt(kProtectorInvalid));
PropertyCell::SetValueWithInvalidation(
factory()->array_iterator_protector(),
handle(Smi::FromInt(kProtectorInvalid), this));
DCHECK(!IsArrayIteratorLookupChainIntact());
}
......
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