bool Isolate::IsFastArrayConstructorPrototypeChainIntact() {
- Handle<PropertyCell> no_elements_cell =
- handle(heap()->array_protector(), this);
+ PropertyCell* no_elements_cell = heap()->array_protector();
bool cell_reports_intact = no_elements_cell->value()->IsSmi() &&
Smi::cast(no_elements_cell->value())->value() == 1;
#ifdef DEBUG
Map* root_array_map =
get_initial_js_array_map(GetInitialFastElementsKind());
- JSObject* initial_array_proto = JSObject::cast(*initial_array_prototype());
- JSObject* initial_object_proto = JSObject::cast(*initial_object_prototype());
+ Context* native_context = context()->native_context();
+ JSObject* initial_array_proto = JSObject::cast(
+ native_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX));
+ JSObject* initial_object_proto = JSObject::cast(
+ native_context->get(Context::INITIAL_OBJECT_PROTOTYPE_INDEX));
if (root_array_map == NULL || initial_array_proto == initial_object_proto) {
// We are in the bootstrapping process, and the entire check sequence
void Isolate::UpdateArrayProtectorOnSetElement(Handle<JSObject> object) {
- Handle<PropertyCell> array_protector = factory()->array_protector();
if (IsFastArrayConstructorPrototypeChainIntact() &&
object->map()->is_prototype_map()) {
Object* context = heap()->native_contexts_list();
*object ||
current_context->get(Context::INITIAL_ARRAY_PROTOTYPE_INDEX) ==
*object) {
- PropertyCell::SetValueWithInvalidation(array_protector,
+ PropertyCell::SetValueWithInvalidation(factory()->array_protector(),
handle(Smi::FromInt(0), this));
break;
}
// object prototype. Also ensure that changes to prototype chain between
// Array and Object fire notifications.
void UpdateArrayProtectorOnSetElement(Handle<JSObject> object);
+ void UpdateArrayProtectorOnSetLength(Handle<JSObject> object) {
+ UpdateArrayProtectorOnSetElement(object);
+ }
void UpdateArrayProtectorOnSetPrototype(Handle<JSObject> object) {
UpdateArrayProtectorOnSetElement(object);
}
DCHECK(!object->HasExternalArrayElements());
// Allocate a new fast elements backing store.
+ Isolate* isolate = object->GetIsolate();
Handle<FixedArray> new_elements =
- object->GetIsolate()->factory()->NewUninitializedFixedArray(capacity);
+ isolate->factory()->NewUninitializedFixedArray(capacity);
+
+ isolate->UpdateArrayProtectorOnSetLength(object);
ElementsKind elements_kind = object->GetElementsKind();
ElementsKind new_elements_kind;
BreakArrayGuarantees("Object.prototype[3] = 'three';");
BreakArrayGuarantees("Array.prototype.push(1);");
BreakArrayGuarantees("Array.prototype.unshift(1);");
+ // Break fast array hole handling by changing length.
+ BreakArrayGuarantees("Array.prototype.length = 30;");
// Break fast array hole handling by prototype structure changes.
BreakArrayGuarantees("[].__proto__.__proto__ = { funny: true };");
// By sending elements to dictionary mode.