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

Side by Side Diff: src/elements.cc

Issue 23441080: Correct large packed array length limitation (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: make consistent change Created 7 years, 2 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 | « src/code-stubs-hydrogen.cc ('k') | src/runtime.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 // 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 1960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 MUST_USE_RESULT MaybeObject* ArrayConstructInitializeElements( 1971 MUST_USE_RESULT MaybeObject* ArrayConstructInitializeElements(
1972 JSArray* array, Arguments* args) { 1972 JSArray* array, Arguments* args) {
1973 Heap* heap = array->GetIsolate()->heap(); 1973 Heap* heap = array->GetIsolate()->heap();
1974 1974
1975 // Optimize the case where there is one argument and the argument is a 1975 // Optimize the case where there is one argument and the argument is a
1976 // small smi. 1976 // small smi.
1977 if (args->length() == 1) { 1977 if (args->length() == 1) {
1978 Object* obj = (*args)[0]; 1978 Object* obj = (*args)[0];
1979 if (obj->IsSmi()) { 1979 if (obj->IsSmi()) {
1980 int len = Smi::cast(obj)->value(); 1980 int len = Smi::cast(obj)->value();
1981 if (len > 0 && len < JSObject::kInitialMaxFastElementArray) { 1981 if (len > 0 && len <= JSObject::kInitialMaxFastElementArray) {
1982 ElementsKind elements_kind = array->GetElementsKind(); 1982 ElementsKind elements_kind = array->GetElementsKind();
1983 MaybeObject* maybe_array = array->Initialize(len, len); 1983 MaybeObject* maybe_array = array->Initialize(len, len);
1984 if (maybe_array->IsFailure()) return maybe_array; 1984 if (maybe_array->IsFailure()) return maybe_array;
1985 1985
1986 if (!IsFastHoleyElementsKind(elements_kind)) { 1986 if (!IsFastHoleyElementsKind(elements_kind)) {
1987 elements_kind = GetHoleyElementsKind(elements_kind); 1987 elements_kind = GetHoleyElementsKind(elements_kind);
1988 maybe_array = array->TransitionElementsKind(elements_kind); 1988 maybe_array = array->TransitionElementsKind(elements_kind);
1989 if (maybe_array->IsFailure()) return maybe_array; 1989 if (maybe_array->IsFailure()) return maybe_array;
1990 } 1990 }
1991 1991
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 UNREACHABLE(); 2058 UNREACHABLE();
2059 break; 2059 break;
2060 } 2060 }
2061 2061
2062 array->set_elements(elms); 2062 array->set_elements(elms);
2063 array->set_length(Smi::FromInt(number_of_elements)); 2063 array->set_length(Smi::FromInt(number_of_elements));
2064 return array; 2064 return array;
2065 } 2065 }
2066 2066
2067 } } // namespace v8::internal 2067 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698