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

Side by Side Diff: src/heap.cc

Issue 146213004: A64: Synchronize with r16849. (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-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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 #endif // DEBUG 122 #endif // DEBUG
123 new_space_high_promotion_mode_active_(false), 123 new_space_high_promotion_mode_active_(false),
124 old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit), 124 old_generation_allocation_limit_(kMinimumOldGenerationAllocationLimit),
125 size_of_old_gen_at_last_old_space_gc_(0), 125 size_of_old_gen_at_last_old_space_gc_(0),
126 external_allocation_limit_(0), 126 external_allocation_limit_(0),
127 amount_of_external_allocated_memory_(0), 127 amount_of_external_allocated_memory_(0),
128 amount_of_external_allocated_memory_at_last_global_gc_(0), 128 amount_of_external_allocated_memory_at_last_global_gc_(0),
129 old_gen_exhausted_(false), 129 old_gen_exhausted_(false),
130 store_buffer_rebuilder_(store_buffer()), 130 store_buffer_rebuilder_(store_buffer()),
131 hidden_string_(NULL), 131 hidden_string_(NULL),
132 global_gc_prologue_callback_(NULL),
133 global_gc_epilogue_callback_(NULL),
134 gc_safe_size_of_old_object_(NULL), 132 gc_safe_size_of_old_object_(NULL),
135 total_regexp_code_generated_(0), 133 total_regexp_code_generated_(0),
136 tracer_(NULL), 134 tracer_(NULL),
137 young_survivors_after_last_gc_(0), 135 young_survivors_after_last_gc_(0),
138 high_survival_rate_period_length_(0), 136 high_survival_rate_period_length_(0),
139 low_survival_rate_period_length_(0), 137 low_survival_rate_period_length_(0),
140 survival_rate_(0), 138 survival_rate_(0),
141 previous_survival_rate_trend_(Heap::STABLE), 139 previous_survival_rate_trend_(Heap::STABLE),
142 survival_rate_trend_(Heap::STABLE), 140 survival_rate_trend_(Heap::STABLE),
143 max_gc_pause_(0.0), 141 max_gc_pause_(0.0),
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 if (FLAG_verify_heap) { 1046 if (FLAG_verify_heap) {
1049 VerifyStringTable(this); 1047 VerifyStringTable(this);
1050 } 1048 }
1051 #endif 1049 #endif
1052 1050
1053 return next_gc_likely_to_collect_more; 1051 return next_gc_likely_to_collect_more;
1054 } 1052 }
1055 1053
1056 1054
1057 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) { 1055 void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) {
1058 if (gc_type == kGCTypeMarkSweepCompact && global_gc_prologue_callback_) {
1059 global_gc_prologue_callback_();
1060 }
1061 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { 1056 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) {
1062 if (gc_type & gc_prologue_callbacks_[i].gc_type) { 1057 if (gc_type & gc_prologue_callbacks_[i].gc_type) {
1063 gc_prologue_callbacks_[i].callback(gc_type, flags); 1058 if (!gc_prologue_callbacks_[i].pass_isolate_) {
1059 v8::GCPrologueCallback callback =
1060 reinterpret_cast<v8::GCPrologueCallback>(
1061 gc_prologue_callbacks_[i].callback);
1062 callback(gc_type, flags);
1063 } else {
1064 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1065 gc_prologue_callbacks_[i].callback(isolate, gc_type, flags);
1066 }
1064 } 1067 }
1065 } 1068 }
1066 } 1069 }
1067 1070
1068 1071
1069 void Heap::CallGCEpilogueCallbacks(GCType gc_type) { 1072 void Heap::CallGCEpilogueCallbacks(GCType gc_type) {
1070 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { 1073 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) {
1071 if (gc_type & gc_epilogue_callbacks_[i].gc_type) { 1074 if (gc_type & gc_epilogue_callbacks_[i].gc_type) {
1072 gc_epilogue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags); 1075 if (!gc_epilogue_callbacks_[i].pass_isolate_) {
1076 v8::GCPrologueCallback callback =
1077 reinterpret_cast<v8::GCPrologueCallback>(
1078 gc_epilogue_callbacks_[i].callback);
1079 callback(gc_type, kNoGCCallbackFlags);
1080 } else {
1081 v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(this->isolate());
1082 gc_epilogue_callbacks_[i].callback(
1083 isolate, gc_type, kNoGCCallbackFlags);
1084 }
1073 } 1085 }
1074 } 1086 }
1075 if (gc_type == kGCTypeMarkSweepCompact && global_gc_epilogue_callback_) {
1076 global_gc_epilogue_callback_();
1077 }
1078 } 1087 }
1079 1088
1080 1089
1081 void Heap::MarkCompact(GCTracer* tracer) { 1090 void Heap::MarkCompact(GCTracer* tracer) {
1082 gc_state_ = MARK_COMPACT; 1091 gc_state_ = MARK_COMPACT;
1083 LOG(isolate_, ResourceEvent("markcompact", "begin")); 1092 LOG(isolate_, ResourceEvent("markcompact", "begin"));
1084 1093
1085 mark_compact_collector_.Prepare(tracer); 1094 mark_compact_collector_.Prepare(tracer);
1086 1095
1087 ms_count_++; 1096 ms_count_++;
(...skipping 3656 matching lines...) Expand 10 before | Expand all | Expand 10 after
4744 } 4753 }
4745 } 4754 }
4746 if (!maybe_elms->To(&elms)) return maybe_elms; 4755 if (!maybe_elms->To(&elms)) return maybe_elms;
4747 4756
4748 array->set_elements(elms); 4757 array->set_elements(elms);
4749 array->set_length(Smi::FromInt(length)); 4758 array->set_length(Smi::FromInt(length));
4750 return array; 4759 return array;
4751 } 4760 }
4752 4761
4753 4762
4754 MaybeObject* Heap::AllocateJSArrayAndStorageWithAllocationSite(
4755 ElementsKind elements_kind,
4756 int length,
4757 int capacity,
4758 Handle<AllocationSite> allocation_site,
4759 ArrayStorageAllocationMode mode) {
4760 MaybeObject* maybe_array = AllocateJSArrayWithAllocationSite(elements_kind,
4761 allocation_site);
4762 JSArray* array;
4763 if (!maybe_array->To(&array)) return maybe_array;
4764 return AllocateJSArrayStorage(array, length, capacity, mode);
4765 }
4766
4767
4768 MaybeObject* Heap::AllocateJSArrayStorage( 4763 MaybeObject* Heap::AllocateJSArrayStorage(
4769 JSArray* array, 4764 JSArray* array,
4770 int length, 4765 int length,
4771 int capacity, 4766 int capacity,
4772 ArrayStorageAllocationMode mode) { 4767 ArrayStorageAllocationMode mode) {
4773 ASSERT(capacity >= length); 4768 ASSERT(capacity >= length);
4774 4769
4775 if (capacity == 0) { 4770 if (capacity == 0) {
4776 array->set_length(Smi::FromInt(0)); 4771 array->set_length(Smi::FromInt(0));
4777 array->set_elements(empty_fixed_array()); 4772 array->set_elements(empty_fixed_array());
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
5475 PretenureFlag pretenure) { 5470 PretenureFlag pretenure) {
5476 Context* native_context = isolate()->context()->native_context(); 5471 Context* native_context = isolate()->context()->native_context();
5477 JSFunction* array_function = native_context->array_function(); 5472 JSFunction* array_function = native_context->array_function();
5478 Map* map = array_function->initial_map(); 5473 Map* map = array_function->initial_map();
5479 Map* transition_map = isolate()->get_initial_js_array_map(elements_kind); 5474 Map* transition_map = isolate()->get_initial_js_array_map(elements_kind);
5480 if (transition_map != NULL) map = transition_map; 5475 if (transition_map != NULL) map = transition_map;
5481 return AllocateJSObjectFromMap(map, pretenure); 5476 return AllocateJSObjectFromMap(map, pretenure);
5482 } 5477 }
5483 5478
5484 5479
5485 MaybeObject* Heap::AllocateJSArrayWithAllocationSite(
5486 ElementsKind elements_kind,
5487 Handle<AllocationSite> allocation_site) {
5488 Context* native_context = isolate()->context()->native_context();
5489 JSFunction* array_function = native_context->array_function();
5490 Map* map = array_function->initial_map();
5491 Object* maybe_map_array = native_context->js_array_maps();
5492 if (!maybe_map_array->IsUndefined()) {
5493 Object* maybe_transitioned_map =
5494 FixedArray::cast(maybe_map_array)->get(elements_kind);
5495 if (!maybe_transitioned_map->IsUndefined()) {
5496 map = Map::cast(maybe_transitioned_map);
5497 }
5498 }
5499 return AllocateJSObjectFromMapWithAllocationSite(map, allocation_site);
5500 }
5501
5502
5503 MaybeObject* Heap::AllocateEmptyFixedArray() { 5480 MaybeObject* Heap::AllocateEmptyFixedArray() {
5504 int size = FixedArray::SizeFor(0); 5481 int size = FixedArray::SizeFor(0);
5505 Object* result; 5482 Object* result;
5506 { MaybeObject* maybe_result = 5483 { MaybeObject* maybe_result =
5507 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); 5484 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE);
5508 if (!maybe_result->ToObject(&result)) return maybe_result; 5485 if (!maybe_result->ToObject(&result)) return maybe_result;
5509 } 5486 }
5510 // Initialize the object. 5487 // Initialize the object.
5511 reinterpret_cast<FixedArray*>(result)->set_map_no_write_barrier( 5488 reinterpret_cast<FixedArray*>(result)->set_map_no_write_barrier(
5512 fixed_array_map()); 5489 fixed_array_map());
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after
7069 7046
7070 store_buffer()->TearDown(); 7047 store_buffer()->TearDown();
7071 incremental_marking()->TearDown(); 7048 incremental_marking()->TearDown();
7072 7049
7073 isolate_->memory_allocator()->TearDown(); 7050 isolate_->memory_allocator()->TearDown();
7074 7051
7075 delete relocation_mutex_; 7052 delete relocation_mutex_;
7076 } 7053 }
7077 7054
7078 7055
7079 void Heap::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { 7056 void Heap::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback callback,
7057 GCType gc_type,
7058 bool pass_isolate) {
7080 ASSERT(callback != NULL); 7059 ASSERT(callback != NULL);
7081 GCPrologueCallbackPair pair(callback, gc_type); 7060 GCPrologueCallbackPair pair(callback, gc_type, pass_isolate);
7082 ASSERT(!gc_prologue_callbacks_.Contains(pair)); 7061 ASSERT(!gc_prologue_callbacks_.Contains(pair));
7083 return gc_prologue_callbacks_.Add(pair); 7062 return gc_prologue_callbacks_.Add(pair);
7084 } 7063 }
7085 7064
7086 7065
7087 void Heap::RemoveGCPrologueCallback(GCPrologueCallback callback) { 7066 void Heap::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback) {
7088 ASSERT(callback != NULL); 7067 ASSERT(callback != NULL);
7089 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { 7068 for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) {
7090 if (gc_prologue_callbacks_[i].callback == callback) { 7069 if (gc_prologue_callbacks_[i].callback == callback) {
7091 gc_prologue_callbacks_.Remove(i); 7070 gc_prologue_callbacks_.Remove(i);
7092 return; 7071 return;
7093 } 7072 }
7094 } 7073 }
7095 UNREACHABLE(); 7074 UNREACHABLE();
7096 } 7075 }
7097 7076
7098 7077
7099 void Heap::AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type) { 7078 void Heap::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback,
7079 GCType gc_type,
7080 bool pass_isolate) {
7100 ASSERT(callback != NULL); 7081 ASSERT(callback != NULL);
7101 GCEpilogueCallbackPair pair(callback, gc_type); 7082 GCEpilogueCallbackPair pair(callback, gc_type, pass_isolate);
7102 ASSERT(!gc_epilogue_callbacks_.Contains(pair)); 7083 ASSERT(!gc_epilogue_callbacks_.Contains(pair));
7103 return gc_epilogue_callbacks_.Add(pair); 7084 return gc_epilogue_callbacks_.Add(pair);
7104 } 7085 }
7105 7086
7106 7087
7107 void Heap::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { 7088 void Heap::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback) {
7108 ASSERT(callback != NULL); 7089 ASSERT(callback != NULL);
7109 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { 7090 for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) {
7110 if (gc_epilogue_callbacks_[i].callback == callback) { 7091 if (gc_epilogue_callbacks_[i].callback == callback) {
7111 gc_epilogue_callbacks_.Remove(i); 7092 gc_epilogue_callbacks_.Remove(i);
7112 return; 7093 return;
7113 } 7094 }
7114 } 7095 }
7115 UNREACHABLE(); 7096 UNREACHABLE();
7116 } 7097 }
7117 7098
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
8109 if (FLAG_concurrent_recompilation) { 8090 if (FLAG_concurrent_recompilation) {
8110 heap_->relocation_mutex_->Lock(); 8091 heap_->relocation_mutex_->Lock();
8111 #ifdef DEBUG 8092 #ifdef DEBUG
8112 heap_->relocation_mutex_locked_by_optimizer_thread_ = 8093 heap_->relocation_mutex_locked_by_optimizer_thread_ =
8113 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 8094 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
8114 #endif // DEBUG 8095 #endif // DEBUG
8115 } 8096 }
8116 } 8097 }
8117 8098
8118 } } // namespace v8::internal 8099 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698