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

Side by Side Diff: src/heap.cc

Issue 48923002: Provide private symbols through internal APIs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Mo comments Created 7 years, 1 month 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/heap.h ('k') | src/macros.py » ('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 3264 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 if (!maybe_obj->ToObject(&obj)) return false; 3275 if (!maybe_obj->ToObject(&obj)) return false;
3276 } 3276 }
3277 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(Map::cast(obj)); 3277 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(Map::cast(obj));
3278 if (!maybe_obj->ToObject(&obj)) return false; 3278 if (!maybe_obj->ToObject(&obj)) return false;
3279 } 3279 }
3280 set_observation_state(JSObject::cast(obj)); 3280 set_observation_state(JSObject::cast(obj));
3281 3281
3282 { MaybeObject* maybe_obj = AllocateSymbol(); 3282 { MaybeObject* maybe_obj = AllocateSymbol();
3283 if (!maybe_obj->ToObject(&obj)) return false; 3283 if (!maybe_obj->ToObject(&obj)) return false;
3284 } 3284 }
3285 Symbol::cast(obj)->set_is_private(true);
3285 set_frozen_symbol(Symbol::cast(obj)); 3286 set_frozen_symbol(Symbol::cast(obj));
3286 3287
3287 { MaybeObject* maybe_obj = AllocateSymbol(); 3288 { MaybeObject* maybe_obj = AllocateSymbol();
3288 if (!maybe_obj->ToObject(&obj)) return false; 3289 if (!maybe_obj->ToObject(&obj)) return false;
3289 } 3290 }
3291 Symbol::cast(obj)->set_is_private(true);
3290 set_elements_transition_symbol(Symbol::cast(obj)); 3292 set_elements_transition_symbol(Symbol::cast(obj));
3291 3293
3292 { MaybeObject* maybe_obj = SeededNumberDictionary::Allocate(this, 0, TENURED); 3294 { MaybeObject* maybe_obj = SeededNumberDictionary::Allocate(this, 0, TENURED);
3293 if (!maybe_obj->ToObject(&obj)) return false; 3295 if (!maybe_obj->ToObject(&obj)) return false;
3294 } 3296 }
3295 SeededNumberDictionary::cast(obj)->set_requires_slow_elements(); 3297 SeededNumberDictionary::cast(obj)->set_requires_slow_elements();
3296 set_empty_slow_element_dictionary(SeededNumberDictionary::cast(obj)); 3298 set_empty_slow_element_dictionary(SeededNumberDictionary::cast(obj));
3297 3299
3298 { MaybeObject* maybe_obj = AllocateSymbol(); 3300 { MaybeObject* maybe_obj = AllocateSymbol();
3299 if (!maybe_obj->ToObject(&obj)) return false; 3301 if (!maybe_obj->ToObject(&obj)) return false;
3300 } 3302 }
3303 Symbol::cast(obj)->set_is_private(true);
3301 set_observed_symbol(Symbol::cast(obj)); 3304 set_observed_symbol(Symbol::cast(obj));
3302 3305
3303 // Handling of script id generation is in Factory::NewScript. 3306 // Handling of script id generation is in Factory::NewScript.
3304 set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId)); 3307 set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId));
3305 3308
3306 // Initialize keyed lookup cache. 3309 // Initialize keyed lookup cache.
3307 isolate_->keyed_lookup_cache()->Clear(); 3310 isolate_->keyed_lookup_cache()->Clear();
3308 3311
3309 // Initialize context slot cache. 3312 // Initialize context slot cache.
3310 isolate_->context_slot_cache()->Clear(); 3313 isolate_->context_slot_cache()->Clear();
(...skipping 2277 matching lines...) Expand 10 before | Expand all | Expand 10 after
5588 int attempts = 0; 5591 int attempts = 0;
5589 do { 5592 do {
5590 hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask; 5593 hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask;
5591 attempts++; 5594 attempts++;
5592 } while (hash == 0 && attempts < 30); 5595 } while (hash == 0 && attempts < 30);
5593 if (hash == 0) hash = 1; // never return 0 5596 if (hash == 0) hash = 1; // never return 0
5594 5597
5595 Symbol::cast(result)->set_hash_field( 5598 Symbol::cast(result)->set_hash_field(
5596 Name::kIsNotArrayIndexMask | (hash << Name::kHashShift)); 5599 Name::kIsNotArrayIndexMask | (hash << Name::kHashShift));
5597 Symbol::cast(result)->set_name(undefined_value()); 5600 Symbol::cast(result)->set_name(undefined_value());
5601 Symbol::cast(result)->set_flags(Smi::FromInt(0));
5598 5602
5599 ASSERT(result->IsSymbol()); 5603 ASSERT(!Symbol::cast(result)->is_private());
5600 return result; 5604 return result;
5601 } 5605 }
5602 5606
5603 5607
5608 MaybeObject* Heap::AllocatePrivateSymbol() {
5609 MaybeObject* maybe = AllocateSymbol();
5610 Symbol* symbol;
5611 if (!maybe->To(&symbol)) return maybe;
5612 symbol->set_is_private(true);
5613 return symbol;
5614 }
5615
5616
5604 MaybeObject* Heap::AllocateNativeContext() { 5617 MaybeObject* Heap::AllocateNativeContext() {
5605 Object* result; 5618 Object* result;
5606 { MaybeObject* maybe_result = 5619 { MaybeObject* maybe_result =
5607 AllocateFixedArray(Context::NATIVE_CONTEXT_SLOTS); 5620 AllocateFixedArray(Context::NATIVE_CONTEXT_SLOTS);
5608 if (!maybe_result->ToObject(&result)) return maybe_result; 5621 if (!maybe_result->ToObject(&result)) return maybe_result;
5609 } 5622 }
5610 Context* context = reinterpret_cast<Context*>(result); 5623 Context* context = reinterpret_cast<Context*>(result);
5611 context->set_map_no_write_barrier(native_context_map()); 5624 context->set_map_no_write_barrier(native_context_map());
5612 context->set_js_array_maps(undefined_value()); 5625 context->set_js_array_maps(undefined_value());
5613 ASSERT(context->IsNativeContext()); 5626 ASSERT(context->IsNativeContext());
(...skipping 2353 matching lines...) Expand 10 before | Expand all | Expand 10 after
7967 if (FLAG_concurrent_recompilation) { 7980 if (FLAG_concurrent_recompilation) {
7968 heap_->relocation_mutex_->Lock(); 7981 heap_->relocation_mutex_->Lock();
7969 #ifdef DEBUG 7982 #ifdef DEBUG
7970 heap_->relocation_mutex_locked_by_optimizer_thread_ = 7983 heap_->relocation_mutex_locked_by_optimizer_thread_ =
7971 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 7984 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
7972 #endif // DEBUG 7985 #endif // DEBUG
7973 } 7986 }
7974 } 7987 }
7975 7988
7976 } } // namespace v8::internal 7989 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698