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

Side by Side Diff: src/heap.cc

Issue 149133004: A64: Synchronize with r17807. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 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/heap.h ('k') | src/heap-profiler.cc » ('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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 allocation_timeout_(0), 107 allocation_timeout_(0),
108 disallow_allocation_failure_(false), 108 disallow_allocation_failure_(false),
109 #endif // DEBUG 109 #endif // DEBUG
110 new_space_high_promotion_mode_active_(false), 110 new_space_high_promotion_mode_active_(false),
111 old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit), 111 old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit),
112 size_of_old_gen_at_last_old_space_gc_(0), 112 size_of_old_gen_at_last_old_space_gc_(0),
113 external_allocation_limit_(0), 113 external_allocation_limit_(0),
114 amount_of_external_allocated_memory_(0), 114 amount_of_external_allocated_memory_(0),
115 amount_of_external_allocated_memory_at_last_global_gc_(0), 115 amount_of_external_allocated_memory_at_last_global_gc_(0),
116 old_gen_exhausted_(false), 116 old_gen_exhausted_(false),
117 inline_allocation_disabled_(false),
117 store_buffer_rebuilder_(store_buffer()), 118 store_buffer_rebuilder_(store_buffer()),
118 hidden_string_(NULL), 119 hidden_string_(NULL),
119 gc_safe_size_of_old_object_(NULL), 120 gc_safe_size_of_old_object_(NULL),
120 total_regexp_code_generated_(0), 121 total_regexp_code_generated_(0),
121 tracer_(NULL), 122 tracer_(NULL),
122 young_survivors_after_last_gc_(0), 123 young_survivors_after_last_gc_(0),
123 high_survival_rate_period_length_(0), 124 high_survival_rate_period_length_(0),
124 low_survival_rate_period_length_(0), 125 low_survival_rate_period_length_(0),
125 survival_rate_(0), 126 survival_rate_(0),
126 previous_survival_rate_trend_(Heap::STABLE), 127 previous_survival_rate_trend_(Heap::STABLE),
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX); 932 Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX);
932 if (!cache->IsUndefined()) { 933 if (!cache->IsUndefined()) {
933 NormalizedMapCache::cast(cache)->Clear(); 934 NormalizedMapCache::cast(cache)->Clear();
934 } 935 }
935 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); 936 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK);
936 } 937 }
937 } 938 }
938 939
939 940
940 void Heap::UpdateSurvivalRateTrend(int start_new_space_size) { 941 void Heap::UpdateSurvivalRateTrend(int start_new_space_size) {
942 if (start_new_space_size == 0) return;
943
941 double survival_rate = 944 double survival_rate =
942 (static_cast<double>(young_survivors_after_last_gc_) * 100) / 945 (static_cast<double>(young_survivors_after_last_gc_) * 100) /
943 start_new_space_size; 946 start_new_space_size;
944 947
945 if (survival_rate > kYoungSurvivalRateHighThreshold) { 948 if (survival_rate > kYoungSurvivalRateHighThreshold) {
946 high_survival_rate_period_length_++; 949 high_survival_rate_period_length_++;
947 } else { 950 } else {
948 high_survival_rate_period_length_ = 0; 951 high_survival_rate_period_length_ = 0;
949 } 952 }
950 953
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3113 // } 3116 // }
3114 // { JSConstructEntryStub stub; 3117 // { JSConstructEntryStub stub;
3115 // js_construct_entry_code_ = *stub.GetCode(); 3118 // js_construct_entry_code_ = *stub.GetCode();
3116 // } 3119 // }
3117 // To workaround the problem, make separate functions without inlining. 3120 // To workaround the problem, make separate functions without inlining.
3118 Heap::CreateJSEntryStub(); 3121 Heap::CreateJSEntryStub();
3119 Heap::CreateJSConstructEntryStub(); 3122 Heap::CreateJSConstructEntryStub();
3120 } 3123 }
3121 3124
3122 3125
3126 void Heap::CreateStubsRequiringBuiltins() {
3127 HandleScope scope(isolate());
3128 CodeStub::GenerateStubsRequiringBuiltinsAheadOfTime(isolate());
3129 }
3130
3131
3123 bool Heap::CreateInitialObjects() { 3132 bool Heap::CreateInitialObjects() {
3124 Object* obj; 3133 Object* obj;
3125 3134
3126 // The -0 value must be set before NumberFromDouble works. 3135 // The -0 value must be set before NumberFromDouble works.
3127 { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED); 3136 { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED);
3128 if (!maybe_obj->ToObject(&obj)) return false; 3137 if (!maybe_obj->ToObject(&obj)) return false;
3129 } 3138 }
3130 set_minus_zero_value(HeapNumber::cast(obj)); 3139 set_minus_zero_value(HeapNumber::cast(obj));
3131 ASSERT(std::signbit(minus_zero_value()->Number()) != 0); 3140 ASSERT(std::signbit(minus_zero_value()->Number()) != 0);
3132 3141
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3309 if (!maybe_obj->ToObject(&obj)) return false; 3318 if (!maybe_obj->ToObject(&obj)) return false;
3310 } 3319 }
3311 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(Map::cast(obj)); 3320 { MaybeObject* maybe_obj = AllocateJSObjectFromMap(Map::cast(obj));
3312 if (!maybe_obj->ToObject(&obj)) return false; 3321 if (!maybe_obj->ToObject(&obj)) return false;
3313 } 3322 }
3314 set_observation_state(JSObject::cast(obj)); 3323 set_observation_state(JSObject::cast(obj));
3315 3324
3316 { MaybeObject* maybe_obj = AllocateSymbol(); 3325 { MaybeObject* maybe_obj = AllocateSymbol();
3317 if (!maybe_obj->ToObject(&obj)) return false; 3326 if (!maybe_obj->ToObject(&obj)) return false;
3318 } 3327 }
3328 Symbol::cast(obj)->set_is_private(true);
3319 set_frozen_symbol(Symbol::cast(obj)); 3329 set_frozen_symbol(Symbol::cast(obj));
3320 3330
3321 { MaybeObject* maybe_obj = AllocateSymbol(); 3331 { MaybeObject* maybe_obj = AllocateSymbol();
3322 if (!maybe_obj->ToObject(&obj)) return false; 3332 if (!maybe_obj->ToObject(&obj)) return false;
3323 } 3333 }
3334 Symbol::cast(obj)->set_is_private(true);
3324 set_elements_transition_symbol(Symbol::cast(obj)); 3335 set_elements_transition_symbol(Symbol::cast(obj));
3325 3336
3326 { MaybeObject* maybe_obj = SeededNumberDictionary::Allocate(this, 0, TENURED); 3337 { MaybeObject* maybe_obj = SeededNumberDictionary::Allocate(this, 0, TENURED);
3327 if (!maybe_obj->ToObject(&obj)) return false; 3338 if (!maybe_obj->ToObject(&obj)) return false;
3328 } 3339 }
3329 SeededNumberDictionary::cast(obj)->set_requires_slow_elements(); 3340 SeededNumberDictionary::cast(obj)->set_requires_slow_elements();
3330 set_empty_slow_element_dictionary(SeededNumberDictionary::cast(obj)); 3341 set_empty_slow_element_dictionary(SeededNumberDictionary::cast(obj));
3331 3342
3332 { MaybeObject* maybe_obj = AllocateSymbol(); 3343 { MaybeObject* maybe_obj = AllocateSymbol();
3333 if (!maybe_obj->ToObject(&obj)) return false; 3344 if (!maybe_obj->ToObject(&obj)) return false;
3334 } 3345 }
3346 Symbol::cast(obj)->set_is_private(true);
3335 set_observed_symbol(Symbol::cast(obj)); 3347 set_observed_symbol(Symbol::cast(obj));
3336 3348
3337 // Handling of script id generation is in Factory::NewScript. 3349 // Handling of script id generation is in Factory::NewScript.
3338 set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId)); 3350 set_last_script_id(Smi::FromInt(v8::Script::kNoScriptId));
3339 3351
3340 // Initialize keyed lookup cache. 3352 // Initialize keyed lookup cache.
3341 isolate_->keyed_lookup_cache()->Clear(); 3353 isolate_->keyed_lookup_cache()->Clear();
3342 3354
3343 // Initialize context slot cache. 3355 // Initialize context slot cache.
3344 isolate_->context_slot_cache()->Clear(); 3356 isolate_->context_slot_cache()->Clear();
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
4593 } 4605 }
4594 4606
4595 4607
4596 MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor, 4608 MaybeObject* Heap::AllocateJSObjectWithAllocationSite(JSFunction* constructor,
4597 Handle<AllocationSite> allocation_site) { 4609 Handle<AllocationSite> allocation_site) {
4598 ASSERT(constructor->has_initial_map()); 4610 ASSERT(constructor->has_initial_map());
4599 // Allocate the object based on the constructors initial map, or the payload 4611 // Allocate the object based on the constructors initial map, or the payload
4600 // advice 4612 // advice
4601 Map* initial_map = constructor->initial_map(); 4613 Map* initial_map = constructor->initial_map();
4602 4614
4603 Smi* smi = Smi::cast(allocation_site->transition_info()); 4615 ElementsKind to_kind = allocation_site->GetElementsKind();
4604 ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
4605 AllocationSiteMode mode = TRACK_ALLOCATION_SITE; 4616 AllocationSiteMode mode = TRACK_ALLOCATION_SITE;
4606 if (to_kind != initial_map->elements_kind()) { 4617 if (to_kind != initial_map->elements_kind()) {
4607 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind); 4618 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind);
4608 if (!maybe_new_map->To(&initial_map)) return maybe_new_map; 4619 if (!maybe_new_map->To(&initial_map)) return maybe_new_map;
4609 // Possibly alter the mode, since we found an updated elements kind 4620 // Possibly alter the mode, since we found an updated elements kind
4610 // in the type info cell. 4621 // in the type info cell.
4611 mode = AllocationSite::GetMode(to_kind); 4622 mode = AllocationSite::GetMode(to_kind);
4612 } 4623 }
4613 4624
4614 MaybeObject* result; 4625 MaybeObject* result;
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
5514 int attempts = 0; 5525 int attempts = 0;
5515 do { 5526 do {
5516 hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask; 5527 hash = isolate()->random_number_generator()->NextInt() & Name::kHashBitMask;
5517 attempts++; 5528 attempts++;
5518 } while (hash == 0 && attempts < 30); 5529 } while (hash == 0 && attempts < 30);
5519 if (hash == 0) hash = 1; // never return 0 5530 if (hash == 0) hash = 1; // never return 0
5520 5531
5521 Symbol::cast(result)->set_hash_field( 5532 Symbol::cast(result)->set_hash_field(
5522 Name::kIsNotArrayIndexMask | (hash << Name::kHashShift)); 5533 Name::kIsNotArrayIndexMask | (hash << Name::kHashShift));
5523 Symbol::cast(result)->set_name(undefined_value()); 5534 Symbol::cast(result)->set_name(undefined_value());
5535 Symbol::cast(result)->set_flags(Smi::FromInt(0));
5524 5536
5525 ASSERT(result->IsSymbol()); 5537 ASSERT(!Symbol::cast(result)->is_private());
5526 return result; 5538 return result;
5527 } 5539 }
5528 5540
5529 5541
5542 MaybeObject* Heap::AllocatePrivateSymbol() {
5543 MaybeObject* maybe = AllocateSymbol();
5544 Symbol* symbol;
5545 if (!maybe->To(&symbol)) return maybe;
5546 symbol->set_is_private(true);
5547 return symbol;
5548 }
5549
5550
5530 MaybeObject* Heap::AllocateNativeContext() { 5551 MaybeObject* Heap::AllocateNativeContext() {
5531 Object* result; 5552 Object* result;
5532 { MaybeObject* maybe_result = 5553 { MaybeObject* maybe_result =
5533 AllocateFixedArray(Context::NATIVE_CONTEXT_SLOTS); 5554 AllocateFixedArray(Context::NATIVE_CONTEXT_SLOTS);
5534 if (!maybe_result->ToObject(&result)) return maybe_result; 5555 if (!maybe_result->ToObject(&result)) return maybe_result;
5535 } 5556 }
5536 Context* context = reinterpret_cast<Context*>(result); 5557 Context* context = reinterpret_cast<Context*>(result);
5537 context->set_map_no_write_barrier(native_context_map()); 5558 context->set_map_no_write_barrier(native_context_map());
5538 context->set_js_array_maps(undefined_value()); 5559 context->set_js_array_maps(undefined_value());
5539 ASSERT(context->IsNativeContext()); 5560 ASSERT(context->IsNativeContext());
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
6566 6587
6567 6588
6568 intptr_t Heap::PromotedExternalMemorySize() { 6589 intptr_t Heap::PromotedExternalMemorySize() {
6569 if (amount_of_external_allocated_memory_ 6590 if (amount_of_external_allocated_memory_
6570 <= amount_of_external_allocated_memory_at_last_global_gc_) return 0; 6591 <= amount_of_external_allocated_memory_at_last_global_gc_) return 0;
6571 return amount_of_external_allocated_memory_ 6592 return amount_of_external_allocated_memory_
6572 - amount_of_external_allocated_memory_at_last_global_gc_; 6593 - amount_of_external_allocated_memory_at_last_global_gc_;
6573 } 6594 }
6574 6595
6575 6596
6597 void Heap::EnableInlineAllocation() {
6598 ASSERT(inline_allocation_disabled_);
6599 inline_allocation_disabled_ = false;
6600
6601 // Update inline allocation limit for new space.
6602 new_space()->UpdateInlineAllocationLimit(0);
6603 }
6604
6605
6606 void Heap::DisableInlineAllocation() {
6607 ASSERT(!inline_allocation_disabled_);
6608 inline_allocation_disabled_ = true;
6609
6610 // Update inline allocation limit for new space.
6611 new_space()->UpdateInlineAllocationLimit(0);
6612
6613 // Update inline allocation limit for old spaces.
6614 PagedSpaces spaces(this);
6615 for (PagedSpace* space = spaces.next();
6616 space != NULL;
6617 space = spaces.next()) {
6618 space->EmptyAllocationInfo();
6619 }
6620 }
6621
6622
6576 V8_DECLARE_ONCE(initialize_gc_once); 6623 V8_DECLARE_ONCE(initialize_gc_once);
6577 6624
6578 static void InitializeGCOnce() { 6625 static void InitializeGCOnce() {
6579 InitializeScavengingVisitorsTables(); 6626 InitializeScavengingVisitorsTables();
6580 NewSpaceScavenger::Initialize(); 6627 NewSpaceScavenger::Initialize();
6581 MarkCompactCollector::Initialize(); 6628 MarkCompactCollector::Initialize();
6582 } 6629 }
6583 6630
6584 6631
6585 bool Heap::SetUp() { 6632 bool Heap::SetUp() {
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
7916 if (FLAG_concurrent_recompilation) { 7963 if (FLAG_concurrent_recompilation) {
7917 heap_->relocation_mutex_->Lock(); 7964 heap_->relocation_mutex_->Lock();
7918 #ifdef DEBUG 7965 #ifdef DEBUG
7919 heap_->relocation_mutex_locked_by_optimizer_thread_ = 7966 heap_->relocation_mutex_locked_by_optimizer_thread_ =
7920 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 7967 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
7921 #endif // DEBUG 7968 #endif // DEBUG
7922 } 7969 }
7923 } 7970 }
7924 7971
7925 } } // namespace v8::internal 7972 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698