[vm] Only include debugger/profiler slots in RawCode in product mode.
Saves 5 words per Code in product mode JIT.
Change-Id: I799a9c3bc1f4492d329c588ba1ea98f5b8baa304
Reviewed-on: https://dart-review.googlesource.com/75421
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index 84bc363..ba822e0 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -1675,15 +1675,12 @@
s->Push(code->ptr()->inlined_id_to_function_);
s->Push(code->ptr()->code_source_map_);
}
- if (s->kind() != Snapshot::kFullAOT) {
- s->Push(code->ptr()->await_token_positions_);
- }
-
if (s->kind() == Snapshot::kFullJIT) {
s->Push(code->ptr()->deopt_info_array_);
s->Push(code->ptr()->static_calls_target_table_);
- NOT_IN_PRODUCT(s->Push(code->ptr()->return_address_metadata_));
}
+ NOT_IN_PRODUCT(s->Push(code->ptr()->await_token_positions_));
+ NOT_IN_PRODUCT(s->Push(code->ptr()->return_address_metadata_));
}
void WriteAlloc(Serializer* s) {
@@ -1739,14 +1736,12 @@
s->WriteRef(code->ptr()->inlined_id_to_function_);
s->WriteRef(code->ptr()->code_source_map_);
}
- if (s->kind() != Snapshot::kFullAOT) {
- s->WriteRef(code->ptr()->await_token_positions_);
- }
if (s->kind() == Snapshot::kFullJIT) {
s->WriteRef(code->ptr()->deopt_info_array_);
s->WriteRef(code->ptr()->static_calls_target_table_);
- NOT_IN_PRODUCT(s->WriteRef(code->ptr()->return_address_metadata_));
}
+ NOT_IN_PRODUCT(s->WriteRef(code->ptr()->await_token_positions_));
+ NOT_IN_PRODUCT(s->WriteRef(code->ptr()->return_address_metadata_));
s->Write<int32_t>(code->ptr()->state_bits_);
}
@@ -1823,30 +1818,22 @@
reinterpret_cast<RawCodeSourceMap*>(d->ReadRef());
#if !defined(DART_PRECOMPILED_RUNTIME)
- code->ptr()->await_token_positions_ =
- reinterpret_cast<RawArray*>(d->ReadRef());
-
if (d->kind() == Snapshot::kFullJIT) {
code->ptr()->deopt_info_array_ =
reinterpret_cast<RawArray*>(d->ReadRef());
code->ptr()->static_calls_target_table_ =
reinterpret_cast<RawArray*>(d->ReadRef());
-#if defined(PRODUCT)
- code->ptr()->return_address_metadata_ = Object::null();
-#else
- code->ptr()->return_address_metadata_ = d->ReadRef();
-#endif
- } else {
- code->ptr()->deopt_info_array_ = Array::null();
- code->ptr()->static_calls_target_table_ = Array::null();
- code->ptr()->return_address_metadata_ = Object::null();
}
+#endif // !DART_PRECOMPILED_RUNTIME
+#if !defined(PRODUCT)
+ code->ptr()->await_token_positions_ =
+ reinterpret_cast<RawArray*>(d->ReadRef());
+ code->ptr()->return_address_metadata_ = d->ReadRef();
code->ptr()->var_descriptors_ = LocalVarDescriptors::null();
code->ptr()->comments_ = Array::null();
-
code->ptr()->compile_timestamp_ = 0;
-#endif // !DART_PRECOMPILED_RUNTIME
+#endif
code->ptr()->state_bits_ = d->Read<int32_t>();
}
diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc
index e554b4a..3607520 100644
--- a/runtime/vm/compiler/aot/precompiler.cc
+++ b/runtime/vm/compiler/aot/precompiler.cc
@@ -1128,8 +1128,8 @@
parsed_function,
/* optimized = */ false);
helper.Compile(&pipeline);
- Code::Handle(func.unoptimized_code())
- .set_var_descriptors(Object::empty_var_descriptors());
+ NOT_IN_PRODUCT(Code::Handle(func.unoptimized_code())
+ .set_var_descriptors(Object::empty_var_descriptors()));
const Object& result = PassiveObject::Handle(
DartEntry::InvokeFunction(func, Object::empty_array()));
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler.cc b/runtime/vm/compiler/backend/flow_graph_compiler.cc
index cc2eb01..d5ce4e7 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler.cc
@@ -1037,6 +1037,9 @@
}
void FlowGraphCompiler::FinalizeVarDescriptors(const Code& code) {
+#if defined(PRODUCT)
+ // No debugger: no var descriptors.
+#else
// TODO(alexmarkov): revise local vars descriptors when compiling bytecode
if (code.is_optimized() || flow_graph().function().HasBytecode()) {
// Optimized code does not need variable descriptors. They are
@@ -1062,6 +1065,7 @@
var_descs.SetVar(0, Symbols::CurrentContextVar(), &info);
}
code.set_var_descriptors(var_descs);
+#endif
}
void FlowGraphCompiler::FinalizeCatchEntryMovesMap(const Code& code) {
diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc
index e2e44ad..40d64b8 100644
--- a/runtime/vm/compiler/jit/compiler.cc
+++ b/runtime/vm/compiler/jit/compiler.cc
@@ -1550,7 +1550,8 @@
const Code& code = Code::Handle(helper.Compile(&pipeline));
if (!code.IsNull()) {
- code.set_var_descriptors(Object::empty_var_descriptors());
+ NOT_IN_PRODUCT(
+ code.set_var_descriptors(Object::empty_var_descriptors()));
return DartEntry::InvokeFunction(initializer, Object::empty_array());
}
}
@@ -1625,7 +1626,7 @@
CompileParsedFunctionHelper helper(parsed_function, false, kNoOSRDeoptId);
const Code& code = Code::Handle(helper.Compile(&pipeline));
if (!code.IsNull()) {
- code.set_var_descriptors(Object::empty_var_descriptors());
+ NOT_IN_PRODUCT(code.set_var_descriptors(Object::empty_var_descriptors()));
const Object& result = PassiveObject::Handle(
DartEntry::InvokeFunction(func, Object::empty_array()));
return result.raw();
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index a569a49..84485ea 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -15704,7 +15704,7 @@
}
const Code::Comments& Code::comments() const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
Comments* comments = new Code::Comments(Array::Handle());
#else
Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_));
@@ -15713,7 +15713,7 @@
}
void Code::set_comments(const Code::Comments& comments) const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
UNREACHABLE();
#else
ASSERT(comments.comments_.IsOld());
@@ -15722,7 +15722,7 @@
}
void Code::SetPrologueOffset(intptr_t offset) const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
UNREACHABLE();
#else
ASSERT(offset >= 0);
@@ -15733,7 +15733,8 @@
}
intptr_t Code::GetPrologueOffset() const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
+ UNREACHABLE();
return -1;
#else
const Object& object = Object::Handle(raw_ptr()->return_address_metadata_);
@@ -15771,8 +15772,8 @@
result.set_pointer_offsets_length(pointer_offsets_length);
result.set_is_optimized(false);
result.set_is_alive(false);
- result.set_comments(Comments::New(0));
- result.set_compile_timestamp(0);
+ NOT_IN_PRODUCT(result.set_comments(Comments::New(0)));
+ NOT_IN_PRODUCT(result.set_compile_timestamp(0));
result.set_pc_descriptors(Object::empty_descriptors());
}
return result.raw();
@@ -15886,15 +15887,14 @@
}
#endif
+#ifndef PRODUCT
const Code::Comments& comments = assembler->GetCodeComments();
code.set_compile_timestamp(OS::GetCurrentMonotonicMicros());
-#ifndef PRODUCT
CodeCommentsWrapper comments_wrapper(comments);
CodeObservers::NotifyAll(name, instrs.PayloadStart(),
assembler->prologue_offset(), instrs.Size(),
optimized, &comments_wrapper);
-#endif
code.set_comments(comments);
if (assembler->prologue_offset() >= 0) {
code.SetPrologueOffset(assembler->prologue_offset());
@@ -15905,6 +15905,7 @@
}
INC_STAT(Thread::Current(), total_code_size,
code.comments().comments_.Length());
+#endif
return code.raw();
}
@@ -16250,7 +16251,7 @@
}
RawArray* Code::await_token_positions() const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
return Array::null();
#else
return raw_ptr()->await_token_positions_;
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index e27aa96..8025cc8 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -5128,7 +5128,7 @@
void set_comments(const Comments& comments) const;
RawObject* return_address_metadata() const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
UNREACHABLE();
return NULL;
#else
@@ -5169,7 +5169,7 @@
void DumpSourcePositions() const;
RawLocalVarDescriptors* var_descriptors() const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
UNREACHABLE();
return NULL;
#else
@@ -5177,7 +5177,7 @@
#endif
}
void set_var_descriptors(const LocalVarDescriptors& value) const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
UNREACHABLE();
#else
ASSERT(value.IsOld());
@@ -5265,7 +5265,7 @@
const char* QualifiedName() const;
int64_t compile_timestamp() const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
return 0;
#else
return raw_ptr()->compile_timestamp_;
@@ -5331,7 +5331,7 @@
static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT
void set_compile_timestamp(int64_t timestamp) const {
-#if defined(DART_PRECOMPILED_RUNTIME)
+#if defined(PRODUCT)
UNREACHABLE();
#else
StoreNonPointer(&raw_ptr()->compile_timestamp_, timestamp);
diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h
index db5a9d0..adc81d8 100644
--- a/runtime/vm/raw_object.h
+++ b/runtime/vm/raw_object.h
@@ -1386,24 +1386,27 @@
RawArray* stackmaps_;
RawArray* inlined_id_to_function_;
RawCodeSourceMap* code_source_map_;
- NOT_IN_PRECOMPILED(RawArray* await_token_positions_);
NOT_IN_PRECOMPILED(RawInstructions* active_instructions_);
NOT_IN_PRECOMPILED(RawArray* deopt_info_array_);
// (code-offset, function, code) triples.
NOT_IN_PRECOMPILED(RawArray* static_calls_target_table_);
+ NOT_IN_PRODUCT(RawArray* await_token_positions_);
// If return_address_metadata_ is a Smi, it is the offset to the prologue.
// Else, return_address_metadata_ is null.
- NOT_IN_PRECOMPILED(RawObject* return_address_metadata_);
- NOT_IN_PRECOMPILED(RawLocalVarDescriptors* var_descriptors_);
- NOT_IN_PRECOMPILED(RawArray* comments_);
-#if defined(DART_PRECOMPILED_RUNTIME)
+ NOT_IN_PRODUCT(RawObject* return_address_metadata_);
+ NOT_IN_PRODUCT(RawLocalVarDescriptors* var_descriptors_);
+ NOT_IN_PRODUCT(RawArray* comments_);
+
+#if !defined(PRODUCT)
+ VISIT_TO(RawObject*, comments_);
+#elif defined(DART_PRECOMPILED_RUNTIME)
VISIT_TO(RawObject*, code_source_map_);
#else
- VISIT_TO(RawObject*, comments_);
+ VISIT_TO(RawObject*, static_calls_target_table_);
#endif
// Compilation timestamp.
- NOT_IN_PRECOMPILED(int64_t compile_timestamp_);
+ NOT_IN_PRODUCT(int64_t compile_timestamp_);
// state_bits_ is a bitfield with three fields:
// The optimized bit, the alive bit, and a count of the number of pointer