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

Side by Side Diff: include/v8.h

Issue 2921883002: [heap] Lower external allocation limit when external memory shrinks. (Closed)
Patch Set: accounting Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 10022 matching lines...) Expand 10 before | Expand all | Expand 10 after
10033 return I::kNumIsolateDataSlots; 10033 return I::kNumIsolateDataSlots;
10034 } 10034 }
10035 10035
10036 10036
10037 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( 10037 int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
10038 int64_t change_in_bytes) { 10038 int64_t change_in_bytes) {
10039 const int64_t kMemoryReducerActivationLimit = 1024 * 1024; 10039 const int64_t kMemoryReducerActivationLimit = 1024 * 1024;
10040 typedef internal::Internals I; 10040 typedef internal::Internals I;
10041 int64_t* external_memory = reinterpret_cast<int64_t*>( 10041 int64_t* external_memory = reinterpret_cast<int64_t*>(
10042 reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset); 10042 reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
10043 const int64_t external_memory_limit = *reinterpret_cast<int64_t*>( 10043 int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
10044 reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset); 10044 reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset);
10045 int64_t* external_memory_at_last_mc = 10045 int64_t* external_memory_at_last_mc =
10046 reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) + 10046 reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(this) +
10047 I::kExternalMemoryAtLastMarkCompactOffset); 10047 I::kExternalMemoryAtLastMarkCompactOffset);
10048 const int64_t amount = *external_memory + change_in_bytes; 10048 const int64_t amount = *external_memory + change_in_bytes;
10049 10049
10050 *external_memory = amount; 10050 *external_memory = amount;
10051 10051
10052 int64_t allocation_diff_since_last_mc = 10052 int64_t allocation_diff_since_last_mc =
10053 *external_memory_at_last_mc - *external_memory; 10053 *external_memory_at_last_mc - *external_memory;
10054 allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0 10054 allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0
10055 ? -allocation_diff_since_last_mc 10055 ? -allocation_diff_since_last_mc
10056 : allocation_diff_since_last_mc; 10056 : allocation_diff_since_last_mc;
10057 if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) { 10057 if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) {
10058 CheckMemoryPressure(); 10058 CheckMemoryPressure();
10059 } 10059 }
10060 10060
10061 if (change_in_bytes > 0 && amount > external_memory_limit) { 10061 if (change_in_bytes < 0) {
10062 *external_memory_limit += change_in_bytes;
10063 }
10064
10065 if (change_in_bytes > 0 && amount > *external_memory_limit) {
10062 ReportExternalAllocationLimitReached(); 10066 ReportExternalAllocationLimitReached();
10063 } 10067 }
10064 return *external_memory; 10068 return *external_memory;
10065 } 10069 }
10066 10070
10067 Local<Value> Context::GetEmbedderData(int index) { 10071 Local<Value> Context::GetEmbedderData(int index) {
10068 #ifndef V8_ENABLE_CHECKS 10072 #ifndef V8_ENABLE_CHECKS
10069 typedef internal::Object O; 10073 typedef internal::Object O;
10070 typedef internal::HeapObject HO; 10074 typedef internal::HeapObject HO;
10071 typedef internal::Internals I; 10075 typedef internal::Internals I;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
10198 */ 10202 */
10199 10203
10200 10204
10201 } // namespace v8 10205 } // namespace v8
10202 10206
10203 10207
10204 #undef TYPE_CHECK 10208 #undef TYPE_CHECK
10205 10209
10206 10210
10207 #endif // INCLUDE_V8_H_ 10211 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698