Commit 8f357557 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[snapshot] Ensure deterministic CSA builtin code in snapshot.

Use large zone segments for CSA builin generation when serializer is
active. Turbofan backend uses pointer comparison of zone allocated
objects. Large zone segments ensure determistic order of objects.

Bug: v8:7188
Change-Id: I18e1e18fa79cded561563de1329bc3d9a8c364fb
Reviewed-on: https://chromium-review.googlesource.com/817601Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50023}
parent 05675403
......@@ -107,7 +107,11 @@ Code* BuildWithCodeStubAssemblerJS(Isolate* isolate, int32_t builtin_index,
// Canonicalize handles, so that we can share constant pool entries pointing
// to code targets without dereferencing their handles.
CanonicalHandleScope canonical(isolate);
Zone zone(isolate->allocator(), ZONE_NAME);
SegmentSize segment_size = isolate->serializer_enabled()
? SegmentSize::kLarge
: SegmentSize::kDefault;
Zone zone(isolate->allocator(), ZONE_NAME, segment_size);
const int argc_with_recv =
(argc == SharedFunctionInfo::kDontAdaptArgumentsSentinel) ? 0 : argc + 1;
compiler::CodeAssemblerState state(isolate, &zone, argc_with_recv,
......@@ -127,7 +131,10 @@ Code* BuildWithCodeStubAssemblerCS(Isolate* isolate, int32_t builtin_index,
// Canonicalize handles, so that we can share constant pool entries pointing
// to code targets without dereferencing their handles.
CanonicalHandleScope canonical(isolate);
Zone zone(isolate->allocator(), ZONE_NAME);
SegmentSize segment_size = isolate->serializer_enabled()
? SegmentSize::kLarge
: SegmentSize::kDefault;
Zone zone(isolate->allocator(), ZONE_NAME, segment_size);
// The interface descriptor with given key must be initialized at this point
// and this construction just queries the details from the descriptors table.
CallInterfaceDescriptor descriptor(isolate, interface_descriptor);
......
......@@ -42,7 +42,8 @@ const size_t kASanRedzoneBytes = 0;
} // namespace
Zone::Zone(AccountingAllocator* allocator, const char* name)
Zone::Zone(AccountingAllocator* allocator, const char* name,
SegmentSize segment_size)
: allocation_size_(0),
segment_bytes_allocated_(0),
position_(0),
......@@ -50,7 +51,8 @@ Zone::Zone(AccountingAllocator* allocator, const char* name)
allocator_(allocator),
segment_head_(nullptr),
name_(name),
sealed_(false) {
sealed_(false),
segment_size_(segment_size) {
allocator_->ZoneCreation(this);
}
......@@ -148,6 +150,9 @@ Address Zone::NewExpand(size_t size) {
V8::FatalProcessOutOfMemory("Zone");
return nullptr;
}
if (segment_size_ == SegmentSize::kLarge) {
new_size = kMaximumSegmentSize;
}
if (new_size < kMinimumSegmentSize) {
new_size = kMinimumSegmentSize;
} else if (new_size > kMaximumSegmentSize) {
......
......@@ -34,9 +34,13 @@ namespace internal {
//
// Note: The implementation is inherently not thread safe. Do not use
// from multi-threaded code.
enum class SegmentSize { kLarge, kDefault };
class V8_EXPORT_PRIVATE Zone final {
public:
Zone(AccountingAllocator* allocator, const char* name);
Zone(AccountingAllocator* allocator, const char* name,
SegmentSize segment_size = SegmentSize::kDefault);
~Zone();
// Allocate 'size' bytes of memory in the Zone; expands the Zone by
......@@ -109,6 +113,7 @@ class V8_EXPORT_PRIVATE Zone final {
Segment* segment_head_;
const char* name_;
bool sealed_;
SegmentSize segment_size_;
};
// ZoneObject is an abstraction that helps define classes of objects
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment