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

Side by Side Diff: src/runtime.cc

Issue 23622016: limit InitialMaxFastElement by MaxRegularSpaceAllocationSize (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Created 7 years, 3 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/objects.cc ('k') | no next file » | 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 14501 matching lines...) Expand 10 before | Expand all | Expand 10 after
14512 return object; 14512 return object;
14513 } 14513 }
14514 14514
14515 14515
14516 static MaybeObject* ArrayConstructorCommon(Isolate* isolate, 14516 static MaybeObject* ArrayConstructorCommon(Isolate* isolate,
14517 Handle<JSFunction> constructor, 14517 Handle<JSFunction> constructor,
14518 Handle<Object> type_info, 14518 Handle<Object> type_info,
14519 Arguments* caller_args) { 14519 Arguments* caller_args) {
14520 bool holey = false; 14520 bool holey = false;
14521 bool can_use_type_feedback = true; 14521 bool can_use_type_feedback = true;
14522 Heap* heap = isolate->heap();
14522 if (caller_args->length() == 1) { 14523 if (caller_args->length() == 1) {
14523 Object* argument_one = (*caller_args)[0]; 14524 Object* argument_one = (*caller_args)[0];
14524 if (argument_one->IsSmi()) { 14525 if (argument_one->IsSmi()) {
14525 int value = Smi::cast(argument_one)->value(); 14526 int value = Smi::cast(argument_one)->value();
14526 if (value < 0 || value >= JSObject::kInitialMaxFastElementArray) { 14527 if (value < 0 || value >= JSObject::InitialMaxFastElementArray(heap)) {
14527 // the array is a dictionary in this case. 14528 // the array is a dictionary in this case.
14528 can_use_type_feedback = false; 14529 can_use_type_feedback = false;
14529 } else if (value != 0) { 14530 } else if (value != 0) {
14530 holey = true; 14531 holey = true;
14531 } 14532 }
14532 } else { 14533 } else {
14533 // Non-smi length argument produces a dictionary 14534 // Non-smi length argument produces a dictionary
14534 can_use_type_feedback = false; 14535 can_use_type_feedback = false;
14535 } 14536 }
14536 } 14537 }
14537 14538
14538 JSArray* array; 14539 JSArray* array;
14539 MaybeObject* maybe_array; 14540 MaybeObject* maybe_array;
14540 if (!type_info.is_null() && 14541 if (!type_info.is_null() &&
14541 *type_info != isolate->heap()->undefined_value() && 14542 *type_info != heap->undefined_value() &&
14542 Cell::cast(*type_info)->value()->IsAllocationSite() && 14543 Cell::cast(*type_info)->value()->IsAllocationSite() &&
14543 can_use_type_feedback) { 14544 can_use_type_feedback) {
14544 Handle<Cell> cell = Handle<Cell>::cast(type_info); 14545 Handle<Cell> cell = Handle<Cell>::cast(type_info);
14545 Handle<AllocationSite> site = Handle<AllocationSite>( 14546 Handle<AllocationSite> site = Handle<AllocationSite>(
14546 AllocationSite::cast(cell->value()), isolate); 14547 AllocationSite::cast(cell->value()), isolate);
14547 ASSERT(!site->IsLiteralSite()); 14548 ASSERT(!site->IsLiteralSite());
14548 ElementsKind to_kind = site->GetElementsKind(); 14549 ElementsKind to_kind = site->GetElementsKind();
14549 if (holey && !IsFastHoleyElementsKind(to_kind)) { 14550 if (holey && !IsFastHoleyElementsKind(to_kind)) {
14550 to_kind = GetHoleyElementsKind(to_kind); 14551 to_kind = GetHoleyElementsKind(to_kind);
14551 // Update the allocation site info to reflect the advice alteration. 14552 // Update the allocation site info to reflect the advice alteration.
14552 site->SetElementsKind(to_kind); 14553 site->SetElementsKind(to_kind);
14553 } 14554 }
14554 14555
14555 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( 14556 maybe_array = heap->AllocateJSObjectWithAllocationSite(
14556 *constructor, site); 14557 *constructor, site);
14557 if (!maybe_array->To(&array)) return maybe_array; 14558 if (!maybe_array->To(&array)) return maybe_array;
14558 } else { 14559 } else {
14559 maybe_array = isolate->heap()->AllocateJSObject(*constructor); 14560 maybe_array = heap->AllocateJSObject(*constructor);
14560 if (!maybe_array->To(&array)) return maybe_array; 14561 if (!maybe_array->To(&array)) return maybe_array;
14561 // We might need to transition to holey 14562 // We might need to transition to holey
14562 ElementsKind kind = constructor->initial_map()->elements_kind(); 14563 ElementsKind kind = constructor->initial_map()->elements_kind();
14563 if (holey && !IsFastHoleyElementsKind(kind)) { 14564 if (holey && !IsFastHoleyElementsKind(kind)) {
14564 kind = GetHoleyElementsKind(kind); 14565 kind = GetHoleyElementsKind(kind);
14565 maybe_array = array->TransitionElementsKind(kind); 14566 maybe_array = array->TransitionElementsKind(kind);
14566 if (maybe_array->IsFailure()) return maybe_array; 14567 if (maybe_array->IsFailure()) return maybe_array;
14567 } 14568 }
14568 } 14569 }
14569 14570
14570 maybe_array = isolate->heap()->AllocateJSArrayStorage(array, 0, 0, 14571 maybe_array = heap->AllocateJSArrayStorage(array, 0, 0,
14571 DONT_INITIALIZE_ARRAY_ELEMENTS); 14572 DONT_INITIALIZE_ARRAY_ELEMENTS);
14572 if (maybe_array->IsFailure()) return maybe_array; 14573 if (maybe_array->IsFailure()) return maybe_array;
14573 maybe_array = ArrayConstructInitializeElements(array, caller_args); 14574 maybe_array = ArrayConstructInitializeElements(array, caller_args);
14574 if (maybe_array->IsFailure()) return maybe_array; 14575 if (maybe_array->IsFailure()) return maybe_array;
14575 return array; 14576 return array;
14576 } 14577 }
14577 14578
14578 14579
14579 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConstructor) { 14580 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConstructor) {
14580 HandleScope scope(isolate); 14581 HandleScope scope(isolate);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
14695 // Handle last resort GC and make sure to allow future allocations 14696 // Handle last resort GC and make sure to allow future allocations
14696 // to grow the heap without causing GCs (if possible). 14697 // to grow the heap without causing GCs (if possible).
14697 isolate->counters()->gc_last_resort_from_js()->Increment(); 14698 isolate->counters()->gc_last_resort_from_js()->Increment();
14698 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14699 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14699 "Runtime::PerformGC"); 14700 "Runtime::PerformGC");
14700 } 14701 }
14701 } 14702 }
14702 14703
14703 14704
14704 } } // namespace v8::internal 14705 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698