| OLD | NEW | 
|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 9396 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 9407       index_offset_ += delta; | 9407       index_offset_ += delta; | 
| 9408     } | 9408     } | 
| 9409   } | 9409   } | 
| 9410 | 9410 | 
| 9411   Handle<JSArray> ToArray() { | 9411   Handle<JSArray> ToArray() { | 
| 9412     Handle<JSArray> array = isolate_->factory()->NewJSArray(0); | 9412     Handle<JSArray> array = isolate_->factory()->NewJSArray(0); | 
| 9413     Handle<Object> length = | 9413     Handle<Object> length = | 
| 9414         isolate_->factory()->NewNumber(static_cast<double>(index_offset_)); | 9414         isolate_->factory()->NewNumber(static_cast<double>(index_offset_)); | 
| 9415     Handle<Map> map; | 9415     Handle<Map> map; | 
| 9416     if (fast_elements_) { | 9416     if (fast_elements_) { | 
| 9417       map = isolate_->factory()->GetFastElementsMap(Handle<Map>(array->map())); | 9417       map = isolate_->factory()->GetElementsTransitionMap(array, | 
|  | 9418                                                           FAST_ELEMENTS); | 
| 9418     } else { | 9419     } else { | 
| 9419       map = isolate_->factory()->GetSlowElementsMap(Handle<Map>(array->map())); | 9420       map = isolate_->factory()->GetElementsTransitionMap(array, | 
|  | 9421                                                           DICTIONARY_ELEMENTS); | 
| 9420     } | 9422     } | 
| 9421     array->set_map(*map); | 9423     array->set_map(*map); | 
| 9422     array->set_length(*length); | 9424     array->set_length(*length); | 
| 9423     array->set_elements(*storage_); | 9425     array->set_elements(*storage_); | 
| 9424     return array; | 9426     return array; | 
| 9425   } | 9427   } | 
| 9426 | 9428 | 
| 9427  private: | 9429  private: | 
| 9428   // Convert storage to dictionary mode. | 9430   // Convert storage to dictionary mode. | 
| 9429   void SetDictionaryMode(uint32_t index) { | 9431   void SetDictionaryMode(uint32_t index) { | 
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 9900 } | 9902 } | 
| 9901 | 9903 | 
| 9902 | 9904 | 
| 9903 // Move contents of argument 0 (an array) to argument 1 (an array) | 9905 // Move contents of argument 0 (an array) to argument 1 (an array) | 
| 9904 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 9906 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 
| 9905   ASSERT(args.length() == 2); | 9907   ASSERT(args.length() == 2); | 
| 9906   CONVERT_CHECKED(JSArray, from, args[0]); | 9908   CONVERT_CHECKED(JSArray, from, args[0]); | 
| 9907   CONVERT_CHECKED(JSArray, to, args[1]); | 9909   CONVERT_CHECKED(JSArray, to, args[1]); | 
| 9908   FixedArrayBase* new_elements = from->elements(); | 9910   FixedArrayBase* new_elements = from->elements(); | 
| 9909   MaybeObject* maybe_new_map; | 9911   MaybeObject* maybe_new_map; | 
|  | 9912   ElementsKind elements_kind; | 
| 9910   if (new_elements->map() == isolate->heap()->fixed_array_map() || | 9913   if (new_elements->map() == isolate->heap()->fixed_array_map() || | 
| 9911       new_elements->map() == isolate->heap()->fixed_cow_array_map()) { | 9914       new_elements->map() == isolate->heap()->fixed_cow_array_map()) { | 
| 9912     maybe_new_map = to->map()->GetFastElementsMap(); | 9915     elements_kind = FAST_ELEMENTS; | 
| 9913   } else if (new_elements->map() == | 9916   } else if (new_elements->map() == | 
| 9914              isolate->heap()->fixed_double_array_map()) { | 9917              isolate->heap()->fixed_double_array_map()) { | 
| 9915     maybe_new_map = to->map()->GetFastDoubleElementsMap(); | 9918     elements_kind = FAST_DOUBLE_ELEMENTS; | 
| 9916   } else { | 9919   } else { | 
| 9917     maybe_new_map = to->map()->GetSlowElementsMap(); | 9920     elements_kind = DICTIONARY_ELEMENTS; | 
| 9918   } | 9921   } | 
|  | 9922   maybe_new_map = to->GetElementsTransitionMap(elements_kind); | 
| 9919   Object* new_map; | 9923   Object* new_map; | 
| 9920   if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 9924   if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map; | 
| 9921   to->set_map(Map::cast(new_map)); | 9925   to->set_map(Map::cast(new_map)); | 
| 9922   to->set_elements(new_elements); | 9926   to->set_elements(new_elements); | 
| 9923   to->set_length(from->length()); | 9927   to->set_length(from->length()); | 
| 9924   Object* obj; | 9928   Object* obj; | 
| 9925   { MaybeObject* maybe_obj = from->ResetElements(); | 9929   { MaybeObject* maybe_obj = from->ResetElements(); | 
| 9926     if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 9930     if (!maybe_obj->ToObject(&obj)) return maybe_obj; | 
| 9927   } | 9931   } | 
| 9928   from->set_length(Smi::FromInt(0)); | 9932   from->set_length(Smi::FromInt(0)); | 
| (...skipping 3211 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 13140   } else { | 13144   } else { | 
| 13141     // Handle last resort GC and make sure to allow future allocations | 13145     // Handle last resort GC and make sure to allow future allocations | 
| 13142     // to grow the heap without causing GCs (if possible). | 13146     // to grow the heap without causing GCs (if possible). | 
| 13143     isolate->counters()->gc_last_resort_from_js()->Increment(); | 13147     isolate->counters()->gc_last_resort_from_js()->Increment(); | 
| 13144     isolate->heap()->CollectAllGarbage(false); | 13148     isolate->heap()->CollectAllGarbage(false); | 
| 13145   } | 13149   } | 
| 13146 } | 13150 } | 
| 13147 | 13151 | 
| 13148 | 13152 | 
| 13149 } }  // namespace v8::internal | 13153 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|