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 10003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10014 array->set_elements(*storage_); | 10014 array->set_elements(*storage_); |
10015 return array; | 10015 return array; |
10016 } | 10016 } |
10017 | 10017 |
10018 private: | 10018 private: |
10019 // Convert storage to dictionary mode. | 10019 // Convert storage to dictionary mode. |
10020 void SetDictionaryMode(uint32_t index) { | 10020 void SetDictionaryMode(uint32_t index) { |
10021 ASSERT(fast_elements_); | 10021 ASSERT(fast_elements_); |
10022 Handle<FixedArray> current_storage(*storage_); | 10022 Handle<FixedArray> current_storage(*storage_); |
10023 Handle<SeededNumberDictionary> slow_storage( | 10023 Handle<SeededNumberDictionary> slow_storage( |
10024 isolate_->factory()->NewSeededNumberDictionary( | 10024 SeededNumberDictionary::New(isolate_, current_storage->length())); |
10025 current_storage->length())); | |
10026 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); | 10025 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); |
10027 for (uint32_t i = 0; i < current_length; i++) { | 10026 for (uint32_t i = 0; i < current_length; i++) { |
10028 HandleScope loop_scope(isolate_); | 10027 HandleScope loop_scope(isolate_); |
10029 Handle<Object> element(current_storage->get(i), isolate_); | 10028 Handle<Object> element(current_storage->get(i), isolate_); |
10030 if (!element->IsTheHole()) { | 10029 if (!element->IsTheHole()) { |
10031 Handle<SeededNumberDictionary> new_storage = | 10030 Handle<SeededNumberDictionary> new_storage = |
10032 SeededNumberDictionary::AtNumberPut(slow_storage, i, element); | 10031 SeededNumberDictionary::AtNumberPut(slow_storage, i, element); |
10033 if (!new_storage.is_identical_to(slow_storage)) { | 10032 if (!new_storage.is_identical_to(slow_storage)) { |
10034 slow_storage = loop_scope.CloseAndEscape(new_storage); | 10033 slow_storage = loop_scope.CloseAndEscape(new_storage); |
10035 } | 10034 } |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10556 } | 10555 } |
10557 // The backing storage array must have non-existing elements to preserve | 10556 // The backing storage array must have non-existing elements to preserve |
10558 // holes across concat operations. | 10557 // holes across concat operations. |
10559 storage = isolate->factory()->NewFixedArrayWithHoles( | 10558 storage = isolate->factory()->NewFixedArrayWithHoles( |
10560 estimate_result_length); | 10559 estimate_result_length); |
10561 } else { | 10560 } else { |
10562 // TODO(126): move 25% pre-allocation logic into Dictionary::Allocate | 10561 // TODO(126): move 25% pre-allocation logic into Dictionary::Allocate |
10563 uint32_t at_least_space_for = estimate_nof_elements + | 10562 uint32_t at_least_space_for = estimate_nof_elements + |
10564 (estimate_nof_elements >> 2); | 10563 (estimate_nof_elements >> 2); |
10565 storage = Handle<FixedArray>::cast( | 10564 storage = Handle<FixedArray>::cast( |
10566 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); | 10565 SeededNumberDictionary::New(isolate, at_least_space_for)); |
10567 } | 10566 } |
10568 | 10567 |
10569 ArrayConcatVisitor visitor(isolate, storage, fast_case); | 10568 ArrayConcatVisitor visitor(isolate, storage, fast_case); |
10570 | 10569 |
10571 for (int i = 0; i < argument_count; i++) { | 10570 for (int i = 0; i < argument_count; i++) { |
10572 Handle<Object> obj(elements->get(i), isolate); | 10571 Handle<Object> obj(elements->get(i), isolate); |
10573 if (obj->IsJSArray()) { | 10572 if (obj->IsJSArray()) { |
10574 Handle<JSArray> array = Handle<JSArray>::cast(obj); | 10573 Handle<JSArray> array = Handle<JSArray>::cast(obj); |
10575 if (!IterateElements(isolate, array, &visitor)) { | 10574 if (!IterateElements(isolate, array, &visitor)) { |
10576 return isolate->heap()->exception(); | 10575 return isolate->heap()->exception(); |
(...skipping 4542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15119 } | 15118 } |
15120 return NULL; | 15119 return NULL; |
15121 } | 15120 } |
15122 | 15121 |
15123 | 15122 |
15124 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15123 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15125 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15124 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15126 } | 15125 } |
15127 | 15126 |
15128 } } // namespace v8::internal | 15127 } } // namespace v8::internal |
OLD | NEW |