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

Side by Side Diff: src/elements.cc

Issue 260083011: Return MaybeHandle from Object::ToSmi. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/ic.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 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 "v8.h" 5 #include "v8.h"
6 6
7 #include "arguments.h" 7 #include "arguments.h"
8 #include "conversions.h" 8 #include "conversions.h"
9 #include "elements.h" 9 #include "elements.h"
10 #include "objects.h" 10 #include "objects.h"
(...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 MUST_USE_RESULT 1841 MUST_USE_RESULT
1842 MaybeHandle<Object> ElementsAccessorBase<ElementsAccessorSubclass, 1842 MaybeHandle<Object> ElementsAccessorBase<ElementsAccessorSubclass,
1843 ElementsKindTraits>:: 1843 ElementsKindTraits>::
1844 SetLengthImpl(Handle<JSObject> obj, 1844 SetLengthImpl(Handle<JSObject> obj,
1845 Handle<Object> length, 1845 Handle<Object> length,
1846 Handle<FixedArrayBase> backing_store) { 1846 Handle<FixedArrayBase> backing_store) {
1847 Isolate* isolate = obj->GetIsolate(); 1847 Isolate* isolate = obj->GetIsolate();
1848 Handle<JSArray> array = Handle<JSArray>::cast(obj); 1848 Handle<JSArray> array = Handle<JSArray>::cast(obj);
1849 1849
1850 // Fast case: The new length fits into a Smi. 1850 // Fast case: The new length fits into a Smi.
1851 Handle<Object> smi_length = Object::ToSmi(isolate, length); 1851 Handle<Object> smi_length;
1852 1852
1853 if (!smi_length.is_null() && smi_length->IsSmi()) { 1853 if (Object::ToSmi(isolate, length).ToHandle(&smi_length) &&
1854 smi_length->IsSmi()) {
1854 const int value = Handle<Smi>::cast(smi_length)->value(); 1855 const int value = Handle<Smi>::cast(smi_length)->value();
1855 if (value >= 0) { 1856 if (value >= 0) {
1856 Handle<Object> new_length = ElementsAccessorSubclass:: 1857 Handle<Object> new_length = ElementsAccessorSubclass::
1857 SetLengthWithoutNormalize(backing_store, array, smi_length, value); 1858 SetLengthWithoutNormalize(backing_store, array, smi_length, value);
1858 ASSERT(!new_length.is_null()); 1859 ASSERT(!new_length.is_null());
1859 1860
1860 // even though the proposed length was a smi, new_length could 1861 // even though the proposed length was a smi, new_length could
1861 // still be a heap number because SetLengthWithoutNormalize doesn't 1862 // still be a heap number because SetLengthWithoutNormalize doesn't
1862 // allow the array length property to drop below the index of 1863 // allow the array length property to drop below the index of
1863 // non-deletable elements. 1864 // non-deletable elements.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 UNREACHABLE(); 1992 UNREACHABLE();
1992 break; 1993 break;
1993 } 1994 }
1994 1995
1995 array->set_elements(*elms); 1996 array->set_elements(*elms);
1996 array->set_length(Smi::FromInt(number_of_elements)); 1997 array->set_length(Smi::FromInt(number_of_elements));
1997 return array; 1998 return array;
1998 } 1999 }
1999 2000
2000 } } // namespace v8::internal 2001 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698