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

Side by Side Diff: src/runtime.cc

Issue 356503005: Version 3.26.31.8 (merged r21903) (Closed) Base URL: https://v8.googlecode.com/svn/branches/3.26
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/version.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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "v8.h" 8 #include "v8.h"
9 9
10 #include "accessors.h" 10 #include "accessors.h"
(...skipping 10008 matching lines...) Expand 10 before | Expand all | Expand 10 after
10019 10019
10020 if (fast_elements_) { 10020 if (fast_elements_) {
10021 if (index < static_cast<uint32_t>(storage_->length())) { 10021 if (index < static_cast<uint32_t>(storage_->length())) {
10022 storage_->set(index, *elm); 10022 storage_->set(index, *elm);
10023 return; 10023 return;
10024 } 10024 }
10025 // Our initial estimate of length was foiled, possibly by 10025 // Our initial estimate of length was foiled, possibly by
10026 // getters on the arrays increasing the length of later arrays 10026 // getters on the arrays increasing the length of later arrays
10027 // during iteration. 10027 // during iteration.
10028 // This shouldn't happen in anything but pathological cases. 10028 // This shouldn't happen in anything but pathological cases.
10029 SetDictionaryMode(index); 10029 SetDictionaryMode();
10030 // Fall-through to dictionary mode. 10030 // Fall-through to dictionary mode.
10031 } 10031 }
10032 ASSERT(!fast_elements_); 10032 ASSERT(!fast_elements_);
10033 Handle<SeededNumberDictionary> dict( 10033 Handle<SeededNumberDictionary> dict(
10034 SeededNumberDictionary::cast(*storage_)); 10034 SeededNumberDictionary::cast(*storage_));
10035 Handle<SeededNumberDictionary> result = 10035 Handle<SeededNumberDictionary> result =
10036 SeededNumberDictionary::AtNumberPut(dict, index, elm); 10036 SeededNumberDictionary::AtNumberPut(dict, index, elm);
10037 if (!result.is_identical_to(dict)) { 10037 if (!result.is_identical_to(dict)) {
10038 // Dictionary needed to grow. 10038 // Dictionary needed to grow.
10039 clear_storage(); 10039 clear_storage();
10040 set_storage(*result); 10040 set_storage(*result);
10041 } 10041 }
10042 } 10042 }
10043 10043
10044 void increase_index_offset(uint32_t delta) { 10044 void increase_index_offset(uint32_t delta) {
10045 if (JSObject::kMaxElementCount - index_offset_ < delta) { 10045 if (JSObject::kMaxElementCount - index_offset_ < delta) {
10046 index_offset_ = JSObject::kMaxElementCount; 10046 index_offset_ = JSObject::kMaxElementCount;
10047 } else { 10047 } else {
10048 index_offset_ += delta; 10048 index_offset_ += delta;
10049 } 10049 }
10050 // If the initial length estimate was off (see special case in visit()),
10051 // but the array blowing the limit didn't contain elements beyond the
10052 // provided-for index range, go to dictionary mode now.
10053 if (fast_elements_ &&
10054 index_offset_ >= static_cast<uint32_t>(
10055 FixedArrayBase::cast(*storage_)->length())) {
10056 SetDictionaryMode();
10057 }
10050 } 10058 }
10051 10059
10052 bool exceeds_array_limit() { 10060 bool exceeds_array_limit() {
10053 return exceeds_array_limit_; 10061 return exceeds_array_limit_;
10054 } 10062 }
10055 10063
10056 Handle<JSArray> ToArray() { 10064 Handle<JSArray> ToArray() {
10057 Handle<JSArray> array = isolate_->factory()->NewJSArray(0); 10065 Handle<JSArray> array = isolate_->factory()->NewJSArray(0);
10058 Handle<Object> length = 10066 Handle<Object> length =
10059 isolate_->factory()->NewNumber(static_cast<double>(index_offset_)); 10067 isolate_->factory()->NewNumber(static_cast<double>(index_offset_));
10060 Handle<Map> map = JSObject::GetElementsTransitionMap( 10068 Handle<Map> map = JSObject::GetElementsTransitionMap(
10061 array, 10069 array,
10062 fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS); 10070 fast_elements_ ? FAST_HOLEY_ELEMENTS : DICTIONARY_ELEMENTS);
10063 array->set_map(*map); 10071 array->set_map(*map);
10064 array->set_length(*length); 10072 array->set_length(*length);
10065 array->set_elements(*storage_); 10073 array->set_elements(*storage_);
10066 return array; 10074 return array;
10067 } 10075 }
10068 10076
10069 private: 10077 private:
10070 // Convert storage to dictionary mode. 10078 // Convert storage to dictionary mode.
10071 void SetDictionaryMode(uint32_t index) { 10079 void SetDictionaryMode() {
10072 ASSERT(fast_elements_); 10080 ASSERT(fast_elements_);
10073 Handle<FixedArray> current_storage(*storage_); 10081 Handle<FixedArray> current_storage(*storage_);
10074 Handle<SeededNumberDictionary> slow_storage( 10082 Handle<SeededNumberDictionary> slow_storage(
10075 SeededNumberDictionary::New(isolate_, current_storage->length())); 10083 SeededNumberDictionary::New(isolate_, current_storage->length()));
10076 uint32_t current_length = static_cast<uint32_t>(current_storage->length()); 10084 uint32_t current_length = static_cast<uint32_t>(current_storage->length());
10077 for (uint32_t i = 0; i < current_length; i++) { 10085 for (uint32_t i = 0; i < current_length; i++) {
10078 HandleScope loop_scope(isolate_); 10086 HandleScope loop_scope(isolate_);
10079 Handle<Object> element(current_storage->get(i), isolate_); 10087 Handle<Object> element(current_storage->get(i), isolate_);
10080 if (!element->IsTheHole()) { 10088 if (!element->IsTheHole()) {
10081 Handle<SeededNumberDictionary> new_storage = 10089 Handle<SeededNumberDictionary> new_storage =
(...skipping 5181 matching lines...) Expand 10 before | Expand all | Expand 10 after
15263 } 15271 }
15264 return NULL; 15272 return NULL;
15265 } 15273 }
15266 15274
15267 15275
15268 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15276 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15269 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15277 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15270 } 15278 }
15271 15279
15272 } } // namespace v8::internal 15280 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698