OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 12954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12965 if (length == 0) return 0; | 12965 if (length == 0) return 0; |
12966 } | 12966 } |
12967 // Compute the number of enumerable elements. | 12967 // Compute the number of enumerable elements. |
12968 return NumberOfOwnElements(static_cast<PropertyAttributes>(DONT_ENUM)); | 12968 return NumberOfOwnElements(static_cast<PropertyAttributes>(DONT_ENUM)); |
12969 } | 12969 } |
12970 | 12970 |
12971 | 12971 |
12972 int JSObject::GetOwnElementKeys(FixedArray* storage, | 12972 int JSObject::GetOwnElementKeys(FixedArray* storage, |
12973 PropertyAttributes filter) { | 12973 PropertyAttributes filter) { |
12974 int counter = 0; | 12974 int counter = 0; |
| 12975 |
| 12976 // If this is a String wrapper, add the string indices first, |
| 12977 // as they're guaranteed to preced the elements in numerical order |
| 12978 // and ascending order is required by ECMA-262, 6th, 9.1.12. |
| 12979 if (IsJSValue()) { |
| 12980 Object* val = JSValue::cast(this)->value(); |
| 12981 if (val->IsString()) { |
| 12982 String* str = String::cast(val); |
| 12983 if (storage) { |
| 12984 for (int i = 0; i < str->length(); i++) { |
| 12985 storage->set(counter + i, Smi::FromInt(i)); |
| 12986 } |
| 12987 } |
| 12988 counter += str->length(); |
| 12989 } |
| 12990 } |
| 12991 |
12975 switch (GetElementsKind()) { | 12992 switch (GetElementsKind()) { |
12976 case FAST_SMI_ELEMENTS: | 12993 case FAST_SMI_ELEMENTS: |
12977 case FAST_ELEMENTS: | 12994 case FAST_ELEMENTS: |
12978 case FAST_HOLEY_SMI_ELEMENTS: | 12995 case FAST_HOLEY_SMI_ELEMENTS: |
12979 case FAST_HOLEY_ELEMENTS: { | 12996 case FAST_HOLEY_ELEMENTS: { |
12980 int length = IsJSArray() ? | 12997 int length = IsJSArray() ? |
12981 Smi::cast(JSArray::cast(this)->length())->value() : | 12998 Smi::cast(JSArray::cast(this)->length())->value() : |
12982 FixedArray::cast(elements())->length(); | 12999 FixedArray::cast(elements())->length(); |
12983 for (int i = 0; i < length; i++) { | 13000 for (int i = 0; i < length; i++) { |
12984 if (!FixedArray::cast(elements())->get(i)->IsTheHole()) { | 13001 if (!FixedArray::cast(elements())->get(i)->IsTheHole()) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13071 } | 13088 } |
13072 for (; i < backing_length; ++i) { | 13089 for (; i < backing_length; ++i) { |
13073 if (storage != NULL) storage->set(counter, Smi::FromInt(i)); | 13090 if (storage != NULL) storage->set(counter, Smi::FromInt(i)); |
13074 ++counter; | 13091 ++counter; |
13075 } | 13092 } |
13076 } | 13093 } |
13077 break; | 13094 break; |
13078 } | 13095 } |
13079 } | 13096 } |
13080 | 13097 |
13081 if (this->IsJSValue()) { | |
13082 Object* val = JSValue::cast(this)->value(); | |
13083 if (val->IsString()) { | |
13084 String* str = String::cast(val); | |
13085 if (storage) { | |
13086 for (int i = 0; i < str->length(); i++) { | |
13087 storage->set(counter + i, Smi::FromInt(i)); | |
13088 } | |
13089 } | |
13090 counter += str->length(); | |
13091 } | |
13092 } | |
13093 DCHECK(!storage || storage->length() == counter); | 13098 DCHECK(!storage || storage->length() == counter); |
13094 return counter; | 13099 return counter; |
13095 } | 13100 } |
13096 | 13101 |
13097 | 13102 |
13098 int JSObject::GetEnumElementKeys(FixedArray* storage) { | 13103 int JSObject::GetEnumElementKeys(FixedArray* storage) { |
13099 return GetOwnElementKeys(storage, static_cast<PropertyAttributes>(DONT_ENUM)); | 13104 return GetOwnElementKeys(storage, static_cast<PropertyAttributes>(DONT_ENUM)); |
13100 } | 13105 } |
13101 | 13106 |
13102 | 13107 |
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15930 Handle<Object> new_value) { | 15935 Handle<Object> new_value) { |
15931 if (cell->value() != *new_value) { | 15936 if (cell->value() != *new_value) { |
15932 cell->set_value(*new_value); | 15937 cell->set_value(*new_value); |
15933 Isolate* isolate = cell->GetIsolate(); | 15938 Isolate* isolate = cell->GetIsolate(); |
15934 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15939 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
15935 isolate, DependentCode::kPropertyCellChangedGroup); | 15940 isolate, DependentCode::kPropertyCellChangedGroup); |
15936 } | 15941 } |
15937 } | 15942 } |
15938 } // namespace internal | 15943 } // namespace internal |
15939 } // namespace v8 | 15944 } // namespace v8 |
OLD | NEW |