| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 // The common functionality when building with or without snapshots. | 5 // The common functionality when building with or without snapshots. |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #include "src/api.h" | 9 #include "src/api.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 | 128 |
| 129 uint32_t required = kMaxUInt32; | 129 uint32_t required = kMaxUInt32; |
| 130 if (single_chunk) { | 130 if (single_chunk) { |
| 131 // If both the startup snapshot data and the context snapshot data on | 131 // If both the startup snapshot data and the context snapshot data on |
| 132 // this space fit in a single page, then we consider limiting the size | 132 // this space fit in a single page, then we consider limiting the size |
| 133 // of the first page. For this, we add the chunk sizes and some extra | 133 // of the first page. For this, we add the chunk sizes and some extra |
| 134 // allowance. This way we achieve a smaller startup memory footprint. | 134 // allowance. This way we achieve a smaller startup memory footprint. |
| 135 required = (startup_reservations[startup_index].chunk_size() + | 135 required = (startup_reservations[startup_index].chunk_size() + |
| 136 2 * context_reservations[context_index].chunk_size()) + | 136 2 * context_reservations[context_index].chunk_size()) + |
| 137 Page::kObjectStartOffset; | 137 Page::kObjectStartOffset; |
| 138 // Add a small allowance to the code space for small scripts. |
| 139 if (space == CODE_SPACE) required += 32 * KB; |
| 138 } else { | 140 } else { |
| 139 // We expect the vanilla snapshot to only require on page per space. | 141 // We expect the vanilla snapshot to only require on page per space. |
| 140 DCHECK(!is_default_snapshot); | 142 DCHECK(!is_default_snapshot); |
| 141 } | 143 } |
| 142 | 144 |
| 143 if (space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE) { | 145 if (space >= FIRST_PAGED_SPACE && space <= LAST_PAGED_SPACE) { |
| 144 uint32_t max_size = | 146 uint32_t max_size = |
| 145 MemoryAllocator::PageAreaSize(static_cast<AllocationSpace>(space)); | 147 MemoryAllocator::PageAreaSize(static_cast<AllocationSpace>(space)); |
| 146 sizes_out[space - FIRST_PAGED_SPACE] = Min(required, max_size); | 148 sizes_out[space - FIRST_PAGED_SPACE] = Min(required, max_size); |
| 147 } else { | 149 } else { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 int startup_length; | 220 int startup_length; |
| 219 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); | 221 memcpy(&startup_length, data->data + kStartupLengthOffset, kIntSize); |
| 220 int context_offset = ContextOffset(startup_length); | 222 int context_offset = ContextOffset(startup_length); |
| 221 const byte* context_data = | 223 const byte* context_data = |
| 222 reinterpret_cast<const byte*>(data->data + context_offset); | 224 reinterpret_cast<const byte*>(data->data + context_offset); |
| 223 DCHECK_LT(context_offset, data->raw_size); | 225 DCHECK_LT(context_offset, data->raw_size); |
| 224 int context_length = data->raw_size - context_offset; | 226 int context_length = data->raw_size - context_offset; |
| 225 return Vector<const byte>(context_data, context_length); | 227 return Vector<const byte>(context_data, context_length); |
| 226 } | 228 } |
| 227 } } // namespace v8::internal | 229 } } // namespace v8::internal |
| OLD | NEW |