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

Side by Side Diff: src/heap.cc

Issue 12459026: ES6 symbols: implement name property (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 9 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/d8.js ('k') | src/heap-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 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 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 template VisitSpecialized<Context::kSize>); 1772 template VisitSpecialized<Context::kSize>);
1773 1773
1774 table_.Register(kVisitConsString, 1774 table_.Register(kVisitConsString,
1775 &ObjectEvacuationStrategy<POINTER_OBJECT>:: 1775 &ObjectEvacuationStrategy<POINTER_OBJECT>::
1776 template VisitSpecialized<ConsString::kSize>); 1776 template VisitSpecialized<ConsString::kSize>);
1777 1777
1778 table_.Register(kVisitSlicedString, 1778 table_.Register(kVisitSlicedString,
1779 &ObjectEvacuationStrategy<POINTER_OBJECT>:: 1779 &ObjectEvacuationStrategy<POINTER_OBJECT>::
1780 template VisitSpecialized<SlicedString::kSize>); 1780 template VisitSpecialized<SlicedString::kSize>);
1781 1781
1782 table_.Register(kVisitSymbol,
1783 &ObjectEvacuationStrategy<POINTER_OBJECT>::
1784 template VisitSpecialized<Symbol::kSize>);
1785
1782 table_.Register(kVisitSharedFunctionInfo, 1786 table_.Register(kVisitSharedFunctionInfo,
1783 &ObjectEvacuationStrategy<POINTER_OBJECT>:: 1787 &ObjectEvacuationStrategy<POINTER_OBJECT>::
1784 template VisitSpecialized<SharedFunctionInfo::kSize>); 1788 template VisitSpecialized<SharedFunctionInfo::kSize>);
1785 1789
1786 table_.Register(kVisitJSWeakMap, 1790 table_.Register(kVisitJSWeakMap,
1787 &ObjectEvacuationStrategy<POINTER_OBJECT>:: 1791 &ObjectEvacuationStrategy<POINTER_OBJECT>::
1788 Visit); 1792 Visit);
1789 1793
1790 table_.Register(kVisitJSRegExp, 1794 table_.Register(kVisitJSRegExp,
1791 &ObjectEvacuationStrategy<POINTER_OBJECT>:: 1795 &ObjectEvacuationStrategy<POINTER_OBJECT>::
(...skipping 3628 matching lines...) Expand 10 before | Expand all | Expand 10 after
5420 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( 5424 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(
5421 hash_table_map()); 5425 hash_table_map());
5422 ASSERT(result->IsHashTable()); 5426 ASSERT(result->IsHashTable());
5423 return result; 5427 return result;
5424 } 5428 }
5425 5429
5426 5430
5427 MaybeObject* Heap::AllocateSymbol(PretenureFlag pretenure) { 5431 MaybeObject* Heap::AllocateSymbol(PretenureFlag pretenure) {
5428 // Statically ensure that it is safe to allocate symbols in paged spaces. 5432 // Statically ensure that it is safe to allocate symbols in paged spaces.
5429 STATIC_ASSERT(Symbol::kSize <= Page::kNonCodeObjectAreaSize); 5433 STATIC_ASSERT(Symbol::kSize <= Page::kNonCodeObjectAreaSize);
5430 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; 5434 AllocationSpace space = pretenure == TENURED ? OLD_POINTER_SPACE : NEW_SPACE;
5431 5435
5432 Object* result; 5436 Object* result;
5433 MaybeObject* maybe = AllocateRaw(Symbol::kSize, space, OLD_DATA_SPACE); 5437 MaybeObject* maybe = AllocateRaw(Symbol::kSize, space, OLD_POINTER_SPACE);
5434 if (!maybe->ToObject(&result)) return maybe; 5438 if (!maybe->ToObject(&result)) return maybe;
5435 5439
5436 HeapObject::cast(result)->set_map_no_write_barrier(symbol_map()); 5440 HeapObject::cast(result)->set_map_no_write_barrier(symbol_map());
5437 5441
5438 // Generate a random hash value. 5442 // Generate a random hash value.
5439 int hash; 5443 int hash;
5440 int attempts = 0; 5444 int attempts = 0;
5441 do { 5445 do {
5442 hash = V8::RandomPrivate(isolate()) & Name::kHashBitMask; 5446 hash = V8::RandomPrivate(isolate()) & Name::kHashBitMask;
5443 attempts++; 5447 attempts++;
5444 } while (hash == 0 && attempts < 30); 5448 } while (hash == 0 && attempts < 30);
5445 if (hash == 0) hash = 1; // never return 0 5449 if (hash == 0) hash = 1; // never return 0
5446 5450
5447 Symbol::cast(result)->set_hash_field( 5451 Symbol::cast(result)->set_hash_field(
5448 Name::kIsNotArrayIndexMask | (hash << Name::kHashShift)); 5452 Name::kIsNotArrayIndexMask | (hash << Name::kHashShift));
5453 Symbol::cast(result)->set_name(undefined_value());
5449 5454
5450 ASSERT(result->IsSymbol()); 5455 ASSERT(result->IsSymbol());
5451 return result; 5456 return result;
5452 } 5457 }
5453 5458
5454 5459
5455 MaybeObject* Heap::AllocateNativeContext() { 5460 MaybeObject* Heap::AllocateNativeContext() {
5456 Object* result; 5461 Object* result;
5457 { MaybeObject* maybe_result = 5462 { MaybeObject* maybe_result =
5458 AllocateFixedArray(Context::NATIVE_CONTEXT_SLOTS); 5463 AllocateFixedArray(Context::NATIVE_CONTEXT_SLOTS);
(...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after
7812 static_cast<int>(object_sizes_last_time_[index])); 7817 static_cast<int>(object_sizes_last_time_[index]));
7813 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7818 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7814 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7819 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7815 7820
7816 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7821 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7817 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7822 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7818 ClearObjectStats(); 7823 ClearObjectStats();
7819 } 7824 }
7820 7825
7821 } } // namespace v8::internal 7826 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/d8.js ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698