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

Side by Side Diff: src/objects.cc

Issue 23453019: Allow uncacheable identifiers to go generic. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adding test Created 7 years, 3 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 1891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 set_properties(values); 1902 set_properties(values);
1903 } 1903 }
1904 1904
1905 set_map(new_map); 1905 set_map(new_map);
1906 1906
1907 FastPropertyAtPut(field_index, storage); 1907 FastPropertyAtPut(field_index, storage);
1908 return value; 1908 return value;
1909 } 1909 }
1910 1910
1911 1911
1912 static bool IsIdentifier(UnicodeCache* cache, Name* name) {
1913 // Checks whether the buffer contains an identifier (no escape).
1914 if (!name->IsString()) return false;
1915 String* string = String::cast(name);
1916 if (string->length() == 0) return false;
1917 ConsStringIteratorOp op;
1918 StringCharacterStream stream(string, &op);
1919 if (!cache->IsIdentifierStart(stream.GetNext())) {
1920 return false;
1921 }
1922 while (stream.HasMore()) {
1923 if (!cache->IsIdentifierPart(stream.GetNext())) {
1924 return false;
1925 }
1926 }
1927 return true;
1928 }
1929
1930
1931 MaybeObject* JSObject::AddFastProperty(Name* name, 1912 MaybeObject* JSObject::AddFastProperty(Name* name,
1932 Object* value, 1913 Object* value,
1933 PropertyAttributes attributes, 1914 PropertyAttributes attributes,
1934 StoreFromKeyed store_mode, 1915 StoreFromKeyed store_mode,
1935 ValueType value_type, 1916 ValueType value_type,
1936 TransitionFlag flag) { 1917 TransitionFlag flag) {
1937 ASSERT(!IsJSGlobalProxy()); 1918 ASSERT(!IsJSGlobalProxy());
1938 ASSERT(DescriptorArray::kNotFound == 1919 ASSERT(DescriptorArray::kNotFound ==
1939 map()->instance_descriptors()->Search( 1920 map()->instance_descriptors()->Search(
1940 name, map()->NumberOfOwnDescriptors())); 1921 name, map()->NumberOfOwnDescriptors()));
1941 1922
1942 // Normalize the object if the name is an actual name (not the 1923 // Normalize the object if the name is an actual name (not the
1943 // hidden strings) and is not a real identifier. 1924 // hidden strings) and is not a real identifier.
1944 // Normalize the object if it will have too many fast properties. 1925 // Normalize the object if it will have too many fast properties.
1945 Isolate* isolate = GetHeap()->isolate(); 1926 Isolate* isolate = GetHeap()->isolate();
1946 if ((!name->IsSymbol() && 1927 if (!name->IsCacheable(isolate) || TooManyFastProperties(store_mode)) {
1947 !IsIdentifier(isolate->unicode_cache(), name) &&
1948 name != isolate->heap()->hidden_string()) ||
1949 TooManyFastProperties(store_mode)) {
1950 MaybeObject* maybe_failure = 1928 MaybeObject* maybe_failure =
1951 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 1929 NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
1952 if (maybe_failure->IsFailure()) return maybe_failure; 1930 if (maybe_failure->IsFailure()) return maybe_failure;
1953 return AddSlowProperty(name, value, attributes); 1931 return AddSlowProperty(name, value, attributes);
1954 } 1932 }
1955 1933
1956 // Compute the new index for new field. 1934 // Compute the new index for new field.
1957 int index = map()->NextFreePropertyIndex(); 1935 int index = map()->NextFreePropertyIndex();
1958 1936
1959 // Allocate new instance descriptors with (name, index) added 1937 // Allocate new instance descriptors with (name, index) added
(...skipping 14008 matching lines...) Expand 10 before | Expand all | Expand 10 after
15968 #define ERROR_MESSAGES_TEXTS(C, T) T, 15946 #define ERROR_MESSAGES_TEXTS(C, T) T,
15969 static const char* error_messages_[] = { 15947 static const char* error_messages_[] = {
15970 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 15948 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
15971 }; 15949 };
15972 #undef ERROR_MESSAGES_TEXTS 15950 #undef ERROR_MESSAGES_TEXTS
15973 return error_messages_[reason]; 15951 return error_messages_[reason];
15974 } 15952 }
15975 15953
15976 15954
15977 } } // namespace v8::internal 15955 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698