OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 MaybeObject* maybe_obj = array->GetHeap()->AllocateFixedArray(1); | 1903 MaybeObject* maybe_obj = array->GetHeap()->AllocateFixedArray(1); |
1904 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; | 1904 if (!maybe_obj->To(&new_backing_store)) return maybe_obj; |
1905 new_backing_store->set(0, length); | 1905 new_backing_store->set(0, length); |
1906 { MaybeObject* result = array->SetContent(new_backing_store); | 1906 { MaybeObject* result = array->SetContent(new_backing_store); |
1907 if (result->IsFailure()) return result; | 1907 if (result->IsFailure()) return result; |
1908 } | 1908 } |
1909 return array; | 1909 return array; |
1910 } | 1910 } |
1911 | 1911 |
1912 | 1912 |
| 1913 // TODO(ishell): Temporary wrapper until handlified. |
| 1914 Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, |
| 1915 Arguments* args) { |
| 1916 CALL_HEAP_FUNCTION(array->GetIsolate(), |
| 1917 ArrayConstructInitializeElements(*array, args), |
| 1918 Object); |
| 1919 } |
| 1920 |
| 1921 |
1913 MUST_USE_RESULT MaybeObject* ArrayConstructInitializeElements( | 1922 MUST_USE_RESULT MaybeObject* ArrayConstructInitializeElements( |
1914 JSArray* array, Arguments* args) { | 1923 JSArray* array, Arguments* args) { |
1915 Heap* heap = array->GetIsolate()->heap(); | 1924 Heap* heap = array->GetIsolate()->heap(); |
1916 | 1925 |
1917 // Optimize the case where there is one argument and the argument is a | 1926 // Optimize the case where there is one argument and the argument is a |
1918 // small smi. | 1927 // small smi. |
1919 if (args->length() == 1) { | 1928 if (args->length() == 1) { |
1920 Object* obj = (*args)[0]; | 1929 Object* obj = (*args)[0]; |
1921 if (obj->IsSmi()) { | 1930 if (obj->IsSmi()) { |
1922 int len = Smi::cast(obj)->value(); | 1931 int len = Smi::cast(obj)->value(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2000 UNREACHABLE(); | 2009 UNREACHABLE(); |
2001 break; | 2010 break; |
2002 } | 2011 } |
2003 | 2012 |
2004 array->set_elements(elms); | 2013 array->set_elements(elms); |
2005 array->set_length(Smi::FromInt(number_of_elements)); | 2014 array->set_length(Smi::FromInt(number_of_elements)); |
2006 return array; | 2015 return array; |
2007 } | 2016 } |
2008 | 2017 |
2009 } } // namespace v8::internal | 2018 } } // namespace v8::internal |
OLD | NEW |