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 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, new_length, new_length); | 1968 RETURN_IF_EMPTY_HANDLE_VALUE(isolate, new_length, new_length); |
1969 | 1969 |
1970 ASSERT(new_length->IsNumber()); | 1970 ASSERT(new_length->IsNumber()); |
1971 array->set_length(*new_length); | 1971 array->set_length(*new_length); |
1972 return array; | 1972 return array; |
1973 } else { | 1973 } else { |
1974 return ThrowArrayLengthRangeError(isolate); | 1974 return ThrowArrayLengthRangeError(isolate); |
1975 } | 1975 } |
1976 } | 1976 } |
1977 | 1977 |
1978 Factory* factory = isolate->factory(); | |
1979 // Fall-back case: The new length is not a number so make the array | 1978 // Fall-back case: The new length is not a number so make the array |
1980 // size one and set only element to length. | 1979 // size one and set only element to length. |
1981 Handle<FixedArray> new_backing_store = factory->NewFixedArray(1); | 1980 Handle<FixedArray> new_backing_store = isolate->factory()->NewFixedArray(1); |
1982 new_backing_store->set(0, *length); | 1981 new_backing_store->set(0, *length); |
1983 factory->SetContent(array, new_backing_store); | 1982 JSArray::SetContent(array, new_backing_store); |
1984 return array; | 1983 return array; |
1985 } | 1984 } |
1986 | 1985 |
1987 | 1986 |
1988 Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, | 1987 Handle<Object> ArrayConstructInitializeElements(Handle<JSArray> array, |
1989 Arguments* args) { | 1988 Arguments* args) { |
1990 // Optimize the case where there is one argument and the argument is a | 1989 // Optimize the case where there is one argument and the argument is a |
1991 // small smi. | 1990 // small smi. |
1992 if (args->length() == 1) { | 1991 if (args->length() == 1) { |
1993 Handle<Object> obj = args->at<Object>(0); | 1992 Handle<Object> obj = args->at<Object>(0); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 UNREACHABLE(); | 2070 UNREACHABLE(); |
2072 break; | 2071 break; |
2073 } | 2072 } |
2074 | 2073 |
2075 array->set_elements(*elms); | 2074 array->set_elements(*elms); |
2076 array->set_length(Smi::FromInt(number_of_elements)); | 2075 array->set_length(Smi::FromInt(number_of_elements)); |
2077 return array; | 2076 return array; |
2078 } | 2077 } |
2079 | 2078 |
2080 } } // namespace v8::internal | 2079 } } // namespace v8::internal |
OLD | NEW |