Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/builtins.h" | 5 #include "src/builtins.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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 PrototypeIterator iter(isolate, receiver); | 244 PrototypeIterator iter(isolate, receiver); |
| 245 return PrototypeHasNoElements(&iter); | 245 return PrototypeHasNoElements(&iter); |
| 246 } | 246 } |
| 247 | 247 |
| 248 | 248 |
| 249 // Returns empty handle if not applicable. | 249 // Returns empty handle if not applicable. |
| 250 MUST_USE_RESULT | 250 MUST_USE_RESULT |
| 251 inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( | 251 inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( |
| 252 Isolate* isolate, Handle<Object> receiver, Arguments* args, | 252 Isolate* isolate, Handle<Object> receiver, Arguments* args, |
| 253 int first_added_arg) { | 253 int first_added_arg) { |
| 254 // We explicitly add a HandleScope to avoid creating several copies of the | |
| 255 // same handle which would otherwise cause issue when left-trimming later-on. | |
| 256 HandleScope scope(isolate); | |
| 254 if (!receiver->IsJSArray()) return MaybeHandle<FixedArrayBase>(); | 257 if (!receiver->IsJSArray()) return MaybeHandle<FixedArrayBase>(); |
| 255 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 258 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 256 // If there may be elements accessors in the prototype chain, the fast path | 259 // If there may be elements accessors in the prototype chain, the fast path |
| 257 // cannot be used if there arguments to add to the array. | 260 // cannot be used if there arguments to add to the array. |
| 258 Heap* heap = isolate->heap(); | 261 Heap* heap = isolate->heap(); |
| 259 if (args != NULL && !IsJSArrayFastElementMovingAllowed(isolate, *array)) { | 262 if (args != NULL && !IsJSArrayFastElementMovingAllowed(isolate, *array)) { |
| 260 return MaybeHandle<FixedArrayBase>(); | 263 return MaybeHandle<FixedArrayBase>(); |
| 261 } | 264 } |
| 262 if (array->map()->is_observed()) return MaybeHandle<FixedArrayBase>(); | 265 if (array->map()->is_observed()) return MaybeHandle<FixedArrayBase>(); |
| 263 if (!array->map()->is_extensible()) return MaybeHandle<FixedArrayBase>(); | 266 if (!array->map()->is_extensible()) return MaybeHandle<FixedArrayBase>(); |
| 264 Handle<FixedArrayBase> elms(array->elements(), isolate); | 267 Handle<FixedArrayBase> elms(array->elements(), isolate); |
| 265 Map* map = elms->map(); | 268 Map* map = elms->map(); |
| 266 if (map == heap->fixed_array_map()) { | 269 if (map == heap->fixed_array_map()) { |
| 267 if (args == NULL || array->HasFastObjectElements()) return elms; | 270 if (args == NULL || array->HasFastObjectElements()) return elms; |
|
ulan
2016/02/15 15:33:09
I think CloseAndEscape should be used here and in
| |
| 268 } else if (map == heap->fixed_cow_array_map()) { | 271 } else if (map == heap->fixed_cow_array_map()) { |
| 269 elms = JSObject::EnsureWritableFastElements(array); | 272 elms = JSObject::EnsureWritableFastElements(array); |
| 270 if (args == NULL || array->HasFastObjectElements()) return elms; | 273 if (args == NULL || array->HasFastObjectElements()) return elms; |
| 271 } else if (map == heap->fixed_double_array_map()) { | 274 } else if (map == heap->fixed_double_array_map()) { |
| 272 if (args == NULL) return elms; | 275 if (args == NULL) return elms; |
| 273 } else { | 276 } else { |
| 274 return MaybeHandle<FixedArrayBase>(); | 277 return MaybeHandle<FixedArrayBase>(); |
| 275 } | 278 } |
| 276 | 279 |
| 277 // Adding elements to the array prototype would break code that makes sure | 280 // Adding elements to the array prototype would break code that makes sure |
| (...skipping 4099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4377 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4380 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 4378 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4381 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4379 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4382 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 4380 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4383 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4381 #undef DEFINE_BUILTIN_ACCESSOR_C | 4384 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 4382 #undef DEFINE_BUILTIN_ACCESSOR_A | 4385 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 4383 | 4386 |
| 4384 | 4387 |
| 4385 } // namespace internal | 4388 } // namespace internal |
| 4386 } // namespace v8 | 4389 } // namespace v8 |
| OLD | NEW |