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

Side by Side Diff: src/builtins.cc

Issue 1099203004: Revert of Protect the emptiness of Array prototype elements with a PropertyCell. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | src/compilation-dependencies.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return false; 192 return false;
193 } 193 }
194 } 194 }
195 return true; 195 return true;
196 } 196 }
197 197
198 198
199 static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap, 199 static inline bool IsJSArrayFastElementMovingAllowed(Heap* heap,
200 JSArray* receiver) { 200 JSArray* receiver) {
201 DisallowHeapAllocation no_gc; 201 DisallowHeapAllocation no_gc;
202 Isolate* isolate = heap->isolate(); 202 PrototypeIterator iter(heap->isolate(), receiver);
203 if (!isolate->IsFastArrayConstructorPrototypeChainIntact()) {
204 return false;
205 }
206
207 // If the array prototype chain is intact (and free of elements), and if the
208 // receiver's prototype is the array prototype, then we are done.
209 Object* prototype = receiver->map()->prototype();
210 if (prototype->IsJSArray() &&
211 isolate->is_initial_array_prototype(JSArray::cast(prototype))) {
212 return true;
213 }
214
215 // Slow case.
216 PrototypeIterator iter(isolate, receiver);
217 return ArrayPrototypeHasNoElements(heap, &iter); 203 return ArrayPrototypeHasNoElements(heap, &iter);
218 } 204 }
219 205
220 206
221 // Returns empty handle if not applicable. 207 // Returns empty handle if not applicable.
222 MUST_USE_RESULT 208 MUST_USE_RESULT
223 static inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( 209 static inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements(
224 Isolate* isolate, 210 Isolate* isolate,
225 Handle<Object> receiver, 211 Handle<Object> receiver,
226 Arguments* args, 212 Arguments* args,
(...skipping 16 matching lines...) Expand all
243 elms = JSObject::EnsureWritableFastElements(array); 229 elms = JSObject::EnsureWritableFastElements(array);
244 if (args == NULL || array->HasFastObjectElements()) return elms; 230 if (args == NULL || array->HasFastObjectElements()) return elms;
245 } else if (map == heap->fixed_double_array_map()) { 231 } else if (map == heap->fixed_double_array_map()) {
246 if (args == NULL) return elms; 232 if (args == NULL) return elms;
247 } else { 233 } else {
248 return MaybeHandle<FixedArrayBase>(); 234 return MaybeHandle<FixedArrayBase>();
249 } 235 }
250 236
251 // Adding elements to the array prototype would break code that makes sure 237 // Adding elements to the array prototype would break code that makes sure
252 // it has no elements. Handle that elsewhere. 238 // it has no elements. Handle that elsewhere.
253 if (isolate->IsAnyInitialArrayPrototype(array)) { 239 if (array->GetIsolate()->is_initial_array_prototype(*array)) {
254 return MaybeHandle<FixedArrayBase>(); 240 return MaybeHandle<FixedArrayBase>();
255 } 241 }
256 242
257 // Need to ensure that the arguments passed in args can be contained in 243 // Need to ensure that the arguments passed in args can be contained in
258 // the array. 244 // the array.
259 int args_length = args->length(); 245 int args_length = args->length();
260 if (first_added_arg >= args_length) return handle(array->elements(), isolate); 246 if (first_added_arg >= args_length) return handle(array->elements(), isolate);
261 247
262 ElementsKind origin_kind = array->map()->elements_kind(); 248 ElementsKind origin_kind = array->map()->elements_kind();
263 DCHECK(!IsFastObjectElementsKind(origin_kind)); 249 DCHECK(!IsFastObjectElementsKind(origin_kind));
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 } 1658 }
1673 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1659 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1674 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1660 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1675 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 1661 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
1676 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1662 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1677 #undef DEFINE_BUILTIN_ACCESSOR_C 1663 #undef DEFINE_BUILTIN_ACCESSOR_C
1678 #undef DEFINE_BUILTIN_ACCESSOR_A 1664 #undef DEFINE_BUILTIN_ACCESSOR_A
1679 1665
1680 1666
1681 } } // namespace v8::internal 1667 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/compilation-dependencies.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698