Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: src/runtime/runtime-object.cc

Issue 2885883004: [heap] Fix verification of unsafe object layout changes. (Closed)
Patch Set: remove redundant check Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects-inl.h ('k') | test/cctest/test-mementos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 123 }
124 124
125 // Fall back to GetObjectProperty. 125 // Fall back to GetObjectProperty.
126 return Runtime::GetObjectProperty(isolate, receiver_obj, key_obj); 126 return Runtime::GetObjectProperty(isolate, receiver_obj, key_obj);
127 } 127 }
128 128
129 namespace { 129 namespace {
130 130
131 bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver, 131 bool DeleteObjectPropertyFast(Isolate* isolate, Handle<JSReceiver> receiver,
132 Handle<Object> raw_key) { 132 Handle<Object> raw_key) {
133 DisallowHeapAllocation no_allocation;
133 // This implements a special case for fast property deletion: when the 134 // This implements a special case for fast property deletion: when the
134 // last property in an object is deleted, then instead of normalizing 135 // last property in an object is deleted, then instead of normalizing
135 // the properties, we can undo the last map transition, with a few 136 // the properties, we can undo the last map transition, with a few
136 // prerequisites: 137 // prerequisites:
137 // (1) The receiver must be a regular object and the key a unique name. 138 // (1) The receiver must be a regular object and the key a unique name.
138 Map* map = receiver->map(); 139 Map* map = receiver->map();
139 if (map->IsSpecialReceiverMap()) return false; 140 if (map->IsSpecialReceiverMap()) return false;
140 if (!raw_key->IsUniqueName()) return false; 141 if (!raw_key->IsUniqueName()) return false;
141 Handle<Name> key = Handle<Name>::cast(raw_key); 142 Handle<Name> key = Handle<Name>::cast(raw_key);
142 // (2) The property to be deleted must be the last property. 143 // (2) The property to be deleted must be the last property.
(...skipping 10 matching lines...) Expand all
153 if (!backpointer->IsMap()) return false; 154 if (!backpointer->IsMap()) return false;
154 // (5) The last transition must have been caused by adding a property 155 // (5) The last transition must have been caused by adding a property
155 // (and not any kind of special transition). 156 // (and not any kind of special transition).
156 if (Map::cast(backpointer)->NumberOfOwnDescriptors() != nof - 1) return false; 157 if (Map::cast(backpointer)->NumberOfOwnDescriptors() != nof - 1) return false;
157 158
158 // Preconditions successful. No more bailouts after this point. 159 // Preconditions successful. No more bailouts after this point.
159 160
160 // Zap the property to avoid keeping objects alive. Zapping is not necessary 161 // Zap the property to avoid keeping objects alive. Zapping is not necessary
161 // for properties stored in the descriptor array. 162 // for properties stored in the descriptor array.
162 if (details.location() == kField) { 163 if (details.location() == kField) {
164 isolate->heap()->NotifyObjectLayoutChange(*receiver, no_allocation);
163 Object* filler = isolate->heap()->one_pointer_filler_map(); 165 Object* filler = isolate->heap()->one_pointer_filler_map();
164 FieldIndex index = FieldIndex::ForPropertyIndex(map, details.field_index()); 166 FieldIndex index = FieldIndex::ForPropertyIndex(map, details.field_index());
165 JSObject::cast(*receiver)->RawFastPropertyAtPut(index, filler); 167 JSObject::cast(*receiver)->RawFastPropertyAtPut(index, filler);
166 // We must clear any recorded slot for the deleted property, because 168 // We must clear any recorded slot for the deleted property, because
167 // subsequent object modifications might put a raw double there. 169 // subsequent object modifications might put a raw double there.
168 // Slot clearing is the reason why this entire function cannot currently 170 // Slot clearing is the reason why this entire function cannot currently
169 // be implemented in the DeleteProperty stub. 171 // be implemented in the DeleteProperty stub.
170 if (index.is_inobject() && !map->IsUnboxedDoubleField(index)) { 172 if (index.is_inobject() && !map->IsUnboxedDoubleField(index)) {
171 isolate->heap()->ClearRecordedSlot( 173 isolate->heap()->ClearRecordedSlot(
172 *receiver, HeapObject::RawField(*receiver, index.offset())); 174 *receiver, HeapObject::RawField(*receiver, index.offset()));
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 // While iteration alone may not have observable side-effects, calling 1118 // While iteration alone may not have observable side-effects, calling
1117 // toNumber on an object will. Make sure the arg is not an array of objects. 1119 // toNumber on an object will. Make sure the arg is not an array of objects.
1118 ElementsKind kind = JSObject::cast(*obj)->GetElementsKind(); 1120 ElementsKind kind = JSObject::cast(*obj)->GetElementsKind();
1119 if (!IsFastNumberElementsKind(kind)) return isolate->heap()->ToBoolean(false); 1121 if (!IsFastNumberElementsKind(kind)) return isolate->heap()->ToBoolean(false);
1120 1122
1121 return isolate->heap()->ToBoolean(!obj->IterationHasObservableEffects()); 1123 return isolate->heap()->ToBoolean(!obj->IterationHasObservableEffects());
1122 } 1124 }
1123 1125
1124 } // namespace internal 1126 } // namespace internal
1125 } // namespace v8 1127 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | test/cctest/test-mementos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698