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

Side by Side Diff: src/handles.cc

Issue 12330012: ES6 symbols: Allow symbols as property names (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Platform ports Created 7 years, 10 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 | « src/factory.cc ('k') | src/heap.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 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 Handle<Object> ForceDeleteProperty(Handle<JSObject> object, 259 Handle<Object> ForceDeleteProperty(Handle<JSObject> object,
260 Handle<Object> key) { 260 Handle<Object> key) {
261 Isolate* isolate = object->GetIsolate(); 261 Isolate* isolate = object->GetIsolate();
262 CALL_HEAP_FUNCTION(isolate, 262 CALL_HEAP_FUNCTION(isolate,
263 Runtime::ForceDeleteObjectProperty(isolate, object, key), 263 Runtime::ForceDeleteObjectProperty(isolate, object, key),
264 Object); 264 Object);
265 } 265 }
266 266
267 267
268 Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object, 268 Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object,
269 Handle<String> key, 269 Handle<Name> key,
270 Handle<Object> value, 270 Handle<Object> value,
271 PropertyAttributes attributes, 271 PropertyAttributes attributes,
272 StrictModeFlag strict_mode) { 272 StrictModeFlag strict_mode) {
273 CALL_HEAP_FUNCTION(object->GetIsolate(), 273 CALL_HEAP_FUNCTION(object->GetIsolate(),
274 object->SetPropertyWithInterceptor(*key, 274 object->SetPropertyWithInterceptor(*key,
275 *value, 275 *value,
276 attributes, 276 attributes,
277 strict_mode), 277 strict_mode),
278 Object); 278 Object);
279 } 279 }
(...skipping 10 matching lines...) Expand all
290 Handle<Object> GetProperty(Handle<Object> obj, 290 Handle<Object> GetProperty(Handle<Object> obj,
291 Handle<Object> key) { 291 Handle<Object> key) {
292 Isolate* isolate = Isolate::Current(); 292 Isolate* isolate = Isolate::Current();
293 CALL_HEAP_FUNCTION(isolate, 293 CALL_HEAP_FUNCTION(isolate,
294 Runtime::GetObjectProperty(isolate, obj, key), Object); 294 Runtime::GetObjectProperty(isolate, obj, key), Object);
295 } 295 }
296 296
297 297
298 Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver, 298 Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver,
299 Handle<JSObject> holder, 299 Handle<JSObject> holder,
300 Handle<String> name, 300 Handle<Name> name,
301 PropertyAttributes* attributes) { 301 PropertyAttributes* attributes) {
302 Isolate* isolate = receiver->GetIsolate(); 302 Isolate* isolate = receiver->GetIsolate();
303 CALL_HEAP_FUNCTION(isolate, 303 CALL_HEAP_FUNCTION(isolate,
304 holder->GetPropertyWithInterceptor(*receiver, 304 holder->GetPropertyWithInterceptor(*receiver,
305 *name, 305 *name,
306 attributes), 306 attributes),
307 Object); 307 Object);
308 } 308 }
309 309
310 310
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 result = isolate->factory()->undefined_value(); 623 result = isolate->factory()->undefined_value();
624 } 624 }
625 return result; 625 return result;
626 } 626 }
627 627
628 628
629 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) { 629 static bool ContainsOnlyValidKeys(Handle<FixedArray> array) {
630 int len = array->length(); 630 int len = array->length();
631 for (int i = 0; i < len; i++) { 631 for (int i = 0; i < len; i++) {
632 Object* e = array->get(i); 632 Object* e = array->get(i);
633 if (!(e->IsString() || e->IsNumber())) return false; 633 if (!(e->IsName() || e->IsNumber())) return false;
634 } 634 }
635 return true; 635 return true;
636 } 636 }
637 637
638 638
639 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSReceiver> object, 639 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSReceiver> object,
640 KeyCollectionType type, 640 KeyCollectionType type,
641 bool* threw) { 641 bool* threw) {
642 USE(ContainsOnlyValidKeys); 642 USE(ContainsOnlyValidKeys);
643 Isolate* isolate = object->GetIsolate(); 643 Isolate* isolate = object->GetIsolate();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 desc->SetEnumCache(*bridge_storage, 829 desc->SetEnumCache(*bridge_storage,
830 *storage, 830 *storage,
831 indices.is_null() ? Object::cast(Smi::FromInt(0)) 831 indices.is_null() ? Object::cast(Smi::FromInt(0))
832 : Object::cast(*indices)); 832 : Object::cast(*indices));
833 if (cache_result) { 833 if (cache_result) {
834 object->map()->SetEnumLength(enum_size); 834 object->map()->SetEnumLength(enum_size);
835 } 835 }
836 836
837 return ReduceFixedArrayTo(storage, enum_size); 837 return ReduceFixedArrayTo(storage, enum_size);
838 } else { 838 } else {
839 Handle<StringDictionary> dictionary(object->property_dictionary()); 839 Handle<NameDictionary> dictionary(object->property_dictionary());
840 840
841 int length = dictionary->NumberOfElements(); 841 int length = dictionary->NumberOfElements();
842 if (length == 0) { 842 if (length == 0) {
843 return Handle<FixedArray>(isolate->heap()->empty_fixed_array()); 843 return Handle<FixedArray>(isolate->heap()->empty_fixed_array());
844 } 844 }
845 845
846 // The enumeration array is generated by allocating an array big enough to 846 // The enumeration array is generated by allocating an array big enough to
847 // hold all properties that have been seen, whether they are are deleted or 847 // hold all properties that have been seen, whether they are are deleted or
848 // not. Subsequently all visible properties are added to the array. If some 848 // not. Subsequently all visible properties are added to the array. If some
849 // properties were not visible, the array is trimmed so it only contains 849 // properties were not visible, the array is trimmed so it only contains
850 // visible properties. This improves over adding elements and sorting by 850 // visible properties. This improves over adding elements and sorting by
851 // index by having linear complexity rather than n*log(n). 851 // index by having linear complexity rather than n*log(n).
852 852
853 // By comparing the monotonous NextEnumerationIndex to the NumberOfElements, 853 // By comparing the monotonous NextEnumerationIndex to the NumberOfElements,
854 // we can predict the number of holes in the final array. If there will be 854 // we can predict the number of holes in the final array. If there will be
855 // more than 50% holes, regenerate the enumeration indices to reduce the 855 // more than 50% holes, regenerate the enumeration indices to reduce the
856 // number of holes to a minimum. This avoids allocating a large array if 856 // number of holes to a minimum. This avoids allocating a large array if
857 // many properties were added but subsequently deleted. 857 // many properties were added but subsequently deleted.
858 int next_enumeration = dictionary->NextEnumerationIndex(); 858 int next_enumeration = dictionary->NextEnumerationIndex();
859 if (!object->IsGlobalObject() && next_enumeration > (length * 3) / 2) { 859 if (!object->IsGlobalObject() && next_enumeration > (length * 3) / 2) {
860 StringDictionary::DoGenerateNewEnumerationIndices(dictionary); 860 NameDictionary::DoGenerateNewEnumerationIndices(dictionary);
861 next_enumeration = dictionary->NextEnumerationIndex(); 861 next_enumeration = dictionary->NextEnumerationIndex();
862 } 862 }
863 863
864 Handle<FixedArray> storage = 864 Handle<FixedArray> storage =
865 isolate->factory()->NewFixedArray(next_enumeration); 865 isolate->factory()->NewFixedArray(next_enumeration);
866 866
867 storage = Handle<FixedArray>(dictionary->CopyEnumKeysTo(*storage)); 867 storage = Handle<FixedArray>(dictionary->CopyEnumKeysTo(*storage));
868 ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_ENUM)); 868 ASSERT(storage->length() == object->NumberOfLocalProperties(DONT_ENUM));
869 return storage; 869 return storage;
870 } 870 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 data->next = prev_next_; 932 data->next = prev_next_;
933 data->limit = prev_limit_; 933 data->limit = prev_limit_;
934 #ifdef DEBUG 934 #ifdef DEBUG
935 handles_detached_ = true; 935 handles_detached_ = true;
936 #endif 936 #endif
937 return deferred; 937 return deferred;
938 } 938 }
939 939
940 940
941 } } // namespace v8::internal 941 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698