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

Side by Side Diff: src/objects.cc

Issue 1237953002: Simplify PrepareForDataProperty in the IsElement case (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Only used to modify an existing value, so don't make holey Created 5 years, 5 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.h ('k') | src/objects-inl.h » ('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 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 6942 matching lines...) Expand 10 before | Expand all | Expand 10 after
6953 case ACCESSOR_CONSTANT: 6953 case ACCESSOR_CONSTANT:
6954 return false; 6954 return false;
6955 } 6955 }
6956 6956
6957 UNREACHABLE(); 6957 UNREACHABLE();
6958 return false; 6958 return false;
6959 } 6959 }
6960 6960
6961 6961
6962 // static 6962 // static
6963 Handle<Map> Map::PrepareForDataElement(Handle<Map> map, Handle<Object> value) {
6964 ElementsKind kind = map->elements_kind();
6965 bool holey = IsHoleyElementsKind(kind);
6966
6967 switch (kind) {
6968 case FAST_SMI_ELEMENTS:
6969 case FAST_HOLEY_SMI_ELEMENTS:
6970 if (value->IsSmi()) return map;
6971 kind = value->IsNumber() ? FAST_DOUBLE_ELEMENTS : FAST_ELEMENTS;
6972 break;
6973
6974 case FAST_DOUBLE_ELEMENTS:
6975 case FAST_HOLEY_DOUBLE_ELEMENTS:
6976 if (value->IsNumber()) return map;
6977 kind = FAST_ELEMENTS;
6978 break;
6979
6980 case FAST_ELEMENTS:
6981 case FAST_HOLEY_ELEMENTS:
6982 case DICTIONARY_ELEMENTS:
6983 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
6984 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
6985 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
6986 case EXTERNAL_##TYPE##_ELEMENTS: \
6987 case TYPE##_ELEMENTS:
6988
6989 TYPED_ARRAYS(TYPED_ARRAY_CASE)
6990 #undef TYPED_ARRAY_CASE
6991 return map;
6992 }
6993
6994 if (holey) kind = GetHoleyElementsKind(kind);
6995 return Map::AsElementsKind(map, kind);
6996 }
6997
6998
6999 // static
7000 Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor, 6963 Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor,
7001 Handle<Object> value) { 6964 Handle<Object> value) {
7002 // Dictionaries can store any property value. 6965 // Dictionaries can store any property value.
7003 if (map->is_dictionary_map()) return map; 6966 if (map->is_dictionary_map()) return map;
7004 6967
7005 // Migrate to the newest map before storing the property. 6968 // Migrate to the newest map before storing the property.
7006 map = Update(map); 6969 map = Update(map);
7007 6970
7008 Handle<DescriptorArray> descriptors(map->instance_descriptors()); 6971 Handle<DescriptorArray> descriptors(map->instance_descriptors());
7009 6972
(...skipping 8943 matching lines...) Expand 10 before | Expand all | Expand 10 after
15953 Handle<Object> new_value) { 15916 Handle<Object> new_value) {
15954 if (cell->value() != *new_value) { 15917 if (cell->value() != *new_value) {
15955 cell->set_value(*new_value); 15918 cell->set_value(*new_value);
15956 Isolate* isolate = cell->GetIsolate(); 15919 Isolate* isolate = cell->GetIsolate();
15957 cell->dependent_code()->DeoptimizeDependentCodeGroup( 15920 cell->dependent_code()->DeoptimizeDependentCodeGroup(
15958 isolate, DependentCode::kPropertyCellChangedGroup); 15921 isolate, DependentCode::kPropertyCellChangedGroup);
15959 } 15922 }
15960 } 15923 }
15961 } // namespace internal 15924 } // namespace internal
15962 } // namespace v8 15925 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698